How to detect if imageSegmenter has closed
3 views (last 30 days)
Show older comments
Hello!
I am designing an app which allows the user to segment a set of images, and displays relevant information based on the segmentation. I have a "Segment" button, and within its callback it will load the currnt image in imageSegmenter. The code pauses while it waits for the user to export the mask from imageSegmenter (which they must keep the default name of BW), then closes imageSegmenter, like so:
% Button pushed function: SegmentButton
function SegmentButtonPushed(app, event)
evalin('base','clear BW');
imageSegmenter(app.CurrentImage)
msgbox('When you are finished, export the mask and binary image using the names that are automatically generated by the app')
A = 0;
while A == 0
pause(5)
A = evalin('base','exist(''BW'')');
end
imageSegmenter CLOSE
BW = evalin('base','BW');
evalin('base','clear BW');
evalin('base','clear maskedImage')
% Remaining code within this section analyzes the mask BW
end
However, I need the code to allow for mistakes on the users part. As it is, if the imageSegmenter app is prematurely closed, or if they change the name of the exported mask, BW will not be generated and the while loop will not break. I want to be able to make a stipulation that says "if they close the app early, or export the wrong thing, break the while loop. Only preform the rest of the code if the BW was exported". That way, they can just press the segment button again and do it properly, without having to deal with an error in the program. My issue is I don't know what syntax would allow this.
Is there a way to programatically check if the imageSegmenter app is closed early?
As a secondary question, does anyone know if it's possible to get a built in matlab app (like imageSegmenter) to run within an axis on the app designer gui, rather than needing to open it in a separate window? It's not super important that I can do that, it just might make things more user friendly.
0 Comments
Answers (1)
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!