问题
I'm working with the image segmentation. I need to compute image gradient in the point, so I was trying to understand by myself (because I know how to calculate gradient when having an ordinary equation) but I failed. I was googling... and googling but to find wright answer I couldn't.
Can anyone say or give some information how to compute image gradient in the point step by step?
回答1:
The gradient at each pixel of an image I(x, y)
is simply the 2D vector (dI/dx,dI/dy)(x, y)
. Approximate dI/dx
and dI/dy
with centered finite difference:
dI/dx(x, y) = (I(x + 1, y) - I(x - 1, y)) / 2 = (I(x + 1, y) - I(x, y) + I(x, y) - I(x - 1, y)) / 2
dI/dy(x, y) = (I(x, y + 1) - I(x, y - 1)) / 2 = (I(x, y + 1) - I(x, y) + I(x, y) - I(x, y - 1)) / 2
来源:https://stackoverflow.com/questions/21067303/image-gradient-in-the-point