Greetings ImageJ community,
We wanted to share a new macro that will be useful for anyone doing
agricultural research. See below...
Best,
Matthew Ott
// This macro calculates the percent green of an image
// with the Hue set to 44 and 122, which includes
// all the green hues of plant tissue. It identifies
// any green in the image and turns it to black and
// everything else becomes white. From this ImageJ
// calculates the percent of the pixels that were green,
// but then changed to black.Weeds must be brushed
// or "spray painted" white to exclude them.
// **Important note - the scale of this macro is set
// to an average of the pictures we at the USDA-ARS
// and University of MN were processing. We scale the
// image using a meter stick in the photo taken at a
// height of about 1.5 meters. The protocol (hue
// settings etc.) was developed by James Eklund
// of the USDA-Agricultural Research Service and
// the macro for the protocol was developed by
// Matthew Ott of the University of Minnesota with
// the aid of Arjun Mehta's online guide for creating
// macros:
//
http://www.scribd.com/doc/95224926/How-to-Automate-// ImageJ-Analysis-With-Macros-and-Batch-Processing
run("Set Scale...", "distance=3494.5 known=100 unit=cm");
run("Color Threshold...");
// Color Thresholder 1.49m
// Autogenerated macro, single images only!
min=newArray(3);
max=newArray(3);
filter=newArray(3);
a=getTitle();
run("HSB Stack");
run("Convert Stack to Images");
selectWindow("Hue");
rename("0");
selectWindow("Saturation");
rename("1");
selectWindow("Brightness");
rename("2");
min[0]=44;
max[0]=122;
filter[0]="pass";
min[1]=0;
max[1]=255;
filter[1]="pass";
min[2]=0;
max[2]=255;
filter[2]="pass";
for (i=0;i<3;i++){
selectWindow(""+i);
setThreshold(min[i], max[i]);
run("Convert to Mask");
if (filter[i]=="stop") run("Invert");
}
imageCalculator("AND create", "0","1");
imageCalculator("AND create", "Result of 0","2");
for (i=0;i<3;i++){
selectWindow(""+i);
close();
}
selectWindow("Result of 0");
close();
selectWindow("Result of Result of 0");
rename(a);
// Colour Thresholding-------------
run("8-bit");
setAutoThreshold("Default");
//run("Threshold...");
setOption("BlackBackground", false);
run("Convert to Mask");
run("Analyze Particles...", " show=Masks display summarize");
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html