如何在MATLAB Figure的“属性检查器”手动设置图像

1. 设置坐标轴的比例尺相等

在MATLAB中,可以通过设置图形对象的 axis 属性来使得 x 轴和 y 轴的比例尺相等。以下是具体步骤:

  • 打开绘图窗口。
  • 在菜单栏中选择 View > Property Inspector (属性检查器)。
  • 在属性检查器窗口中,找到并选择要调整的轴(通常是 Axes 或者 Axes对象)。
  • 找到 位置>DataAspectRatio 属性,将其设置为 [1 1 1]

2. 添加背景网格

在设计区域中选中Axes组件,然后在右侧的属性检查器中进行如下设置:

  • 找到并展开 Grid 属性。
  • 勾选 XGridYGrid 选项以启用x轴和y轴的网格。

3. 设置让图像数据tight显示

  • 找到Axes>标尺
  • 将为XLimitMethodYLimitMethodZLimitMethod设置为tight

4. 设置同时显示上下左右的坐标轴线

  • 在设计区域中选中 Axes 组件。
  • 在属性检查器中,找到并展开 框样式 属性。
  • 找到 Box 属性,并将其设置为 on

官方参考手册

  • 8
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的 MATLAB 代码示例,可以在 app 上实现手动分割细胞图像: ```matlab function varargout = cell_segmentation_gui(varargin) % CELL_SEGMENTATION_GUI MATLAB code for cell_segmentation_gui.fig % CELL_SEGMENTATION_GUI, by itself, creates a new CELL_SEGMENTATION_GUI or raises the existing % singleton*. % % H = CELL_SEGMENTATION_GUI returns the handle to a new CELL_SEGMENTATION_GUI or the handle to % the existing singleton*. % % CELL_SEGMENTATION_GUI('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in CELL_SEGMENTATION_GUI.M with the given input arguments. % % CELL_SEGMENTATION_GUI('Property','Value',...) creates a new CELL_SEGMENTATION_GUI or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before cell_segmentation_gui_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to cell_segmentation_gui_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help cell_segmentation_gui % Last Modified by GUIDE v2.5 25-May-2021 21:34:35 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @cell_segmentation_gui_OpeningFcn, ... 'gui_OutputFcn', @cell_segmentation_gui_OutputFcn, ... 'gui_LayoutFcn', [], ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before cell_segmentation_gui is made visible. function cell_segmentation_gui_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to cell_segmentation_gui (see VARARGIN) % Choose default command line output for cell_segmentation_gui handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes cell_segmentation_gui wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = cell_segmentation_gui_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in load_image_btn. function load_image_btn_Callback(hObject, eventdata, handles) % hObject handle to load_image_btn (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Load the image from file [file, path] = uigetfile('*.png;*.jpg;*.bmp', 'Select an image file'); if file ~= 0 image_path = fullfile(path, file); handles.image = imread(image_path); imshow(handles.image, 'Parent', handles.image_axes); guidata(hObject, handles); end % --- Executes on button press in segment_btn. function segment_btn_Callback(hObject, eventdata, handles) % hObject handle to segment_btn (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Perform manual segmentation on the loaded image mask = roipoly(handles.image); imshow(mask, 'Parent', handles.mask_axes); % Save the segmentation mask to a file [file, path] = uiputfile('*.png', 'Save the segmentation mask'); if file ~= 0 mask_path = fullfile(path, file); imwrite(mask, mask_path); end % --- Executes on button press in clear_btn. function clear_btn_Callback(hObject, eventdata, handles) % hObject handle to clear_btn (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Clear the image and mask handles.image = []; handles.mask = []; cla(handles.image_axes); cla(handles.mask_axes); guidata(hObject, handles); ``` 这段代码实现了一个简单的 GUI,其中包含三个按钮:一个用于加载图像,一个用于手动分割图像,一个用于清除图像和掩模。当用户单击“加载图像”按钮时,将显示一个文件对话框,用户可以选择要加载的图像。当用户单击“手动分割”按钮时,将打开一个新的图像窗口,并允许用户手动绘制一个掩码,以指示哪些区域应该被分割。最后,当用户单击“清除”按钮时,将清除所有图像和掩码,以便用户可以开始新的分割过程。 你可以根据自己的需求对此代码进行修改和扩展,以实现更复杂的细胞图像分割任务。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值