How to generate the following color Image: Yellow, Green, and Red
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Image Analyst
2012-12-1
编辑:Image Analyst
2012-12-1
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 个评论
BHANU SRINIVASA
2020-2-1
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
2020-2-1
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));
更多回答(1 个)
Bloti Teh
2018-11-24
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);
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!