setConstrainedPosition
Set ROI object to new position
setConstrainedPosition is not recommended. For information about
            setting position constraints, see Version History.
Description
setConstrainedPosition(
                sets the ROI object h,pos)h to a new position. The candidate
                position, pos, is subject to the position constraint function
                specified by setPositionConstraintFcn.
Input Arguments
Candidate position of the ROI object, specified as a numeric array. The
                        shape of the array depends on the type of ROI object, and is consistent with
                        the form returned by the setPosition
                        function.
| ROI Object | Position | 
|---|---|
| imellipse | 4-element vector of the form [xmin ymin width
                                            height], representing the new size and
                                        position of a bounding box around the ellipse. The new size
                                        of the bounding box iswidth-by-heightpixels. The upper-left corner of the box is at the new (x,y)
                                        coordinate
                                        (xmin,ymin). | 
| imline | 2-by-2 matrix of the form [x1 y1; x2
                                            y2], representing the new position of the two
                                        endpoints of the line. | 
| impoint | 1-by-2 vector of the form [x
                                        y]. | 
| impoly | n-by-2 matrix. The two columns define the new x- and y-coordinates, respectively, of each of the n vertices. | 
| imrect | 4-element vector of the form [xmin ymin width
                                            height]. The new size of the rectangle iswidth-by-heightpixels. The upper-left corner of the rectangle is at the new
                                        (x,y) coordinate
                                            (xmin,ymin). | 
Version History
Introduced in R2008aStarting in R2018b, a new set of ROI objects replaces the existing set of ROI objects. The new objects provide more functional capabilities, such as face color transparency. The new classes also support events that you can use to respond to changes in your ROI such as moving or being clicked. Although there are no plans to remove the old ROI objects at this time, switch to the new ROIs to take advantage of the additional capabilities and flexibility. For more information on creating ROIs using the new ROI functions, see Create ROI Shapes.
With the existing ROIs, you use makeConstrainToRectFcn to
                create a function to specify the limits of the area in which you can draw or move an
                ROI. You then register this function with the ROI. When you use the
                    setPosition object function, the ROI moves to wherever you
                specify, even if it is outside of the constrained limits. If you use
                    setConstrainedPosition, the ROI honors the limits set by the
                constrained position function.
With the new ROIs, you use the DrawingArea property of the ROI
                to specify the area in which you can draw or move an ROI. When you set the location
                using the Position property, it does not honor limits set by the
                    DrawingArea property.
Update all instances of setConstrainedPosition.
| Discouraged Usage | Recommended Replacement | 
|---|---|
| This example uses the
                                             imshow('cell.tif') h = impoint(gca,20,60); % Make a function that constrains movement of the point x = get(gca,'XLim'); y = get(gca,'YLim'); fcn = makeConstrainToRectFcn('impoint',x,y);; % Apply the constraint function to the ROI. setPositionConstraintFcn(h,fcn); % Try to specify a Position value outside the limits. setConstrainedPosition(h,[1 51]); % Note how ROI does not honor value outside of limits. | With the new ROIs, use the
                                             I = imread('cell.tif'); imshow(I) h = drawpoint(gca,'Position',[20 60]) [height width] = size(I); %Get image dimensions h.DrawingArea = [20,20,(width-40),(height-40)]; | 
See Also
imroi | getPositionConstraintFcn | setPositionConstraintFcn | setPosition | getPosition
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)