How can I change the color of a grid?
13 次查看(过去 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 中查找有关 3-D Scene Control 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!