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

contrastimadjust()image processingImage Processing Toolboximcontrast()

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

Best Answer

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]);