From: zhang on 30 Apr 2010 18:26 Hi ! I'm trying to get the x,y,width and height parameters of a rectangle that gets dragged... h = imrect(gca, [a, b, c, d]); api = iptgetapi(h); api.addNewPositionCallback( [x y width heigth] ); The example case works just fine, only it's a title and it's in a weird syntax: addNewPositionCallback(h,@(p) title(mat2str(p,3))); First question: can anyone explain the syntex from the example case? Second question: How can I get the x, y, width and height parameters with addNewPositionCallback? Thanks in advance.
From: Ashish Uthama on 5 May 2010 06:48 > The example case works just fine, only it's a title and it's in a weird > syntax: > addNewPositionCallback(h,@(p) title(mat2str(p,3))); > > First question: can anyone explain the syntex from the example case? The first argument is the handle to the imrect object while the second is an anonymous callback function. As the function name 'addNewPositionCallback' indicates, this function will cause the anonymous function to be called each time the position changes. The input argument passed is the 'position' (see second help reference below). The MAT2STR function converts Anonymous functions: http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f4-70115.html Or please paste this in the MATLAB command window: web([docroot,'/techdoc/matlab_prog/f4-70115.html']) Details of the callback function signature: help imrect/addNewPositionCallback > Second question: How can I get the x, y, width and height parameters > with addNewPositionCallback? Again: help imrect/addNewPositionCallback The input argument is the position (a 1x4 array with x,y,width and height). What is it that you are trying to do? Do you want a callback function (i.e the function gets called every time the position changes) or a one time placement of the rectangle and the resulting position?
|
Pages: 1 Prev: Convert shapefiles to georeference raster Next: Convert shapefiles to georeference raster |