Posted by
Gabriel Landini on
Nov 06, 2018; 9:01am
URL: http://imagej.273.s1.nabble.com/Color-thresholding-180-255-of-L-value-and-obtain-L-a-b-values-using-a-macro-tp5021413p5021415.html
On Monday, 5 November 2018 22:34:12 GMT
[hidden email] wrote:
> Dear all,
>
> I am trying to run color thresholding to my image (I want to pick up
> 180-255 of L* value), converting it to Lab stack, restore selection, and
> measure stack (obtain L*, a*, b* value). I recorded macro so that I can do
> this in a streamlined way. Please see below. This macro returns a messgae
> saying "Supported conversions: 8-bit -> 16 bit* etc...". It seems it cannot
> convert the image to Lab stack after color thresholding, but I do not know
> why it cannot reproduce what I can run manually. I would appreciate your
> help with debugging this code.
Here is a way of getting the Lab stack and the selection. Note that it reloads
the image.
// Color Thresholder 1.52i
// Autogenerated macro, single images only!
min=newArray(3);
max=newArray(3);
filter=newArray(3);
a=getTitle();
call("ij.plugin.frame.ColorThresholder.RGBtoLab");
run("RGB Stack");
run("Convert Stack to Images");
selectWindow("Red");
rename("0");
selectWindow("Green");
rename("1");
selectWindow("Blue");
rename("2");
min[0]=180;
max[0]=255;
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-------------
setOption("BlackBackground", true);
run("Convert to Mask");
run("Create Selection");
run("Revert");
run("Lab Stack");
run("Restore Selection");
The other simpler way of doing this is to just convert your image to Lab, then
threshold the first slice (which is L) with the greyscale thresholder and call
createSelection, no need to use the colour thresholder.
Hope it helps.
Gabriel
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html