I need matlab code for the above mentioned question in the picture. Please provi
ID: 3904455 • Letter: I
Question
I need matlab code for the above mentioned question in the picture. Please provide complete and authentic code. It would be pleasing. Thanks in advance.
Whenever we deal with three dimensional images either in their rotation, scaling, projection or any other processing, all the main operations are performed by matrices and their manipulations You are required to take at least 5 images (as a demo) in .jpeg format with different resolutions, extract their RGB values matrix one by one and perform following operations. I) Image Rescaling 2) Rotation at different angles in degrees. 3) Image projection from a higher dimension to lower one. Your MATLAB code should not be hardcoded. It should accept any JPEG image and should perform said operations with different rescaling factors, rotation angles and projection requirements. After processing, also calculate through an error algorithm that how much the original image differs from processed image. (Include paper calculations in your report too, if any)Explanation / Answer
Answer:
We shall prompt the user to enter the scaling factor, degrees of rotation of the image and scale for dimensions
Img1=imread('image1.jpeg'); % read all the 5 images one by one using imread() command
r1=Img1( :,:, 1); % r matirx
g1=Img1(:,:, 2); % g matrix
b1=Img1(:,:,3); %b matrix
prompt1='Enter the scaling factor' ;
scale= input(prompt1);
prompt2='Enter the rotation in degrees';
D=input(prompt2);
Img11=imresize(Img1,scale) ; % scale by say factor of scale=as per user input
Img12=imrotate(Img1,D,'bilinear','crop'); % rotate by say D degrees anticlockwise direction
[m1 n1]=size(Img1); % check the dimension of the 2D image
prompt3='Enter X dimension for projection of image'
Xval=input(prompt3);
prompt4='Enter Y dimension for projection of image';
Yval=input(prompt4);
Img13= imresize(Img1,[Xval Yval]); % set the dimension of the image to lower dimension say here it is (Xval x Yval)
% displaying and comparing the original images and processed images
figure;
imshowpair(Img1,Img11);
figure;
imshowpair(Img1,Img12);
figure;
imshowpair(Img1,Img13);
%calculate absolute differences between processed and original image and display the image difference
diff11=imabsdiff( Img1,Img11);
figure;
imshow(diff11,[]);
diff12=imabsdiff(Img1,Img12);
figure;
imshow(diff12,[]);
diff13=imabsdiff(Img1,Img13);
imshow(diff13,[]);