本文主要是介绍通过MATLAB实现基于冠状动脉造影图像序列的心脏及血管的三维光流运动估计,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.仿真预览
2.部分核心代码
function [us,vs] = func_guangliu(images01,images02,areas);imag01 = images01;
imag02 = images02;
%获取图像对边界进行调整
[r,c] = size(images01);
r_5 = r-5;
c_5 = c-5;
z = zeros(r,c);
v1 = z;
v2 = z;
%初始化
gradt = v1;
gradx = v1;
grady = v1;
alpha2 = 625;
times = 20;%计算梯度
gradt(5:r_5,5:c_5) = ( imag02(6:r_5+1,6:c_5+1)-imag01(6:r_5+1,6:c_5+1) + imag02(6:r_5+1,5:c_5) - imag01(6:r_5+1,5:c_5) + imag02(5:r_5 ,6:c_5+1) - imag01(5:r_5 ,6:c_5+1) + imag02(5:r_5 ,5:c_5) - imag01(5:r_5 , 5:c_5))/4;
grady(5:r_5,5:c_5) = ( imag02(6:r_5+1,6:c_5+1)-imag02(5:r_5 ,6:c_5+1) + imag02(6:r_5+1,5:c_5) - imag02(5:r_5 ,5:c_5) + imag01(6:r_5+1,6:c_5+1) - imag01(5:r_5 ,6:c_5+1) + imag01(6:r_5+1,5:c_5) - imag01(5:r_5 , 5:c_5))/4;
gradx(5:r_5,5:c_5) = ( imag02(6:r_5+1,6:c_5+1)-imag02(6:r_5+1,5:c_5) + imag02(5:r_5 ,6:c_5+1) - imag02(5:r_5 ,5:c_5) + imag01(6:r_5+1,6:c_5+1) - imag01(6:r_5+1,5:c_5) + imag01(5:r_5 ,6:c_5+1) - imag01(5:r_5 , 5:c_5))/4;for i=1:timesdelta =(gradx.*v1+grady.*v2+gradt)./(alpha2+gradx.^2+grady.^2);v1 = v1-gradx.*delta;v2 = v2-grady.*delta;
end;u = z;
u(5:r_5,5:c_5) = v1(5:r_5,5:c_5);
v = z;
v(5:r_5,5:c_5) = v2(5:r_5,5:c_5);xskip = round(r/areas);
[us1,vs1] = size(u(1:xskip:r,1:xskip:c));
us = zeros(us1,vs1);
vs = us;N = xskip^2;for i=1:us1-1for j=1:vs1-1hk = i*xskip-xskip+1;hl = i*xskip;wk = j*xskip-xskip+1;wl = j*xskip;us(i,j) = sum(sum(u(hk:hl,wk:wl)))/N;vs(i,j) = sum(sum(v(hk:hl,wk:wl)))/N;end;
end;
C31
这篇关于通过MATLAB实现基于冠状动脉造影图像序列的心脏及血管的三维光流运动估计的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!