Clear Filters
Clear Filters

how can i change the image contrast?

4 views (last 30 days)
Diogo Simões
Diogo Simões on 7 Apr 2022
Answered: Deep on 13 Sep 2024
I need to change the image contrast,increase and decrease the contrast. only where it belongs to the region of interest.

Answers (1)

Deep
Deep on 13 Sep 2024
Hi Diogo,
As per my understanding, you are looking to adjust the contrast of an image within a specific region of interest (ROI) using MATLAB. Please refer to the attached MATLAB script to achieve the desired results as shown below:
The attached script loads the image into MATLAB. The ROI is selected with “roipoly”, and its validity is checked. For contrast adjustment, “stretchlim” calculates the limits for the ROI, and “imadjust” enhances its contrast, preserving the rest of the image. The enhanced ROI is then merged back into the original image for display.
For more detailed information on contrast enhancement techniques, you can refer to the following MathWorks help page: https://www.mathworks.com/help/images/contrast-enhancement-techniques.html.
Here are documentation links of relevant MATLAB functions used in the code:
  1. imread - https://www.mathworks.com/help/matlab/ref/imread.html
  2. roipoly - https://www.mathworks.com/help/images/ref/roipoly.html
  3. im2double - https://www.mathworks.com/help/matlab/ref/im2double.html
  4. stretchlim - https://www.mathworks.com/help/images/ref/stretchlim.html
  5. imadjust - https://www.mathworks.com/help/images/ref/imadjust.html
  6. im2uint8 - https://www.mathworks.com/help/images/ref/im2uint8.html
I hope this helps!

Tags

Community Treasure Hunt

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

Start Hunting!