Java DIP Laplacian Operator - Digital image processing

What is Laplacian Operator?

Laplacian Operator is also known as a derivative operator to be used to find edges in an image. Let’s find out the difference between Laplacian and other operators like Prewitt, Sobel, Robinson, and Kirsch. The difference is that all are first order derivative masks but Laplacian is a second order kind of derivative mask.

Here we use OpenCV function filter2D to perform Laplacian operator to images. Find this operator in Imgproc package. Here’s the syntax:

The function arguments are described below:

Sr.No. Arguments
1

src

It is source image.

2

dst

It is destination image.

3

ddepth

It is the depth of dst. A negative value (such as -1) indicates that the depth is the same as the source.

4

kernel

It is the kernel to be scanned through the image.

5

anchor

It is the position of the anchor relative to its kernel. The location Point (-1, -1) indicates the center by default.

6

delta

It is a value to be added to each pixel during the convolution. By default it is 0.

7

BORDER_DEFAULT

We let this value by default.

Other than the filter2D() method, the other methods used by the Imgproc class are described as below:

Sr.No. Methods
1

cvtColor(Mat src, Mat dst, int code, int dstCn)

It converts an image from one color space to another.

2

dilate(Mat src, Mat dst, Mat kernel)

It dilates an image by using a specific structuring element.

3

equalizeHist(Mat src, Mat dst)

It equalizes the histogram of a grayscale image.

4

filter2D(Mat src, Mat dst, int ddepth, Mat kernel, Point anchor, double delta)

It convolves an image with the kernel.

5

GaussianBlur(Mat src, Mat dst, Size ksize, double sigmaX)

It blurs an image using a Gaussian filter.

6

integral(Mat src, Mat sum)

It calculates the integral of an image.

Example

Below mentioned example discusses about the use of Imgproc class to apply Laplacian operator to an image of Grayscale.

Output

After executing the above code , the following output is seen:

Original Image

originalimage

This original image is convolved with the Laplacian Negative operator as given below:

Laplacian Negative

0 -1 0
-1 4 -1
0 -1 0

Convolved Image(Laplacian Negative)

Convolved Image(Laplacian Negative)

This original image is convolved with the Laplacian Positive operator as given below:

Laplacian Positive

0 1 0
1 -4 1
0 1 0

Convolved Image (Laplacian Positive)

Convolved Image (Laplacian Positive)

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Digital image processing Topics