Why image rotates after adding to a figure- how to prevent it?
3 ビュー (過去 30 日間)
古いコメントを表示
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):
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/284221/image.jpeg)
But I see it is rotated. in fact, my original .png is:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/284222/image.png)
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
0 件のコメント
採用された回答
Star Strider
2020 年 4 月 13 日
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.
.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!