Image gradient (Image Gradient) concept and solution

Refers to a gradient image (compared with adjacent pixels) of a rate of change of the image pixels in both x and y directions, is a two-dimensional vector, a two component composition, changes in the X-axis, Y-axis variations.
Wherein the change in the X-axis is the current pixel to the right (X plus 1) is a pixel value obtained by subtracting the left of the current pixel (X minus 1) pixel value.
Similarly, changes in the Y-axis is the pixel value below the current pixel (Y plus 1) is above the current pixel is subtracted (Y minus 1) pixel value.
Calculated from the two components, forming a two-dimensional vector, to obtain the gradient of the pixel image. Take the arctangent arctan, a gradient angle can be obtained.
This seeking process image gradient can be achieved by a convolution kernel: [- 1,0,1]
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
absolute values of the gradient image for
Here Insert Picture Description
image gradient angle
Here Insert Picture Description
python code

import numpy as np
import scipy.signal as sig
data = np.array([[0, 105, 0], [40, 255, 90], [0, 55, 0]])
G_x = sig.convolve2d(data, np.array([[-1, 0, 1]]), mode='valid') 
G_y = sig.convolve2d(data, np.array([[-1], [0], [1]]), mode='valid')
Published 11 original articles · won praise 4 · views 20000 +

Guess you like

Origin blog.csdn.net/greatwall_sdut/article/details/104571526