Login  Register

Launching a Histogram from the roi Manager

Posted by Dan McDonald on Sep 30, 2016; 6:44pm
URL: http://imagej.273.s1.nabble.com/Launching-a-Histogram-from-the-roi-Manager-tp5017262.html

Dear List,

 

I am trying to write a macro to get a histogram of a selection via the
roiManager.

 

When I manually click through the steps I get what I expect.  When I try to
execute the same steps through a macro I get different results. I have
included a snip of my code below.

 

I think that when I select a selection through the roiManager in the macro
and then execute run("Histogram") it is not running a histogram on the
selected selection I think I've specified.

 

     selectWindow("rootDiameterImage");

// Transfer roi from roiManager to new file

     run("From ROI Manager");

     totalRootSegments=roiManager("count");

     for(k_rs=0; k_rs <totalRootSegments;k_rs++) {

         roiManager("Select", k_rs);

         run("Histogram");

         getHistogram(Values,Counts,256);

         for(i_Hist=1; i_Hist<Values.length; i_Hist++) {

              thisValue=Values[i_Hist];

              thisCount=Counts[i_Hist];

              thisProduct=thisValue*thisCount;

              sumOfValueTimesCount=sumOfValueTimesCount +thisProduct;

              sumOfCount=sumOfCount+thisCount;

         }

 

Can anyone see what I am doing wrong?

 

When I manually click in the roiManager for a selection and then run a
histogram and examine the values under the histogram "list" I get what I was
expecting.  

 

When I examine the values within the histogram from the macro I get values
not associated with the "selection."

 

Thanks for your assistance,

 

Dan

 

Daniel W. McDonald,

Co-founder and President,

Phenotype Screening Corporation,

4028 Papermill Road, Suite 10,

Knoxville, TN 37909

(865) 385-8641 cell

(865) 694-9459 office

[hidden email]

daniel.w.mcdonald1 on Skype

www.phenotypescreening.com

 


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html