DSPRelated.com
Forums

Gray scale image of matrix

Started by Amit September 4, 2006
Hi all,

Assume you have a NxN doubly stochastic square matrix
with the main diagonal elements have the highest
probability score in the row and column they belong
to. I wanted to know how to plot a gray scale image of
the matrix where the gray scale shade of each element
in the matrix is representative of the probability
score of that element. Higher the probability score
gives a darker shade. For eg, a score of 1 is pitch
black, 0 is plain white and 0.5 is ideal gray. A
sample 3x3 matrix for this is:

M = [0.7 0.2 0.1; 0.1 0.5 0.4; 0.2 0.3 0.5];

Thanks,
Amit
imagesc(-M), colormap(gray)

--
Shawn Mikula, Ph.D.,
Postdoctoral Scholar
Center for Neuroscience
University of California-Davis,
1544 Newton Court,
Davis, CA 95618,
Phone: 530-754-9209
Fax: 530-754-9136
mail: s...@ucdavis.edu
web: http://brainmaps.org

Hi all,

Assume you have a NxN doubly stochastic square matrix
with the main diagonal elements have the highest
probability score in the row and column they belong
to. I wanted to know how to plot a gray scale image of
the matrix where the gray scale shade of each element
in the matrix is representative of the probability
score of that element. Higher the probability score
gives a darker shade. For eg, a score of 1 is pitch
black, 0 is plain white and 0.5 is ideal gray. A
sample 3x3 matrix for this is:

M = [0.7 0.2 0.1; 0.1 0.5 0.4; 0.2 0.3 0.5];

Thanks,
Amit
Hi,

try this :

M = [0.7 0.2 0.1; 0.1 0.5 0.4; 0.2 0.3 0.5];

figure;
colormap(gray);
imagesc(1-M);
caxis([0 1])
axis off

Je