Grayscale image = Max(RGB)

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)

Respuestas (3)

Walter Roberson
Walter Roberson el 4 de Oct. de 2012

0 votos

I might be misinterpreting, but I think you are asking for
grayImage = max(YourImage, 3);

8 comentarios

Adela
Adela el 4 de Oct. de 2012
having the Red(255),Green(0),Blue(0) , he wanted the max(RGB) as the max of gray scale.
Jan
Jan el 4 de Oct. de 2012
@Adela: Exactly. And this is what Walter's code does.
Perhaps you want to divide by 255 afterwards?
Btw, who is "he"?
Adela
Adela el 4 de Oct. de 2012
sorry. "he" refers to my professor. i'll try it out:) btw, wonder if you may know the idea/purpose behind of doing this? because my professor did not mention much, but i'm curious.
Image Analyst
Image Analyst el 4 de Oct. de 2012
Editada: Image Analyst el 4 de Oct. de 2012
It's probably to get the background image to do a "flat field" correction. For the blue ink pixels, the max will most likely be the red channel and the blue text won't show up, so this will get you a grayscale version of the image without the ink. Then you can divide by that max image (the background image) to "background-correct" the image. It's a simple way for you students, but there are probably some more accurate (less noisy) ways of doing it, but this is fine for instructional purposes and to just illustrate the concept.
Adela
Adela el 4 de Oct. de 2012
Hi, i actually dont understand this argument if the ink is blue, so the max will be the blue channel not red if the ink is red, then the max will be the red channel and if the ink is green, the max value is also the green channel?
Image Analyst
Image Analyst el 4 de Oct. de 2012
You're right - I misspoke.
Jan
Jan el 4 de Oct. de 2012
@Adela: You professor is payed for explaining such details. Ask him. He will remember your activity and curiosity.
Adela
Adela el 4 de Oct. de 2012
it was part of my project and he is not going to give more details. Probably he wants me to extract the red component, because most of my sample images is pinky.

Iniciar sesión para comentar.

Adam Mackay
Adam Mackay el 28 de Oct. de 2022

0 votos

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.
Image Analyst
Image Analyst el 28 de Oct. de 2022

0 votos

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)');

Categorías

Más información sobre Image Processing Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 4 de Oct. de 2012

Comentada:

el 28 de Oct. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by