Progamatically using the histogram plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Progamatically using the histogram plugin

karl wettin-4-3
Hello forum,

I want to use the histogram plugin to do some simple automated  
computer vision thingies, but I can't figure out how to load an image  
and pass it down to the plugin from my code. Looking at the plugin  
code it seems to use static things in IJ, GUI calls and what not in  
order to figure out what image to use.

Didn't investigate this too much. Is there a simpler way out than to  
refactor the code to fit my needs? It would be great to use IJ as is  
and just do something like new Histogram(image).getBins().

Help would be most appreciated.



        karl
Reply | Threaded
Open this post in threaded view
|

Re: Progamatically using the histogram plugin

Wayne Rasband
On May 27, 2009, at 5:14 AM, Karl Wettin wrote:

> Hello forum,
>
> I want to use the histogram plugin to do some simple automated
> computer vision thingies, but I can't figure out how to load an image
> and pass it down to the plugin from my code. Looking at the plugin
> code it seems to use static things in IJ, GUI calls and what not in
> order to figure out what image to use.
>
> Didn't investigate this too much. Is there a simpler way out than to
> refactor the code to fit my needs? It would be great to use IJ as is
> and just do something like new Histogram(image).getBins().
>
> Help would be most appreciated.

Use the getStatistics() method of the ImagePlus class to get the
histogram.

     ImagePlus imp = IJ.openImage(path);
     int[] histogram = imp.getStatistics().histogram;

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Progamatically using the histogram plugin

karl wettin-4-3
27 maj 2009 kl. 16.08 skrev Wayne Rasband:

> On May 27, 2009, at 5:14 AM, Karl Wettin wrote:
>>
>> I want to use the histogram plugin to do some simple automated  
>> computer vision thingies, but I can't figure out how to load an  
>> image and pass it down to the plugin from my code.
>
> Use the getStatistics() method of the ImagePlus class to get the  
> histogram.
>
>    ImagePlus imp = IJ.openImage(path);
>    int[] histogram = imp.getStatistics().histogram;

Excellent, thanks!

This works really well. I'm using the histogram to classify real  
estate images as photos or blueprints with the Weka IBk (k=2) and I  
get 100% certainty with 2000 images as ground truth and testing on  
10000 images. (Not sure what to use it for, but it's really cool. ;)


         karl