issue with imshow ploting

I am trying to plot/show an image with the certain parameters, but it doesn't show. Only the contour. Does anyone know how I can resolve my image to be shown the the parameters and contour? Thanks in advance
imshow(image,'Border','tight','InitialMagnification',100)
colormap(gray)
hold on
contour(phi,[0 0],'r')

回答 (2 件)

Brian B
Brian B 2013 年 3 月 4 日

0 投票

It is probably a scaling issue. What are the sizes of image and phi?

9 件のコメント

Brian B
Brian B 2013 年 3 月 4 日
編集済み: Brian B 2013 年 3 月 4 日
If I use
image = rand(100,140);
[X,Y] = meshgrid(1:140);
phi = cos(X/5).*sin(Y/4);
then I can see the contour on top of the image with your code.
Jerome
Jerome 2013 年 3 月 4 日
image and phi are the same size, 700 x 900
Brian B
Brian B 2013 年 3 月 4 日
Do you see the image after the first statement (before you change the colormap and plot the contour)?
Jerome
Jerome 2013 年 3 月 4 日
The image never shows!
Brian B
Brian B 2013 年 3 月 4 日
What is the result of
min(image(:))
max(image(:))
Brian B
Brian B 2013 年 3 月 4 日
編集済み: Brian B 2013 年 3 月 4 日
...or just try
imshow(image,[],'Border','tight','InitialMagnification',100)
(note the empty brackets).
Jerome
Jerome 2013 年 3 月 4 日
min(image(:)) - 7
max(image(:)) = 255
Brian B
Brian B 2013 年 3 月 4 日
編集済み: Brian B 2013 年 3 月 4 日
By default, imshow expects values between 0 and 1. You can normalize your matrix, or you can explicitly tell it what range to map to the coloraxis (using 'DisplayRange' or the bracket notation above, but with the min and max values as in [-7 255]), or you can tell it to map the whole range by passing in the empty brackets as I did above.
Jerome
Jerome 2013 年 3 月 4 日
Thanks a lot!
Image Analyst
Image Analyst 2013 年 3 月 4 日

0 投票

It's not clear if you meant
min(image(:)) = 7
or
min(image(:)) = -7
But either way you can do
imshow(yourImage, []);
It's also a bad idea to call your image "image" because it would blow away the built in image() function. I hope you didn't do that.

1 件のコメント

Brian B
Brian B 2013 年 3 月 4 日
True! I read it so quickly I didn't even notice the missing "=".
On the same note, as a control engineer I am always appalled when examples in the MATLAB documentation assign the output of a function testing some true or false condition to a variable named tf! Where are your transfer functions, now?

この質問は閉じられています。

タグ

質問済み:

2013 年 3 月 4 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by