Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Problem - creating a tiled image from multiple tiff sources in JAI

Thread Tools

Problem - creating a tiled image from multiple tiff sources in JAI

voncroy14 voncroy14 is offline
Junior Member
Join Date: Jul 2009
Posts: 1
Hello everybody!

I am writing a program for division operation between two images. In order to be able to manipulate large images, i have divided each image into several tiles of size 512x512. Each tile is correctly computed.
My big problem is that when I use the division operation in the following situation

(img1 - img2)/(img1 + img2)

it is obvious that the pixels resulted in the final image will have values between 0 and 1. The problem is that when i combine the tiles into one image, the pixels have 0.0 value, instead of their original value.
For reading the tiles I am using the JAI.create("stream", stream) function in order to be able to release their handle and delete these files at the end of the operation. For creating the image from tiles I am using the MosaicDescriptor.
Can anyone help me solve this problem? Why are the final values 0.0?

Here is a piece of code that follows exactly after the tiles were created:

//combine the tiles into a large image to form the final result
//NumberX, NumberY = number of tiles on X axis and Y axis
RenderedOp auxx;
List<RenderedOp> renderedOps = new ArrayList<RenderedOp>();
List<FileSeekableStream> streamList = new ArrayList<FileSeekableStream>();
tileWidth = 512;
tileHeight = 512;
nr = 0;
for (int i = 0; i < NumberY; i++)
for (int j = 0; j < NumberX; j++)
try {

FileSeekableStream stream = null;
stream = new FileSeekableStream("iesire" + (nr++) + ".tif");
// use the stream operator because the fileload operator does not allow to release the handle on the opened file
RenderedOp input = JAI.create("stream", stream);

auxx = TranslateDescriptor.create(input, (float) (tileWidth * j), (float) (tileHeight * i), null, null);

} catch (IOException ex) {
Logger.getLogger(Divide.class.getName()).log(Level .SEVERE, null, ex);


RenderedOp finalImage = MosaicDescriptor.create(
(RenderedImage[]) renderedOps.toArray(new RenderedOp[renderedOps.size()]),
null, null, null, null, null

JAI.create("filestore", finalImage, this.Params.get(2), "TIFF");

for(FileSeekableStream s : streamList)
try {
} catch (IOException ex) {
Logger.getLogger(Divide.class.getName()).log(Level .SEVERE, null, ex);

for (int i = 0; i < nr; i++)
File f = new File("iesire" + i + ".tif");

Any suggestions will be greatly appreciated.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
JAI Problem - TIFF Image to JPEG conversion surendra Java 1 06-21-2008 07:39 AM
Need Raw Tile Data of Tiled Tiff Douglas at AI Java 1 09-30-2005 09:06 PM
Creating tiled image from multiple tiff sources in JAI Michael David Pedersen Java 2 07-22-2004 09:59 PM
convert a tiff image to another format (using JAI ?) cyril Java 1 09-08-2003 01:29 PM
JAI, Image I/O, TIFF Images, and ImageReadParam Chuck Taylor Java 1 09-04-2003 12:21 AM