How can I change the color of a grid?
11 ビュー (過去 30 日間)
古いコメントを表示
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,
0 件のコメント
回答 (2 件)
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Modify Image Colors についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!