Pattern recognition using a coherent optical correlator has many advantages, including high speed operation at almost the speed of light and the implementation of parallel processing. The key part of an optical correlator is the so-called optical filter. Properly designed filter should clearly indicate the presence of desired features in an image to be detected. Therefore,the performance of an optical system relies essentially upon the performance of the filter. Much research have been conducted to improve the performance of optical correlators. Most approaches to the filter design, however, fall short of providing robustness to minute changes in the image. In this paper a new approach to the adaptive design of optical filters, which are both shift- and scale-invariant, is proposed. The filters are constructed in real-time in an optical pattern recognition system by an adaptive, iterative numerical approach. The design is formalized as an optimization procedure, for which the filter performance is the function to be maximized. During the training procedure filter parameters are selected to maximize the distinction between the target and other objects in the image. The latter problem is solved using the genetic algorithm. Filters obtained in this optimization procedure are good discriminators since they utilize all the visual information about the target. Computer simulations demonstrate high discrimination of the designed filters.