|
Image Processing : Transforming Between Domains |
|
The Hough transform is used to transform from the spatial domain to the Hough domain and back again. The image information within the Hough domain shows the pixels of the original (spatial) image as sinusoidal curves. If the points of the original image form a straight line, their related sinusoidal curves in the Hough domain will intersect. Many intersections produce a peak. Masks can be easily applied to the image within the Hough domain to determine if and where straight lines occur.
The Radon transform is used to transform from the spatial domain to the Radon domain and back again. The image information within the Radon domain shows a line through the original image as a point. Specific features (geometries) in the original image produce peaks or collections of points. Masks can be easily applied to the image within the Radon domain to determine if and where these specific features occur.
Unlike transformations to and from the frequency and time-frequency domains, the Hough and Radon transforms do lose some data during the transformation process. These transformations are usually applied to the original image as a mask instead of producing an image from the results of the transform itself. See the HOUGH and RADON descriptions in the IDL Reference Guide for more information on Hough and Radon transform theory.
The following sections introduce the concepts needed to work with images and these transforms:
The Hough transformation process is used to find straight lines within an image. See Finding Straight Lines with the Hough Transform for an example. The Radon transformation process is used to enhance contrast within an image. See Color Density Contrasting with the Radon Transform for an example.
When an image is transformed from the spatial domain to either the Hough or Radon domain, the transformation process is referred to as a Hough or Radon projection. The projection process can be performed with either IDL's HOUGH function or IDL's RADON function, depending on which transform you want to use.
The following example shows how to use IDL's HOUGH and RADON functions to compute and display the Hough and Radon projections. This example uses the first image within the abnorm.dat file, which is in the examples/data directory. Complete the following steps for a detailed description of the process.
| Example Code See forwardhoughandradon.pro in the examples/doc/image subdirectory of the IDL installation directory for code that duplicates this example. |
abnorm.dat file:
imageSize = [64, 64]
file = FILEPATH('abnorm.dat', $
SUBDIRECTORY = ['examples', 'data'])
image = READ_BINARY(file, DATA_DIMS = imageSize)
displaySize = 2*imageSize offset = displaySize/3
DEVICE, DECOMPOSED = 0 LOADCT, 0
WINDOW, 0, XSIZE = displaySize[0], $ YSIZE = displaySize[1], TITLE = 'Original Image' TVSCL, CONGRID(image, displaySize[0], $ displaySize[1])
The following figure shows the original image.
houghTransform = HOUGH(image, RHO = houghRadii, $ THETA = houghAngles, /GRAY)
WINDOW, 1, XSIZE = displaySize[0] + 1.5*offset[0], $ YSIZE = displaySize[1] + 1.5*offset[1], $ TITLE = 'Hough Transform' TVSCL, CONGRID(houghTransform, displaySize[0], $ displaySize[1]), offset[0], offset[1] PLOT, houghAngles, houghRadii, /XSTYLE, /YSTYLE, $ TITLE = 'Hough Transform', XTITLE = 'Theta', $ YTITLE = 'Rho', /NODATA, /NOERASE, /DEVICE, $ POSITION = [offset[0], offset[1], $ displaySize[0] + offset[0], $ displaySize[1] + offset[1]], CHARSIZE = 1.5
The following figure shows the resulting Hough transform.
![]() |
radonTransform = RADON(image, RHO = radonRadii, $ THETA = radonAngles, /GRAY)
WINDOW, 2, XSIZE = displaySize[0] + 1.5*offset[0], $ YSIZE = displaySize[1] + 1.5*offset[1], $ TITLE = 'Radon Transform' TVSCL, CONGRID(radonTransform, displaySize[0], $ displaySize[1]), offset[0], offset[1] PLOT, radonAngles, radonRadii, /XSTYLE, /YSTYLE, $ TITLE = 'Radon Transform', XTITLE = 'Theta', $ YTITLE = 'Rho', /NODATA, /NOERASE, /DEVICE, $ POSITION = [offset[0], offset[1], $ displaySize[0] + offset[0], $ displaySize[1] + offset[1]], CHARSIZE = 1.5
The following figure shows the resulting Radon transform.
After manipulating an image within either the Hough or Radon domain, you may need to transform the image from that domain back to the spatial domain. This transformation process is referred to as a Hough or Radon backprojection. The backprojection process can be performed with either IDL's HOUGH function or IDL's RADON function, depending on which domain your image is in. You can perform the backprojection process with these functions by setting the BACKPROJECT keyword.
The following example shows how to use IDL's HOUGH and RADON functions to compute the backprojection from these domains. This example uses the first image within the abnorm.dat file, which is in the examples/data directory. Although the image is not manipulated while it is in the Hough or Radon domain, information is lost when using these transforms. Complete the following steps for a detailed description of the process.
| Example Code See backprojecthoughandradon.pro in the examples/doc/image subdirectory of the IDL installation directory for code that duplicates this example. |
abnorm.dat file:
imageSize = [64, 64]
file = FILEPATH('abnorm.dat', $
SUBDIRECTORY = ['examples', 'data'])
image = READ_BINARY(file, DATA_DIMS = imageSize)
displaySize = 2*imageSize offset = displaySize/3
DEVICE, DECOMPOSED = 0 LOADCT, 0
houghTransform = HOUGH(image, RHO = houghRadii, $ THETA = houghAngles, /GRAY)
WINDOW, 1, XSIZE = displaySize[0] + 1.5*offset[0], $ YSIZE = displaySize[1] + 1.5*offset[1], $ TITLE = 'Hough Transform' TVSCL, CONGRID(houghTransform, displaySize[0], $ displaySize[1]), offset[0], offset[1] PLOT, houghAngles, houghRadii, /XSTYLE, /YSTYLE, $ TITLE = 'Hough Transform', XTITLE = 'Theta', $ YTITLE = 'Rho', /NODATA, /NOERASE, /DEVICE, $ POSITION = [offset[0], offset[1], $ displaySize[0] + offset[0], $ displaySize[1] + offset[1]], CHARSIZE = 1.5
radonTransform = RADON(image, RHO = radonRadii, $ THETA = radonAngles, /GRAY)
WINDOW, 2, XSIZE = displaySize[0] + 1.5*offset[0], $ YSIZE = displaySize[1] + 1.5*offset[1], $ TITLE = 'Radon Transform' TVSCL, CONGRID(radonTransform, displaySize[0], $ displaySize[1]), offset[0], offset[1] PLOT, radonAngles, radonRadii, /XSTYLE, /YSTYLE, $ TITLE = 'Radon Transform', XTITLE = 'Theta', $ YTITLE = 'Rho', /NODATA, /NOERASE, /DEVICE, $ POSITION = [offset[0], offset[1], $ displaySize[0] + offset[0], $ displaySize[1] + offset[1]], CHARSIZE = 1.5
The following figure shows the Hough and Radon transforms.
![]() |
backprojectHough = HOUGH(houghTransform, /BACKPROJECT, $ RHO = houghRadii, THETA = houghAngles, $ NX = imageSize[0], NY = imageSize[1]) backprojectRadon = RADON(radonTransform, /BACKPROJECT, $ RHO = radonRadii, THETA = radonAngles, $ NX = imageSize[0], NY = imageSize[1])
WINDOW, 2, XSIZE = (3*displaySize[0]), $ YSIZE = displaySize[1], $ TITLE = 'Hough and Radon Backprojections' TVSCL, CONGRID(image, displaySize[0], $ displaySize[1]), 0 TVSCL, CONGRID(backprojectHough, displaySize[0], $ displaySize[1]), 1 TVSCL, CONGRID(backprojectRadon, displaySize[0], $ displaySize[1]), 2
The following figure shows the original image and its Hough and Radon transforms. These resulting images shows information is blurred when using the Hough and Radon transformations.
This example uses the Hough transform to find straight lines within an image. The image comes from the rockland.png file found in the examples/data directory. The image is a saturation composite of a 24 hour period in Rockland, Maine. A saturation composite is normally used to highlight intensities, but the Hough transform is used in this example to extract the power lines, which are straight lines. The Hough transform is applied to the green band of the image. The results of the transform are scaled to only include lines longer than 85 pixels. The scaled results are then backprojected by the Hough transform to produce an image of only the straight power lines. Complete the following steps for a detailed description of the process.
| Example Code See findinglineswithhough.pro in the examples/doc/image subdirectory of the IDL installation directory for code that duplicates this example. |
rockland.png file:
file = FILEPATH('rockland.png', $
SUBDIRECTORY = ['examples', 'data'])
image = READ_PNG(file)
imageSize = SIZE(image, /DIMENSIONS)
DEVICE, DECOMPOSED = 1
WINDOW, 0, XSIZE = imageSize[1], YSIZE = imageSize[2], $ TITLE = 'Rockland, Maine' TV, image, TRUE = 1
The following figure shows the original image.
intensity = REFORM(image[1, *, *])
intensitySize = SIZE(intensity, /DIMENSIONS)
mask = intensity GT 240
| Note The intensity image values range from 0 to 255. The threshold was derived by iteratively viewing the intensity image at several different values. |
DEVICE, DECOMPOSED = 0 LOADCT, 0
WINDOW, 1, XSIZE = intensitySize[0], $ YSIZE = intensitySize[1], $ TITLE = 'Mask to Locate Power Lines' TVSCL, mask
The following figure shows the mask of the original image.
transform = HOUGH(mask, RHO = rho, THETA = theta)
displaySize = [256, 256] offset = displaySize/3
TVLCT, red, green, blue, /GET TVLCT, 255 - red, 255 - green, 255 - blue
WINDOW, 2, XSIZE = displaySize[0] + 1.5*offset[0], $ YSIZE = displaySize[1] + 1.5*offset[1], $ TITLE = 'Hough Transform' TVSCL, CONGRID(transform, displaySize[0], $ displaySize[1]), offset[0], offset[1] PLOT, theta, rho, /XSTYLE, /YSTYLE, $ TITLE = 'Hough Transform', XTITLE = 'Theta', $ YTITLE = 'Rho', /NODATA, /NOERASE, /DEVICE, $ POSITION = [offset[0], offset[1], $ displaySize[0] + offset[0], $ displaySize[1] + offset[1]], CHARSIZE = 1.5, $ COLOR = !P.BACKGROUND
transform = (TEMPORARY(transform) - 85) > 0
The value of 85 comes from an estimate of the length of the power lines within the original and intensity images.
WINDOW, 2, XSIZE = displaySize[0] + 1.5*offset[0], $ YSIZE = displaySize[1] + 1.5*offset[1], $ TITLE = 'Scaled Hough Transform' TVSCL, CONGRID(transform, displaySize[0], $ displaySize[1]), offset[0], offset[1] PLOT, theta, rho, /XSTYLE, /YSTYLE, $ TITLE = 'Scaled Hough Transform', XTITLE = 'Theta', $ YTITLE = 'Rho', /NODATA, /NOERASE, /DEVICE, $ POSITION = [offset[0], offset[1], $ displaySize[0] + offset[0], $ displaySize[1] + offset[1]], CHARSIZE = 1.5, $ COLOR = !P.BACKGROUND
The top image in the following figure shows the Hough transform of the intensity image. This transform is masked to only include straight lines of more than 85 pixels. The bottom image in the following figure shows the results of this mask. Only the far left and right intersections are retained.
![]() |
backprojection = HOUGH(transform, /BACKPROJECT, $ RHO = rho, THETA = theta, $ NX = intensitySize[0], NY = intensitySize[1])
WINDOW, 4, XSIZE = intensitySize[0], $ YSIZE = intensitySize[1], $ TITLE = 'Resulting Power Lines' TVSCL, backprojection
The following figure shows the resulting backprojection, which contains only the power lines.
This example uses the Radon transform to provide more contrast within an image based on its color density. The image comes from the endocell.jpg file found in the examples/data directory. The image is a photomicrograph of cultured endothelial cells. The edges (outlines) within the image are defined by the Roberts filter. The Radon transform is then applied to the filtered image. The transform is scaled to only include the values above the mean of the transform. The scaled results are backprojected by the Radon transform. The resulting backprojection is used as a mask on the original image. The final resulting image shows more color contrast along the edges of the cell nuclei within the image.
| Example Code See contrastingcellswithradon.pro in the examples/doc/image subdirectory of the IDL installation directory for code that duplicates this example. |
endocell.jpg file:
file = FILEPATH('endocell.jpg', $
SUBDIRECTORY = ['examples', 'data'])
READ_JPEG, file, endocellImage
imageSize = SIZE(endocellImage, /DIMENSIONS)/4
endocellImage = CONGRID(endocellImage, $ imageSize[0], imageSize[1])
DEVICE, DECOMPOSED = 0 LOADCT, 0
WINDOW, 0, XSIZE = 2*imageSize[0], YSIZE = imageSize[1], $ TITLE = 'Original (left) and Filtered (right)' TV, endocellImage, 0
image = ROBERTS(endocellImage) TVSCL, image, 1
The following figure shows the results of the edge detection filter.
![]() |
transform = RADON(image, RHO = rho, THETA = theta)
displaySize = [256, 256] offset = displaySize/3
WINDOW, 1, XSIZE = displaySize[0] + 1.5*offset[0], $ YSIZE = displaySize[1] + 1.5*offset[1], $ TITLE = 'Radon Transform' TVSCL, CONGRID(transform, displaySize[0], $ displaySize[1]), offset[0], offset[1] PLOT, theta, rho, /XSTYLE, /YSTYLE, $ TITLE = 'Radon Transform', XTITLE = 'Theta', $ YTITLE = 'Rho', /NODATA, /NOERASE, /DEVICE, $ POSITION = [offset[0], offset[1], $ displaySize[0] + offset[0], $ displaySize[1] + offset[1]], CHARSIZE = 1.5
scaledTransform = transform > MEAN(transform)
WINDOW, 2, XSIZE = displaySize[0] + 1.5*offset[0], $ YSIZE = displaySize[1] + 1.5*offset[1], $ TITLE = 'Scaled Radon Transform' TVSCL, CONGRID(scaledTransform, displaySize[0], $ displaySize[1]), offset[0], offset[1] PLOT, theta, rho, /XSTYLE, /YSTYLE, $ TITLE = 'Scaled Radon Transform', XTITLE = 'Theta', $ YTITLE = 'Rho', /NODATA, /NOERASE, /DEVICE, $ POSITION = [offset[0], offset[1], $ displaySize[0] + offset[0], $ displaySize[1] + offset[1]], CHARSIZE = 1.5
The following figure shows the original Radon transform of the edge-filtered image and the resulting scaled transform. The high intensity values within the diamond shape of the center of the transform represent high color density within the filtered and original image. The transform is scaled to highlight this segment of intersecting lines.
![]() |
backprojection = RADON(scaledTransform, /BACKPROJECT, $ RHO = rho, THETA=theta, NX = imageSize[0], $ NY = imageSize[1])
WINDOW, 3, XSIZE = 2*imageSize[0], YSIZE = imageSize[1], $ TITLE = 'Backproject (left) and Final Result (right)' TVSCL, backprojection, 0
constrastingImage = endocellImage*backprojection
TVSCL,constrastingImage, 1
The following figure shows the Radon backprojection and a combined image of the original and the backprojection. The cell nuclei now have more contrast than the rest of the image.
![]() |
IDL Online Help (March 06, 2007)