Central finite distance gradient simplified
I'm asked to compute central finite difference scheme (f(i+1)-f(i-1)) on an image. My attempt is something like:
def gradient_x_diff(img):
img = img.astype(float)
return np.fabs(np.roll(imgf,1, axis = 0) - imgf(np.roll(imgf,1, axis = 0))
However, it's hinted that the solution is straightforward. It should be something like this:
def gradient_x_diff(img):
img = img.astype(float)
return img[*]-img[**]
What should I parse instead of the * and ** ?
Topic image-preprocessing gradient
Category Data Science