A. Familiarization with discrete FFT
This images above are circles of small (center), medium (right) and big (left) radius. This corresponds to different aperture size when used for FFT.
The images on the left are the transformed image of the small circle image above: lefmost(shifted FT), middle (FT) and rightmost (FT'd twice). The expected image from analytic solutions is an airy disc, a series of dark and bright concentric rings. In this case however, the continuity of the rings of the FT'd image depends on the radius of the original image. The shifted image shifted the positions of the maximum and minimum. Unshifted image has a decreasing intensity starting from the corners while the shifted image shifted the coordinates of the maximum at the center of the image. The last image (FT'd twice) is supposed to be inverted. But by symmetry of the original image, it is not obsereved.
Another sample image on the leftmost part is used. The center left image is the FT'd image of the left image and the center right image is the FT'd image shifted. The same principles can be observed in shifting and this time, inversion of the final image when FT'd twice is observable (rightmost image) due to asymmetry of the input image.
B. Simulation of an image device...
The leftmost image is the original image to be convolved with the images of circles with different radii (image from left to right next to the original are the resulting images for increasing radius).
A circle is like a lens in FT that inverts any image convolved with it at higher values of radius. This is the case of the rightmost image wherein the radius of the circle is large enough to let the effect be an inverting lens. Below this value (at least for this case), the image becomes blurry. The effect of the decreasing radius approaches the airy disc-like convolved image. The effect becomes a slit that 'diffracts' the incoming signal resulting to interference which produces the maxima and minima in the disc.
C. Template matching using correlation
The first image on the left most side in the figures above is correlated with the next two image and their corresponding result is the next two image on the rightmost portion of the figures. From the inputs to be compared, the images are very different as depicted by dark regions of the resulting images where the value of correlation is low. The parts with yellow color are those positions where the images are very similar (high correlation). This is essential for template matching. the resulting conjugated image will tell how similar the input images are.
D. Edge detection using convolution integral
The images are the 'vip image' convolved with different patterns with varying edge values.
From the left, the first image is the result of convolution with a horizontal patterned edge where the horizontal edges are detected. The second image is the convolution with a vertically edged pattern. As expected, the vertical edges are detected shown by the distortions in that region. The third image is a convolution with a diagonally aligned pattern. The expected result should show distortions except on the diagonal. It is hardly seen in the image. Finally, the last image is convolved with a spot pattern. As expected, only the center stayed undistorted compared to the sorrounding edge. In this way, convolution as a tool for edge detection is verified.
Rating:
I had fun transforming the images and learnes more about the concept of Fourier Transform and other techniques related. The results I got are good enough to verify from the simulations in Scilab the physical concepts regarding Fourier Transform. Expected results were met and some agreement with the analytic results were satisfied. So I'll give myself a perfect 10. for this activity.
The codes: courtesy again of Dr. Soriano
FFT
im=imread('C:\Documents and Settings\AP186user24\Desktop\a_a6.bmp');
Igray = im2gray(im);
//unshifted
FIgray = fft2(Igray);
//imshow(abs(FIgray),[]);xset("colormap",hotcolormap(256))
//for the shifted output
FIshifted=fftshift(FIgray);
imshow(abs(FIshifted),[]);xset("colormap",hotcolormap(256))
//fft applied twice
//imshow(abs(fft2(FIgray)),[]);xset("colormap",hotcolormap(256))
CONVOLUTION
r=imread('C:\Documents and Settings\AP186user24\Desktop\circle_a6.bmp');
a=imread('C:\Documents and Settings\AP186user24\Desktop\vip.bmp');
rgray = im2gray(r);
agray = im2gray(a);
Fr = fftshift(rgray);
//aperture is already in the Fourier Plane and need not be FFT'ed
Fa = fft2(agray);
FRA = Fr.*(Fa);
IRA = fft2(FRA); //inverse FFT
FImage = abs(IRA);
imshow(FImage, [ ]);xset("colormap",hotcolormap(256))
CORRELATION
r=imread('C:\Documents and Settings\AP186user24\Desktop\corr1.bmp');
a=imread('C:\Documents and Settings\AP186user24\Desktop\corr4.bmp');
rgray = im2gray(r);
agray = im2gray(a);
Fr=fft2(rgray);
Fa=fft2(agray);
FI=Fa.*conj(Fr);
Fnew=fft2(FI);
Fimage=abs(Fnew);
imshow(Fimage, [ ]);xset("colormap",hotcolormap(256))
EDGE DETECTION
a=imread('C:\Documents and Settings\AP186user24\Desktop\vip.bmp');
agray = im2gray(a);
pattern1=[-1 -1 -1; 2 2 2; -1 -1 -1];
pattern2=[-1 2 -1; -1 2 -1; -1 2 -1];
pattern3=[-1 -1 2; -1 2 -1; 2 -1 -1];
pattern4=[-1 -1 -1; -1 8 -1; -1 -1 -1];
FImage=imcorrcoef(agray, pattern4);
imshow(FImage, [ ]);xset("colormap",hotcolormap(256))
end.........................................................................................................................................
From the left, the first image is the result of convolution with a horizontal patterned edge where the horizontal edges are detected. The second image is the convolution with a vertically edged pattern. As expected, the vertical edges are detected shown by the distortions in that region. The third image is a convolution with a diagonally aligned pattern. The expected result should show distortions except on the diagonal. It is hardly seen in the image. Finally, the last image is convolved with a spot pattern. As expected, only the center stayed undistorted compared to the sorrounding edge. In this way, convolution as a tool for edge detection is verified.
Rating:
I had fun transforming the images and learnes more about the concept of Fourier Transform and other techniques related. The results I got are good enough to verify from the simulations in Scilab the physical concepts regarding Fourier Transform. Expected results were met and some agreement with the analytic results were satisfied. So I'll give myself a perfect 10. for this activity.
The codes: courtesy again of Dr. Soriano
FFT
im=imread('C:\Documents and Settings\AP186user24\Desktop\a_a6.bmp');
Igray = im2gray(im);
//unshifted
FIgray = fft2(Igray);
//imshow(abs(FIgray),[]);xset("colormap",hotcolormap(256))
//for the shifted output
FIshifted=fftshift(FIgray);
imshow(abs(FIshifted),[]);xset("colormap",hotcolormap(256))
//fft applied twice
//imshow(abs(fft2(FIgray)),[]);xset("colormap",hotcolormap(256))
CONVOLUTION
r=imread('C:\Documents and Settings\AP186user24\Desktop\circle_a6.bmp');
a=imread('C:\Documents and Settings\AP186user24\Desktop\vip.bmp');
rgray = im2gray(r);
agray = im2gray(a);
Fr = fftshift(rgray);
//aperture is already in the Fourier Plane and need not be FFT'ed
Fa = fft2(agray);
FRA = Fr.*(Fa);
IRA = fft2(FRA); //inverse FFT
FImage = abs(IRA);
imshow(FImage, [ ]);xset("colormap",hotcolormap(256))
CORRELATION
r=imread('C:\Documents and Settings\AP186user24\Desktop\corr1.bmp');
a=imread('C:\Documents and Settings\AP186user24\Desktop\corr4.bmp');
rgray = im2gray(r);
agray = im2gray(a);
Fr=fft2(rgray);
Fa=fft2(agray);
FI=Fa.*conj(Fr);
Fnew=fft2(FI);
Fimage=abs(Fnew);
imshow(Fimage, [ ]);xset("colormap",hotcolormap(256))
EDGE DETECTION
a=imread('C:\Documents and Settings\AP186user24\Desktop\vip.bmp');
agray = im2gray(a);
pattern1=[-1 -1 -1; 2 2 2; -1 -1 -1];
pattern2=[-1 2 -1; -1 2 -1; -1 2 -1];
pattern3=[-1 -1 2; -1 2 -1; 2 -1 -1];
pattern4=[-1 -1 -1; -1 8 -1; -1 -1 -1];
FImage=imcorrcoef(agray, pattern4);
imshow(FImage, [ ]);xset("colormap",hotcolormap(256))
end.........................................................................................................................................
No comments:
Post a Comment