When determining that the pixel row does not have the correlation with the reference line (No in S146), determination unit 32 newly sets the pixel row determined not to have the correlation to the reference line (S147). The part (a) of FIG. 13 illustrates the case where the pixel rows up to pixel row 7 have the correlation with pixel row 2 that is the reference line selected in step S110 while pixel row 8 does not have the correlation with pixel row 2. Pixel row 8 is the first pixel row determined not to have the correlation with the pixel row 2 that is the reference line in the sequential determination of the correlation. At this point, the correlation lines for pixel row 2 that is the reference line are pixel rows 3 to 7 (see the correlation line for the second line in the part (a) of FIG. 13). As illustrated in a part (b) of FIG. 13, determination unit 32 newly sets pixel row 8 that is the first pixel row determined not to have the correlation to the reference line.
When the negative determination is made in step S144, the processing proceeds to step S147 to perform the above processing.
Subsequently, determination unit 32 determines whether the above determination is made for all the lines (pixel rows) (S148). When determining that the above determination is made for all the lines (Yes in S148), determination unit 32 proceeds to step S149. The processing in step S149 is the same as that in step S50 in FIG. 4.