To create a mak for an image

1 回表示 (過去 30 日間)
Utkarsh Goyal
Utkarsh Goyal 2020 年 10 月 1 日
コメント済み: Tanguy 2020 年 10 月 30 日
Hello
I am very new to the MATLAB, and I want to create the image mask so that I can train my image segmentation network.
So in masked image I want pigs to be in white in color and all the other things to be balck so it will be bianry image pigs will be in white and all other(gates, ropes, fence,background) in black.
Please help me with the code.
Thanks
  4 件のコメント
Sindar
Sindar 2020 年 10 月 3 日
Once you've got a viable segmentation in the app, you can generate code and try it on other images
Tanguy
Tanguy 2020 年 10 月 30 日
You could loop over your images, open them with imtool3D, segment with smartbrush tool, and save your manual segmentation automatically after closing the image:
list = dir('*.png'); % list your image files
for ii = 1:length(list)
% load file
filename = fullfile(list(ii).folder,list(ii).name);
I = imread(filename);
% Open viewer
h = figure('Toolbar','none','Menubar','none');
tool = imtool3D(I,[],h);
% wait until you draw your mask and close the figure
waitfor(h);
% save mask
Mask = tool.getMask(1);
imwrite(Mask, strrep(filename,'.png','_mask.png')) % save the mask
end
Hope that helps!

サインインしてコメントする。

回答 (1 件)

Raunak Gupta
Raunak Gupta 2020 年 10 月 5 日
Hi,
For generating mask for large amount of data you need to have good amount of labeled data in which you correctly mention the mask manually. For that you may use Image Segmenter App for automatic segmentation using Auto cluster options mentioned here. Then you can adjust the mask so that it becomes perfect by using the steps mentioned in this answer
This way you will get some labeled data, which you can use in training a semantic segmentation model which can help you label more images. Below documentation can help you get started with Semantic segmentation using Deep Learning.

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by