How to calculate gradient features of an image?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
My code is:
a = imread('C:\Users\DELL\Desktop\01_test.tif');
[Gx, Gy] = gradient(a);
[Gmag, Gdir] = gradient(Gx, Gy);
figure, imshow(Gmag, []), title('Gradient magnitude') figure, imshow(Gdir, []), title('Gradient direction') title('Gradient Magnitude (Gmag) and Gradient Direction (Gdir) using Sobel method') figure; imshowpair(Gx, Gy, 'montage'); axis off; title('Directional Gradients, Gx and Gy, using Sobel method')
error is:
??? Error using ==> rdivide Integers can only be combined with integers of the same class, or scalar doubles.
Error in ==> gradient at 75 g(2:n-1,:) = (f(3:n,:)-f(1:n-2,:))./h(:,ones(p,1));
1 comentario
Guillaume
el 22 de Oct. de 2014
Please use the {} Code button to format your code.
And what is your question exactly?
Respuestas (2)
Guillaume
el 22 de Oct. de 2014
You left out the important bit of the error, which is the one that told you on which line of your code the error occurred. I assume it's the
[Gmag, Gdir] = gradient(Gx, Gy);
10 comentarios
Munshida P
el 25 de Ag. de 2019
how to calulate the average gradient ?
i have calculated Gx,Gy,Gmag,Gdir
Munshida P
el 24 de Ag. de 2019
how to calculate average gradient of an image
6 comentarios
Walter Roberson
el 25 de Ag. de 2019
[Gmag, Gdir] = imgradient(YourGrayscaleImage, 'prewitt');
average_gradient = sum(double(Gmag(:))) ./ ((size(Gmag,1)-1) .* ((size(Gmag,2)-1).*sqrt(2));
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!