After uploading an image, rotate the image from GUI pushbutton?
Ältere Kommentare anzeigen
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 Kommentar
Jan
am 1 Mai 2016
Please post the relevant code and explain the issues you have with any details. How could we suggest an improvement otherwise?
Antworten (2)
Walter Roberson
am 1 Mai 2016
[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
am 2 Mai 2016
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.
Kategorien
Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!