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

Discussion in 'Java' started by voncroy14, Jul 17, 2009.

  1. voncroy14

    voncroy14

    Joined:
    Jul 17, 2009
    Messages:
    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);

    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
     
    voncroy14, Jul 17, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chuck Taylor
    Replies:
    1
    Views:
    8,381
    Chuck Taylor
    Sep 4, 2003
  2. cyril
    Replies:
    1
    Views:
    819
    cyril
    Sep 8, 2003
  3. surendra
    Replies:
    1
    Views:
    8,512
    dipakPardesi
    Jun 21, 2008
  4. Michael David Pedersen
    Replies:
    2
    Views:
    3,637
    Michael David Pedersen
    Jul 22, 2004
  5. Douglas at AI

    Need Raw Tile Data of Tiled Tiff

    Douglas at AI, Sep 30, 2005, in forum: Java
    Replies:
    1
    Views:
    632
    Andrey Kuznetsov
    Sep 30, 2005
Loading...

Share This Page