Anonymous user
Canny edge detector: Difference between revisions
m
→{{header|J}}
m (→{{header|J}}) |
|||
Line 698:
unique =: 3 : 'y*i.$y'
connect =: 3 : 'attach^:_ unique y'
canny =: 3 : 0
Line 715 ⟶ 716:
NB. Step 3 - edge detection
NB. find the octant (eighth of circle) in which the gradient lies▼
▲ octant =: 3 : '4|(>.(_0.5+((4%(o. 1))*(12&o. y))))'
NB. test pattern <(i:6)(4 : 'octant (x j. y)')"0/(i:6)
Line 724 ⟶ 723:
NB. is this gradient the greatest of immmediate colinear neighbore?
greatestOf =: 4 : '(x greaterThan y) *. ((-x) greaterThan y)'
▲ NB. find the octant (eighth of circle) in which the gradient lies
NB. relative address of neighbor relevant to grad direction▼
og =: octant image2
nbr =: 4 2 $ _1 0, _1 _1, 0 _1, 1 _1
NB. mask for maximum
ok0 =: (0=og) *.
ok1 =: (1=og) *.
ok2 =: (2=og) *.
ok3 =: (3=og) *.
image3 =: image2 *. (ok0 +. ok1 +. ok2 +. ok3)
NB. Step 4 - Weak edge suppression
|