This paper addresses a method to implement ternary filters with binary phase spatial light modulators (SLMs) for realtime optical pattern recognition applications using a filtering-based optical processor. A complex ternary filter can be considered as a binary phase function multiplied by a binary amplitude filter, which selects information by blocking or letting pass spatial frequencies. The main problem is that commercially available SLMs cannot provide amplitude and phase modulation at the same time and at high filtering rates. The method presented here involves coding the binary amplitude in phase only, by adding a linear phase to the frequencies representing undesired information. This information will be rejected outside the correlation plane, whereas useful information will pass without alteration. Computer simulations and experimental results have been obtained for different applications. These results show that the pure phase filters obtained are absolutely equivalent to the desired ternary filters and, furthermore, that any ternary filtering function can be easily implemented in a VanderLugt correlator that uses a binary phase SLM, thanks to this technique.