Calculate the image gradient
Ältere Kommentare anzeigen
I use the function imgradientxy to get the Gx and Gy firstly. Then obtain the direction of the gradient.
some codes like:
% code
b = zeros(100);
b(1:4:end,:) = 1;
[Gx, Gy] = imgradientxy(b);
theta = atan(Gy./Gx);
The image only has some horizontal lines. So The Gx is all zeros and the theta have a lot NAN. What should I do to get the gradient for this image and for other?
2 Kommentare
naser telesi
am 1 Mär. 2017
if Gx is zero then let Gx = 1 to avoid divide by zero problem
Matt J
am 1 Mär. 2017
if Gx is zero then let Gx = 1 to avoid divide by zero problem
But theta will be wrong...
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 23 Sep. 2013
1 Stimme
Why do it yourself? Why not just use imgradient()?
1 Kommentar
Donghui Sun
am 23 Sep. 2013
Kategorien
Mehr zu Object Analysis finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!