How to replace every pixel below a certain color value with a different value?

I want to process an image stack such that every pixel with a color value below, say, 2000 is changed to a color value of 10000. What is the simplest way to do this?

You can do that by simply playing with the minimum and maximum intensity values using the Brightness & Contrast tool (Image > Adjust > Brightness/Contrast…). Just keep in mind that the changes won’t be done until your press “Apply”.

1 Like

Dear @etterbi

you can do in a manual way the following steps, I am using th dot_blot.jpg example image that you can find in File>Open Samples…

  1. Use Threshold Tool (Image > Adjust > Threshold…) with Over/Under option so you can see in blue all the values below a certain value (in my case 100)

  2. then from Edit>Selection>Create Selection you can create a selection, pay attention that you have also to invert it (this because usually the over/under option would exclude the blue areas: you can do it with Edit>Selection>Make Inverse

  3. Finally you can the blue areas (the pixel with an intensity lower than 100) to a new value (in my case I decided for 255) with Process>Math>Set…

There is also a more programmatic way to do it, but maybe for you that could be enough.

Have a nice day,
Emanuele Martini

4 Likes

In Fiji, there is also a convenient “Replace Value” command in “Plugins/Process”, but sadly, it works on 8-bit images only. Would be a nice feature to have it for all types…

2 Likes

@emartini is right. My approach only transforms all pixels below the minimum to 0 and above the maximum to the maximum value of the image type.

@Nicolas, what you can do after that, is to use the Replace Value command from MorphoLibJ, that works on all types of grayscale images :wink:

2 Likes