I am new to gui creation in Matlab and have just worked through the simple Gui tutorial.
What I want to do is the following:
load an image -> drag multiple (e.g. 3) rectangles over the roi using imrect with a specific size (e.g. 32x100 px) and then get the coordinates to process the image only in the specified region by an edge detecting algorithm I programmed.
I am loading and displaying the image using a pushbutton
and I know I can draw a rectangle and get the position via another pushbutton
can someone help me with the next step that is fixing the size of the rectangle and how to store the data for every instance I click the button and place a rectangle properly?
Every help is appreciated!
Best Wishes, Chris
I don't think you can constrain imrect(), rbbox(), or getrect() to work with fixed size rectangles and not allow the user to change the size of the rectangle. The workaround is to have two scroll bars, one for vertical movement and one for horizontal movement. The slider callbacks will calculate the new position of the box sides and draw it using plot(). Then the user clicks an OK button. In fact I do this for some of my apps.
The alternative is to use dragrect(). I haven't used this before. Here is the description from the help:
Drag a rectangle that is 50 pixels wide and 100 pixels in height. waitforbuttonpress point1 = get(gcf,'CurrentPoint') % button down detected rect = [point1(1,1) point1(1,2) 50 100] [r2] = dragrect(rect)
dragrect returns immediately if a mousebutton is not currently pressed. Use dragrect ina ButtonDownFcn, or from the command line in conjunctionwith waitforbuttonpress, to ensure that the mousebutton is down when dragrect is called. dragrect returnswhen you release the mouse button.
If the drag ends over a figure window, the positions of therectangles are returned in that figure's coordinate system. If thedrag ends over a part of the screen not contained within a figurewindow, the rectangles are returned in the coordinate system of thefigure over which the drag began.
Note: You cannot use normalized figure units with dragrect.