increasing gray shades of image display

조회 수: 2 (최근 30일)
try analyst
try analyst 2016년 7월 26일
답변: DGM 2023년 5월 7일
Dear All, Is there any way to increase gray shades of any displayed image?
regards

답변 (1개)

DGM
DGM 2023년 5월 7일
Shade: a pure color mixed with black.
Increase: to become greater in quantity or value.
Gray: any color of neutral hue between white and black.
So we want to work on neutral colors within any image, and we want to either make those neutral colors brighter or more numerous. That's pretty vague, but if we don't know what we actually want, there's no reason we can't just just try a bunch of things in the hopes that one of them is satisfactory.
We could increase the brightness of a grayscale image.
% read the image
inpict = imread('cameraman.tif');
% increase brightness
outpict = inpict + 50;
imshow(outpict,'border','tight')
... but what if our image is color? Increasing the brightness as before wouldn't "increase the gray shades" as required. Maybe we can make the entire image gray. In that way, we increase the number of pixels which are gray.
% read the image
inpict = imread('llama.jpg');
% make saturation zero
outpict = rgb2gray(inpict);
imshow(outpict,'border','tight')
Alternatively, instead of making everything gray, we could just make things grayer.
% read the image
inpict = imread('llama.jpg');
% convert to HSV
hsvpict = rgb2hsv(inpict);
% reduce saturation either linearly or nonlinearly
hsvpict(:,:,2) = imadjust(hsvpict(:,:,2),[0.2 1],[0 1],1.5); % both
% convert to RGB
outpict = hsv2rgb(hsvpict);
imshow(outpict,'border','tight')
... but what if the image is RGB, but is already completely gray? Then we wouldn't be able to make it grayer! Maybe instead of increasing the grayness of pixels, we could increase the grayest of pixels.
% read the image
inpict = imread('llama.jpg');
% get a map of saturation
[~,S,~] = imsplit(rgb2hsv(inpict));
% emphasize only regions with low saturation
S = imadjust(S,[0.07 0.16],[1 0]);
% brighten low-saturation regions
brightness = 0.3;
outpict = im2double(inpict) + S*brightness;
imshow(outpict,'border','tight')
... but what if our image is a uniform gray field? Then we could increase the number of shades!
% a uniform gray field
inpict = 128*ones(255,'uint8');
% increase the number of unique gray levels
outpict = imnoise(inpict,'gaussian');
imshow(outpict,'border','tight')
Yes, I'm being facetious. Clarity is important when asking a question. An unclear question may either cause confusion and waste other people's time, or it may gain no attention, wasting your time.

카테고리

Help CenterFile Exchange에서 Display and Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by