# How to calculate gradient features of an image?

16 Ansichten (letzte 30 Tage)
Maninder am 22 Okt. 2014
Kommentiert: Munshida P am 25 Aug. 2019
My code is:
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 KommentarKeine anzeigenKeine ausblenden
Guillaume am 22 Okt. 2014
And what is your question exactly?

Melden Sie sich an, um zu kommentieren.

### Antworten (2)

Guillaume am 22 Okt. 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
line that gives you the error, since the 2nd argument to gradient must be a scalar value.
##### 10 Kommentare9 ältere Kommentare anzeigen9 ältere Kommentare ausblenden
Munshida P am 25 Aug. 2019
how to calulate the average gradient ?
i have calculated Gx,Gy,Gmag,Gdir

Melden Sie sich an, um zu kommentieren.

Munshida P am 24 Aug. 2019
how to calculate average gradient of an image
##### 6 Kommentare5 ältere Kommentare anzeigen5 ältere Kommentare ausblenden
Munshida P am 25 Aug. 2019
Thank you sir. I will try it now

Melden Sie sich an, um zu kommentieren.

### Kategorien

Find more on Object Analysis in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!