图像分析之曲率滤波(困惑篇)

本文与其说是介绍曲率滤波,倒不如说是叙述在阅读曲率滤波论文和代码时的一些困惑。主要是代码与论文无法对应的困惑,如果你能解决这些困惑,欢迎指教解惑。本文中所述的曲率滤波来自[2015 龚元浩]一文中第六章的内容。

更新记录

本文持续更新,如果你发现错误,欢迎指出。

2016年01月02日,发布博文。

参考

[2015 龚元浩] Spectrally regularized surfaces

https://github.com/YuanhaoGong/CurvatureFilter

https://en.wikipedia.org/wiki/Gaussian_curvature

https://en.wikipedia.org/wiki/Developable_surface

相关代码

 平均曲率滤波关键代码段

function res =
 proj_MC(im,BT,BT_pre,BT_nex,BT_lef,BT_rig,BT_lu,BT_ld,BT_ru,BT_rd,step)
res = im; BT8 = 8*im(BT); dist = zeros(size(BT_pre,1),4,'single');
tmp1 = 2.5*(im(BT_pre) + im(BT_nex)) - BT8;
tmp2 = 2.5*(im(BT_lef) + im(BT_rig)) - BT8;
dist(:,1) = tmp1  + 5*im(BT_rig) - im(BT_ru) - im(BT_rd);
dist(:,2) = tmp1  + 5*im(BT_lef) - im(BT_lu) - im(BT_ld);
dist(:,3) = tmp2  + 5*im(BT_pre) - im(BT_lu) - im(BT_ru);
dist(:,4) = tmp2  + 5*im(BT_nex) - im(BT_ld) - im(BT_rd);
tmp = abs(dist); [v,ind] = min(tmp,[],2);
tmp = sub2ind(size(dist),(1:size(dist,1))',ind);
tmp = dist(tmp); res(BT) = res(BT) + step/8*tmp;

高斯曲率滤波关键代码段

function res =
 proj_GC(im,BT,BT_pre,BT_nex,BT_lef,BT_rig,BT_lu,BT_ld,BT_ru,BT_rd,step)
res = im; BT2 = 2*im(BT); BT3 = 3*im(BT);
dist = zeros(size(BT_pre,1),8,'single');
dist(:,1) = im(BT_pre) + im(BT_nex) - BT2; 
dist(:,2) = im(BT_lef) + im(BT_rig) - BT2;
dist(:,3) = im(BT_lu) + im(BT_rd) - BT2; 
dist(:,4) = im(BT_ld) + im(BT_ru) - BT2;
dist(:,5) = im(BT_pre) + im(BT_lef) + im(BT_lu) - BT3; 
dist(:,6) = im(BT_pre) + im(BT_rig) + im(BT_ru) - BT3;
dist(:,7) = im(BT_nex) + im(BT_lef) + im(BT_ld) - BT3; 
dist(:,8) = im(BT_nex) + im(BT_rig) + im(BT_rd) - BT3;
dist(:,1:4) = dist(:,1:4)/2; 
dist(:,5:8) = dist(:,5:8)/3; %% minimal projection
tmp = abs(dist); [v,ind] = min(tmp,[],2);
tmp = sub2ind(size(dist),(1:size(dist,1))',ind);
tmp = dist(tmp); res(BT) = res(BT) + step*tmp;

正文

图像分析之曲率滤波(困惑篇)_第1张图片

你可能感兴趣的:(图像分析之曲率滤波(困惑篇))