Posted by
asuspeg on
URL: http://imagej.273.s1.nabble.com/YUV-thresholding-in-a-macro-tp5015832.html
Hello everyone,
I'm using imageJ to determine the %area of cells (microalgae) on a substrate (platic microplates) to follow the developement of the microalgae day after day.
So, I take photos of my cultures day after day and use the "Color Threshold" tool for thresholding my pictures in terms of colour saturation (my cells are yellow and the background is black). For that, I use the YUV color space and after selecting "dark background", I adjust the "U" value at 100. After that, I simply use the "Analyze particles" tool to extract the %area value of the cells.
It works very well but I have something like 100 photos to treat per day, and it will increase in the next weeks... That's why I would like to automatize the treatment by using a Macro.
So, I use the tool "Record..." and do my manipulations (I click on "Macro" button in the "Color Threshold" window after seting up the parameters cited above), save the macro and install it.
Unfortunately, the macro doesn't work, even with just one picture: it blocks at the Color Threshold step by doing a HSB threshold with default parameters, and few seconds after, closes the picture with the message "There are no image open".
I don't know what's the problem... but I think it's the same problem than described in a previous post:
http://imagej.1557.x6.nabble.com/unconsistency-while-using-YUV-color-threshold-in-macro-td5003443.htmlThank you for your help !
Here is an example of 2 pictures I use:
https://www.dropbox.com/sh/qiueaj5n7wk3xkm/AACslOuyjMZddDfRDorgEcUla?dl=0Here is my macro:
run("Color Threshold...");
// Color Thresholder 1.49v
// Autogenerated macro, single images only!
min=newArray(3);
max=newArray(3);
filter=newArray(3);
a=getTitle();
call("ij.plugin.frame.ColorThresholder.RGBtoYUV");
run("RGB Stack");
run("Convert Stack to Images");
selectWindow("Red");
rename("0");
selectWindow("Green");
rename("1");
selectWindow("Blue");
rename("2");
min[0]=0;
max[0]=255;
filter[0]="pass";
min[1]=0;
max[1]=100;
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("Analyze Particles...", "size=500-Infinity display summarize");