I’m writing my own version of Canny’s edge detection algorithm. My question is, how can I compute the direction of gradient? I already know that:

But what should I do when Gy = Gx = 0?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think it actually doesnt’ matter what value you give to theta, as a Gx and Gy equal to zero means that there is no gradient, meaning there is no edge. That pixel has no edges, so it has not either an angle of direction of the edge. detect when Gy=gx=0 and write in theta whathever you want.
Oh! but dont forget that arctan(Inf)=pi/2! If only the value of Gx is zero remember that you have a result!
EDIT: In the image all the black areas have not gradient, thus have not angle.