Using ImageJ Process/Math/Macro

Hi all,
I am interested in using the Process/Math/Macro capability, but I am not quite understanding how the syntax works for the equation that the command uses.

For instance, if I want to segment an image into three levels of gray (20,170,255), I thought that I could write
if(v<50) v=20;else;if(v>200) v=255;else;if(v<200 || v>50) v=170);
however this just makes my entire image = 170.
This does work
if(v<50) v=20;else;if(v>200) v=255;
so it’s the || (AND) function that isn’t working as I expected. Any thoughts?
Thank you!
Bob

The semicolons following ‘else’ are a problem. Here is macro code that segments an image into three gray levels:

newImage("Untitled", "8-bit ramp", 500, 500, 1);
run("Macro...", "code=[if(v<50)v=20;else if(v>200)v=255;else v=170;]");
1 Like

Well I just realized (blushing) that I should have been using && instead of ||.
Sigh.
Apologies for the noise.
Bob