matlab - Draw multiple draggable rectangles on image? -


With the following code, I can easily draw a draggable rectangle on the image.

  figure; Imshow ('image.png'); H = true; P = wait (h); Get the% reset status rectangle ('position', p, 'linewidth', 2, 'edge collar', 'r'); % Come here   

Enter image details here < P> The problem is: How can I attract more than one dragable rectangle on the image? And besides, Number of rectangles is not pre-operated is not known.

PS If it is already possible to attract the number of rectangles it will be easier, for example, if I want to draw 2 rectangles, the following code will work, i.e. only Wait () :

  figure; Imshow ('image.png'); H = true; P = wait (h); Get the% reset status rectangle ('position', p, 'linewidth', 2, 'edge collar', 'r'); % Draw here p2 = wait (h); Get the% reset status rectangle ('position', P2, 'linewidth', 2, 'edge collar', 'R'); One way to wrap position acquisitions in the loop on one side is to add a    

In this situation, when you will do this type of codebutton which is correcting handles when you are done if you are handling it to indicate any type of uicontrol Is removed, then h is no longer valid, therefore prevents isvalid while loops the loop. ~ isempty is used as the last returned value of p .

Note that this code overwrites every p time if you want to record all the positions, not only attract the rectangles, you will need to add it . , imshow (I) h = absolute UI control ('style', 'pushbutton', 'string', 'don' ', ...' condition ', [20 20 50 20] ... 'callback', 'delete (h)'); While isvalid (h) p = wait (h); If ~ isempty (p) rectangle ('position', p, 'linewidth', 2, 'edge collar', 'r'); End End

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -