如何阻止在Matlab中编辑/拖动不占优势的可能性? [英] How to block possibility to edit/drag impoly in matlab?

查看:111
本文介绍了如何阻止在Matlab中编辑/拖动不占优势的可能性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在matlab的image_area上创建了一个多边形. 我使用过不富裕的行为. 但是创建多边形之后. 我需要阻止移动和拖动不完全的可能性(已经创建了ROI). 我不知道该怎么办?

I create a polygon on image_area in matlab. I used impoly. But after creation polygon. I need to block possibility to move and drag impoly (ROI is already created). I don't know how I should do it ?

请多多帮助.

推荐答案

您可以设置

You can set the makeConstrainToRectFcn such that it is a rectangle encompassing your ROI, then whenever you try to move the latter it won't work. You can also, after creating the ROI, set the setVerticesDraggable method to false in order to prevent vertices from being dragged.

示例代码(改编自Mathworks的示例):

Sample code (adapted from example by the Mathworks):

clc
clear

figure
imshow('gantrycrane.png');
h = impoly(gca, [188,30; 189,142; 93,141; 13,41; 14,29]);

%// Get currentposition
Pos = getPosition(h);

%// Prevent draggable vertices
setVerticesDraggable(h,0);

%// Set up rectangle to prvent movement of ROI
fcn = makeConstrainToRectFcn('impoly', [min(Pos(:,1)) max(Pos(:,1))], [min(Pos(:,2)) max(Pos(:,2))]);

%// Apply function
h.setPositionConstraintFcn(fcn);

导致这种情况(红色矩形为插图):

which results in this kind of situation (with red rectangle for illustration):

这篇关于如何阻止在Matlab中编辑/拖动不占优势的可能性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆