467,122 Members | 1,270 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,122 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
work

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();
pb2.addSource(source);
pb2.add(histogram);
pb2.add(null);
pb2.add(1);
pb2.add(1);

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;
pb.addSource(source);
pb.add(low);
pb.add(high);
pb.add(map);
target = JAI.create("threshold", pb, null);
display.set(target);

return target ;

}

Exception in thread "main" java.lang.IllegalArgumentException: Histogram -
Param
eter value`s class (javax.media.jai.Histogram) is not an instance of the
paramet
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)

Adam

Jul 17 '05 #1
  • viewed: 6283
Share:

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.