Using Stretchlim and Imadjust (automatically and manually)

9 ビュー (過去 30 日間)
dunphy
dunphy 2021 年 12 月 20 日
編集済み: DGM 2024 年 2 月 1 日
How do I correct my code by
(1) first getting an output which uses stretchlim and imadjust to adjust the contrast of an image automatically
(2) manually adjusting the contrast level [low_in high_in] using the imadjust function.
img = imread('coins.png'); %to open the original image of the coins
imshow(img); %to show the original image of the coins
orig_imadjust = imadjust(img); %to automatically adjust the contrast of the coin image using imadjust
orig_stretchlim = stretchlim (img) %to automatically adjust the contrast of the coin image stretchlim
% ??? -- to manually adjust the contrast level using imadjust function [low_in high_in]
orig_imhista = imhist(orig_imadjust) %to get the histogram of orig_imadjust
orig_imhistb = imhist(orig_stretchlim) %to get the histogram of orig_stretchlim
montage({img,orig_imadjust,orig_stretchlim,orig_imhista,orig_imhistb},"Size",[2 3])

回答 (2 件)

Image Analyst
Image Analyst 2021 年 12 月 20 日
Look at the documentation for imadjust(). It allows you to specify the min and max output gray levels, and the gray level range of the input image what will get mapped into that min to max range.
Any gray levels in the input image below the min output level will be clipped to the min output gray level you specified.
Any gray levels in the input image above the max output level will be clipped to the max output gray level you specified.

DGM
DGM 2022 年 7 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by