In: Computer Science
The effect of double exposure can be created by adding two images together.
Write a Matlab function to add two images and produce an output image that is the same size as the overlap region of the two input images.
Test your function.
Now, we need to add two images for that need to define two variable a & b for reading two images. for the reading two image use the function imread. now we need to check the dimention of two images for that functon called to use imfinfo which will tell the dimention of the image, here the example
imfinfo('imagename.jpg')
if the dimention is not same then it is difficult to add the two images, to make two dimention same for that function called imresize, here the example:
c = imresize (b, [size(a,1) size(a,2)];
here, i have change the dimention of b compared to a. now the both dimention of a & b is same.
next step need to add two images, for that we need to add function called imadd, here the example for easy to understand:
d = imadd(a,c);
where a is the first image & c is the modified image on dimention, for see the image you can use the function called imshow which you can view the image for example here the code:
imshow(a), here a is first image.
to display the out for adding of two images, here the code used:
subplot (221); imshow(a);title('1st Image');
subplot (222); imshow(b);title('2nd Image');
subplot (223); imshow(c);title('resize Image');
subplot (224); imshow(d);title('Addition Image');
The complete Code here the follows:
a = imread('sample1.jpg');
b = imread('sample2.jpg');
imfinfo('sample1.jpg')
imfinfo('sample2.jpg)
c = imresize (b, [size(a,1) size(a,2)]);
imshow(a)
figure,imshow(b)
figure,imshow(c)
d = imadd(a, c)
subplot(221);imshow(a);title('1st Image')
subplot(222);imshow(b);title('2nd Image')
subplot(223);imshow(c);title('Resize Image')
subplot(224);imshow(d);title('Addition Image')