Using imcontrast() to adjust image, then apply that adjustment to several images

32 views (last 30 days)
Hello,
I checked through some of the posts on the forums and found some related to my question, but they did not answer my question.
I want to use the imcontrast() tool to manually adjust a single image's contrast values and then use the adjustment parameters on other images. I see that when I use the slider from imcontrast() it changes the values of the maximum and minimum in the window. I thought those were the new minimum and maximum, so I tried to use the imadjust() function, but it did not work.
For example: I called the imcontrast() function. A window popped up with a slider and I adjusted the sliders until the image looked like what I wanted it to look like. I then took note of the current values of max and min. I also wrote down the starting values of the max and min. I then called imadjust and used the parameters to adjust the image. The only problem was that the resulting image from imadjust() did not look like the image produced from imcontrast().
imshow(G)
imcontrast()
This is before I use the adjustment:
After I have adjusted the image using the sliders:
Below are the results from the function call:
imadjust(G,[0 255], [237 255] )
Am I thinking about this wrong? I want to set the parameters manually using the imcontrast() function, then use those adjustment parameters to change a series of images using the imadjust() function.
Thank you,
Chris

Accepted Answer

Image Analyst
Image Analyst on 28 Feb 2014
Chris, you go the input and output reversed. The input is [237, 255] and should be the second argument. That is the range that you want mapped into an output range of 0-255 which should be the third argument, so try this:
G_out = imadjust(G, [237 255], [0 255]);
  2 Comments
Yu Zou
Yu Zou on 17 Aug 2018
I have Error as following:
Error using imadjust>validateLowHigh (line 338) IMADJUST: LOW_IN, HIGH_IN, LOW_OUT and HIGH_OUT must be in the range [0.0, 1.0].
Error in imadjust (line 107) validateLowHigh(lowIn,highIn,lowOut,highOut);

Sign in to comment.

More Answers (1)

thairi mohamed amine
thairi mohamed amine on 12 Nov 2019
salut il faut mettre seulement les valeurs que tu as trouver [237 255] en plus il faut les diviser par 255.
donc tu dois écrire : G_out = imadjust(G, [0.929, 1]);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!