Fill in ROIs based on result table (e.g. Mean gray value)

Hi,
I have an open image with all my ROIs and the corresponding result table. Is there any automatic way to selectively fill ROIs with a color (let’s say black) based on the measured mean gray value? I want to fill ROIs with a gray value above or under a certain value.

Thanks.

L

Just solved it by myself :sweat_smile::grinning:

run(“Set Measurements…”, “mean min redirect=None decimal=3”);
roiManager(“Measure”);
numROIs = roiManager(“count”);
for (i=0; i<numROIs;i++) {
Mean = getResult(“Mean”, i);
roiManager(“Select”, i);
if(Mean>140) {
setForegroundColor(0, 0, 0);
run(“Fill”, “slice”);
}
}