The operation function of selecting rectangular frame area in the image using MATLAB is the process __matlab

Source: Internet
Author: User

In GUI functions of the MATLAB Image Processing Toolkit (image processing Toolbox), there are some functions used to select rectangles or elliptical regions on an image or an axis, using the following example:

[plain] view plain copy print?   Figure, Imshow (' cameraman.tif ');   h = imrect (GCA, [10 10 100 100]);   API = Iptgetapi (h);   Api.addnewpositioncallback (@ (P) title (MAT2STR (p,3));   FCN = MAKECONSTRAINTORECTFCN (' Imrect ', Get (GCA, ' Xlim '), Get (GCA, ' Ylim '));   API.SETPOSITIONCONSTRAINTFCN (FCN); The following explains the program features,

First line of code: display a built-in image of Matlab

The first line of code: Draws a rectangular area at the top left corner of the image, returns the handle value of the axes object in the rectangular area H,matlab help is interpreted as:

h = imrect (hparent, position) Createsa draggable rectangle on the object specified by Hparent. Position Isa Four-element Vector that specifies the initial size and locationof the rectangle.position has the form [xminy Min width height].
The third line of code: Get handle H API interface for subsequent program calls.

Four lines of code: Add a callback function, when the position of the rectangle is updated, this callback function is invoked to react to this, the way to react here is to display the position and size information of the rectangular box in the image's caption. MAT2STR is used to convert the rectangular box position data of the handle function p to a string.

Line five: Define a rectangular box area limit function that allows the rectangle frame to be confined to the interior of the image and not be moved to the outside of the image.

Line six: The function of calling the SETPOSITIONCONSTRAINTFCN function after the fifth line of code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.