how to smoothen only the high intensity pixel in a color image
6 views (last 30 days)
Show older comments
alexander
on 31 May 2021
Commented: Image Analyst
on 29 Jul 2021
@Image Analyst i want to smoothen or reduce the pixel value high pixels can anyone help me with the code part
0 Comments
Accepted Answer
Image Analyst
on 31 May 2021
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 Comments
Image Analyst
on 29 Jul 2021
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);
More Answers (0)
See Also
Categories
Find more on Computer Vision with Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!