我是靠谱客的博主 傻傻鸡,这篇文章主要介绍评估二值化的数据集指标,白色像素占整个图像的区域面积,现在分享给大家,希望可以做个参考。

最近项目组搭了一个二值化的数据集,因此也需要对比一些相关的数据指标,其中一个就是 衡量foreground map(白色区域)所占整个图像的面积比例,即obj.area,因此自己写了一个matlab脚本,希望会对别人有好处吧。

废话不多说,直接贴代码:

直接将你需要测试的数据集,放在根目录下,然后再脚本中修改下你的文件名称即可。

clc
clear
close all

% Evaluation Dataset metric
% For binary image dataset, this .m file compute the mean ratio of the foreground map into entire map on dataset. 


dataset_path = ['./dataset/']; % put your dataset_path into this path, then run this .m file.
imgFiles = dir(dataset_path); 
imgNUM = length(imgFiles)-2;

tic;
total_ratio = 0;

for i = 1:imgNUM

    name =  imgFiles(i+2).name;
    Pic = imread([dataset_path name]);
    Level = 0.1;
    Pic = im2bw(Pic, Level);    % binary image
    A = Pic;
    S = numel(A);               % total number of pixel in entire image
    s = sum(sum(A));            % total number of pixel in the foreground 
    ratio = s/S;
    total_ratio = total_ratio + ratio;
    fprintf('The %d image ratio is: %d/%dn',i,ratio,imgNUM);
   end

fprintf('The mean ratio is: %dn',rem(total_ratio/imgNUM,1));

最后

以上就是傻傻鸡最近收集整理的关于评估二值化的数据集指标,白色像素占整个图像的区域面积的全部内容,更多相关评估二值化内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(53)

评论列表共有 0 条评论

立即
投稿
返回
顶部