在 MATLAB App Designer 中创建 "Rotate 90 degrees" 按钮
Creating a "Rotate 90 degrees" button in MATLAB App Designer
我正在尝试使用 MATLAB 中的 App Designer 制作一个简单的 GUI。我想要一个名为“Rotate 90”的按钮,每次按下时都会将图形旋转 90 度。我设法做的是只旋转一次,但是我有一个明显的问题,当再次按下时,它会再次旋转原始图片,而不是刚刚生成的新图片。
UIAXes 是我之前在其中显示图形的轴。
在回调之前我有以下属性:
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
OpenimageButton matlab.ui.control.Button
TextArea matlab.ui.control.TextArea
DropDownHistogram matlab.ui.control.DropDown
DropDownProperties matlab.ui.control.DropDown
Rotate90Button matlab.ui.control.Button
Rotate180Button matlab.ui.control.Button
UIAxes matlab.ui.control.UIAxes
UIAxes_2 matlab.ui.control.UIAxes
end
properties (Access = private)
oldpath = addpath(genpath('/Libraries/')) % Load libraries
ImageFile; % Image loaded
handlehistogram;
fullname;
degrees;
end
回调函数如下:
% Button pushed function: Rotate90Button
function Rotate90ButtonPushed(app, event)
image90 = app.ImageFile;
rotated90 = imrotate(image90, 90);
imagesc(app.UIAxes, rotated90);
end
如果有人感兴趣,我就是这样解决的:
我添加了一个 属性 叫做 rotatedImg
properties (Access = private)
oldpath = addpath(genpath('/Libraries/')) % Load libraries
ImageFile; % Image loaded
handlehistogram;
fullname;
filename;
degrees;
rotatedImg;
end
我在回调函数中写了这个:
% Button pushed function: Rotate90Button
function Rotate90ButtonPushed(app, event)
app.rotatedImg = imrotate(app.rotatedImg, 90);
imagesc(app.UIAxes, app.rotatedImg);
end
我正在尝试使用 MATLAB 中的 App Designer 制作一个简单的 GUI。我想要一个名为“Rotate 90”的按钮,每次按下时都会将图形旋转 90 度。我设法做的是只旋转一次,但是我有一个明显的问题,当再次按下时,它会再次旋转原始图片,而不是刚刚生成的新图片。
UIAXes 是我之前在其中显示图形的轴。 在回调之前我有以下属性:
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
OpenimageButton matlab.ui.control.Button
TextArea matlab.ui.control.TextArea
DropDownHistogram matlab.ui.control.DropDown
DropDownProperties matlab.ui.control.DropDown
Rotate90Button matlab.ui.control.Button
Rotate180Button matlab.ui.control.Button
UIAxes matlab.ui.control.UIAxes
UIAxes_2 matlab.ui.control.UIAxes
end
properties (Access = private)
oldpath = addpath(genpath('/Libraries/')) % Load libraries
ImageFile; % Image loaded
handlehistogram;
fullname;
degrees;
end
回调函数如下:
% Button pushed function: Rotate90Button
function Rotate90ButtonPushed(app, event)
image90 = app.ImageFile;
rotated90 = imrotate(image90, 90);
imagesc(app.UIAxes, rotated90);
end
如果有人感兴趣,我就是这样解决的:
我添加了一个 属性 叫做 rotatedImg
properties (Access = private)
oldpath = addpath(genpath('/Libraries/')) % Load libraries
ImageFile; % Image loaded
handlehistogram;
fullname;
filename;
degrees;
rotatedImg;
end
我在回调函数中写了这个:
% Button pushed function: Rotate90Button
function Rotate90ButtonPushed(app, event)
app.rotatedImg = imrotate(app.rotatedImg, 90);
imagesc(app.UIAxes, app.rotatedImg);
end