Shreyas Pimpalgaonkar
Shreyas Pimpalgaonkar

Reputation: 350

Make nearby pixels white opencv

I have a binary image and I want to achieve the following -

If a pixel is white, make it's nearby 10x10 pixels white.

I know I can do it by using convolutions and a kernel, but are there any functions in opencv that can do this?

Upvotes: 2

Views: 201

Answers (1)

Jeru Luke
Jeru Luke

Reputation: 21203

To better illustrate my comment here is an example.

This is the image:

enter image description here

Performing dilation using a kernel of size 5 x 5:

kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (5, 5))
dilation = cv2.dilate(img, kernel, iterations = 1)
cv2.imshow('dilation', dilation)

This is the result:

enter image description here

Upvotes: 2

Related Questions