

The second part of the activity deals with convolution of two images. The system resembles an imaging system with the circle serving as an aperture and the text 'VIP' as the object. The radius of the circle is varied and the following results were obtained.
As can be seen, the larger the radius of the aperture, the better the reconstruction. This is because the number of frequencies that can pass through is dependent on the size of the aperture. For larger apertures, more frequencies can pass through. Hence a better reconstruction is obtained as opposed to that of apertures with smaller radii.
The third part of the activity is to find the correlation of the letter 'A' in the sentence "THE RAIN IN SPAIN STAYS MAINLY ON THE PLANE." To do this, the FFT of 'A' is multiplied element per element with the FFT of the text. The result shows that the letter A's in the text are highlighted because of high correlation.

The last part of the activity shows edge detection using the convolution integral. Four patterns were used (horizontal, vertical, diagonal, and spot). The following results were obtained.

The code (taken from Reference 1):
//first part
I=imread("C:\Documents and Settings\2004-28298\Desktop\activity 5\circle.bmp");
Igray=im2gray(I);
FIgray= fft2(Igray);
fc=abs(fftshift(FIgray))/max(abs(fftshift(FIgray)));
ffc=abs(fft2(FIgray))/max(abs(fft2(FIgray)));
imwrite(fc,"C:\Documents and Settings\mimie\Desktop\activity 5\fc.bmp");
imwrite(ffc,"C:\Documents and Settings\mimie\Desktop\activity 5\ffc.bmp");
//2nd part
o=imread("C:\Documents and Settings\mimie\Desktop\activity 5\vip.bmp");
I=imread("C:\Documents and Settings\mimie\Desktop\activity 5\30r.bmp");
lgray=im2gray(I);
ogray=im2gray(o);
fl=fftshift(lgray);
fo=fft2(ogray);
col=fo.*(fl);
icol=fft2(col);
fimage=abs(icol);
fimagenorm=fimage/max(fimage);
imwrite(fimagenorm,""C:\Documents and Settings\mimie\Desktop\activity 5\vip30r.bmp");
//3rd part
t=imread("C:\Documents and Settings\mimie\Desktop\activity 5\text.bmp");
a2=imread("C:\Documents and Settings\mimie\Desktop\activity 5\A2.bmp");
tgray=im2gray(t);
a2gray=im2gray(a2);
ft=fft2(tgray);
fa2=fft2(a2gray);
cft=conj(ft);
cta2=fa2.*(cft);
fcta2=fft(cta2);
ta2=fftshift(abs(fcta2))/max(fftshift(abs(fcta2)));
imwrite(ta2,"C:\Documents and Settings\mimie\Desktop\activity 5\ta2.bmp");
//last part
i=imread("C:\Documents and Settings\mimie\Desktop\activity 5\vip.bmp");
igray=im2gray(i);
pattern1=[-1,-1,-1; 2,2,2; -1,-1,-1];
pattern2=[-1,2,-1; -1,2,-1;-1,2,-1];
pattern3=[-1,-1,-1; -1,8,-1;-1,2,-1];
pattern4=[2,-1,-1;-1,2,-1;-1,-1,2];
c1=imcorrcoef(igray,pattern1);
c2=imcorrcoef(igray,pattern2);
c3=imcorrcoef(igray,pattern3);
c4=imcorrcoef(igray,pattern4);
c1norm=c1/max(c1);
c2norm=c2/max(c2);
c3norm=c3/max(c3);
c4norm=c4/max(c4);
imwrite(c1norm,"C:\Documents and Settings\mimie\Desktop\activity 5\c1norm.bmp");
imwrite(c2norm,"C:\Documents and Settings\mimie\Desktop\activity 5\c2norm.bmp");
imwrite(c3norm,"C:\Documents and Settings\mimie\Desktop\activity 5\c3norm.bmp");
imwrite(c4norm,"C:\Documents and Settings\mimie\Desktop\activity 5\c4norm.bmp");
**Remember to comment the part of the code you don't need.
Many thanks to Ma'am Jing for providing the code which guided me through this activity. Thank you also to Kaye and Miguel for the discussions we had, and to Raffy for helping me. I give myself a 9/10 for this activity because I did what was expected from the activity.
[1] Dr. Maricor Soriano. Activity 5 Manual.
No comments:
Post a Comment