DrawingFinished event No response
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Roche de Guzman
il 30 Gen 2021
Commentato: cui,xingxing
il 27 Apr 2023
imshow(I,[]); % show image from image data
drawroi = drawassisted; evs = events(class(drawroi)); % event source and events list for class
% test for action:
i = 7; % drawing finished
ev = evs{i}; addlistener(drawroi,ev,@(source,data) disp(data)); % event and its listener
Hello,
I'm trying to create a response when the drawing of an ROI is finished, DrawingFinished event, by adding a listener as shown in the commands.
The other events (such as i = 9 for ROI moved, i = 2 for waypoint added, etc.) are working but not for drawing started (i = 6) and finished (i = 7).
Thanks in advance!
0 Commenti
Risposta accettata
Tim Jackman
il 10 Feb 2021
drawassisted is a simple wrapper around the image.roi.AssistedFreehand object. The function drawassisted really only constructs the ROI object and calls the draw method on the object so the user can begin drawing immediately. The problem with using drawassisted is that you can't set up listeners for the ROI object until after the object has already been drawn. For most events this isn't an issue but, as you observed, you can't set up DrawingStarted and DrawingFinished because the draw interaction will occur before you get the chance.
My suggestion would be to use the formal interface images.roi.AssistedFreehand directly:
Step 1: Construct the ROI object and parent it to the axes
I = imread('peppers.png');
imshow(I);
ax = gca;
drawroi = images.roi.AssistedFreehand('Parent',ax);
Step 2: Set up the listeners
addlistener(drawroi,'DrawingStarted',@(~,~) disp('Drawing Has Started'));
addlistener(drawroi,'DrawingFinished',@(~,~) disp('Drawing Has Finished'));
Step 3: Call draw method to begin interactively drawing the ROI
draw(drawroi);
3 Commenti
Petr Kryze
il 30 Mar 2022
This is great. I have huge problems finding a comprehensive list of EventNames for Rectangle ROIs, because I need event callbacks at creation, finish and deletion of ROI. This has helped!
cui,xingxing
il 27 Apr 2023
@Tim Jackman The official documentation doesn't make this clear, so I hope it can be added to the documentation,Thank you for your advice!
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!