Auto set max brightness - Color Threshold Macro

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Auto set max brightness - Color Threshold Macro

ams376
This post has NOT been accepted by the mailing list yet.
When manually using the Color Threshold command, ImageJ automatically sets the max brightness according to the selected image. When you put this into a macro using the recording tool it will set the max brightness to a fixed value. Is there a way to create a Color Threshold macro that doesn't use a fixed max, but automatically sets it according to the selected image like how the command works when using it manually.? Macro posted below.. The line I'm referring to - "max[2]=10;".



//run("Threshold...");
// Color Thresholder 1.48v
// 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]=0;
max[0]=255;
filter[0]="pass";
min[1]=0;
max[1]=255;
filter[1]="pass";
min[2]=0;
max[2]=10;
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", false);
Reply | Threaded
Open this post in threaded view
|

Re: Auto set max brightness - Color Threshold Macro

Ryan Smith
This post has NOT been accepted by the mailing list yet.
I also need a solution for this problem: auto setting max brightness value in the color threshold macro. Please help community!
Reply | Threaded
Open this post in threaded view
|

Re: Auto set max brightness - Color Threshold Macro

shubham1278
Hi,

I found the answer to this issue. You can change the macro as follows

//run("Threshold...");
// Color Thresholder 1.48v
// 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");
selectWindow("2");
setAutoThreshold("Default");
//run("Threshold...");
getThreshold(lower,upper);
resetThreshold();
//run("Close");

//print(lower+","+upper);

min[0]=0;
max[0]=255;
filter[0]="pass";
min[1]=0;
max[1]=255;
filter[1]="pass";
min[2]=lower;
max[2]=upper;
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", false);

Best,
Shubham



--
Sent from: http://imagej.1557.x6.nabble.com/

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