[MACRO] Color Histogram putting all results tables in same sheet

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

[MACRO] Color Histogram putting all results tables in same sheet

Hiero
Hello guys,
I started using Color Histogram and I get very excited with the possibilities... =D
I made this macro for a simple application.

makeRectangle(316, 148, 32, 26);
run("Color Histogram");
saveAs("Results", "C:\\Users\\Rafael-PC\\Desktop\\Macro\\Results12.xls");
close();
makeRectangle(750, 144, 32, 26);
run("Color Histogram");
save("Results", "C:\\Users\\Rafael-PC\\Desktop\\Macro\\Results12.xls");
close();
makeRectangle(1190, 168, 32, 26);
run("Color Histogram");
saveAs("Results", "C:\\Users\\Rafael-PC\\Desktop\\Macro\\Results10.xls");
close();
makeRectangle(1636, 186, 32, 26);
run("Color Histogram");
saveAs("Results", "C:\\Users\\Rafael-PC\\Desktop\\Macro\\Results9.xls");
close();
makeRectangle(274, 582, 32, 26);
run("Color Histogram");
saveAs("Results", "C:\\Users\\Rafael-PC\\Desktop\\Macro\\Results8.xls");
close();
makeRectangle(730, 594, 32, 26);
run("Color Histogram");
saveAs("Results", "C:\\Users\\Rafael-PC\\Desktop\\Macro\\Results7.xls");
close();
makeRectangle(1184, 614, 32, 26);
run("Color Histogram");
saveAs("Results", "C:\\Users\\Rafael-PC\\Desktop\\Macro\\Results6.xls");
close();
makeRectangle(1618, 628, 32, 26);
run("Color Histogram");
saveAs("Results", "C:\\Users\\Rafael-PC\\Desktop\\Macro\\Results5.xls");
close();
makeRectangle(288, 1038, 32, 26);
run("Color Histogram");
saveAs("Results", "C:\\Users\\Rafael-PC\\Desktop\\Macro\\Results4.xls");
close();
makeRectangle(730, 1056, 32, 26);
run("Color Histogram");
saveAs("Results", "C:\\Users\\Rafael-PC\\Desktop\\Macro\\Results3.xls");
close();
makeRectangle(1190, 1046, 32, 26);
run("Color Histogram");
saveAs("Results", "C:\\Users\\Rafael-PC\\Desktop\\Macro\\Results2.xls");
close();
makeRectangle(1650, 1062, 32, 26);
run("Color Histogram");
saveAs("Results", "C:\\Users\\Rafael-PC\\Desktop\\Macro\\Results1.xls");
close();

 Is possible I put all this Results tables in one sheet?
How can I do that?
Thank in Advance =D
Reply | Threaded
Open this post in threaded view
|

Re: [MACRO] Color Histogram putting all results tables in same sheet

Rasband, Wayne (NIH/NIMH) [E]
On May 8, 2014, at 7:16 PM, Hiero wrote:

> Hello guys,
> I started using Color Histogram and I get very excited with the
> possibilities... =D
> I made this macro for a simple application.
>
> makeRectangle(316, 148, 32, 26);
> run("Color Histogram");
> saveAs("Results", "C:\\Users\\Rafael-PC\\Desktop\\Macro\\Results12.xls");
> close();
> makeRectangle(750, 144, 32, 26);
> run("Color Histogram");
> save("Results", "C:\\Users\\Rafael-PC\\Desktop\\Macro\\Results12.xls");
> close();
> makeRectangle(1190, 168, 32, 26);
> run("Color Histogram");
> saveAs("Results", "C:\\Users\\Rafael-PC\\Desktop\\Macro\\Results10.xls");
> close();
>
>  [snip]
>
> Is possible I put all this Results tables in one sheet?
> How can I do that?

Use the getStatistics() macro function instead of the Color Histogram plugin, as this example does:

  run("Clear Results");
  row = 0;
  makeRectangle(316, 148, 32, 26);
  measure(row++);
  makeRectangle(750, 144, 32, 26);
  measure(row++);
  makeRectangle(1190, 168, 32, 26);
  measure(row++);
  makeRectangle(1536, 186, 32, 26);
  measure(row++);
  path = getDirectory("home")+"results.csv";
  saveAs("Results", path);

  function measure(row) {
     getSelectionBounds(x, y, w, h);
     setResult("x", row, x);
     setResult("y", row, y);
     setRGBWeights(1, 0, 0);
     getStatistics(area, mean, min, max, std);
     setResult("r-mean", row, mean);
     setResult("r-std", row, std);
     setRGBWeights(0, 1, 0);
     getStatistics(area, mean, min, max, std);
     setResult("g-mean", row, mean);
     setResult("g-std", row, std);
     setRGBWeights(0, 0, 1);
     getStatistics(area, mean, min, max, std);
     setResult("b-mean", row, mean);
     setResult("b-std", row, std);
  }

-wayne

> --
> View this message in context: http://imagej.1557.x6.nabble.com/MACRO-Color-Histogram-putting-all-results-tables-in-same-sheet-tp5007643.html
> Sent from the ImageJ mailing list archive at Nabble.com.

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