Laplacian interpolation implementation in matlab
2016-06-23 00:56
555 查看
Some time ago, I quoted a passage from a website which is able to give a general idea about the Laplacian interpolation.
The address is http://blog.csdn.net/seamanj/article/details/50701112
Here, I want to implement this algorithm in matlab.
Firstly, I would like to elaborate the underlying mathematical principle.
The requirement originates from a paper named “Anatomy transfer“, the 7th section of which tells us: Given by value on the boundary, we can use Laplace interpolation to infer the value in the interior part.
Then I recommend to refer to the 2.1 part of alec jacobson thesis. In order to better understand, we reinterpret this part in our own way showed in N4 of Alec jacobson thesis analysis. From which we can get the following formula:
LΩ¯ΩuΩ=MΩ¯Ω¯fΩ¯−LΩ¯0u0
where Ω¯¯¯=Ω+∂Ω=Ω+0
Here, our purpose is to make Δu zero; therefore, fΩ¯=0, which leads to the following formula:
LΩ¯ΩuΩ=−LΩ¯0u0
where LΩ¯Ω,LΩ¯0 are parts of LΩ¯Ω¯, which is a stiffness matrix being able to be solved through solve stiffness matrix in matlab, u0 is the known value on the boundary. That leaves only uΩ as the unknown.
the main.m file is listed as follows, the complete source code can be found in attachment.
The result picture is like:
we only change the positions of the border vertices expressed in dark red dot, the interior part in yellow color would be optimized by laplacian interpolation.
the complete matlab source code
The address is http://blog.csdn.net/seamanj/article/details/50701112
Here, I want to implement this algorithm in matlab.
Firstly, I would like to elaborate the underlying mathematical principle.
The requirement originates from a paper named “Anatomy transfer“, the 7th section of which tells us: Given by value on the boundary, we can use Laplace interpolation to infer the value in the interior part.
Then I recommend to refer to the 2.1 part of alec jacobson thesis. In order to better understand, we reinterpret this part in our own way showed in N4 of Alec jacobson thesis analysis. From which we can get the following formula:
LΩ¯ΩuΩ=MΩ¯Ω¯fΩ¯−LΩ¯0u0
where Ω¯¯¯=Ω+∂Ω=Ω+0
Here, our purpose is to make Δu zero; therefore, fΩ¯=0, which leads to the following formula:
LΩ¯ΩuΩ=−LΩ¯0u0
where LΩ¯Ω,LΩ¯0 are parts of LΩ¯Ω¯, which is a stiffness matrix being able to be solved through solve stiffness matrix in matlab, u0 is the known value on the boundary. That leaves only uΩ as the unknown.
the main.m file is listed as follows, the complete source code can be found in attachment.
xRes = 16; yRes = 16; wrap = 0; [F,V,res,edge_norms] = create_regular_grid(xRes,yRes,wrap,wrap); V = [V(:,1), V(:,2), zeros(size(V,1),1)]; subplot_handle = subplot(2,2,1); cla(subplot_handle); tsurf(F,V,0,0); title('Input domain'); indices = 1:size(V,1); border = indices( V(:,1) == 0 | V(:,1) == 1 | V(:,2) == 0 | V(:,2) == 1 ); interior = indices(~ismember(indices, border)); subplot_handle = subplot(2,2,2); cla(subplot_handle); display_domain(F,V,border); title('Paritioned domain'); [bi_L,bi_U,bi_P,bi_Q,bi_R,bi_S] = biharm_factor_system( ... V, ... F, ... interior, ... border); V(border,:) = [ V(border,1).*2 ... V(border,2).*2 ... -2 * V(border,1) .*V(border,1) + 2 * V(border,1) ]; %zeros(size(border,2),1) % Build RHS and use factor system matrix to solve for new positions in each % coordinate bi_V = biharm_solve_with_factor( ... bi_L, bi_U, bi_P, bi_Q, bi_R, bi_S, ... V, interior, border); % % % Display solution subplot_handle = subplot(2,2,3); % clear cubplot just in case cla(subplot_handle); display_domain(F,bi_V,border); view(3) zoom out zoom(1.5) title('laplacian interpolation'); axis equal; axis vis3d;
The result picture is like:
we only change the positions of the border vertices expressed in dark red dot, the interior part in yellow color would be optimized by laplacian interpolation.
the complete matlab source code
相关文章推荐
- matlab 交换矩阵的行和列
- MATLAB 散点图
- 【混淆矩阵】matlab画混淆矩阵
- Ncut matlab 代码bug 修复(适用于R2014a)
- 关于matlab中的kmeans和reshape函数
- matlab制作视频,还待完善
- MATLAB读取多幅图片 借鉴
- matlab连续读取多幅图像
- 偏微分方程数值解法的MATLAB源码
- matlab2015a安装教程
- matlab中CRC的函数使用
- 如何快糙好猛地在Windows下编译CAFFE并使用其matlab和python接口
- VS2008 C++ 调用MATLAB 2009b 生成的DLL .
- MATLAB 线性拟合 决定系数R2求解
- MATLAB函数大全
- 主成分分析法的matlab实现
- 主成分回归
- 数学建模系列- 解决Matlab读取Excel文件报错:Could not start Excel server for import问题
- Matlab连接MySQL小例
- 卷积相关公式的matlab代码