Image comparison and compression

I am doing project based on image comparison. I need to compare two images. I use basic pixel by pixel comparison . If the images are of different size the comparison can not be done. So i was planning to compress the image to make them of same size(Resolution). But while compressing the image the pixel value might change (i am not sure about whether they will change or not ? correct me if im wrong) So in that circumstances pixel by pixel comparison may not be an efficient method. Can any one please help me with this. Please.

 Accepted Answer

Walter Roberson
Walter Roberson on 1 Feb 2012
I think you mean "resize" rather than "compress".
Yes, resizing images will generally change pixels.
What you should do about the change of pixels depends upon what you mean by "image comparison".
If I have a picture that is a green background (square) that has a purple circle and an orange triangle inside it, and I create a second image in which I leave all the sizes and shapes exactly the same, but change the colors to yellow, red, and brown, then should the images compare as being fairly similar (same object shapes, same sizes and positions), or should the images compare as being completely different (since not one pixel is the same color) ?

6 Comments

Yes sir , I meant resizing. According to the scenario you gave,i am asking if the shapes of the object in the image and their color are same. but the overall size of the image is different i.e. if one picture is 900 × 600 pixels..and another is 1024X768.In that case , when i do pixel by pixel comparison will i get the result as "both are same image" or both are not same image ?
A pixel-by-pixel comparison will not work if the images are not the same size.
If the two images started from a single image that was then resized, then there can be different results depending on the resizing algorithm, so resizing will not necessarily give you something that you could compare pixel by pixel.
If the two images are of the same _scene_, but taken with different resolutions, then you can have issues about the lighting having changed or the camera position having changed a little. And if you control for those using lights and a tripod, then if the same camera was being used, the different resolutions are most likely achieved in the camera by _it_ applying a resizing algorithm (since the camera image sensor is a fixed size.)
Concentrating on pixel by pixel comparisons is probably not going to work very well, especially if the images were taken under different conditions.
Ok sir, in that case (The image is of same scene but of different resolution)what kind of algorithm will help me to perform image comparison ?
To check: is the lighting controlled, and a tripod used, and the objects in the scene are stationary? Can we count on the two images covering _exactly_ the same view, or should we expect that there might be a small amount of displacement, even if only due to camera shake?
Sir i am actually considering two images has exactly same scene in it. No change in brightness or any other property but only in their size. And if i check if they are same or not i should get the correct result. can u help me with this?
Call imresize, then subtract them and see if the sum of the differences of all the pixels is less than some value that you specify.

Sign in to comment.

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!