How can I change the color of a grid?

11 ビュー (過去 30 日間)
leonardo araujo
leonardo araujo 2016 年 4 月 23 日
回答済み: Lori Lewis 2018 年 12 月 9 日
Dear users,
I'm intending to draw a grid on a image for point count using the command:
Ig2(50:50:end,:,:) = 0;
Ig2(:,50:50:end,:) = 0;
imshow(Ig2);
Over the image a black grid is draw. How do I change the color of the grid to yellow or red?
BR,

回答 (2 件)

Daniel
Daniel 2016 年 5 月 6 日
If I were to check the size of your image matrix Ig2 I would see that
size(Ig2)
returns
x y c
Where x is the number of row in your matrix.
Where y is the number of columns in your matrix
Where c is of value 3 because you need to specify the intensity of Red, Green, Blue for each pixel.
So for any pixel that is at row 'i' and column 'j' I can choose the colour by changing the intensity of Red, Green and Blue in the following way:
Ig2(i,j,1) = 1; %Set red to full intensity
Ig2(i,j,2) = 0; %Set green to zero intensity
Ig2(i,j,3) = 0; %Set blue to zero intensity
Now the pixel at location i,j will be red.
Back to your problem. To get a red grid all you need to do is the following:
Ig2(50:50:end,:,1) = 1;
Ig2(50:50:end,:,2) = 0;
Ig2(50:50:end,:,3) = 0;
Ig2(:,50:50:end,1) = 1;
Ig2(:,50:50:end,2) = 0;
Ig2(:,50:50:end,3) = 0;
imshow(Ig2);
Play with the values on the right hand side to get different colours. Hint: to get yellow you have to mix red and green.

Lori Lewis
Lori Lewis 2018 年 12 月 9 日
set(gca, 'Color', 'r')

カテゴリ

Help Center および File ExchangeModify Image Colors についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by