image comparisson matlab

please Mr... could u explain to me what's the procedure in matlab to compare 2 images, (based on color or anythig that allows me to compare them), taken by a webcam, and saved in a folder???... really thankfull for ypu attention to my question.. :D

 Accepted Answer

The simplest test to measure digital equality is to find out if they're equal:
doc isequal

2 Comments

Note: due to noise in webcam electronics, even very carefully controlled scenes with no movement and with consistent illumination, will almost never be recorded as being exactly the same.
Yes. I'm also surprised at him accepting this answer since it will never find equality for all 3 million color pixels. All 1 million (or whatever) red values, green values, and blue values would ALL have to be identical - that's not going to happen. Usually when we just make some super-simple suggestion like Sean's, that we know won't work, it is because we are trying to provoke the poster into realizing that they need to provide more information and think about their situation more. I'm sure that was the case with Sean. MSE or SSIM would be much better metrics to use.

Sign in to comment.

More Answers (2)

Walter Roberson
Walter Roberson on 8 Dec 2011

1 vote

A slightly more sophisticated method than isequal() is to convert the images to double precision, subtract them, and calculate the average difference between them. If the average difference is less than the statistical noise of the system, one could postulate that they are the same.
Caution: if you do this and there happens to be a pixel which is (say) fully red in one image where it was fully black in the other, then even though that is a large difference in that one point, when that error is averaged over all of the pixels, the statistical error test might well still easily be met. Because of this, the difference alone is not usually the measure used. Key term for you to investigate: MSE
Image Analyst
Image Analyst on 9 Dec 2011

1 vote

I could also throw SSIM into the mix: http://en.wikipedia.org/wiki/Structural_similarity
The structural similarity (SSIM) index is a method for measuring the similarity between two images. The SSIM index is a full reference metric, in other words, the measuring of image quality based on an initial uncompressed or distortion-free image as reference. SSIM is designed to improve on traditional methods like peak signal-to-noise ratio (PSNR) and mean squared error (MSE), which have proved to be inconsistent with human eye perception.
The SSIM metric is calculated on various windows of an image. The measure between two windows x and y of common size N×N is:

1 Comment

Do you know why there are negative value (like -0.05 at some point) in the ssim_map using the SSIM_index.m? It is not consistent to the paper description.
Thank you!

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!