码迷,mamicode.com
首页 > 其他好文 > 详细

CG_图片轮廓mask提取-matlab

时间:2020-06-09 16:59:56      阅读:85      评论:0      收藏:0      [点我收藏+]

标签:cname   atl   height   nova   txt   dir   matlab   src   function   

 

<script src="https://gist.github.com/novav/63a27bb4bb068be659f71dc9568aef84.js"></script>

 

% Windows
function convert_data()
    source_root_dir = ‘E:/data/‘;
    %cname = ‘000003_1.jpg‘;
    target_root_dir = ‘E:/data/‘;
    fine_height = 256; 
    fine_width = 192;
    mode = ‘train‘;
    [im_names, cloth_names] = textread([‘E:\data\train_pairs_ansi.txt‘],‘%s %s‘);
    N = length(im_names);
	for i = 1:N;
        imname = im_names{i} ;
		cname = cloth_names{i};
        fprintf(‘%d/%d: %s %s\n‘, i, N, imname, cname);
        convert([source_root_dir, mode], [target_root_dir, mode], cname)
    end
end    
    
function convert(source_root_dir, target_root_dir, cname)
    im_c = imread([source_root_dir ‘/‘ ‘cloth-parse-seg/‘ cname]);
    % save cloth mask
    mask = double((im_c(:,:,1) <= 250) & (im_c(:,:,2) <= 250) & (im_c(:,:,3) <= 250));
    mask = imfill(mask);
    mask = medfilt2(mask);
    imwrite(mask, [target_root_dir ‘/cloth-parse-seg-mask/‘ cname]);
end

  

--

CG_图片轮廓mask提取-matlab

标签:cname   atl   height   nova   txt   dir   matlab   src   function   

原文地址:https://www.cnblogs.com/xiaoniu-666/p/13072941.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!