RGB to HSB question

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

RGB to HSB question

yccheok
Hello all,

Recently, I try to find out the HSB histogram of an
image using ImageJ.
Since my java code had problem running
HSB_Histogram.txt, where my java
program cannot allocated Color_Histogram.jar although
it had been installed
at /home/yccheok/ImageJ/plugins.

Although I added java class path on
/home/yccheok/ImageJ/plugins/Color_Histogram.jar,
I still having problem in using the
Color_Histogram.jar

Hence, I decide to port over the HSB_Histogram.txt
macro code into java code,
as follow:

           
System.out.println("-->"+IJ.getImage().getBitDepth());
// 24
             IJ.run("HSB Stack");
           
System.out.println("-->"+IJ.getImage().getBitDepth());
// 8
             IJ.run("Convert Stack to RGB");

                        // Although we had converted HSB->RGB, but IJ still
seem
                        // like pointing to HSB. How can we make IJ
pointing to
                        // RGB?
                        //
           
System.out.println("-->"+IJ.getImage().getBitDepth());
// 8

                        // The imagePlus2 is HSB stack. But I would like to
have RGB image.
                        // How I can achieve this?
                        //
             imagePlus2 = IJ.getImage();

Thank you very much!

yccheok

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 
Reply | Threaded
Open this post in threaded view
|

Re: RGB to HSB question

Gabriel Landini
On Saturday 14 January 2006 04:24, Cheok Yan Cheng wrote:
> Recently, I try to find out the HSB histogram of an
> image using ImageJ.
> Since my java code had problem running
> HSB_Histogram.txt, where my java
> program cannot allocated Color_Histogram.jar although
> it had been installed
> at /home/yccheok/ImageJ/plugins.

I get this error with the updated ColorHistogram. The histogram seems to be
calculated, though.

java.lang.NoSuchMethodError: ColorHistogramWindow.getMean()[D
 at ColorHistogram_.run(ColorHistogram_.java:72)
 at ij.IJ.runFilterPlugIn(IJ.java:197)
 at ij.IJ.runUserPlugIn(IJ.java:275)
 at ij.IJ.runPlugIn(IJ.java:117)
 at ij.Executer.runPlugIn(Executer.java:171)
 at ij.Executer.runCommand(Executer.java:133)
 at ij.Executer.run(Executer.java:63)
 at java.lang.Thread.run(Thread.java:595)


By the way, trying the HSB_Histogram macro here I noted that the name of the
Histogram window does not include the ".tif" anymore (I do not know since
when) so the HSB_Histogram.txt macro needed some fixing. Here is the latest
version.

-----------------------8<-----------------------------
// Calculates the HSB histogram of an RGB image
// The RGB histograms correspond to the H, S and B components respectively
// Requires Color_Histogram plugin by Dimiter Prodanov
// 14/1/2006 fixed renaming of images

a=getTitle();
if (bitDepth()==24)  {
   run("HSB Stack");
   run("Convert Stack to RGB");
   run("Color Histogram");
   b=getTitle();
   selectWindow(a+" (RGB)");
   run("Close");
   selectWindow(a);
   run("RGB Color");
   c="title='HSB Histogram of "+a+"'";
   selectWindow(b);
   run("Rename...", c);
}
else{
   showMessage(a +" is not an RGB image.");
}
-----------------------8<-----------------------------

Cheers,
Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: RGB to HSB question

Gabriel Landini
I found that the error I just reported was generated because of an old class
file remaining in the same directory (the new plugin is a jar file and the
old one was not).

Sorry for the false alarm.

The amended macro works fine too.

Cheers,

G.
Reply | Threaded
Open this post in threaded view
|

Another suggested use for HSB

Michael Cammer
Instead of dealing with overlays, I have found the HSV conversion very
useful for manual tracing of features for measurement.

I set up tools for people to mark features in differnt colors on grayscale
images that have been converted to RGB (mostly EMs).

Then, after all features have been marked, we threshold on the Hue plane
to pull out the individual features for automated analysis.



_________________________________________
Michael Cammer
Analytical Imaging Facility and
Dept. ASB Biophotonics Innovation Laboratory
Albert Einstein College of Medicine
1300 Morris Park Avenue, Bronx, NY  10461
718-430-2890  Fax 718-430-8996
work:  http://www.aecom.yu.edu/aif/
personal:  http://coxcammer.com/