Skip to main content

Please, TiledImage info!!

2 replies [Last post]
sportinguista
Offline
Joined: 2010-05-30

Hi, I´m starting a new project with JAI and I don´t know how to handle tiles.

I have a big multiband TIFF file (35MB) and I want to procesate it to pixel-level. I´ve readed a lot of documentation and tutorials, but I still don´t understand..

In my first aproximation (it´s similar to my real code):

RenderedImage img = (RenderedImage) JAI.create("imageread", "c:\\corte.tif");
RenderedImageAdapter ria = new RenderedImageAdapter(img);
image = ria.getAsBufferedImage();

//ojects required to obtain pixels data
this.writableRaster = image.getRaster();
this.sampleModel = image.getSampleModel();
this.dataBuffer = writableRaster.getDataBuffer();
this.showInfo(image);

int[] pixels = new int[bands * width * height];
Raster inputRaster = image.getData();
inputRaster.getPixels(0, 0, width, height, pixels);
int offset;
for (int h = 0; h < height; h++)
for (int w = 0; w < width; w++)
{
offset = h*width*bands + w*bands;
for (int band = 0; band < bands; band++) {
if (pixels[offset+band] == 0) pixels[offset+band] = 255;
}
}
writableRaster.setPixels(0, 0, width, height, pixels);
TiledImage ti = new TiledImage(image,1,1);
ti.setData(writableRaster);

Well, the last instruction gives me OutOfMemoryError exception.

How can I mend it? Expanding memory?... how to make it?

I don´t know how to work with tiles... I just know creating a PlanarImage pi, then a TiledImage (pi, false)... what´s next? how can I access tiles? where do I indicate tiles dimensions?

Please somebody help, I am really stuck

Thank you :)

Message was edited by: sportinguista

Well, the last instruction gives me OutOfMemoryError exception.

How can I mend it? Expanding memory?... how to make it?

I don´t know how to work with tiles... I just know creating a PlanarImage pi, then a TiledImage (pi, false)... what´s next? how can I access tiles? where do I indicate tiles dimensions?

Please somebody help, I am really stuck

Thank you :)

Reply viewing options

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

Hello,

Some examples in http://www.lac.inpe.br/JIPCookbook/1300-create-rgb.jsp
may be of help.

Rafael

> Hi, I´m starting a new project with JAI and I don´t know how to handle tiles.
>
> I have a big multiband TIFF file (35MB) and I want to procesate it to pixel-level. I´ve readed a lot of documentation and tutorials, but I still don´t understand..
>
> In my first aproximation (it´s similar to my real code):
>
> RenderedImage img = (RenderedImage) JAI.create("imageread", "c:\\corte.tif");
> RenderedImageAdapter ria = new RenderedImageAdapter(img);
> image = ria.getAsBufferedImage();
>
> //ojects required to obtain pixels data
> this.writableRaster = image.getRaster();
> this.sampleModel = image.getSampleModel();
> this.dataBuffer = writableRaster.getDataBuffer();
> this.showInfo(image);
>
> int[] pixels = new int[bands * width * height];
> Raster inputRaster = image.getData();
> inputRaster.getPixels(0, 0, width, height, pixels);
> int offset;
> for (int h = 0; h< height; h++)
> for (int w = 0; w< width; w++)
> {
> offset = h*width*bands + w*bands;
> for (int band = 0; band< bands; band++) {
> if (pixels[offset+band] == 0) pixels[offset+band] = 255;
> }
> }
> writableRaster.setPixels(0, 0, width, height, pixels);
> TiledImage ti = new TiledImage(image,1,1);
> ti.setData(writableRaster);
>
> Well, the last instruction gives me OutOfMemoryError exception.
>
> How can I mend it? Expanding memory?... how to make it?
>
> I don´t know how to work with tiles... I just know creating a PlanarImage pi, then a TiledImage (pi, false)... what´s next? how can I access tiles? where do I indicate tiles dimensions?
>
>
> Please somebody help, I am really stuck
>
> Thank you :)
> [Message sent by forum member 'sportinguista']
>
> http://forums.java.net/jive/thread.jspa?messageID=472060
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>
>

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

sportinguista
Offline
Joined: 2010-05-30

............continue my post...........

if (pixels[offset+band] == 0) pixels[offset+band] = 255;
}
}
writableRaster.setPixels(0, 0, width, height, pixels);
TiledImage ti = new TiledImage(image,1,1);
ti.setData(writableRaster);

Well, the last instruction gives me OutOfMemoryError exception.

How can I mend it? Expanding memory?... how to make it?

I don´t know how to work with tiles... I just know creating a PlanarImage pi, then a TiledImage (pi, false)... what´s next? how can I access tiles? where do I indicate tiles dimensions?

Please somebody help, I am really stuck

Thank you :)

Message was edited by: sportinguista