www.gusucode.com > images 案例代码 matlab源码程序 > images/CalculateDirGradientsAndMagnitudeAndDirectionExample.m
%% Calculate Directional Gradients and Then Magnitude and Direction % %% % Read image into workspace. I = imread('coins.png'); %% % Calculate x and y directional gradients and then gradient magnitude and % direction. [Gx, Gy] = imgradientxy(I); [Gmag, Gdir] = imgradient(Gx, Gy); figure; imshowpair(Gmag, Gdir, 'montage'); axis off; title('Gradient Magnitude, Gmag (left), and Gradient Direction, Gdir (right), using Sobel method') figure; imshowpair(Gx, Gy, 'montage'); axis off; title('Directional Gradients, Gx and Gy, using Sobel method')