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

KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 3월 4일
"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?

댓글을 달려면 로그인하십시오.

 채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 3월 4일

1 개 추천

This one?
imagesc(M);

댓글 수: 3

Pryschepa Daryna
Pryschepa Daryna 2021년 3월 4일
That outputs colorful M , but I need to output it grayscale with imshow
Bjorn Gustavsson
Bjorn Gustavsson 2021년 3월 4일
No, you don't need to use imshow to get the matrix in gray-scale. You can set the colormap to gray. You can also read the help and documentation to imshow to learn how that functions works, particularly with respect to intensity-scaling of inputs with different data-types...

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2021년 3월 4일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 White에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by