Canny edge detector: Difference between revisions

m (J: further speedups and a draft of image cleanup)
Line 672:
 
=={{header|J}}==
<p>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). </p>
<p>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. </p>
<p>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 3-by-3 region (or if they are connected to a common third edge point). Edges are represented as points having a common unique identifier. </p>
 
<ul>ToDo:
ToDo: <li>figure out how to upload the images ...</li>
<li>generate gaussian filter for given sigma</li>
</ul>
 
<lang J>
Line 752 ⟶ 755:
)
</lang>
<p>The above implementation solves the 'inner problem' of Canny Edge Detection in the J, with no external dependencies. Standard libraries provide additional support including interfaces to image file formats and graphic displays. </p>
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.
 
<p>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.</p>
The file valve.png referenced in this code is, or is related to, one of these: [https://saush.files.wordpress.com/2011/04/engine.png engine.png] [http://i.stack.imgur.com/Q06qi.png Q06qi.png] [https://upload.wikimedia.org/wikipedia/commons/thumb/f/f0/Valve_original_%281%29.PNG/300px-Valve_original_%281%29.PNG Valve_original(1).PNG] [http://www.danmorella.com/wordpress/wp-content/uploads/2012/03/30_gear.jpg 30_gear.jpg]
 
<p>The file 'valve.png' referenced in this code is from one of several Wikipedia articles on edge detection. It can be viewed at [https://upload.wikimedia.org/wikipedia/commons/2/2e/Valve_gaussian_%282%29.PNG[https://upload.wikimedia.org/wikipedia/commons/2/2e/Valve_gaussian_%282%29.PNG]]</p>
<lang J>
 
NB. viewers
require'viewmat'