Generate the following image by defining image matrix:
Red Green Blue Yellow Green.
B(1:100,1:100,1:100,1:00,1:3)=0; imshow (B) B(1:50,1:50,1) =1; B(51:100,51:100,2)=1; imshow(B)
I am trying to get a 3x3 with the specified colors; Red Green Blue Yellow Green. It's not working, it gives error.
No products are associated with this question.
B(1:100,1:100,1:100,1:00,1:3)=0 tries to define a 5 dimensional array in which the fourth dimension is empty. 1:00 is empty. Perhaps you meant 1:100 .
RGB matrices are 3 dimensional.
You may wish to use zeros() to initialize the matrix.
Is this what you're looking for:
redChannel = zeros(100, 100, 'uint8'); greenChannel = zeros(100, 100, 'uint8'); blueChannel = zeros(100, 100, 'uint8'); redChannel(1:50,:) = 255; greenChannel(:, 1:50) = 255; blueChannel(51:100, 51:100) = 255; coloredImage = cat(3, redChannel, greenChannel, blueChannel); imshow(coloredImage)
Play games and win prizes!Learn more