3802
Color Density Contrasting in an Image using the IDL Radon Transform
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 sub-directory under your IDL 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 applied to the filtered image. The high intensity values within the triangle of the center of the transform represent high color density within the filtered and original 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 bounded by the edges of the filtered image.
Code Example:
PRO contrastingCells
; Determine path to file.
file = FILEPATH('endocell.jpg', $
SUBDIRECTORY = ['examples', 'data'])
; Import image within file into IDL.
READ_JPEG, file, endocellImage
HELP, endocellImage
; Determine image's size, but divide it by 4 to reduce
; the image.
imageSize = SIZE(endocellImage, /DIMENSIONS)/4
; Resize image to half its original length and width.
endocellImage = CONGRID(endocellImage, $
imageSize[0], imageSize[1])
; If you are on a truecolor display, set the DECOMPOSED
; keyword to the DEVICE command to zero before using
; any color table related routines.
DEVICE, DECOMPOSED = 0
; Load in the STD GAMMA-II color table.
LOADCT, 5
; Display original image.
WINDOW, 0, XSIZE = imageSize[0], YSIZE = imageSize[1], $
TITLE = 'Endocells'
TV, endocellImage
; Filter original image to clarify the edges of the
; cells.
image = ROBERTS(endocellImage)
; Display filtered image.
WINDOW, 1, XSIZE = imageSize[0], YSIZE = imageSize[1], $
TITLE = 'Filtered'
TVSCL, image
; Transform the filtered image.
transform = RADON(image, RHO = rho, THETA = theta)
; Display transform of image.
transformSize = SIZE(transform, /DIMENSIONS)
WINDOW, 2, TITLE = 'Transform of Image', $
XSIZE = transformSize[0], YSIZE = transformSize[1]
TVSCL, transform
; Scale the transform to include only the density
; values above the mean of the transform.
scaledTransform = transform > MEAN(transform)
; Display scaled transform.
WINDOW, 3, TITLE = 'Scaled Transform of Image', $
XSIZE = transformSize[0], YSIZE = transformSize[1]
TVSCL, scaledTransform
; Backproject the scaled transform.
backprojection = RADON(scaledTransform, /BACKPROJECT, $
RHO = rho, THETA=theta, NX = imageSize[0], $
NY = imageSize[1])
; Display backprojection.
WINDOW, 4, XSIZE = imageSize[0], YSIZE = imageSize[1], $
TITLE = 'Backprojection'
TVSCL, backprojection
; Use the backprojection as a mask to provide
; a color density contrast of the original image.
constrastingImage = endocellImage*backprojection
; Display resulting contrast image.
WINDOW, 5, XSIZE = imageSize[0], YSIZE = imageSize[1], $
TITLE = 'Constrast'
TVSCL, endocellImage*backprojection
END
_________________________________________________
Reviewed by BC on 09/05/2014