Mount a matrix in RGB that is equivalent to a GrayScale with an altered color

1

I have a Matlab array of one dimension ie grayscale, but I would like to create an RGB equivalent in which all black of this, i.e. all zero is a green tone. And let all other white and gray colors be kept from the original matrix in the same color.

    
asked by anonymous 15.05.2014 / 18:49

1 answer

1

As you did not inform the original matrix, I'll assume this:

% matriz original:
matrix_cinza = rand(64, 64);

And viewing:

% imagem original
% Sendo: cat(3, VERMELHO, VERDE, AZUL)
% Mas, como é escala de cinza os três canais são iguais.
imagem_cinza = cat(3, matrix_cinza, matrix_cinza, matrix_cinza);

Tohighlighttheblackelementsyoucancreateamatriz_destacaandchangethevalueofthosethatareblackto1.Inthiscase,valueslessthan0.1wereconsideredblack,butyoucanchangethemtothedesiredlevelinmatrix_destaca<0.1.

matrix_destaca=matrix_cinza;matrix_destaca(matrix_destaca<0.1)=1;

Soyoucangeneratethehighlightedimagejustthegreenimagelayer:

imagem_destacada=cat(3,matrix_cinza,matrix_destaca,matrix_cinza);image(imagem_destacada);

Whatresultsin:

    
15.05.2014 / 20:21