MATLAB: Enhancing contrast in image

contrast enhancementImage Processing Toolbox

Hello,
I have a grayscale image with varying level of contrast and in order to enhance the contrast within the low contrast region I would like to define a square, compute the average and then adjust the weak regions accordingly.
Right now I'm extracting the pixel values of the rectangle I want to change with impixelregion and then just reading out the ROI. But how would I adjust the contrast in the other region?
Thank you!

Best Answer

How about doing it all over with adapthisteq() or imadjust()? If you want just the box, then you're going to have to extract it, enhance the contrast with something like imadjust() and then write it back - at least that's one way.