470,599 Members | 1,438 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,599 developers. It's quick & easy.

Building a Histogram in JAI

Hi All, I am trying to use JAI to build a histogram of an image i have. I
have posted the code below, and the error I get at runtime. I have taken the
code from the offical java examples, so I am really puzzled why it doesn't

public PlanarImage thresholding (PlanarImage source) {

// set up the histogram
int[] bins = { 256 };
double[] low = { 0.0D };
double[] high = { 256.0D };

Histogram histogram = new Histogram(bins, low, high);

ParameterBlock pb2 = new ParameterBlock();

RenderedOp op = JAI.create("histogram", pb2, null);
histogram = (Histogram) op.getProperty("histogram");

// get histogram contents
int[] local_array = new int[histogram.getNumBins(0)];
for ( int i = 0; i < histogram.getNumBins(0); i++ ) {
local_array = histogram.getBinSize(0, i);
System.out.println("No Of Bins:- "+local_array) ;

ParameterBlock pb = new ParameterBlock();

low[0] = 0.0F;
high[0] = 106.0F;
target = JAI.create("threshold", pb, null);

return target ;


Exception in thread "main" java.lang.IllegalArgumentException: Histogram -
eter value`s class (javax.media.jai.Histogram) is not an instance of the
er class (javax.media.jai.ROI) for parameter "roi".
at javax.media.jai.JAI.createNS(JAI.java:1091)
at javax.media.jai.JAI.create(JAI.java:977)
at Threshold.thresholding(Threshold.java:116)
at Main.<init>(Main.java:66)
at Test.main(Test.java:6)


Jul 17 '05 #1
0 6429

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by bleh | last post: by
27 posts views Thread by ext_u | last post: by
12 posts views Thread by KraftDiner | last post: by
2 posts views Thread by Daniel Nogradi | last post: by
5 posts views Thread by arnuld | last post: by
1 post views Thread by avenger3200 | last post: by
reply views Thread by Kurt Smith | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.