伯克利数据集读取.mat格式

state = 'val';%修改为test或train,分别处理两个文件夹 bsdsRoot
file_list =(fullfile('E:','下载内容','BSR_bsds500','BSR','BSDS500','data','groundTruth',state,'3096.mat'));%获取该文件夹中所有jpg格式的图像
%for i=1:length(file_list)
i=1;
    mat = load(file_list);
    [~,image_name,~] = fileparts(file_list);
    gt = mat.groundTruth;
    for gtid=1:length(gt)
        bmap = gt{gtid}.Boundaries;
        if gtid==1
            image = bmap;
        else
            image(bmap==true)=true;
        end

    end
    %黑底白边
    imwrite(double(image),fullfile(state,[image_name '.jpg']));

你可能感兴趣的:(图像处理,c++编程)