How to output matrix grayscale?
Ältere Kommentare anzeigen
I am trying to output my matrix grayscale with imshow(), but its looks like gradient.
My code is:
s=4;
A=256;
N=200;
i=1:N;
r=0.1*(i-N/2);
f=exp(-r.^2/2/s^2);
M=A*(f'*f);
imshow(M,[]);
Please, help me to find a solution to this problem
1 Kommentar
KALYAN ACHARJYA
am 4 Mär. 2021
"matrix grayscale with imshow(), but its looks like gradient"
Can you re-read the statement again and explain more? graysclae is scale range (shaded variation), where as gradient is derivative?
Akzeptierte Antwort
Weitere Antworten (1)
Bjorn Gustavsson
am 4 Mär. 2021
You could use imagesc instead of imshow. Combined with colorbar you get a neat display of your matrix. Since you asked for gray-scale, you'll also have to set the colormap, so something like this:
imagesc(M)
colorbar
colormap(gray)
HTH
Kategorien
Mehr zu White finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!