How to generate the following color Image: Yellow, Green, and Red
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Walter Roberta
il 1 Dic 2012
Commentato: Image Analyst
il 1 Feb 2020
Please how to generate the following color image:Yellow, Green,and Red by defining image Matrix And Showing me the colors of the image on the screen. The outer image size is 200 x 200 pixels, center image is 150 x 150 pixels, and the innermost image size is 100 x 100 pixels.
0 Commenti
Risposta accettata
Image Analyst
il 1 Dic 2012
Modificato: Image Analyst
il 1 Dic 2012
Try this:
redChannel = 255 * ones(200, 200, 'uint8');
greenChannel = 255 * ones(200, 200, 'uint8');
blueChannel = 255 * zeros(200, 200, 'uint8');
% Blacken the inner most 150x150 for red
% so that it will be only Green.
redChannel(25:174, 25:174) = 0;
% Set the inner most 100x100 for red and
% Clears the inner most 100 x 100 for green
% so that it will be only red.
redChannel(50:149, 50:149) = 255;
greenChannel(50:149, 50:149) = 0;
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
imshow(rgbImage);
2 Commenti
BHANU SRINIVASA
il 1 Feb 2020
hey ,
how can we display a [mxnx3] matrix as an image
i have the matrix and im not able to display the image
Image Analyst
il 1 Feb 2020
Why not? imshow() should work
imshow(yourImage);
yourImage should be either:
- a uint8 image with integer values in the range 0-255
- a uint16 image with integer values in the range 0-65535
- a double image with double values in the range 0-1
If you have anything else, like an RGB image with double values in the range 0-255, you'll have to cast it to one of the above types with functions like mat2gray(), rescale(), im2double(), im2uint8, etc. For examples:
rgbImage = uint8(rgbImage);
rgbImage = mat2gray(rgbImage);
rgbImage = uint8(rescale(rgbImage, 0, 255));
Più risposte (1)
Bloti Teh
il 24 Nov 2018
redChannel = 255 * ones(200, 200, 'uint8');
greenChannel = 255 * ones(200, 200, 'uint8');
blueChannel = 255 * zeros(200, 200, 'uint8');
% Blacken the inner most 150x150 for red
% so that it will be only Green.
redChannel(25:174, 25:174) = 0;
% Set the inner most 100x100 for red and
% Clears the inner most 100 x 100 for green
% so that it will be only red.
redChannel(50:149, 50:149) = 255;
greenChannel(50:149, 50:149) = 0;
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
imshow(rgbImage);
1 Commento
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!