EDGE_DOG
EDGE_DOG is an IDL function that applies the Difference of Gaussians filter to a 2D image array to generate an array containing difference values that represent edges in the original image.
Example
You can use the EDGE_DOG function to isolate certain structures in an image based on their size. This example isolates some of the bone structures in a CT scan.
; Read an image.
file = FILEPATH('ctbone157.jpg', SUBDIR=['examples','data'])
ctscan = READ_IMAGE(file)
; Process the image with EDGE_DOG.
result = EDGE_DOG(ctscan, RADIUS1=6.0, RADIUS2=20.0, THRESHOLD=15, $
ZERO_CROSSINGS=[0,255])
; Display the original and processed images.
g0 = IMAGE(ctscan, LAYOUT=[2,1,1], DIMENSIONS=[800, 500], $
TITLE='Original image')
g1 = IMAGE(result, LAYOUT = [2,1,2], /CURRENT, $
TITLE='Image processed with EDGE_DOG')
Note: Also see “Detecting Edges” for additional examples.
Syntax
Result = EDGE_DOG(Array [, RADIUS1=value] [, RADIUS2=value] [, THRESHOLD=value] [, ZERO_CROSSINGS=value])
Return Value
EDGE_DOG returns a signed difference array of the same shape as the input array. The input type is converted to an output type as follows:
Input |
Output |
BYTE |
INT |
INT |
LONG |
UINT |
LONG |
ULONG |
LONG64 |
ULONG64 |
LONG64 |
Non-numeric types: not allowed |
|
All other types |
Same as input type |
Arguments
Array
A 2D array of any numeric type containing the image.
Keywords
RADIUS1
RADIUS2
The Difference of Gaussian filter works by applying two different Gaussian filters to the data, each with a different filter radius. RADIUS1 and RADIUS2 give the standard deviation of the two different Gaussian functions.
Set these keywords equal to scalars giving the radius in pixels of the two Gaussian smoothing filters. The defaults are RADIUS1=3.0 and RADIUS2=5.0. The difference between the two RADIUS values influences the size of the features detected by the filter.
Note: See Difference of Gaussians on Wikipedia.org for more information on the theory behind setting the radius values.
THRESHOLD
Set this keyword equal to a non-negative integer (or a float if Image is floating point) giving the clipping threshold. Gaussian differences that are smaller than this threshold are replaced with zero. This has the effect of removing small features from the result. It can be used to prevent noise in the image from being detected as edges. The default value is zero, meaning no thresholding is applied.
ZERO_CROSSINGS
Set this keyword equal to a two-element vector containing the values used to replace array values less than or equal to 0 and greater than zero, respectively. This creates a binary image useful for visualizing the edges.
Additional Example
This example performs edge detection on an RGB image.
; Read an image.
file = FILEPATH('rose.jpg', SUBDIR=['examples','data'])
rose = READ_IMAGE(file)
; Process the image with EDGE_DOG.
COLOR_CONVERT rose, yuv, /RGB_YUV
y = BYTE(REFORM(yuv[0,*,*])*255)
result = EDGE_DOG(y, THRESHOLD=3, ZERO_CROSSINGS=[0,255])
; Display the original and processed images.
g0 = IMAGE(rose, LAYOUT=[2,1,1], DIMENSIONS=[800, 500], $
TITLE='Original image')
g1 = IMAGE(result, LAYOUT = [2,1,2], /CURRENT, $
TITLE='Image processed with EDGE_DOG')
Version History
6.4 |
Introduced |
Resources and References
See Wikipedia.org for more information on Difference of Gaussians and the mathematics involved in this image enhancement algorithm.