Development and testing of image processing algorithms for real-time aerospace pattern recognition applications can be extremely time consuming and labor intensive. There is a need to close the gap between high-level software environments and efficient implementations. Image algebra is an algebraic structure designed for image processing that can be used as a basis for a high-level algorithm development environment. Systematic methods for mapping algorithms represented by image algebra statements to specific architectures are being studied. In this paper we discuss template decomposition, a problem encountered in mapping image algebra statements to combinations of parallel and pipeline architectures. In particular, we show that the gray scale morphological template decomposition problem can be viewed as a linear problem, even though morphological transformations are nonlinear. We show how methods for solving linear programming problems and, in particular, the transportation problem can be applied to template decomposition.