本文與其說是介紹曲率濾波,倒不如說是敘述在閱讀曲率濾波論文和代碼時的一些困惑。主要是代碼與論文無法對應的困惑,如果你能解決這些困惑,歡迎指教解惑。本文中所述的曲率濾波來自[2015 龔元浩]一文中第六章的內容。
更新記錄
本文持續更新!如文中有錯誤,或你對本文有疑問或建議,歡迎留言或發郵件至quarrying#qq.com!
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;