After uploading an image, rotate the image from GUI pushbutton?

Having issues rotating an image in my GUI after it has been uploaded onto the GUI. I believe it has something to do with keeping global variables attached to the image after it has been selected. I am using 'imrotate' to rotate the image 90 degrees but I'm still having issues with rotating the image after it has been uploaded. Any suggestions?

댓글 수: 1

Please post the relevant code and explain the issues you have with any details. How could we suggest an improvement otherwise?

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

답변 (2개)

Walter Roberson
Walter Roberson 2016년 5월 1일
[filename, filedir] = uigetfile('*.tif');
fullname = fullfile(filedir, filename);
TheImage = imread(fullname);
RotImage = imrotate(TheImage, 90);
ax1 = subplot(1,2,1); imshow(TheImage, 'Parent', ax1); title('original');
ax2 = subplot(1,2,2); imshow(RotImage, 'Parent', ax2); title('rotated');
handles.TheImage = TheImage;
handles.RotImage = RotImage;
fig = ancestor(ax1, 'figure');
guidata(fig, handles);
Image Analyst
Image Analyst 2016년 5월 2일
If you want to rotate the image in a button callback, you can attach the image array to the handles structure like Walter did, or you can make the array global. Simply have the line
global TheImage;
in every function where you want to use TheImage, like the button that reads in TheImage and displays it, and the other button that rotates and displays it.

질문:

2016년 5월 1일

답변:

2016년 5월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by