Calculate the image gradient
이전 댓글 표시
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
naser telesi
2017년 3월 1일
if Gx is zero then let Gx = 1 to avoid divide by zero problem
Matt J
2017년 3월 1일
if Gx is zero then let Gx = 1 to avoid divide by zero problem
But theta will be wrong...
채택된 답변
추가 답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Object Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!