# Revision history [back]

Actually, if used properly then erosion and dilations is exactly what you need. You use it to peel off or to add one layer of pixels around white pixels. Check this tutorial for more information

Something like this should seperate the two elements, after whicgh you can apply a findCountours, to find the individual objects.

Mat binary_image;
Mat output_image;
// you would like to apply a dilation of the white pixels, in order to erode the black ones.
int dilation_type = MORPH_RECT;
int dilation_size = 3;
Mat element = getStructuringElement( dilation_type, Size( 2*dilation_size + 1, 2*dilation_size+1 ), Point( dilation_size, dilation_size ) );
dilate(binary_image, output_image, element);


Actually, if used properly then erosion and dilations is exactly what you need. You use it to peel off or to add one layer of pixels around white pixels. Check this tutorial for more information

Something like this should seperate the two elements, after whicgh you can apply a findCountours, findCountours, to find the individual objects.

Mat binary_image;
Mat output_image;
// you would like to apply a dilation of the white pixels, in order to erode the black ones.
int dilation_type = MORPH_RECT;
int dilation_size = 3;
Mat element = getStructuringElement( dilation_type, Size( 2*dilation_size + 1, 2*dilation_size+1 ), Point( dilation_size, dilation_size ) );
dilate(binary_image, output_image, element);


Actually, if used properly then erosion and dilations is exactly what you need. You use it to peel off or to add one layer of pixels around white pixels. Check this tutorial for more information

Something like this should seperate the two elements, after whicgh you can apply a findCountours, to find the individual objects.

Mat binary_image;
Mat output_image;
// you would like to apply a dilation of the white pixels, in order to erode the black ones.