extension joomla, template joomla,banner extension joomla,jomla slider,slider joomla
Sobel and Prewitt edge detector in C++: Image Processing

Sobel and Prewitt are used extensively for detecting edges in image processing.

Sobel Operator

The operator calculates the gradient of the image intensity at each point, giving the direction of the largest possible increase from light to dark and the rate of change in that direction. The result therefore shows how “abruptly” or “smoothly” the image changes at that point, and therefore how likely it is that part of the image represents an edge, as well as how that edge is likely to be oriented. The Sobel kernels are given by

Here the kernel hx is sensitive to changes in the x direction, i.e., edges that
run vertically, or have a vertical component. Similarly, the kernel hy is sensitive to changes in y direction, i.e., edges that run horizontally, or have a horizontal component. But how do we combine the results of convolution with these two kernels to give a single measure of the presence of an edge?
. The two gradients computed at each pixel (Gx and Gy) by convolving with above two kernels can be regarded as the x and y components of gradient vector. This vector is oriented along the direction of change, normal to the direction in which the edge runs. Gradient magnitude and direction are given by
Magnitude

Note: To reduce the complexity of above square root calculation, gradient magnitude is some times approximated by absolute summation i.e G = abs(Gx) + abs(Gy).
Direction

Prewitt Operator
Prewitt operator also works same as Sobel operator. But the kernel data is little different

Other operations are same as Sobel.

Source Code: C++
The following source code is written for Sobel but is similar for Prewitt.

Original Image

After applying Sobel Operator



Related Article



destination source:https://www.programming-techniques.com/?p=52