inavas
inavas

Reputation: 161

Is it possible to join regions of an image in Matlab?

I have an image with some regions that I would like to join, would this be possible?

The image is the following:

enter image description here

I'm using regionprops to count that regions as well, and I want that the result of this image is 2 regions instead of 4 that actually are, more or less like that:

enter image description here

(this image is an example, in order to explain it better).

In fact, I want to join the regions that are near each other.

Would this be possible? How?

Upvotes: 1

Views: 94

Answers (1)

Alex Witsil
Alex Witsil

Reputation: 862

I would first convolve

(conv2 -- https://www.mathworks.com/help/matlab/ref/conv2.html)

the original image with a 2D Gaussian in order to smooth the image. In doing so, the edges of the regions will be broadened and run into one another -- effectively making multiple regions that are close together bleed into one region. You will have to play with the 2D Gaussian by varying your sigma in order to achieve the desired smoothness.

Once the image is filtered/smoothed, you can use your original algorithm within regionprops to count the number or regions.

Let me know if that helps or if I am being unclear.

Upvotes: 1

Related Questions