-1

Has anyone got an idea how could I check if the image(.jpeg) copied from a CD is exactly the same as the one that its pasted to PC. Is there a algorithm that would check all the pixels or written data of the file?

Thank you in advance for your answer!

Ghoul Fool
  • 6,249
  • 10
  • 67
  • 125
  • How are you copying them? If, for example, you're using Windows and just copy/paste in Windows Explorer, they will be bit-for-bit exactly the same. – Cully May 08 '14 at 06:55
  • Yes im copying them normal copy/paste, but the copy is coming from a cd that is maybe old/damaged and i want to know if the copy would be the same as the one on the cd? – user3615166 May 08 '14 at 07:22
  • Computers are digital. It's generally all or nothing. Windows won't tell you it copied the file from a CD to your hard drive unless it copied it exactly, bit-for-bit. – Cully May 08 '14 at 07:26
  • Ok i understand that and thank you for you answear. But now i want to know if there is a way to check if 2 pictures are exactly the same(pixel to pixel or something)? – user3615166 May 08 '14 at 07:30
  • Images are binary files. There are some binary file comparison programs posted here: http://stackoverflow.com/questions/8166697/tool-for-comparing-2-binary-files-in-windows – Cully May 08 '14 at 07:40
  • You could probably also find some good results searching for "compare two binary files" – Cully May 08 '14 at 07:41
  • Ok thank you a lot for you answears, i tried that VBinDiff and it works fine. – user3615166 May 08 '14 at 08:12

1 Answers1

1

This warrants a comment but is too long to fit:

It sounds like you want to compare the images and not the files themselves. The latter would be easy. I presume then you want to do the harder image comparison.

The problem with JPEG is that it is lossy. The process introduces errors. If you take a JPEG image, open it up and save it again, then open the saved image, it is likely not to be exactly the same as the first image.

Even if the sampling and quantization tables are the same, you can still get rounding errors.

First check if the pixel dimensions match. Then, for each pixel, convert to the YCbCr color space and compare the values within a range.

Pseudocode

srcY = YfromRGB (srcR, srcG, srcB) ;
dstY = YfromRGB (dstR, dstG, dstB) ;

if ((srcY - dstY) * (srcY - dstY) < SOMEDELTA) they are roughy the same

do the same for Cb and Cr for every pixel.

Here, I have only taken into account JPEG process difference. Some encoders may do gamma correction throwing the thing off even more.

user3344003
  • 20,574
  • 3
  • 26
  • 62