Canny edge detector: Difference between revisions

Content added Content deleted
(Added Mathematica)
Line 667: Line 667:
imIn.cannyEdgeDetection(45, 50, 1.0f).savePGM("lena_canny.pgm");
imIn.cannyEdgeDetection(45, 50, 1.0f).savePGM("lena_canny.pgm");
}</lang>
}</lang>




=={{header|J}}==
=Implemmentation=
The image is represented as a 2D array of pixels, with first and second axes representing down and right respectively. Array elements represent monochromatic intensity values as integers ranging from 0 (black) to 255 (white).
Intensity gradient fields are similarly structured. Gradient values are vectors, and are represented here as complex numbers, with real and imaginary components representing down and right respectively.
Edge and non-edge points are represented as zeros and ones respectively. Edges are sets of connected points. Edge points are considered to be connected if within a 3X3 region (or if they are connected to a common third edge point). Edges are represented as points having a common unique identifier.
<lang J>
... implementation goes here ...
}</lang>
The above implementation solves the 'inner problem' of Canny Edge Detection fully in the J language, with no external dependencies. Standard libraries provide necessary additional support including interfaces to image file formats and graphic displays.
Image file libraries for different image formats import into and export from a generalized data structure, an array of pixels with three or four color channels. The following code invokes these standard libraries, and also converts between the import format and the monochromatic representation used here for edge detection.

<lang J>
... usage goes here …
</lang>


=={{header|Mathematica}}==
=={{header|Mathematica}}==