0

I am trying to understand the concept of Non-maximum suppression(Canny Edge detection), So I started looking at the matlab code. The part of matlab code to determine the direction of the edge is shown below.

switch direction
    case 1
        idx = find((iy<=0 & ix>-iy)  | (iy>=0 & ix<-iy));
    case 2
        idx = find((ix>0 & -iy>=ix)  | (ix<0 & -iy<=ix));
    case 3
        idx = find((ix<=0 & ix>iy) | (ix>=0 & ix<iy));
    case 4
        idx = find((iy<0 & ix<=iy) | (iy>0 & ix>=iy));
end

Here,

  • ix:input image filtered by derivative of gaussian along x
  • iy:input image filtered by derivative of gaussian along y
  • case 1: 0-45degrees or 181-225degrees
  • case 2: 46-90degrees or 226-270degrees
  • case 3: 91-135degrees or 271-315degrees
  • case 4: 136-180degrees or 316-360degree

How are the conditions inside the switch cases corresponds to the cases explained below the code. Could any one please explain this. ?

Unapiedra
  • 15,037
  • 12
  • 64
  • 93
Nrupatunga
  • 469
  • 1
  • 8
  • 16

1 Answers1

1

At first glance, find((iy<=0 & ix>-iy) | (iy>=0 & ix<-iy)); returns the indices of all pixels where

  • (iy<=0 & ix>-iy), so
    • the y derivative is less than zero, so the edge is downward, between 90° and 270°
    • the x derivative is greater than zero, so the edge is leftward, between 180° and 360°
    • the magnitude of ix is greater than iy, so the edge is predominantly tilted vertically, not horizontally
    • resulting in an edge between 180° and 225°
  • or (iy>=0 & ix<-iy)), so
    • the y derivative is greater than zero, so the edge is upward, between 270° and 90°
    • the x derivative is less than zero, so the edge is rightward, between 0° and 180°
    • the magnitude of ix is greater than iy, so the edge is tilted vertically
    • resulting in an edge between 0°and 45°

Assuming that the pixels are ordered from up to down and from left to right, and an exactly vertical edge (black on the left, white on the right) is defined as 0°

The other 3 terms of the switch case are analogous.

This is not directly related to non-maximum suppression. I assume this is part of a canny edge filter or something similar, in which case the next step would be to find the local maximum in the just determined direction of the edge. This is done by comparing each pixel with its local neighbours in the edge direction, and erasing all but the maximum.

HugoRune
  • 13,157
  • 7
  • 69
  • 144
  • Thank you for the reply Mr.HugoRune. It helped me to understand the concept with knowledge of edge descriptors. Thank you so much :) – Nrupatunga Jun 15 '14 at 05:27
  • You are welcome :) If this answer resolves your question, please mark it as accepted by clicking the outlined check mark below the vote buttons. – HugoRune Jun 16 '14 at 13:44