Using MATLAB write a code for the following Write a script t
Using MATLAB write a code for the following:
Write a script that reads two different JPEG images into MATLAB. Make sure that the images are in your Working Directory/Current Folder or that you specify the exact path to them. Next, superimpose the images. If the matrices are the same size, the elements can simply be added element by element. However, if they are not the same size, one method of handling this is to crop (imresize, imcrop) the larger matrix to be the same size as the smaller, and then add them Submit your code the original images, and the superimpose images.Solution
Ans:
%Reading both files from same folder
im1 = imread(\"Image1.jpeg\");
im2 = imread(\"Image2.jpeg\");
%Getting sizes of both the images
[x1, y1] = size(im1);
[x2, y2] = size(im2);
%Condition to check if both the images are of same size
if (x1==x2) && (y1==y2)
im3 = imadd(im1, im2);
%If not getting the bigger image, rezising it to make it of the same size as the smaller image
%and adding them together
elseif ((x1*y1)>(x2*y2))
im1_resized = imresize(im1, size(im2));
im3 = imadd(im1_resized, im2);
else
im2_resized = imresize(im2, size(im1));
im3 = imadd(im1, im2_resized);
imshow(im1);
title(\'Input Image1\');
imshow(im2);
title(\'Input Image2\');
imshow(im3);
title(\'Superimposed Output Image\');
