Opening and Closing by Area

Include <mln/morpho/area_filter.hpp>

Image{I}
image_concrete_t<I> area_opening(I f, Neighborhood nbh, int area, Compare cmp)
Image{I}
image_concrete_t<I> area_closing(I f, Neighborhood nbh, int area)

On binary images, the area connected opening that preserves connected components (blobs) of a minimum size. On grayscale images, it extracts connected image objects of higher intensity values than the surrounding objects. (The area closing is its complementary operator).

Parameters:
  • f – Input image 𝑓

  • nbh – Elementary structuring element.

  • area – The minimal size of the blobs in order to be preserved

Returns:

An image whose type is deduced from the input image

Exception:

N/A

Notes

Complexity

Example: dense objects detection

../_images/blobs2_binary.png

(a) Original image

../_images/morpho_area_filter_dilated.png

(b) Dilated of the original image (a)

../_images/morpho_area_filter_dilated.png

(c) Result of the area opening of (b)

../_images/morpho_area_filter_out.png

(d) Input image masked by (c)

  // Make blobs connected
  auto disc = mln::se::disc(2);
  auto dil = mln::morpho::dilation(input, disc);

  // Filtering
  auto mask = mln::morpho::area_opening(dil, mln::c8, 2000);

  // Mask
  auto out = mask && input;

Given an original image. A dilation with a small disc allows to connect objects and we remove small connected components with an area opening. Finally, we just have to mask the input with the mask to get the objects in dense regions.