Fourier Transform: Image Processing

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 39

Part 4.

Processing 3 - Fourier methods

4.A. FFT requirements


4.B. Applying high and low pass filters
4.B.1. Inverting filters
4.B.2. Avoiding ringing
4.C. Periodic noise removal
4.C.1. In-place operation
4.C.2. Periodic signals
4.D. Measurements on the power spectrum
4.E. Averaging periodic signals
4.E.1. Processing for peak finding
4.E.2. Filters for regular lattices
4.F. Correlation
4.F.1. Cross-correlation
4.F.2. Autocorrelation
4.G. Convolution and Deconvolution
4.H. Halftone and moiré removal
4.H.1. Color images
4.I. JPEG compression
4.J. The linear Hough transform
4.J.1. Measurements in Hough space

Frequency space offers some attractive advantages for image processing. It makes large linear filtering operations
(equivalent to the application of large neighborhood kernels) much faster, and it collects information together in
different ways that can sometimes separate signal from noise or allow measurements that would be very difficult
in the spatial domain.

4.A. FFT Requirements: The common denominator in all of these operations is the FFT or fast Fourier
transform. The software requires that the image be square with dimension equal to an exact power of two (e.g.,
128, 256, 512, ...). There are several easy ways to select a suitable region from a larger image. One is to copy and
paste the image into a new window of the appropriate size. The step-by-step process is Select | All; Edit |
Copy; File | New (enter the dimensions in pixels); Edit | Paste. If the original image is larger than the new
window you can shift the image within the window to select the region, before de-selecting the region. Note that
you must deselect the pasted region before performing any filter operation, or else the program will attempt to
apply the process to the entire clipboard rather than just to the image area (usually with unexpected and incorrect
results). This can be done in many ways, for instance by choosing Select | All, by clicking in the image with
the ROI/Marquee tool, or by flattening the image (Layer | Flatten Image). If the original image is smaller
than the new window, the surrounding area should ideally be filled with an intermediate grey value (this is called
"padding") to minimize the amplitude of the Fourier terms needed to accommodate the transition to white. This
filling can be done using the paintbucket.

Tutorial Part 4 Page # 1 Fourier methods


Another way is to select a region within the current image, either by
carefully dragging the ROI to the appropriate dimensions as shown
in the Info window (be sure the dimensions are shown in pixels) or
by setting the ROI to a fixed size in the Marquee Options window
(double click the Marquee or ROI tool to display this window). With
either method, it is important to have the image displayed at 100%
magnification. If it is reduced in size it will not in general be possible
to actually draw the region of interest with the desired exact
dimensions and the FT routines will not be able to run.

Once a grey scale image of an appropriate dimension is


ready, select Filter | IP•FFT | Forward FT to
perform the conversion from the spatial domain to the
frequency domain. This will replace the original image with
the power spectrum, which in most cases will not be
directly interpretable. However, a variety of processing and
measurement procedures can be applied, some of which
modify the power spectrum and reconstruct a processed
spatial domain image.

4.B. Applying high and low pass filters. Traditional low-pass filters used for smoothing and high-pass
filters for edge sharpening can be applied by selecting a circular aperture in frequency space and keeping either
the low frequency data inside or the high frequency data outside the circle. Smoothing the edge of the aperture
will reduce ringing, and of course the cutoff frequency itself depends on what you know about the contents of the
image and what you want to keep or eliminate.

To apply a basic circular aperture to the data, create a new, blank image that is the same size as the original (for
example, select Image | Duplicate, Select | All and press Delete to erase the contents). Then choose the
elliptical marquee tool and depress the shift key (which constrains the shape to a circle) and option (Mac) or alt
(Windows) which causes the shape to be drawn from its center, and draw a circle starting from the center of the
power spectrum display. The result is a circular aperture that can be filled with black by selecting Edit | Fill.
The surroundings can be erased by Select | Inverse and pressing Delete.

If the central circular aperture is black and the surroundings white, the filter will keep low frequencies and erase
high frequencies. To apply this filter to the stored Fourier transform and reconstruct a filtered spatial domain
Tutorial Part 4 Page # 2 Fourier methods
image, select Filter | IP•FFT | Filter+Inv. Note: the terms "mask" and "filter" are used interchangeably
here. In some cases the term mask is reserved for operations that remove or keep portions of the power spectrum,
while the term filter is used for the more general case in which some terms may be reduced in magnitude without
being eliminated. Since the filters used in the FFT plug-ins are proportional in value, and a black and white filter
can be used as an ideal mask, the distinction is ignored here. Note that circular masks or filters can also be
produced without manual drawing using the Generate Filters function below (choose annular and set the width
equal to twice the radius).

Original Girl image Power spectrum from FT

Low-pass cutoff filter Inverse FT with low-pass cutoff

Tutorial Part 4 Page # 3 Fourier methods


4.B.1. Inverting the filter or mask image before performing the inverse transforms the
low pass filter to a high pass filter (the black values mark frequencies that are included in
the inverse transform, white values are eliminated). Select Image | Adjust | Invert to
reverse the grey scale of the mask or filter image. Note in the example shown that a single
point has been added to the mask at the very center to keep the constant term (this was
done manually with the pencil tool using the Info window to locate the center - for a
256x256 pixel image the center is at 128,128). The central point defines the average
brightness value of the image.

Hi-pass cutoff filter Inverse FT with hi-pass cutoff


Selecting the proper size for the circular filter is sometimes easier if you can see the power spectrum while you
are constructing the filter. To do this, do not use the Delete key to erase the newly created duplicate image as
discussed above. Instead, just draw the circular region right on the power spectrum display or a duplicate of it,
and then press Delete to erase the area inside the circle. Invert the selection (Select | Inverse) interchange the
foreground/ background colors (click on the tool palette) and press Delete to fill the area outside the circle with
black, and you will have created a hi-pass filter (white in the center and black outside the circle). You can of
course invert this (Image | Adjust | Invert) to make a low-pass filter.

Tutorial Part 4 Page # 4 Fourier methods


4.B.2. The similarity between the low-pass frequency filtered
result and smoothing in the spatial domain, and between the
hi-pass frequency filtered result and a Laplacian in the spatial
domain, reveals that these operations are mathematically
equivalent. In both the high pass and low pass examples there
is a very evident "ringing" phenomenon that arises from the
sharp edge of the cutoff filter. There are many ways to
overcome this, including simply blurring the mask or filter
using the standard Photoshop blur tools (e.g., Filter | Blur |
Gaussian Blur). There are also facilities to generate other
filter masks, including 1/f, Hamming and Butterworth filters
(select Filter | IP•FFT | Gen. Filters). The latter is
illustrated below; notice the reduction in ringing. As above,
inverting the mask image (and if necessary adding a point at
the center to keep the average brightness value of the image)
converts a low-pass to a high-pass filter.

Butterworth low-pass filter Result from low-pass Butterworth

Tutorial Part 4 Page # 5 Fourier methods


Butterworth hi-pass filter Inverse with hi-pass Butterworth

Instead of using the built-in filter shapes (ideal inverse, Hamming and Butterworth), the user can of course also
construct any desired bandpass filter. The filter is simply a grey scale image, with values that vary between black
(unity) and white (zero), typically with radial symmetry. Tools such as the Photoshop gradient tool can be used to
construct such patterns. There is also a plug-in to assist with this (Filter | IP•FFT | Bandpass). The sliders
are used much as a hi-fi equalizer to set amplitude as a function of frequency (shown in terms of pixel spacing);
the initial default is an ideal inverse filter. The filter can then applied using Filter | IP•FFT | Filter &
Inverse, or by Filter | IP•FFT | Apply Filter followed by Filter | IP•FFT | Inverse.

Bandpass filter dialog and the resulting filter.

Tutorial Part 4 Page # 6 Fourier methods


4.C. Periodic noise removal is commonly performed in frequency space. In images with periodic noise,
which can result from the image sensor, from electronic interference, etc., the frequency transform collects all of
the noise into a few spots which can be eliminated. There are automatic ways to locate peaks in the FFT image,
for instance a top hat filter, but in the first examples we will select them manually. The same forward FT is
performed, and then the paintbrush is used to mark each spot corresponding to the halftone pattern present in the
original image. Only points in one-half of the power spectrum need to be marked as the space is symmetric and
redundant. Select Filter | IP•FFT | Symmetry to duplicate the marks in any half of the power spectrum in
the other half as well.

Thresholding (Image | Adjust | Threshold) the marked image will select just the darkest pixels
corresponding to the marked spots, after which the mask filter can be inverted (Image | Adjust | Invert)
because we want to remove the spots, and smoothed (Filter | Blur | Blur More). Performing the inverse
transform (Filter | IP•FFT | Filter+Inv.) produces the spatial domain image with the periodic noise
removed.

Note that the marking of points using the


paintbrush may be simplified if you set the
preferences to show the brush as a circle of the
appropriate size (select File | Preferences |
Display & Cursors) and set the Painting
Tool Cursor to Brush Size and Other Tools to
Precise).

Original Clock image FT Power spectrum of Clock image

Tutorial Part 4 Page # 7 Fourier methods


Mask filter to remove periodic noise Inverse FT using mask filter

4.C.1. An example of doing this “in place” in a region


within an image is shown using the Clown image. The
region of interest was drawn using the shift key to
restrict the marquee to a perfect square while watching
the Info window to set it to 128 pixels in dimension.
Then Filter | IP•FFT | Forward FT was used to
transform just the selected region, manual marking was
used to mark the two dominant noise frequencies, this
was thresholded and inverted to produce the mask, and
then Filter | IP•FFT | Filter+Inverse used to
obtain the image with noise removed.

Tutorial Part 4 Page # 8 Fourier methods


Manual marking of the spikes in the power spectrum is not the only way to create a filter or mask to remove
them. As shown in the example, selecting a region of the image that contains just the noise by drawing a region of
interest asks the user to identify the noise pattern without having to interpret the power spectrum image. Erase
everything else in the image (Select | Inverse followed by Edit | Cut and Selection | Deselect) and then
perform the Fourier transform (Filter | Plug-ins | IP•FFT | Forward FT). The power spectrum shows
the spikes that arise from the noise pattern. Treating this like any other grey scale image can produce a filter or
mask. In this example, the image was smoothed, leveled, thresholded, inverted, and the central spot filled.

Selected region of periodic noise from Clock image Power spectrum

Tutorial Part 4 Page # 9 Fourier methods


Filter mask produced from the power spectrum Application of the filter mask to the entire image

4.C.2. In some cases it is the periodic signal that is important. The procedure is similar. Perform the forward FT
and mark the spots representing periodic information with a black paint circle. If this is done on one-half of the
power spectrum, select Filter | IP•FFT | Symmetry to duplicate the spots for the entire area. Threshold the
spots (Image | Adjust | Threshold) and optionally smooth them (Filter | Blur | Gaussian Blur).
Then select Filter | IP•FFT | Filter+Inv. to produce the filtered spatial domain result.

In the next example, another way to create the filter mask is shown. A circular region of interest is drawn in the
same way described above (set the marquee style to Elliptical, depress the shift and option keys to draw a circle
from the center, and draw the circle so that it fits the circular array of spots that correspond to the periodic spacing
of atom planes in the image). Then convert the circular region of interest outline to a line on the image by
selecting Edit | Stroke and choosing an appropriate width. Then perform the inverse transform using this mask
(Filter | IP•FFT | Filter+Inv.) to produce an image with the periodic atom planes enhanced.

Tutorial Part 4 Page # 10 Fourier methods


Original Carbon image FT Power spectrum

Annular filter mask Enhanced visibility of atoms


Tutorial Part 4 Page # 11 Fourier methods
Another way to create an annular filter is to use the circle drawing procedure to mark a circle region (as described
just above) inside the ring to be preserved and then press Delete to erase it. Then draw another circle just outside
the ring of frequencies to be kept, choose Select | Inverse to change the circle selection to one that includes
the pixels outside the circle, and press Delete to erase that. This will leave just the ring of spots. Then use Image
| Adjust | Threshold to turn all non-white pixels to black, which will produce an annular ring that can be
smoothed and used as a filter mask.

Finally, the Filter | IP•FFT | Gen Filters function will directly generate an annular filter by allowing you
to enter numbers (the fraction of the radius from center to edge of the power spectrum) for the radius and width of
the annular ring. There is likewise a sector mask selection that will generate a mask to select a range of directions,
by angle. In both cases, inverting the mask can be used to remove rather than keep the range of frequencies or
directions, and applying a Gaussian smooth to blur the edges of the mask will reduce ringing.

4.D Measurements on the power spectrum. In order to generate an annular filter, it is useful to be able
to measure the radius of the ring of spots in the Carbon image. This can be done using the Photoshop cursor and
the Info window, by reading the pixel addresses of the spots and calculating the distance to the center.

With Photoshop 5 it is more convenient to use the ruler


tool, place one end on the center of the power spectrum
and drag the other to the ring, and read the distance in
pixels directly in the Info window. The angle is also
displayed. (Digital Darkroom offers a similar ruler
capability.)

Tutorial Part 4 Page # 12 Fourier methods


The Carbon image is a good
example of an image in which the
periodic spacing can be measured
in the FT power spectrum much
more easily than in the spatial
domain image. A circularly
averaged radial profile plot of the
power spectrum shows a peak that
corresponds to the reciprocal of the
atom plane spacing.

This plot is generated as one option by the Filter | IP•FFT


| Profiles... function, which can also be used to plot the
intensity in any selected direction (along a radial line from the
center or DC point to a maximum radius equal to the size of
the inscribed circle in the power spectrum).

Another example of measuring spacings using the FT power spectrum is shown next. In this case, the spacing is
not perfectly regular but the average and variation in spacing and direction can still be measured efficiently from
the power spectrum.

Tutorial Part 4 Page # 13 Fourier methods


Original Hyphilic image. FT Power spectrum.

Circularly averaged radial plot of


power spectrum. The values and
the minimum and maximum limits
(loge) are taken from the actual
stored power spectrum, not from
the 8 bit grey scale display.

Regularly spaced features are much more easily and accurately measured in frequency space than in the spatial
domain image. In the example (Muscle2) the striations are very faint but produce a clear point in the FFT power
spectrum (select Filter | IP•FFT | Forward FT). The location of this point averages all of the repetitive
spacing in the image and can be read from the info window by using the cursor.

Tutorial Part 4 Page # 14 Fourier methods


Muscle2 image (contrast enhanced) FFT Power spectrum

Use the cursor to locate the dark


spike in the power spectrum
corresponding to the regular line
spacing, and read the location in
the Info window. Since the
original image is 512x512, the
central point in the power
spectrum is at x=256, y=256.
Hence the distance from the
center to the spike is 27 pixels,
corresponding to a spacing of
512/27 = 18.96 pixels in the
original image. With Photoshop
5, it is easier to use the ruler tool
to measure the distance from the
center to the spot directly.

Tutorial Part 4 Page # 15 Fourier methods


4.E Averaging periodic signals can be done in another way as well. Rather than manually selecting the
spots in the FT power spectrum, any image processing technique can be applied (such as a top hat filter to select
spots, or background removal to eliminate the gradually varying background) to enhance the spots so that they
can be thresholded to become the filter mask. In the example shown, direct thresholding with (Image | Adjust
| Threshold) is adequate to select the peaks, after which the Filter | IP•FFT | Filter+Inv. selection will
produce a result that averages together the information in all of the periodic repetitions of the pattern in the image.

Original Mullite image FT Power spectrum

Thresholded spots (filter mask). Inverted (averaged) image.

Tutorial Part 4 Page # 16 Fourier methods


4.E.1. Since the power spectrum image can be processed
like any other grey scale image, additional tools can be used
to select just the periodic spots in cases like this. One
powerful tool for finding small dark spots (the dark spikes
in the power spectrum) is the top hat filter. Applying a top
hat (Filter | IP•Rank | TopHat ) with an inner radius
of 1 pixel and an outer radius of 3 to thepower spectrum
sets all pixels that are within the range (darkest to lightest)
of the surrounding neighborhood to medium grey, but
leaves pixels that are darker or lighter than their
surroundings with the difference. Thresholding this image
for (in this case) the dark spots produces a mask that
specifically selects the spots, and then applying Filter |
IP•FFT | Filter+Inv results in a very clean image of
the periodic structure.

Filter | IP•Rank | TopHat applied to power spectrum

Thresholded top hat result Inverse FT using the mask

Tutorial Part 4 Page # 17 Fourier methods


4.E.2. Regular lattices (such as high resolution TEM images of atomic structure) typically generate Fourier
transforms whose power spectra show a regular 2-D array of harmonics. An efficient way to produce a mask or
filter for these spots is to manually mark two fundamental (lowest frequency) spots. All of the other spots will
then be positioned at the locations formed by the vector sums of these point locations (from the center of the
power spectrum), times small integers. The Filter | IP•FFT | Harmonics routine performs this operation. It
requires that you mark one or two points using some unique color or grey scale value. It finds these marks which
match the current pen or foreground color, and generates the harmonic spots which are shown superimposed in
black on the power spectrum. They can be thresholded using Filter | IP•Threshold | BiLevel or Filter |
IP•Threshold | Pen Color (with the pen set to black) and then used as any other filter. The examples show
the application of this procedure to the HRTEM image and the Muscle3 image (the latter requires only a single
point since the pattern has only one direction).

Original HRTEM image Fourier power spectrum with two points marked.

Tutorial Part 4 Page # 18 Fourier methods


Automatically generated lattice mask Inverse transform showing averaged atomic image

Original Muscle3 image (fragment) Power spectrum with one point marked

Tutorial Part 4 Page # 19 Fourier methods


Row of harmonic frequencies selected Filter and Inverse result

4.F. Correlation: Fourier space is also used for locating patterns within images. Cross-correlation can be
understood most straightforwardly as an operation in the spatial domain. If the shape of a target is made into a
kernel whose values are multiplied by the pixel values at every location in the image and normalized for the
absolute values of the pixels, the largest response will result when the image contains the same pattern of grey
scale values. However, the operation is more efficiently performed in the Fourier domain by multiplying
(remembering that these are complex numbers) the transforms of the target and the image together and
performing an inverse transformation on the result. With either implementation, the locations in the image that
match the targer are found efficiently even in the presence of noise, shading, or partial obscuration of the target.

4.F.1. Cross-correlation requires two images, which need not be the same size (the program automatically
pads them to the nearest power of two). First copy the target image into memory using Setup 2nd Image.
Then select the image to be matched, and choose Filter | IP•FFT | CrossCorrelate. As shown in the
examples, the program returns the magnitude of the cross-correlation value which marks the location of matching
regions. The first example is an artificial image containing text and the second one a real image of latex spheres.

TextSam1 image TextSam2 image Cross-correlation result

Tutorial Part 4 Page # 20 Fourier methods


The cross-correlation image is shown first using indexed
color (Image | Mode | Indexed Color) to assist in
locating the maximum point, at the location of the script
m in the image. The image can also be rendered as a
surface (Filter | IP•Render | Surface) to show the
highest point. Notice that the rotated m at the bottom of
the image is not matched. Cross correlation matching of
text requires the letters to be the same size, font and
orientation.

Image of latex spheres (XC_Many) Target image (XC_Targt)

Tutorial Part 4 Page # 21 Fourier methods


Cross-correlation image Rendered cross-correlation image showing matches

The cross-correlation technique can also be applied to color images. All of the Fourier processing routines extract
the grey scale brightness from color images to use in calculating the transforms. The example (Trees) also
illustrates the use of a feature within the image as the target. Manually draw a rectangular region of interest
around a single, well defined treetop. Select Filter | IP•2nd Image | Setup to put this region into the
second image buffer. Then remove the selection marquee (Select | Deselect) and perform the cross-correlation
(Filter | IP•FFT | CrossCorrelate). The result is a grey scale image that shows bright spots corresponding
to the tree tops, which can be processed (e.g. with a top-hat) thresholded and counted.

Original Trees image with selected region of interest.


Tutorial Part 4 Page # 22 Fourier methods
Cross-correlation result.

4.F.2. Autocorrelation is similar mathematically to cross-correlation except that the image itself is used as the
target image. This is used to find degrees of self-similarity or repetition within an image. The procedure is the
same as the cross correlation except that the same image is used as the target. Select Filter | IP•2nd Image |
Setup, then Filter | IP•FFT | Cross Correlate.

Original Shotblasted image Autocorrelation image

Tutorial Part 4 Page # 23 Fourier methods


In the example, the autocorrelation image shows the
spatial correlation in the shotblasted surface (a range
image) and reveals a slight anisotropy, shown by
drawing several contours (Filter | IP•Threshold |
IsoLines). This is one of the standard methods for
quantifying anisotropy in surfaces.

When applied to an image with periodic structure, the


autocorrelation function identifies and isolates that
structure. For example, when applied to the Muscle2
image shown above the result is the regular spacing of
the striations.

4.G. Convolution and Deconvolution: Convolution in the Fourier domain is identical in result to that in
the spatial domain, in which a kernel of values (a blur function) is applied to every pixel in the image (Filter |
IP•Process | Convolve). In Fourier space, this simply involves multiplying the transform of the blur function
with the transform of the image, pixel by pixel (select Filter | IP•FFT | Convolution). In many cases it will
be easier to construct the kernel as an image rather than as a set of numerical values.This is particularly true when
the kernel is not symmetrical. Sometimes the blur function can be measured directly by acquiring an image of a
point (e.g., a star in astronomical images). Some examples of such convolutions are shown applied to the Bug
image below.

Tutorial Part 4 Page # 24 Fourier methods


This also implies that it is possible to remove a blur from an image by dividing by the transform of the blur, and
this process is called Deconvolution. The Filter | IP•FFT | Deconvolution plug-in carries out this
procedure. It deconvolves the main image using the contents of the image previously designated with the Setup
2nd Image function. The two images do not need to be the same size, nor are they restricted to powers of 2 in
size. Deconvolution is typically used to remove blur due to out-of-focus optics or motion from images; the
second image must contain the point spread function of the blur. In some cases it is practical to acquire such an
image by imaging a point (astronomers use the image of a star for this purpose). The deconvolution is actually
performed in the frequency domain by dividing the complex transform of the main image by that of the second
image, but apodizing the values so that points in the second image transform with small amplitudes are not used.
The transform of the reconstructed image is stored and can be displayed using the Filter | IP•FFT | Power
Spectrum function.

In the examples shown, the Bug image has first been convolved with three different types of blur or “point spread
functions” (using Filter | IP•FFT | Convolution) , and then Filter | IP•FFT | Deconvolution used to
recover the original image. The first example is a symmetrical blur as might be produced by out-of-focus optics,
the second is motion blur which corresponds to a straight line (whose direction and distance must be known), and
the third example is a “positive-negative” point spread that corresponds to oblique illumination or DIC
microscopy.

Bug image blurred with symmetrical point spread function (center) and deconvolved

Bug image blurred with line (motion) function (center) and deconvolved

Tutorial Part 4 Page # 25 Fourier methods


Bug image convolved with DIC point spread (center) and deconvolved

4.H. Half tone and moiré removal: Removal of half-tone patterns from photographs is often an important
problem to address, and processing in frequency space is a much better solution than processing such as blurring
that can hide the dots but also reduces edge sharpness. The resolution of the scanner used to input the image also
affects the high frequency noise pattern in the acquired image and can produce additional moiré patterns. This
artefact is also characteristic of grey scale images obtained from single-chip video cameras. The best method for
removing such regular patterns utilizes Fourier transforms and works in frequency space instead of the original
array of pixels in the image.

The example shows an example of an image scanned in from a newspaper; the halftone dots are very evident.
This is actually a small portion of the original image, enlarged to show the dots. In the power spectrum from a
Fourier transform, produced using Filter | IP•FFT | Forward FT, the magnitude of low frequency
information (gradually varying grey scale with position in the image) is plotted in the center of the array and high
frequency information (rapidly varying grey scale with position) is plotted at increasing radii outwards. The dark
spots ("spikes") in the power spectrum far away from the center are the indication of periodic noise in the image.
They align with the repetitive pattern of printed dots, and their darkness indicates how much of various
frequencies are present. Removing them is equivalent to removing the periodic noise. A mask was produced to
remove these spikes. This could have been done manually with the paint brush, but instead the top hat filter
discussed above was used. A small Gaussian blur was applied to the mask so that the pixels on the edges of the
holes in the mask are set to grey, which improves the results as shown before.

Tutorial Part 4 Page # 26 Fourier methods


Original Halftone image FT power spectrum

Mask to remove the periodic noise spikes Image with periodic noise removed

The result of applying this mask as a filter to remove the spikes (select Filter | IP•FFT | Filter+Inverse)
shows that the periodic noise has been removed without affecting any of the other information present. There is
still some pixel-to-pixel variation because the image has been scanned at a higher magnification than it was
printed. A second filter was employed to remove the remaining pixel noise. This is a Butterworth second-order
high-frequency cut-off filter (Filter | IP•FFT | Gen Filters), which keeps low frequencies (gradual
variations in grey scale) while progressively cutting off higher ones (the more rapid variations associated with
pixel noise). In this case the mid-point of the cutoff was set to the spacing of the half-tone dots in the original
image.
Tutorial Part 4 Page # 27 Fourier methods
Butterworth filter Power spectrum with both filters applied

The final version of the power spectrum,with the periodic


spots removed and the high frequencies attentuated can be
shown (Filter | IP•FFT | Power Spectrum) for
information purposes. Selecting Filter |IP•FFT |
Inverse produces the final image. Note that even the
cat's whiskers which are barely discernible in the original
image can be clearly seen. The use of a smoothing or blur
function would have erased these fine lines long before
the halftone dots were smoothed out.

Final processed image

4.H.1. The desirability of processing in frequency space is especially true for color images, in which the half-
tone patterns used for the different color planes have different orientations in order to avoid visible patterns in the
printed image. In this case, the image can be separated into RGB planes and each one subjected to an FFT,
removal of the noise peaks, and then recombining the resulting planes to form the final image. In the example
shown, the three FFT power spectra are shown as color planes as well to emphasize the different locations of the
noise peaks in each. Depending on the origin of theimage, it may be necessary to separate the image into CMY
planes.

Tutorial Part 4 Page # 28 Fourier methods


Original Membrane color image Recombined RGB image after filtering

RGB combination of separate FFT power spectra of the


R G B planes of the original image, showing the distinct
high frequency noise peaks from each plane. For many
printed images, separation into CMYK planes is a better
method because those are the color inks used to print the
interleaved halftones that make up the image.

4.I. JPEG Compression, one of the major compression techniques used in multimedia imaging, is based on
a frequency transform - the discrete cosine transform is closely related to the FFT. The power spectrum or
frequency transform is scanned and small terms are eliminated, which results in compression. For visual
reproduction, the amount of information in the few terms kept may be enough, and image storage requirements
may be reduced by a factor of 10 or more, but note that edge contrast is distorted, small details are lost, and other
artefacts appear that would seriously compromise image measurements. Photoshop supports opening and saving
JPEG images, so you can experiment with compressing images by various amounts and then re-opening them for
visual comparison. The FT power spectrum of the compressed image will show that some information has been
removed but not where. The JPEG compression method transforms separately each 8x8 pixel square in the
Tutorial Part 4 Page # 29 Fourier methods
original image and eliminates terms that have small magnitudes, but the specific terms are not the same for all
regions depending on the presence of detail there.

Girl image (JPEG compressed 10:1) Power spectrum of compressed image.

Difference between original and compressed power


spectra.

The loss of information in JPEG compression can also be seen by subtracting the original image from one after
compression. In the example shown the difference has been contrast expanded to emphasize these effects. Note
that edges have been displaced, features altered in texture and dimension, colors shifted, and that the brightness
offsets between adjacent 8x8 pixel blocks can be seen. In this case the compression reduced the original file size

Tutorial Part 4 Page # 30 Fourier methods


from about 550K to about 24K bytes, or a 20:1 compression. Larger degrees of compression make the effects
more noticeable.

Original Flowers image Difference between original and JPEG version

The images shown in this tutorial have all been JPEG compressed from the original versions. This is done by
Adobe Acrobat® in order to compress the size of the “pdf” files. Many of them are also shown reduced in size.
But the original versions are on the CD-ROM and may be examined before and after processing.

4.J. The Linear Hough Transform. There are many transforms besides the familiar Fourier transform
that map the image from the spatial domain of pixels into some other space where particular kinds of information
can be extracted or processing performed. One that is quite powerful is the Hough transform. The implementation
provided as in this set of plug-ins is the Linear Hough Transform, which is useful for finding linear alignments of
points in an image. The transform uses a space with polar coordinates of angle (the slope of the line, represented
on the horizontal axis from 0 to 180 degrees) and distance (how far the line passes from the origin of the image,
which is located at the upper left hand corner of the original image, and represented on the vertical axis with a
range of ± the diagonal dimension of the image.

To execute the forward Hough transform, which maps every black (pixel value zero) point in an image into the
Hough space, first store the image of interest as the "second" image (either the Filter | IP•2nd Image |
Setup). Then create a new image (File | New) to use as the Hough space. This image does not need to be the
Tutorial Part 4 Page # 31 Fourier methods
same size as the original spatial domain, in fact it will often be much larger to provide better resolution of the ρ,θ
values for the line(s). Then select File | IP•Lines+Points | Hough(Fwd) to calculate the Hough
transform.

Single marked point in a spatial image. The forward Hough transform represents it as a sine curve.

Each pixel in the original spatial image that is black (non-black pixels are ignored) will generate a portion of a
sine curve in Hough space, corresponding to the slope and intercept values of all of the possible lines that would
pass through the original pixel location in the spatial domain image. You may experiment by marking single
points or a few points using the pencil or paintbrush tool and calculating the transforms to understand this better.
Likewise, each point in Hough space corresponds to a line in the spatial domain. The inverse Hough transform
uses the ρ,θ values of any black pixel (non-black pixels are ignored) to draw the corresponding straight lines in
the spatial domain image. To use the inverse transform, store the Hough transform image as the second image
(Filter | IP•2nd Image | Setup), select the original spatial domain image as the foreground image, and
choose Filter | IP•Lines+Points | Hough(Inv). The program will draw the lines in the current
foreground or pen color on top of the original image.

Tutorial Part 4 Page # 32 Fourier methods


Single point in Hough space. The inverse Hough transform makes it a line.

The key to the usefulness of Hough space is that when two (or more) points are present in the spatial image, their
sine curves cross each other and the locations of the crossing points identify the slope and intercept of the line that
would pass through the original points. In the example shown, there are several points (actually small circles
marked with the paint brush) that more-or-less lie on a straight line. In the Hough transform this produces a
crossover point, and the Hough space adds together all of the sine waves so the maximum value is easily found.
This is the set of ρ,θ values that identifies the line that is the "best fit" to the points.

Many points in the spatial domain. The forward Hough transform (note crossover at left).

Tutorial Part 4 Page # 33 Fourier methods


The specific grey scale coding used in the transform assigns a pixel value of 1 to each sine wave (nearly black, so
the sine waves show up well), and increments the value for each overlapping sine wave. Hence the brightest point
in the crossover region identifies the desired point in Hough space (and its value reports the number of points in
the spatial image that "voted" for it). Converting this point to black (pixel value 0) can be done either manually
with the pencil tool or using automatic image processing tools, such as a top hat filter. In the example, this
produces a line that passes through or near all of the points and identifies the alignment which they represent.
This provides a tool to find such alignments of disconnected and irregularly spaced features.

The line drawn on the original spatial domain


image by the inverse Hough transform of the
crossover point.

Such alignments are sometimes easy to recognize visually, because human vision is sensitive to such things (it is
one reason that we see constellations in the night sky). But the Hough transform provides a tool to fit lines to the
data and determine the best-fit angle and position. In the Sat-1 image, for example (only a portion of the image is
shown), there is a straight feature that might be a road or fault. Processing this with a Sobel operator highlights
the disconnected pixels along the edges of the feature. Selecting a region around this feature (the Lasso tool was
used to select the region, the Select | Inverse was used to reverse the selection and the Delete key used to
erase the surrounding region) and thresholding (Image | Adjust | Threshold) to make just the pixels with a
large gradient value produced a suitable set of points for the transform. Finding the maximum value in the
transform image and using the inverse Hough transform to draw the image back onto the original Sat-1 image
shows the alignment found.

Tutorial Part 4 Page # 34 Fourier methods


Sat-1 image (fragment) Selected portion after Sobel processing

Line reconstructed from maximum point in the


Hough transform

4.J.1. Hough space is also useful for measurements. The Linewidt image was processed using a horizontal
derivative, thresholded, and the Hough transform applied. In ths resulting image the four crossover points that
correspond to the vertical lines along the sides of the vertical structures in the SEM picture are clearly marked.
Even though the original image is noisy so that a continuous delineation of the edges would be difficult, the data
from many points are combined in the Hough transform space so that the separation distance between the lines
can be easily and accurately measured (the vertical spacing between the crossover maximum points). The Hough
transform image can be made as large as needed to provide the desired measurement resolution.

Tutorial Part 4 Page # 35 Fourier methods


Original Linewidth image

Processed (horizontal derivative)

Thresholded to delineate edge pixels

Tutorial Part 4 Page # 36 Fourier methods


Hough transform (vertical separation of the bright spots gives spacing of edges).

The Hough transform can also be used to measure orientation. In the example shown (IC image), the edges of the
device are oriented at a slight angle. Applying an edge-enhancement operator (Filter | IP•Process |
SobelMag) followed by thresholding produces an image of pixels along the edges. Making this the second
image (Filter | IP•2nd Image | Setup) and then creating a new image (File | New) whose width is 720
pixels (providing enough precision to measure the orientation accurately), followed by calculating the Hough
transform (Filter | IP•Lines+Points | Hough(Fwd), produces an image in which the bright spots that
mark the lines are found at two angles, as shown on the image. These are about 3.25 degrees less than 90 and 180
degrees, and so a rotation of the image by that amount produces good alignment. The rotation was accomplished
by duplicating the image in a layer (Layer | Duplicate Layer) and then selecting numerical rotation (Layer
| Transform | Numeric) and entering in the desired rotation value.

Tutorial Part 4 Page # 37 Fourier methods


Original IC image Sobel Edge-enhancement and Thresholding

Hough transform with bright spots marked

Image rotation dialog Rotated result


Tutorial Part 4 Page # 38 Fourier methods
Tutorial Part 4 Page # 39 Fourier methods

You might also like