[JAI Question] Histogram Creation

View: New views
3 Messages — Rating Filter:   Alert me  

[JAI Question] Histogram Creation

by jai-interest-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello, I have been toying with JAI image analysis for a project, and I'm having trouble getting a histogram to work. I'm using http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Analysis.doc.html#55476 as a tutorial, and my code for the histogram section that seems to be causing the error follows:

        Histogram h = new Histogram(bins,low,high);
        //parameter block so we can do the histogram operation
        ParameterBlock histBlock = new ParameterBlock();
        histBlock.addSource(output);
        histBlock.add(h);
        histBlock.add(null);
        histBlock.add(1);
        histBlock.add(1);      
        //do the operation
        PlanarImage hImg = (PlanarImage)JAI.create("histogram", histBlock, null);
        //get the data
        h = (Histogram) hImg.getProperty("histogram");

Error:
Exception in thread "main" java.lang.IllegalArgumentException: Histogram - Parameter value`s class (javax.media.jai.Histogram) is not an instance of the parameter class (javax.media.jai.ROI) for parameter "roi".
        at javax.media.jai.JAI.createNS(JAI.java:1087)
        at javax.media.jai.JAI.create(JAI.java:973)
        at main.GetHistogram.main(GetHistogram.java:52)
Java Result: 1

(The last line of code is line 52)
[Message sent by forum member 'loknar' (lokzor@...)]

http://forums.java.net/jive/thread.jspa?messageID=367533

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@...
For additional commands, e-mail: interest-help@...


Re: [JAI Question] Histogram Creation

by Rafael Santos-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Loknar,

Please use
http://www.lac.inpe.br/~rafael.santos/JIPCookbook/4400-jaiop-statistics.jsp#javaadvancedimagingoperatorsjaioperatorsstatisticsoperatorshistogramoperatorhistogramappjava 
as an example.

Rafael

> Hello, I have been toying with JAI image analysis for a project, and I'm having trouble getting a histogram to work. I'm using http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Analysis.doc.html#55476 as a tutorial, and my code for the histogram section that seems to be causing the error follows:
>
>         Histogram h = new Histogram(bins,low,high);
>         //parameter block so we can do the histogram operation
>         ParameterBlock histBlock = new ParameterBlock();
>         histBlock.addSource(output);
>         histBlock.add(h);
>         histBlock.add(null);
>         histBlock.add(1);
>         histBlock.add(1);      
>         //do the operation
>         PlanarImage hImg = (PlanarImage)JAI.create("histogram", histBlock, null);
>         //get the data
>         h = (Histogram) hImg.getProperty("histogram");
>
> Error:
> Exception in thread "main" java.lang.IllegalArgumentException: Histogram - Parameter value`s class (javax.media.jai.Histogram) is not an instance of the parameter class (javax.media.jai.ROI) for parameter "roi".
>         at javax.media.jai.JAI.createNS(JAI.java:1087)
>         at javax.media.jai.JAI.create(JAI.java:973)
>         at main.GetHistogram.main(GetHistogram.java:52)
> Java Result: 1
>
> (The last line of code is line 52)
> [Message sent by forum member 'loknar' (lokzor@...)]
>
> http://forums.java.net/jive/thread.jspa?messageID=367533
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@...
> For additional commands, e-mail: interest-help@...
>
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@...
For additional commands, e-mail: interest-help@...


Re: [JAI Question] Histogram Creation

by Bob Deen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The Histogram parameters changed from v1.0 to 1.1.  I think you're using
documentation that refers to the old version.  Use the javadocs to see
what the correct parameters are.

Also, it's generally safer to use addParameter() (from
ParameterBlockJAI) since it includes parameter names and is thus a bit
more robust to changes.

-Bob

jai-interest@... wrote:

> Hello, I have been toying with JAI image analysis for a project, and I'm having trouble getting a histogram to work. I'm using http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Analysis.doc.html#55476 as a tutorial, and my code for the histogram section that seems to be causing the error follows:
>
>         Histogram h = new Histogram(bins,low,high);
>         //parameter block so we can do the histogram operation
>         ParameterBlock histBlock = new ParameterBlock();
>         histBlock.addSource(output);
>         histBlock.add(h);
>         histBlock.add(null);
>         histBlock.add(1);
>         histBlock.add(1);      
>         //do the operation
>         PlanarImage hImg = (PlanarImage)JAI.create("histogram", histBlock, null);
>         //get the data
>         h = (Histogram) hImg.getProperty("histogram");
>
> Error:
> Exception in thread "main" java.lang.IllegalArgumentException: Histogram - Parameter value`s class (javax.media.jai.Histogram) is not an instance of the parameter class (javax.media.jai.ROI) for parameter "roi".
>         at javax.media.jai.JAI.createNS(JAI.java:1087)
>         at javax.media.jai.JAI.create(JAI.java:973)
>         at main.GetHistogram.main(GetHistogram.java:52)
> Java Result: 1
>
> (The last line of code is line 52)
> [Message sent by forum member 'loknar' (lokzor@...)]
>
> http://forums.java.net/jive/thread.jspa?messageID=367533
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@...
> For additional commands, e-mail: interest-help@...
>


---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@...
For additional commands, e-mail: interest-help@...