title: Phase congruency
text: # Phase congruency
  
  Phase congruency is a measure of feature significance in computer images, a method of edge detection that is particularly robust against changes in illumination and contrast.
  
  ## Foundations
  
  Phase congruency reflects the behaviour of the image in the frequency domain. It has been noted that edgelike features have many of their frequency components in the same phase. The concept is similar to coherence, except that it applies to functions of different wavelength.
  
  For example, the Fourier decomposition of a square wave consists of sine functions, whose frequencies are odd multiples of the fundamental frequency. At the rising edges of the square wave, each sinusoidal component has a rising phase; the phases have maximal congruency at the edges. This corresponds to the human-perceived edges in an image where there are sharp changes between light and dark.
  
  ## Definition
  
  Phase congruency compares the weighted alignment of the Fourier components of a signal $A_{\rm {n}}$ with the sum of the Fourier components.
  
      $PC(t)=\max _{\bar {\phi }}{\frac {\sum _{\rm {n}}A_{\rm {n}}\cos(\phi _{\rm {n}}(t)-{\bar {\phi }})}{\sum _{\rm {n}}A_{n}}}$
  
  where $\phi _{\rm {n}}$ is the local or instantaneous phase as can be calculated using the Hilbert transform and $A_{\rm {n}}$ are the local amplitude, or energy, of the signal. When all the phases are aligned, this is equal to 1.
  
  Several ways of implementing phase congruency have been developed, of which two versions are available in open source, one written for Matlab and the other written in Java as a plugin for the ImageJ software.
  
  Given the different notations used for its formulation, a unified version has been recently presented, where a methodology for the parameter tuning is also presented.
  
  ## Advantages
  
  The square-wave example is naive in that most edge detection methods deal with it equally well. For example, the first derivative has a maximal magnitude at the edges. However, there are cases where the perceived edge does not have a sharp step or a large derivative. The method of phase congruency applies to many cases where other methods fail.
  
  A notable example is an image feature consisting of a single line, such as the letter "l". Many edge-detection algorithms will pick up two adjacent edges: the transitions from white to black, and black to white. On the other hand, the phase congruency map has a single line. A simple Fourier analogy of this case is a triangle wave. In each of its crests there is a congruency of crests from different sinusoidal functions.
  
  ## Disadvantages
  
  Calculating the phase congruency map of an image is very computationally intensive, and sensitive to image noise. Techniques of noise reduction are usually applied prior to the calculation.
  
  