This paper presents an application of morphology neural networks to a template learning problem. Morphology neural networks are a nonlinear version of the familiar artificial neural networks. Typically, an artificial neural net is used to solve pattern classification problems One useful characterization of many neural network algorithms is the ability to 'learn' to respond correctly to new data based only on a selection of known data responses. For example, in the multilayer perceptron model, the 'learning' is a procedure whereby parameters are fed back from output to input neurons and the weights changed to give a better response. The morphological neural net in this paper solves a different type of image processing problem. Specifically, given an input image and an output image which corresponds to a dilated version of the input, one would like to determine what template produced the output. The problem corresponds to teaching the network to solve for the weights in a morphological net, as the weights are the template's values. A reasonable method has been investigated for the boolean case; in this paper results are presented for gray scale images. Image algebra has been shown to provide a succinct expression of neural networks algorithms and also to allow a generalization of neural networks, and thus the authors describe the algorithm in image algebra. The remainder of the paper gives a brief discussion of image algebra, the relationship of image algebra and neural networks, a recap of the dilation morphology neural network boolean for boolean images, and the generalization to grayscale data.