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 |
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 |
Dear Gabriel,
It worked! I would not have been able to figure this out by myself. Thank you so much for your help! Rie On Tue, 6 Nov 2018 at 04:12, Gabriel Landini <[hidden email]> wrote: > 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 > -- ---------------------------------------------------------------------------------------------------------------------- *Rie** Sadohara * Graduate Research Assistant Department of Plant, Soil and Microbial Sciences Michigan State University Plant and Soil Science Building 1066 Bogue St, Room A364 East Lansing, MI 48824 Email: *[hidden email] <[hidden email]>* Find delicious bean recipes here: *https://colorfulhealthfulflavorfulblog.wordpress.com/ <https://colorfulhealthfulflavorfulblog.wordpress.com/>* ------------------------------------------------------------------------------- ---------------------------------------- -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |