离线
|
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:times
- delta =(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-1
- for j=1:vs1-1
- hk = 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
来源:https://blog.csdn.net/ccsss22/article/details/123540836
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |
|