您现在的位置:首页 >> ★免费资源 >> 源码下载 >> 内容

MATLAB代做-python代做-FPGA代做- 生成扩散梯度向量场

时间:2019-7-15 13:30:41 点击:

  核心提示:MATLAB代做-python代做-FPGA代做- 生成扩散梯度向量场 ...
function [un, vn, wn] = dgvf_calc(I, niter, miu, dt, dx, dy, dz)
% Generate the diffusion gradient vector field as in Xu and Prince 1998
% dgvf_calc is the three dimensional extension of the 2D version described in Equation 12
% Xu and Prince 1998,"Snakes, Shapes, and Gradient Vector Flow", IEEE Transactions on Image Processing Vol.7(3)
    % Input:
    % I: three dimensional image (matrix)
    % miu: the smoothing parameter (more smoothing -- higher miu-- for noisy images)   
% niter: number of iterations
% dt: time step
% dx, dy,dz: pixel spacing, set all to one for isotropic images
% Output:
% un, vn, wn: the gradient vector field
% Example usage:
% [un vn wn] = dgvf_calc(I,sqrt(numel(I)), 0.5, 1, 1, 1, 1)
    %
    % Author:   Dr.Khaled Khairy, Janelia Farm Research Campus, Howard Hughes Medical Institute.
    % June 2011. Please send corrections or comments to khairyk@janelia.hhmi.org
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
verbose = 0;
[un, vn, wn] = gradient(double(I)); 
E = -sqrt(un.^2 + vn.^2 + wn.^2); % Energy as in Xu and Prince 1998 Equation 2
                                        % if the image is a line drawing
                                        % then use: E = I --> Eq. 4
[fx, fy, fz] = gradient(-E); clear E;
b = fx.^2 + fy.^2 + fz.^2;              % Equation 15
c1 = b.*fx; clear fx
c2 = b.*fy; clear fy
c3 = b.*fz; clear fz

r = miu*dt/dx/dy/dz;                % Equation 17 (Xu and Prince 1998)
if (dt>(dx*dy*dz/6/miu)), disp('convergence not guaranteed!!!! Resetting dt');dt =(dx*dy*dz/6/miu/2);disp(dt);end; % Equation 18

if verbose, disp('Calculating 3D diffusion gradient vector field');end
%% Start the time stepping (Xu Prince 1998 p.363 using 3D version of Equation 16 (Xu and Prince 1998)
for n = 1:niter,        
    if verbose,disp(['Diffusion gradient calculation iteration : ' num2str(n) '  of  ' num2str(niter)]);end
    
    un = (1-b.*dt).*un+ r.*(  circshift(un,[-1  0  0])...
        + circshift(un,[ 1  0  0])...
        + circshift(un,[ 0 -1  0] )...
        + circshift(un,[ 0  1  0] )...
        + circshift(un,[ 0  0 -1] )...
        + circshift(un,[ 0  0  1])...
        - 6.*un)...
        + c1.*dt;
    
    vn = (1-b.*dt).*vn+ r.*(  circshift(vn,[-1  0  0])...
        + circshift(vn,[ 1  0  0])...
        + circshift(vn,[ 0 -1  0] )...
        + circshift(vn,[ 0  1  0] )...
        + circshift(vn,[ 0  0 -1] )...
        + circshift(vn,[ 0  0  1])...
        - 6.*vn)...
        + c2.*dt;
    wn = (1-b.*dt).*wn+ r.*(  circshift(wn,[-1  0  0])...
        + circshift(wn,[ 1  0  0])...
        + circshift(wn,[ 0 -1  0] )...
        + circshift(wn,[ 0  1  0] )...
        + circshift(wn,[ 0  0 -1] )...
        + circshift(wn,[ 0  0  1])...
        - 6.*wn)...
        + c3.*dt;
end

if sum(isnan([un(:)' vn(:)' wn(:)']));error('diffusion gradient calculation failed');end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

联系:highspeedlogic

QQ :1224848052

微信:HuangL1121

邮箱:1224848052@qq.com

网站:http://www.mat7lab.com/

网站:http://www.hslogic.com/

微信扫一扫:

作者:不详 来源:网络
  • 您是如何找到本站的?
  • 百度搜索
  • Google搜索
  • 查阅资料过程中
  • 论坛发现
  • 百度贴吧发现
  • 朋友介绍
本站最新成功开发工程项目案例
相关文章
相关评论
发表我的评论
  • 大名:
  • 内容:
  • matlab代做|matlab专业代做|matlab淘宝代做(www.hslogic.com) © 2019 版权所有 All Rights Reserved.
  • Email:highspeed_logic@163.com 站长QQ: 1224848052

    专业代做/代写/承接、MATLAB、SIMULINK、FPGA项目、博士/硕士/本科毕业设计、课题设计、论文,毕业论文,Coursework、Eassy、Assignment