这篇主要讲如何获得最右边的结果,论文可以参考:
From Contours to Regions: An Empirical Evaluation
Contour Detection and Hierachical Image Segmentation
根据上图,我们可以得到一般的思路,给定原图和其对应的UCM以及某个参数因子,就可以得到我们想要的结果。大致步骤如下:
1、读取某一原图及其对应的UCM
2、设定thresholding
3、根据thresholding,得到某一level的UCM map
4、对该UCM map的所有regions设定label
5、构建一个三通道的RGB矩阵,每个通道都是thresholding对应level的UCM map
6、找到所有UCM map 的label在原图对应的二维坐标
7、在原图基础上,求regions的label对应坐标位置三个通道的像素值,然后求average
8、对RGB对应的三个通道的每个regions赋值相应的average
代码如下:
load('data/101087_ucm2.mat','ucm2');
image=imread('data/101087.jpg');
%convert ucm to the size of the original image
ucm = ucm2(3:2:end,