How to use the color thresholder app in a script

3 次查看(过去 30 天)
Hi!
I'm trying to write a script to open an image in the RGB color space with feature of interest in blue. Next, I would like to call in in the script the color thresholder app and then to use it to interactively select this feature in the hsv space and export the binary image, named BW to the workspace.
I'm scripting it as I will have a lot of images to run. However, these images will have different shades of blue and it is not possible to apply the same saturation limits on all images and hence the reason for doing it interactively.
I don't know how to wait for the export of the binary image from the color thresholder app by the user before executing the rest of the script.
I'm using Matlab R2016b.
Any help would be greatly appreciated.
Here is the script that I have written so far:
[FileName,PathName] = uigetfile({'*.jpg';'*.tif';'*.png';'*.*'},'select image file');
image = imread(FileName);
figure; imshow(image);
colorThresholder(image);
BW = bwareaopen(BW,100);
BW = imfill(BW,'holes');
objperim = bwperim(BW);

采纳的回答

GMabilleau
GMabilleau 2019-4-4
编辑:GMabilleau 2019-4-4
Hi!
Finally I found a way to do the job by creating a message box and wait for the user to click "ok" into this message box.
Here is the code if it can help others:
[FileName,PathName] = uigetfile({'*.jpg';'*.tif';'*.png';'*.*'},'select image file');
image = imread(FileName);
figure; imshow(image);
colorThresholder(image);
uiwait(msgbox('This message will pause execution until you click OK'));
colorThresholder close;
BW = bwareaopen(BW,100);
BW = imfill(BW,'holes');
objperim = bwperim(BW);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

产品


版本

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by