In step S1403, the image processing unit 214 applies shading correction processing (optical correction processing) to the A image signal and the B image signal to correct or suppress a difference between the signal strengths. A shading correction value has a value that depends on the incident angle of the imaging optical system, the F value, and the optical axis position. Like the conversion coefficient K, the shading correction value can be obtained from the lens unit, the non-volatile memory 220, or the like.
In step S1404, the image processing unit 214 applies spatial band pass filter processing having a specific pass frequency band to the A image signal and the B image signal in order to improve the correlation between the A image signal and the B image signal (the degree to which the signals match) and improve the focus detection accuracy. Examples of band pass filters include differential filters, such as {1, 4, 4, 4, 0, ?4, ?4, ?4, ?1}, that cut DC components and extract edges, and additive filters such as {1, 2, 1} that suppress high-frequency noise components.
In step S1405, the image processing unit 214 calculates the correlation amount between the A image signal and the B image signal after applying the filter processing. The correlation amount is calculated for each shift amount while changing the relative shift amount of the A image signal and the B image signal in a pupil division direction.
The number of signals constituting the A image signal and the B image signal after the band pass filter processing is W (>2), and the kth (1≤k≤W) signals are A(k) and B(k). If the shift amount is s and the range of the shift amount s is Γ, a correlation amount COR is calculated through Formula (1). COR(s)=Σ(k∈W)|A(k)?B(k?s)|,s∈Γ??(1)