Improve image contrast using specific threshold values
Posted: 2009-09-07T02:17:51-07:00
I want to improve the contrast of certain type of images by getting rid of the pixel values below and above a certain threshold, then renormalizing the central pixel range.
I have tried using black-threshold and white-threshold, but these methods dont exactly do what I want, because they set all values below the threshold to 0 (black-threshold) and all values above the threshold to max (white-threshold). Thus my resulting image doesnt actually give any improved contrast.
In essence, this is what I want to do:
Set all pixel values that are below 50 equal to 50.
Set all pixel values that are above 200 equal to 200.
If there is some way I can achieve this in ImageMagick, then I can simply normalize the image afterwards and I will have an image with good contrast for the pixel range that I am interested in.
If someone know a way of doing this I would be very happy!
I have tried using black-threshold and white-threshold, but these methods dont exactly do what I want, because they set all values below the threshold to 0 (black-threshold) and all values above the threshold to max (white-threshold). Thus my resulting image doesnt actually give any improved contrast.
In essence, this is what I want to do:
Set all pixel values that are below 50 equal to 50.
Set all pixel values that are above 200 equal to 200.
If there is some way I can achieve this in ImageMagick, then I can simply normalize the image afterwards and I will have an image with good contrast for the pixel range that I am interested in.
If someone know a way of doing this I would be very happy!