In this paper, an effective and efficient algorithm for finding the optimal morphological erosion filter on binary images is proposed. The design of morphological erosion filter is based on statistical method by minimizing mean square error. Traditionally, finding optimal morphological erosion filters requires searching through a large number of structuring-element combinations which is a long search and time consuming procedure. In the proposed method, the problem of finding the optimal solution is reduced to the problem of searching a minimal path on the error code graph (EGG). Since the graph satisfies some greedy criteria, only few nodes need to be traversed and examined. Experiments are conducted to illustrate the validity of our proposed method.