Why the image is upside down when I display it in a graph?

조회 수: 24 (최근 30일)
afrya
afrya 2014년 1월 7일
댓글: Image Analyst 2014년 1월 13일
Hello,
I have a problem when I display an image in a plot.The image is upside down in the figure window.
Do you know how to fix this problem?
here is my code to display the image in the graph:
% Load the image
img = imread('KAM-Map_12s.bmp');
hold on;
% Plot the image, with x and y coordinnates
image([150 350],[4 4.7],img);
Thanks in advance

채택된 답변

Mischa Kim
Mischa Kim 2014년 1월 13일
편집: Mischa Kim 2014년 1월 13일
Simply add (only)
set(gca,'YDir','reverse');
In other words, try
img = imread('KAM-Map_12s.bmp');
hold on;
image([150 350],[4 4.7],img);
set(gca,'YDir','reverse');

추가 답변 (2개)

afrya
afrya 2014년 1월 13일
thanks for your answer.The image is now in the right order But I still have a problem, when I add set(gca,'YDir','reverse') in my code, the graph is also reversed.

Image Analyst
Image Analyst 2014년 1월 7일
The direction of the y axis is reversed from regular graphs since the convention is that the top of the image is line 1 and line numbers increase as you go down. You can set ydir to 'reverse' or call flipud(imageArray).
  댓글 수: 2
afrya
afrya 2014년 1월 8일
Thanks for your answer.When I call flipud(imageArray), I get this message error
Error in projecttest7 (line 148)
image([150 350],[4 4.7],flipud(img));
Could you tell me how can I set ydir to 'reverse? I don't see how to do it
Image Analyst
Image Analyst 2014년 1월 13일
Is img color or grayscale? What does this say
[rows, columns, numberOfColorChannels] = size(img) % No semicolon

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

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by