Skip to main content

Binary Lossless Encoding

8 replies [Last post]
eljefe6a
Offline
Joined: 2006-05-15

I am trying to binary image lossless encoding (TIFF->PNG->TIFF). No matter what I do, the files are always different. Now, I am just trying to read a tiff and write out a new tiff without any compression.

I tried 2 different methods and neither work.

Has anyone else tried this? Thanks.

<br />
	static void TIFtoTIF2(String filename) {<br />
		RenderedOp src = JAI.create("fileload", filename + ".tif");<br />
		ParameterBlock myPB = src.getParameterBlock();<br />
		ColorModel cm = src.getColorModel();</p>
<p>		FileOutputStream stream = null;<br />
		try {<br />
			stream = new FileOutputStream(filename + "_output2.tif");<br />
		} catch (Exception E) {<br />
			E.printStackTrace();<br />
		}</p>
<p>		TIFFEncodeParam param = new TIFFEncodeParam();<br />
		param.setCompression(TIFFEncodeParam.COMPRESSION_NONE);<br />
		param.setWriteTiled(false);<br />
		param.setLittleEndian( true );</p>
<p>		ImageEncoder enc = ImageCodec.createImageEncoder("TIFF", stream, param);</p>
<p>		try {<br />
			enc.encode(src);<br />
			stream.close();<br />
		} catch (Exception E) {<br />
			E.printStackTrace();<br />
		}<br />
	}</p>
<p>	static void TIFtoTIF(String filename) {<br />
		RenderedImage image = JAI.create("fileload", filename + ".tif");</p>
<p>		System.out.println(image);<br />
		System.out.println(image.getColorModel());</p>
<p>		String format = "TIFF";</p>
<p>		TIFFEncodeParam params = new TIFFEncodeParam();<br />
		params.setCompression(TIFFEncodeParam.COMPRESSION_NONE);</p>
<p>		RenderedOp op = JAI.create("filestore", image, filename<br />
				+ "_fromtif.tif", format, params);</p>
<p>		System.out.println(op);<br />
		System.out.println(op.getColorModel());<br />
	}

Reply viewing options

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

'tiffcmp'?

http://libtiff.org/
http://libtiff.org/tools.html

On Thu, 1 Jun 2006, jai-imageio@javadesktop.org wrote:

> Can you recommend an image comparison program that works correctly?

----------------
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

eljefe6a
Offline
Joined: 2006-05-15

I have even run ImageMagick's compare (http://www.imagemagick.org/api/compare.php) on the before and after tiffs. There is a difference in almost every pixel. This generation loss would affect everyone using JAI.

Does anyone have any ideas?

Robert Engels

The images will always be different in terms of format (due to scanline
size, how much effort they want to put into the compression, etc.).

Barring bugs in your program, the resulting "content" will ALWAYS be the
same if using a lossless encoding though.

-----Original Message-----
From: jai-imageio@javadesktop.org [mailto:jai-imageio@javadesktop.org]
Sent: Thursday, June 01, 2006 11:53 AM
To: interest@jai-imageio.dev.java.net
Subject: [JAI-IMAGEIO] Re: Binary Lossless Encoding

I have even run ImageMagick's compare
(http://www.imagemagick.org/api/compare.php) on the before and after tiffs.
There is a difference in almost every pixel. This generation loss would
affect everyone using JAI.

Does anyone have any ideas?
[Message sent by forum member 'eljefe6a' (eljefe6a)]

http://forums.java.net/jive/thread.jspa?messageID=118267

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

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

eljefe6a
Offline
Joined: 2006-05-15

I posted the methods I am using already. They are going from Uncompressed TIF to Uncompressed TIF. There is no compression at all.

To check if JAI output changes the tiff's fill-in-the-blank I took a second generation tiff and ran the same operation (uncompressed TIF to uncompressed tif to uncompressed tif). And the comparison between the 2nd and 3rd generation tiffs show a difference too.

Robert Engels

Then there is something wrong in the comparison code. As stated before, the
files will be different, the images will be the same.

-----Original Message-----
From: jai-imageio@javadesktop.org [mailto:jai-imageio@javadesktop.org]
Sent: Thursday, June 01, 2006 2:13 PM
To: interest@jai-imageio.dev.java.net
Subject: Re: RE: [JAI-IMAGEIO] Re: Binary Lossless Encoding

I posted the methods I am using already. They are going from Uncompressed
TIF to Uncompressed TIF. There is no compression at all.

To check if JAI output changes the tiff's fill-in-the-blank I took a second
generation tiff and ran the same operation (uncompressed TIF to uncompressed
tif to uncompressed tif). And the comparison between the 2nd and 3rd
generation tiffs show a difference too.
[Message sent by forum member 'eljefe6a' (eljefe6a)]

http://forums.java.net/jive/thread.jspa?messageID=118304

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

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

eljefe6a
Offline
Joined: 2006-05-15

I started up Photoshop and manually did comparisons of random pixel's color. They were all the same color. For the life of me, I can't figure out why ImageMagick messed up.

Thanks for your help Robert.

Can you recommend an image comparison program that works correctly?

Robert Engels

I don't know of one. But it is trivial to write one using Java.

-----Original Message-----
From: jai-imageio@javadesktop.org [mailto:jai-imageio@javadesktop.org]
Sent: Thursday, June 01, 2006 4:43 PM
To: interest@jai-imageio.dev.java.net
Subject: Re: RE: RE: [JAI-IMAGEIO] Re: Binary Lossless Encoding

I started up Photoshop and manually did comparisons of random pixel's color.
They were all the same color. For the life of me, I can't figure out why
ImageMagick messed up.

Thanks for your help Robert.

Can you recommend an image comparison program that works correctly?
[Message sent by forum member 'eljefe6a' (eljefe6a)]

http://forums.java.net/jive/thread.jspa?messageID=118324

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

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

eljefe6a
Offline
Joined: 2006-05-15

Forgot one more method:

[code]
static void TIFToTIF_ImageWrite(String filename) {
RenderedImage image = JAI.create("ImageRead", filename + ".tif");

String format = "TIFF";

RenderedOp op = JAI.create("ImageWrite", image, filename
+ "_fromtiff.tif", format, null);
}
[/code]