You are here : matlabImage Processingimgradientxyz

imgradientxyz() - Image Processing

= imgradientxyz(I) returns the gradient
along the X-axis, Gx, the Y-axis, Gy and
the Z-axis, Gz, for the grayscale
or binary 3-D image I. [Gx,Gy,Gz]
= imgradientxyz(I,method) calculates
the directional gradients using the specified method.Code Generation support:
Yes.MATLAB Function Block support:


= imgradientxyz(I) example[Gx,Gy,Gz]
= imgradientxyz(I,method)


Compute 3-D Directional Image Gradients Using Sobel MethodOpen This Example
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')

Output / Return Value


Alternatives / See Also