An image processing device for pattern matching comprising: a generation unit configured to generate an edge code image based on a gray value of an input image, each element contained in the edge code image including an edge code value and information indicating valid/invalid of the edge code value, each element corresponding to one pixel contained in the input image, the edge code value corresponding to a pixel being valid when an edge is detected at the pixel; a compression unit configured to compress the edge code image by assigning information representing the edge code value for an element having a valid edge code value to an element having an invalid edge code value; a storage unit configured to sequentially store the compressed edge code image; a decompression unit configured to decompress the compressed edge code image stored in the storage unit; and a comparator configured to perform the pattern matching by calculating a similarity degree between the edge code image decompressed by the decompression unit and a model image defined in advance, wherein the compression unit is configured to hold the edge code value generated at every predetermined cycle by the generation unit and the information indicating valid/invalid of the edge code value for a plurality of processing cycles, and output a differential value as an increase information if the edge code value in a present cycle is greater than the edge code value in a previous cycle, and as a decrease information otherwise, and the decompression unit is configured to decompress the compressed edge code image by integrating the obtained differential values. a generation unit configured to generate an edge code image based on a gray value of an input image, each element contained in the edge code image including an edge code value and information indicating valid/invalid of the edge code value, each element corresponding to one pixel contained in the input image, the edge code value corresponding to a pixel being valid when an edge is detected at the pixel; a compression unit configured to compress the edge code image by assigning information representing the edge code value for an element having a valid edge code value to an element having an invalid edge code value; a storage unit configured to sequentially store the compressed edge code image; a decompression unit configured to decompress the compressed edge code image stored in the storage unit; and a comparator configured to perform the pattern matching by calculating a similarity degree between the edge code image decompressed by the decompression unit and a model image defined in advance, wherein the compression unit is configured to hold the edge code value generated at every predetermined cycle by the generation unit and the information indicating valid/invalid of the edge code value for a plurality of processing cycles, and output a differential value as an increase information if the edge code value in a present cycle is greater than the edge code value in a previous cycle, and as a decrease information otherwise, and the decompression unit is configured to decompress the compressed edge code image by integrating the obtained differential values.