필터 지우기
필터 지우기

Why image rotates after adding to a figure- how to prevent it?

조회 수: 1 (최근 30일)
BN
BN 2020년 4월 13일
댓글: Star Strider 2020년 4월 13일
Hey all, I have a problem, I used this code to add my .png image to the current figure (map of the country),
gs = geoshow(A, cmap, R);
gs.CData(repmat(mask,1,1,3)) = 255;
axis equal
box on
hold on
%%% add png file to the current figure
[img, ~, tr] = imread('filename1.png');
im = image('CData',img,'XData',[50 51],'YData',[35 36]);
im.AlphaData = tr;
hold off
The picture adds successfully (colorful circle):
But I see it is rotated. in fact, my original .png is:
But after adding it to figure it seems to it has rotated by 180 degrees. I tried to rotate it before hold off part using imrotate function but it failed.
How can fix this problem?
Thanks

채택된 답변

Star Strider
Star Strider 2020년 4월 13일
Using flipud worked when I tried it:
im = image('CData',flipud(img),'XData',[50 51],'YData',[35 36]);
I do not have the Mapping Toolbox so I could not run the entire code.
.
  댓글 수: 2
BN
BN 2020년 4월 13일
Really thank you it's fixed for me. ?
Star Strider
Star Strider 2020년 4월 13일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by