1. An image processing apparatus for compressing image data by combining spatial frequency conversion, quantization, and entropy coding, the image processing apparatus comprising: a block division section that divides the image data into pixel blocks; a spatial frequency conversion section that performs the spatial frequency conversion on image data for each of the pixel blocks obtained from the block division section; a quantization section that generates quantized data for each of the pixel blocks after performing the spatial frequency conversion by the spatial frequency conversion section; an encoding section that generates code data by performing the entropy coding for each of a plurality of change candidate values comprising: (a) a value of the quantized data on an element of interest in a pixel block after performing the spatial frequency conversion and (b) peripheral values to a value within a predetermined range; and a selection section that selects a change value of the quantized data on the element of interest from the plurality of change candidate values, wherein selecting the change value is based on a size of the code data of each of the plurality of change candidate values, and wherein the selection section sets the code data corresponding to the selected change value as the code data on the element of interest.