how to smoothen only the high intensity pixel in a color image
5 次查看(过去 30 天)
显示 更早的评论
@Image Analyst i want to smoothen or reduce the pixel value high pixels can anyone help me with the code part
0 个评论
采纳的回答
Image Analyst
2021-5-31
Just get a mask where the bright regions are, then blur the image and then replace only where it's blurred and in the mask
Something like (untested)
% Separate into individual color channels.
[r, g, b] = imsplit(rgbImage);
% Get mask of where the bright pixels are.
brightMask = rgb2gray(rgbImage) > 220; % Or whatever value you want.
% Blur entire image.
windowWidth = 15;
kernel = ones(windowWidth, windowWidth) / windowWidth^2;
blurryR = imfilter(r, kernel);
blurryG = imfilter(g, kernel);
blurryB = imfilter(b, kernel);
% Replace mask pixels with smoothed/blurred ones
r(brightMask) = blurryR(brightMask);
g(brightMask) = blurryG(brightMask);
b(brightMask) = blurryB(brightMask);
% Reconstruct output image from individual color channels.
outputImage = cat(3, r, g, b);
2 个评论
Image Analyst
2021-7-29
To dim the bright regions (ONLY) by 20 gray levels in each color channel, do this:
% Replace mask pixels with smoothed/blurred ones
r(brightMask) = blurryR(brightMask) - 20;
g(brightMask) = blurryG(brightMask) - 20;
b(brightMask) = blurryB(brightMask) - 20;
% Reconstruct output image from individual color channels.
outputImage = cat(3, r, g, b);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!