Saving images after setting contrast

Hi,

I have written this macro script for automating setting new contrast to our microscopy images. The problem is it sets the new contrast, but it saves the old image instead of the new one with new contrast.
Can someone take a look at my script and tell me what is wrong with it, please? I have uploaded my script. It is really getting annoying.

Here is the link for some DAPI image samples (min contrast = 500, max contrast 1200):

Script:
setContrast.ijm (1.2 KB)

Thanks

Your code is ok and working.
The problem is that the modified images are auto-scaled during loading.

In the IJ menu Edit>Options>Appearance change the option ‘16-bit range’ to Automatic.

Does this help?

1 Like

It is ok and working? So, you are getting different results? It is strange, becasue it is not working on my laptop. Probably i should run it on a different system.

Thanks

How do you know that? How do you see that?

Yes

What do you mean with ‘different results’?
Maybe here is a misunderstanding.
The pixel content of both images (before and after) is and has to be exactly the same.
With setMinAndMax() you only change the display mapping - not the pixel values.

Have you checked this setting?
Make sure ‘16-bit range = Automatic’ and open your modified images (in ImageJ of course). Then the modified image should be displayed differently.

If you want to change the pixel intensity you have to add run("Apply LUT"); into your code.

Is this still the old topic