After uploading an image, rotate the image from GUI pushbutton?
Afficher commentaires plus anciens
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 commentaire
Jan
le 1 Mai 2016
Please post the relevant code and explain the issues you have with any details. How could we suggest an improvement otherwise?
Réponses (2)
Walter Roberson
le 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
le 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.
Catégories
En savoir plus sur Convert Image Type dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!