This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

makeConstrainToRectFcn

Create rectangularly bounded drag constraint function

Syntax

fcn = makeConstrainToRectFcn(roi,x,y)

Description

example

fcn = makeConstrainToRectFcn(roi,x,y) creates a position constraint function for draggable tools of a given ROI type. The position of the tool is constrained by rectangular boundaries described by position vectors x and y.

Examples

collapse all

Display an image.

imshow('cell.tif')

Create an impoint object at the (x,y) coordinate (20,60). In an image, the positive y direction is downwards.

h = impoint(gca,20,60);

Make a function that constrains the impoint to the image limits.

x = get(gca,'XLim');
y = get(gca,'YLim');
fcn = makeConstrainToRectFcn('impoint',x,y);

Apply the constraint function to the impoint. Try dragging the point past the boundary of the image. The constraint function prevents the point from crossing the image boundary.

setPositionConstraintFcn(h,fcn);

Input Arguments

collapse all

ROI type, specified as 'imellipse', 'imfreehand', 'imline', 'impoint', 'impoly', or 'imrect'.

Data Types: char | string

Rectangular boundaries in the x direction, specified as a 2-element numeric vector of the form [xmin xmax].

Rectangular boundaries in the y direction, specified as a 2-element numeric vector of the form [ymin ymax].

Output Arguments

collapse all

Function handle, returned as a handle. For more information, see Create Function Handle (MATLAB).

Introduced in R2006a