Skip to main content

32 and 64 bit Histogram generation

12 replies [Last post]
shrieky
Offline
Joined: 2007-11-26

Hi All,
I am trying to generate histogram for 32/64 bit images but i got no success because of the limitage of Memory. I tried using -Xmx1024m option too.
My sample code is as follows :

int binsSize = (int) Math.pow(2, cimg21.getColorModel().getPixelSize() / nuofBands);
int[] numBins = new int [nuofBands];
double[] lowValue = new double [nuofBands];
double[] highValue = new double [nuofBands];
for(int j = 0; j < nuofBands; j++)
{
numBins(j) = binsSize;
lowValue(j) = 0D;
highValue(j) = binsSize - 1;
}
ParameterBlock pb = new ParameterBlock();
pb.addSource(cimg21);
pb.add(null);
pb.add(1);
pb.add(1);
pb.add(numBins);
pb.add(lowValue);
pb.add(highValue);

RenderedImage rhist = JAI.create("histogram", pb);
histogram = (Histogram) rhist.getProperty("histogram")
Can anyone help me to generate histogram with a limited memory.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jxc
Offline
Joined: 2005-02-24

> I am trying to generate histogram for 32/64 bit
> images but i got no success because of the limitage
> of Memory. I tried using -Xmx1024m option too.

You might like to decrease the number of bins.

HTH,
-James

shrieky
Offline
Joined: 2007-11-26

Hi James,

I am processing the satellite images.So i would not like to reduce the number of bins. Is there any other way to calculate histogram.

Thanks,
Shrieky

jxc
Offline
Joined: 2005-02-24

Hi Shrieky,

> I am processing the satellite images.So i would not
> like to reduce the number of bins. Is there any other
> way to calculate histogram.

I wonder currently how many bins you have for each band.
If it's 2^16, then for each band you need 2^16 ints, i.e., 256 KB.
If you have many bands, then you might try to use BandSelect
to get each band out and calculate its histogram. If it's 2^32,
then for each band you need 2^32 ints, which is way too big.

Thanks,
-James

shrieky
Offline
Joined: 2007-11-26

Hi James,

I am handling 32 bit and 64 bit images. So that comes to around 2^32 / 2^64. I am processing multiple images. I am trying to calculate the Histogram for all the bands because the user can change the band configuration in the application.So i cannot calculate the histogram everytime.

Thanks,
Shrieky

bpb
Offline
Joined: 2004-06-23

What dimensions are your images? Which format? Are they tiled?

Brian

> Hi James,
>
> I am handling 32 bit and 64 bit images. So that comes
> to around 2^32 / 2^64. I am processing multiple
> images. I am trying to calculate the Histogram for
> all the bands because the user can change the band
> configuration in the application.So i cannot
> calculate the histogram everytime.
>
> Thanks,
> Shrieky

shrieky
Offline
Joined: 2007-11-26

I am processing satellite images.So they need not be tiled.And when it comes to dimensions, they would be 12K x 12K . Format would be TIFF.
Thanks for your reply.That gives me hope.

Regards,
Shrieky

bpb
Offline
Joined: 2004-06-23

I forgot to ask, are they compressed or uncompressed?

Brian

> I am processing satellite images.So they need not be
> tiled.And when it comes to dimensions, they would be
> 12K x 12K . Format would be TIFF.
> Thanks for your reply.That gives me hope.
>
> Regards,
> Shrieky

shrieky
Offline
Joined: 2007-11-26

They are uncompressed.

Shrieky

bpb
Offline
Joined: 2004-06-23

Who are you loading the original image, cimg21?

Brian

> They are uncompressed.
>
> Shrieky

shrieky
Offline
Joined: 2007-11-26

cimg21 is a RenderedImage.

Shrieky

bpb
Offline
Joined: 2004-06-23

Right, but how are you loading it? Also, did you say that it is tiled?

Brian

> cimg21 is a RenderedImage.
>
> Shrieky

shrieky
Offline
Joined: 2007-11-26

yes it is tiled...