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

Joined
Jul 17, 2009
Messages
1
Reaction score
0
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);

renderedOps.add(auxx);
streamList.add(stream);
} catch (IOException ex) {
Logger.getLogger(Divide.class.getName()).log(Level.SEVERE, null, ex);
}

}
}

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


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

for(FileSeekableStream s : streamList)
{
try {
s.close();
} 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");
f.delete();
}

Any suggestions will be greatly appreciated.
Regards,
Andrei
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top