Grayscale image = Max(RGB)
9 次查看(过去 30 天)
显示 更早的评论
Please take a look at attached photo.
i was asked to get the RGB's max pixel for the gray scale.
how do i do that?
gray = max(RGB)
回答(3 个)
Walter Roberson
2012-10-4
I might be misinterpreting, but I think you are asking for
grayImage = max(YourImage, 3);
8 个评论
Jan
2012-10-4
@Adela: You professor is payed for explaining such details. Ask him. He will remember your activity and curiosity.
Adam Mackay
2022-10-28
Max RGB selects the channel with the highest decimal value
Ie: 128, 10, 35 would become 255,0,0 since the red channel has the highest value
In the case of grey scale or grey images
you would normally have all channels equal, for example
127,127,127, in which case there are no channels with the heighest value, so for that particular pixel the values would remain the same for all channels (unchanged)
An example can be observed in this image, in which the colour of the jumper or sweater remains grey for a large portion of it.
0 个评论
Image Analyst
2022-10-28
Here is code with all the methods discussed here:
rgbImage = imread('peppers.png');
subplot(2, 2, 1);
imshow(rgbImage);
impixelinfo;
title('Original Image');
% Get the max for each pixel, and the channel in which the max occurs.
[grayImage, channelImage] = max(rgbImage, [], 3);
subplot(2, 2, 2);
imshow(grayImage);
impixelinfo;
title('Max of each color channel');
subplot(2, 2, 3);
imshow(channelImage, []);
impixelinfo;
title('Channel where max value is');
% Assign the 1's to red, 2's to green, and 3's to blue.
z = zeros(size(rgbImage, 1), size(rgbImage, 2), 'uint8');
r = 255 * uint8(channelImage == 1);
g = 255 * uint8(channelImage == 2);
b = 255 * uint8(channelImage == 3);
rgbImageMax = cat(3, r, g, b);
subplot(2, 2, 4);
imshow(rgbImageMax, []);
impixelinfo;
title('MAX image (Adam''s definition)');
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing and Computer Vision 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!