After trial and errors, I finally made canny edge detector output the correctedge map. But I used the following "hacks". Does anybody have the same problem and solve it in a more elegant fashion?
1. Use negated vertical Sobel derivatives and regular Sobel derivatives for horiztonal direction.
2. Reverse the derivative imagesin X and Y directions in the canny function call.
Is this the supposed way to do it?