Skip to main content

How come they don't compare?

2 replies [Last post]
zarpetkov
Offline
Joined: 2006-05-29
Points: 0

Hello:

New to both the group and Image Processing. Here is sniplet of code showing that 2 images that "must" be identical, do NOT compare:

File file_1, file_2;
BufferedImage img_1, img_2;

// Read the PNG file
file_1 = new File( "File1.png");
img_1 = (BufferedImage)ImageIO.read( file_1);

// Write back to another file the SAME PNG file
file_2 = new File("File2.png");
ImageIO.write(img_1, "png", file_2);

// READ back to another file the PNG file we JUST wrote
img_2 = (BufferedImage)ImageIO.read( file_2);

// Compare() returns a matching factor - DO NOT MACTH
System.out.println(
"Matching Factor = " + compareImage( img_1,img_2 ) );

I gues I am missing something .... am I?

Thanx in advance:

ZAR

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Brian Burkhalter

As PNG is a lossless format the images should be identical.

On Mon, 10 Jul 2006, jai-imageio@javadesktop.org wrote:

> Hello:
>
> New to both the group and Image Processing. Here is sniplet of code showing that 2 images that "must" be identical, do NOT compare:
>
> File file_1, file_2;
> BufferedImage img_1, img_2;
>
> // Read the PNG file
> file_1 = new File( "File1.png");
> img_1 = (BufferedImage)ImageIO.read( file_1);
>
> // Write back to another file the SAME PNG file
> file_2 = new File("File2.png");
> ImageIO.write(img_1, "png", file_2);
>
> // READ back to another file the PNG file we JUST wrote
> img_2 = (BufferedImage)ImageIO.read( file_2);
>
> // Compare() returns a matching factor - DO NOT MACTH
> System.out.println(
> "Matching Factor = " + compareImage( img_1,img_2 ) );
>
>
> I gues I am missing something .... am I?
>
> Thanx in advance:
>
> ZAR
> [Message sent by forum member 'zarpetkov' (zarpetkov)]
>
> http://forums.java.net/jive/thread.jspa?messageID=130986
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

robert engels

It depends on how compareImage() is written. If it compares byte by
byte rather than pixel by pixel they can be different.

As I found out recently, even though PNG is lossless, there
compression quality determines the size vs. speed during compression,
resulting in different bytes for the same image - but the same pixel
values.

On Jul 12, 2006, at 7:04 PM, Brian Burkhalter wrote:

>
>
>> Hello:

[att1.html]