MATLAB Answers

0

differece image of 2 images

Asked by Sajitha K.N. on 28 Aug 2019
Latest activity Edited by Subhadeep Koley on 3 Sep 2019
How to calculate difference image of 2 images read from different folders?

  2 Comments

Rik
on 28 Aug 2019
If they are the same size you can just subtract one from the other. What have you tried so far?
And just to be clear, subtraction between data of for example uint8 might give you unwanted results, cast the images to doubles before subtracting:
diff_img1 = img1 - img2;
diff_img2 = double(img1) - double(img2);
% compare the two as you see fit

Sign in to comment.

1 Answer

Answer by Subhadeep Koley on 3 Sep 2019
Edited by Subhadeep Koley on 3 Sep 2019
 Accepted Answer

MATLAB provides imabsdiff function to find the absolute difference of two images. The following code might help you.
% read image from folder 1
image1=imread('yourImage1.png');
% read image from folder 2
image2=imread('yourImage2.png');
% calculate the absolute difference
absDiffImage=imabsdiff(image1,image2);
% plot the absolute difference image
figure;
imshow(absDiffImage,[]);
colormap(jet);
colorbar;

  0 Comments

Sign in to comment.