Scalable, drag-and-drop box in areas that can select data

Here's the setting:

I have a graph of the data, and I'm trying to find if I can try to put a field on the figure that can be moved and resized, and return some values, such as the percentage and the area under the Curve. It looks something like this:

Example

Any suggestions on where to start? I felt this could be feasible using the GUI'd interface compared to the standard schedule.

+7
source share
1 answer

I would start with imrect . It is draggable and you can add callbacks to it.

(Taken directly from MATLAB help)

 figure, imshow('cameraman.tif'); h = imrect(gca, [10 10 100 100]); addNewPositionCallback(h, @(p) title(mat2str(p, 3))); fcn = makeConstrainToRectFcn('imrect', get(gca,'XLim'), get(gca, 'YLim')); setPositionConstraintFcn(h, fcn); 

Change addNewPositionCallback to suit your needs. In particular, get the right pixels from the image (using the position) and calculate everything you like.

+8
source

All Articles