Hi all, I’m new to ImageJ and coding, also not entirely sure of etiquette for posting, so please correct me if I’ve done this wrong.
Essentially I’m trying to segment out part of an image and then measure it’s area within a 6x6mm circle. The image in questing is a heat map of thickness. I have managed to do it manually (see steps) but then when I tried to create a macros to do the remaining images, it has not worked. I’ll post the images separately
- Open image
- Adjust colour threshold (hue 50-200, sat 100-255, brightness 0-255) - mask to black
- Convert to 8-bit image
- Adjust threshold 1-255
- Create circle 0,0,180,180
- Set measurements to include area fraction and limit to threshold
- Set scale 180 pixels = 6 mm
- Measure
- Save results of measurement
Macros code created:
open("/Desktop/256.png");
run("Color Threshold...");
// Color Thresholder 2.1.0/1.53c
// 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]=50;
max[0]=200;
filter[0]="pass";
min[1]=100;
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-------------
selectWindow("256.png");
run("8-bit");
setAutoThreshold("Default no-reset");
//run("Threshold...");
//setThreshold(1, 255);
setOption("BlackBackground", false);
run("Convert to Mask");
run("Close");
//setTool("oval");
makeOval(0, 0, 180, 180);
run("Set Measurements...", "area mean min area_fraction limit redirect=None decimal=3");
run("Set Scale...", "distance=180 known=6 unit=mm");
run("Measure");
saveAs("Results", "/Desktop/256results.csv");
Many thanks in advance.