How can I change the color of a grid?

10 vues (au cours des 30 derniers jours)
leonardo araujo
leonardo araujo le 23 Avr 2016
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,

Réponses (2)

Daniel
Daniel le 6 Mai 2016
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 le 9 Déc 2018
set(gca, 'Color', 'r')

Catégories

En savoir plus sur Modify Image Colors dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by