www.gusucode.com > images 案例代码 matlab源码程序 > images/Compute3DDirectionalImageGradientsUsingSobelMethodExample.m
%% Compute 3-D Directional Image Gradients Using Sobel Method % %% % Read 3-D data and prepare it for processing. volData = load('mri'); sz = volData.siz; vol = squeeze(volData.D); %% % Calculate the directional gradients. [Gx, Gy, Gz] = imgradientxyz(vol); %% % Visualize the directional gradients as a montage. figure, montage(reshape(Gx,sz(1),sz(2),1,sz(3)),'DisplayRange',[]) title('Gradient magnitude along X') figure, montage(reshape(Gy,sz(1),sz(2),1,sz(3)),'DisplayRange',[]) title('Gradient magnitude along Y') figure, montage(reshape(Gz,sz(1),sz(2),1,sz(3)),'DisplayRange',[]) title('Gradient magnitude along Z')