フィルターのクリア

rotating image using app designer

18 ビュー (過去 30 日間)
Lesly
Lesly 2024 年 4 月 17 日
回答済み: Image Analyst 2024 年 4 月 17 日
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);
imshow(app.img2);
end
end
this is what I have so far, img is for the orginal image use.

回答 (1 件)

Image Analyst
Image Analyst 2024 年 4 月 17 日
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