Reference no: EM132582442
ENGI 7854 Image Processing and Applications - Memorial University of Newfoundland
Calculating the moment invariants
1. Download the grayscale test image (image.png), calculate moments.m, and Moment invariants.m files from D2L under Lab 4 and save them in the MATLAB working directory. Read the files and understand the implementation of calculating the seven invariant moments.
2. Read the image, obtain the size of the image and pad the image by one-fourth the image size in all directions with zeros. Use this as the basis for next steps (referred to as Im1 ).
3. Create spatial transformation matrix T1 for translation as follows:
T1 = maketform('affine', [1 0 0; 0 1 0; Xt Yt 1]);
%Xt,Ytareone-fourthofyouroriginalimage
Use the above transformation matrix T1 and perform the transformation as follows:
Im2 = imtransform(Im1, T,...
'XData',[1 size(Im1,1)],'YData',[1 size(Im1,2)]);
Display the translated image Im2;
4. Create spatial transformation matrix T2 for scaling to 0.5 (of original size) as follows:
T2 = maketform('affine', [0.5 0 0; 0 0.5 0; 0 0 1]);
Use the above transformation matrix T2 and perform the transformation as follows:
Im3 = imtransform(Im1, T2,...
'XData',[1 size(Im1,1)],'YData',[1 size(Im1,2)]);
Display the translated image Im3;
5. Create spatial transformation matrix T3 to rotate the image by 45 degrees as follows:
T3 = maketform('affine', [cos(pi/4) sin(pi/4) 0; -sin(pi/4) cos(pi/4)
0; 0 0 1]);
Use the above transformation matrix T3 and perform the transformation as follows:
Im4 = imtransform(Im1, T3,...
'XData',[-269 size(Im1,1)-270],'YData',[+111 size(Im1,2)+110]);
Display the translated image Im4;
6. Create spatial transformation matrix T4 for rotating the image 90 degrees as follows:
T4 = maketform('affine', [cos(pi/2) sin(pi/2) 0; -sin(pi/2) cos(pi/2)
0; 0 0 1]);
Use the above transformation matrix T4 and perform the transformation as follows:
Im5 = imtransform(Im1, T4,...
'XData',[-539 size(Im1,1)-540],'YData',[1 size(Im1,2)]);
Display the translated image Im5;
7. Flip the original image Im1 from left to right using following command and generate image Im6.
Im6=flipdim(Im1,2);
Display the mirrored image Im6;
8. The downloaded matlab file Moment invariant.m contains a function Moment invariant(), which calls to another function named as calculate moments. Collectively, these functions calculate the moment invariants.
Use the function Moment invariant() and pass the images created from step 2 to step 7 (Im1-Im6) from the command line. For example, the following line will display the moment invariants calculated for Im1:
Moment_invariants(Im1)
Discussion
1. You should include the MATLAB code and results in your lab report.
2. Discuss the values of the moment invariants computed for each image, including any similarities or differences. What do these similiarities or differences mean in terms of image features?
Attachment:- Image Processing and Applications.rar