Login  Register

Color thresholding (180-255 of L* value) and obtain L*a*b* values using a macro

Posted by Rie Sadohara on Nov 05, 2018; 10:34pm
URL: http://imagej.273.s1.nabble.com/Color-thresholding-180-255-of-L-value-and-obtain-L-a-b-values-using-a-macro-tp5021413.html

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.

run("Color Threshold...");
// Color Thresholder 1.52h
// 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-------------
run("Lab Stack");
run("Restore Selection");
run("Measure Stack");





Thank you.

Rie

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