|
On Feb 18, 2011, at 2:38 PM, sonemy wrote:
> Hi.
> I've imported the ij.jar in my project and i need to obtain color statistics
> about my image. Thus, i've imported Color_Histogram plug-in, but i'm not
> able to manage the RGB value and, above all, the statistics of each color
> chanel, such as red mean and mode.
> Is it possible to intervene in the plug-in processing and get data? Or is
> there an alternative way to get the statistics and histograms of the RGB
> channels?
You can get RGB statistics and histograms by using the setWeightingFactors() and getStatistics() methods. Here is a JavaScript example:
imp = IJ.getImage();
if (imp.getBitDepth()!=24)
IJ.error("RGB image required");
ip = imp.getProcessor();
ColorProcessor.setWeightingFactors(1,0,0);
red = ip.getStatistics();
ColorProcessor.setWeightingFactors(0,1,0);
green = ip.getStatistics();
ColorProcessor.setWeightingFactors(0,0,1);
blue = ip.getStatistics();
ColorProcessor.setWeightingFactors(1.0/3.0,1.0/3.0,1.0/3.0);
IJ.log("Means: "+red.mean+", "+green.mean+", "+blue.mean);
IJ.log("Modes: "+red.mode+", "+green.mode+", "+blue.mode);
IJ.log("Histogram");
for (i=0; i<256; i++)
IJ.log(" "+i+": "+red.histogram[i]+", "+green.histogram[i]+", "+blue.histogram[i]);
|