Effacer les filtres
Effacer les filtres

rotating image using app designer

16 vues (au cours des 30 derniers jours)
Lesly le 17 Avr 2024
Hello, I need some help in rotating an image when using a buttom to rotate. I know that I have to use imrotate but im am not sure where to go from here.
% Button pushed function: RotateButton
function rotate(app, event)
app.img2 = imrotate(app.img, 90);
this is what I have so far, img is for the orginal image use.

Réponses (1)

Image Analyst
Image Analyst le 17 Avr 2024
Assuming you have an image variable, not a widget on the UI, called app.img, it should work. But I don't know what app.img is. Did you assign an image as a new field of the app structure? If so that should work. But if img is the name of an axes control that you placed on the UI window that would not work. You would need to get your actual image variable and rotate it and then display it. Something like
rgbImage = imread('peppers.png');
rgbImage = imrotate(rgbImage, 90); % Rotate it and put it back in the same variable.
imshow(rgbImage, 'Parent', app.img); % Display it in the "img" axes control on the GUI.

Community Treasure Hunt

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

Start Hunting!

Translated by