'How to obtain unit gradient vector image python?

I am trying to obtain the correct image for the unit gradient vector calculations. I am working with retinal images. Here is the code that I have used to try and obtain the correct image along with the formula that I am trying to implement.

  1. Nx = arrayx_cropped/np.sqrt(arrayx_cropped**2 + arrayy_cropped**2)
  2. Ny = arrayy_cropped/np.sqrt(arrayx_cropped**2 + arrayy_cropped**2)

Whenever I run this formula the following warning message appears: Runtim Ny = arrayy_cropped/np.sqrt(arrayx_cropped**2 + arrayy_cropped**2)

The resulting image that I obtain is this: This is the image obtained for using the unit gradient formula in the x direction using equation 1)

Again help or advice on how to go about starting to resolve this issue would be greatly appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source