# Understanding zero-phase filters

I'm reading the book "Digital Image Processing" by Gonzalez and Woods and I'm wondering how their definition of zero-phase-shift filter is equivalent to the one given here.

"Digital Image Processing" gives the following definition:

The DFT of $$f(u, v)$$ in Polar coordinates is:

$$F(u, v) = \sum_{x=0}^{M-1}\sum_{y=0}^{N-1} e^{-j 2\pi (\frac{ux}{M} + \frac{vy}{N})} = |F(u, v)|e^{j\phi(u, v)}$$

where $$\phi(u, v) = \arctan\left(\frac{I(u, v)}{R(u, v)}\right)$$ and $$I, R$$ is the imaginary and real part of $$F(u,v)$$. Then filtering means multiplying the filter $$H(u, v)$$ with $$F(u, v)$$ and then taking the inverse DFT i.e. $$F^{-1}\left(H(u, v)R(u, v) + j H(u, v)I(u, v)\right)$$.

"The phase angle is not altered by filtering in the manner just described because $$H(u, v)$$ cancels out when the ratio of the imaginary and real parts is formed. Filters that affect the real and imaginary parts equally, and thus have no effect on the phase, are appropriately called zero-phase-shift filters.".

If I understand it correctly, they are saying $$\phi(u, v) = \arctan\left(\frac{\text{Im}(H(u,v))I(u, v)}{\text{Re}(H(u,v))R(u, v)}\right) = \arctan\left(\frac{I(u, v)}{R(u, v)}\right)$$.

But the other definition looks different. They focus on the imaginary part of $$H(u, v)$$ being zero. This makes more sense to me, because then $$\phi(u, v) = 0$$. Right? But how does this affect "the real and imaginary parts equally"?

The ratio

$$\frac{\textrm{Im}\{H(u,v)I(u,v)\}}{\textrm{Re}\{H(u,v)R(u,v)\}}\tag{1}$$

is only independent of $$H(u,v)$$ if $$H(u,v)$$ is real-valued, which is exactly the condition for a zero-phase filter. The phase can only be zero if the frequency response is real-valued, as you've already noted.

For real-valued $$H(u,v)$$ we have

$$\frac{\textrm{Im}\{H(u,v)I(u,v)\}}{\textrm{Re}\{H(u,v)R(u,v)\}}=\frac{H(u,v)\textrm{ Im}\{I(u,v)\}}{H(u,v)\textrm{ Re}\{R(u,v)\}}=\frac{\textrm{ Im}\{I(u,v)\}}{\textrm{ Re}\{R(u,v)\}}\tag{2}$$

I agree that this may not be sufficiently clear from the text. But if you take a look at Section 4.7.3 "Summary of Steps for Filtering in the Frequency Domain" (3rd ed.), then you'll find the following:

1. Generate a real, symmetric filter function, $$H(u, v)$$, [...]

So in that context, the filter's frequency response is always assumed to be real-valued.

Filters that affect the real and imaginary parts equally, and thus have no effect on the phase, are appropriately called zero-phase-shift filters."

The filter itself is zero-phase, but the input (and therefore the output) waveform can be complex. In this case the real and imaginary components of the input would be effected equally since the filter is not adding any additional phase shift.