Canny edge detector: Difference between revisions
Content added Content deleted
m (→{{header|J}}) |
|||
Line 698: | Line 698: | ||
unique =: 3 : 'y*i.$y' |
unique =: 3 : 'y*i.$y' |
||
connect =: 3 : 'attach^:_ unique y' |
connect =: 3 : 'attach^:_ unique y' |
||
⚫ | |||
canny =: 3 : 0 |
canny =: 3 : 0 |
||
Line 715: | Line 716: | ||
NB. Step 3 - edge detection |
NB. Step 3 - edge detection |
||
⚫ | |||
⚫ | |||
NB. test pattern <(i:6)(4 : 'octant (x j. y)')"0/(i:6) |
NB. test pattern <(i:6)(4 : 'octant (x j. y)')"0/(i:6) |
||
Line 724: | Line 723: | ||
NB. is this gradient the greatest of immmediate colinear neighbore? |
NB. is this gradient the greatest of immmediate colinear neighbore? |
||
greatestOf =: 4 : '(x greaterThan y) *. ((-x) greaterThan y)' |
greatestOf =: 4 : '(x greaterThan y) *. ((-x) greaterThan y)' |
||
⚫ | |||
⚫ | |||
krnl0 =: _1 0 |
|||
krnl1 =: _1 _1 |
|||
krnl2 =: 0 _1 |
|||
krnl3 =: 1 _1 |
|||
og =: octant image2 |
og =: octant image2 |
||
⚫ | |||
nbr =: 4 2 $ _1 0, _1 _1, 0 _1, 1 _1 |
|||
NB. mask for maximum |
NB. mask for maximum colinear gradient |
||
ok0 =: (0=og) *. |
ok0 =: (0=og) *. (0{nbr) greatestOf image2 |
||
ok1 =: (1=og) *. |
ok1 =: (1=og) *. (1{nbr) greatestOf image2 |
||
ok2 =: (2=og) *. |
ok2 =: (2=og) *. (2{nbr) greatestOf image2 |
||
ok3 =: (3=og) *. |
ok3 =: (3=og) *. (3{nbr) greatestOf image2 |
||
image3 =: image2 *. (ok0 +. ok1 +. ok2 +. ok3) |
image3 =: image2 *. (ok0 +. ok1 +. ok2 +. ok3) |
||
NB. Step 4 - Weak edge suppression |
NB. Step 4 - Weak edge suppression |
||