필터 지우기
필터 지우기

How to reverse Y axis on image?

조회 수: 310 (최근 30일)
Elisa Lafforgue
Elisa Lafforgue 2018년 6월 29일
댓글: Lana Neoricic 2021년 1월 7일
Hello,
First of all, I know this question is dumb and that there is plenty of thread on it, but I could not find any solution in those. I already tried a lot of things and it did not work for me. Thus I came here for assistance.
I use the code below to show an image of a flame. In order to mesure the flame length, I have to plot axis. I managed to have axis and all, with a custom origin point, but I could not reverse the y axis.
figure(7);clf;
Image = 'input.jpg';
[rows, columns, ColorChannels] = size(Image);
origin = [center] % center is a well defined coordinates
xdata = -origin(1): columns - origin(1);
ydata = -origin(2): columns - origin(2);
imshow(Image, 'XData', xdata, 'YData', ydata);
axis on;
grid on;
I already tryed a lot of different solutions I found here and it seems some of them have no effect at all So for:
set(gca,'YDir','reverse')
set(gca,'YDir','normal')
set(gcf,'YDir','reverse')
axis ij
set(hAxes,'YDir','reverse')
Some inversed the whole image (I just want the y axis reversed), such as
fliplr or flipud (ydata) in the imshow
I suppose it might be the "imshow" doing but my image is not from a folder but from a previous matlab code (my figure show the image created just before this part of the code in matlab and this image is not saved anywhere in my folders) so I don't know if there is another solution than imshow for this case.
Do I use the code to reverse axis right? Is there any other solutions?
Ps: I tried to put those codes above in different location (before and after the "imshow") yet it still has no effect at all
  댓글 수: 3
Dogukan Engin
Dogukan Engin 2019년 1월 7일
Hello,
I also need help on this one.
Thanks,
Rik
Rik 2019년 1월 7일
Since there is an accepted answer: did you try it, and if so, how didn't it work?

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

채택된 답변

Sergey Efremov
Sergey Efremov 2018년 8월 29일
By default, y axis of an image is upside-down, values ascending from top down. If you set(gca,'YDir','normal'), you will reverse y axis. (gca,'YDir','reverse') will only leave y axis unchanged from default.
  댓글 수: 1
Lana Neoricic
Lana Neoricic 2021년 1월 7일
Wow, this one is not obvious at all! Thank you!

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

추가 답변 (1개)

Elisa Lafforgue
Elisa Lafforgue 2018년 8월 31일
Well, what I did to solve it is just flipping the image before to put the axis then
axis xy
It does the trick but it would give nausea at any matlab expert I think

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by