RGB Image subtracting mean intensity
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Giorgio Gurian
am 29 Okt. 2017
Kommentiert: Image Analyst
am 21 Apr. 2020
Hi, so I just started using MATLAB, and I need to solve this exercise: "Given an RGB image, write a MATLAB code that, for each color channel, every pixel is modified by subtracting to its intensity the mean intensity value of the channel. ". Any help is very appreciated, thanks in advance!
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 29 Okt. 2017
Try this:
rgbImage = im2double(imread('peppers.png'));
subplot(1, 2, 1);
imshow(rgbImage);
title('Original Image', 'FontSize', 20);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
meanR = mean2(redChannel)
meanG = mean2(greenChannel)
meanB = mean2(blueChannel)
rgbImage = cat(3, redChannel - meanR, greenChannel - meanG, blueChannel - meanB);
subplot(1, 2, 2);
imshow(rgbImage);
title('Means Subtracted', 'FontSize', 20);
5 Kommentare
Ronnie II Concepcion
am 21 Apr. 2020
Hi! I would like to imshow a color channel defined by these equation:
128*(((greenChannel-redChannel)/(greenChannel+redChannel))+1)
Can someone please help me? Thanks.
Image Analyst
am 21 Apr. 2020
Try using ./ instead of / and assigning it to a variable then using imshow with brackets:
newImage = 128*(((greenChannel-redChannel) ./ (greenChannel+redChannel))+1);
imshow(newImage, []);
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!