Opening and closing using OpenCV

How do you implement image processing, opening and closing methods using OpenCV with C #? Can someone give me an example?

Thank you

+5
source share
3 answers

If you are using EmguCV (as suggested by go4sri), the code snippet for opening EmguCV will look like this:

Image<Gray, Byte> src = new Image<Gray, Byte>( "Your Image.png" );
Image<Gray, Byte> dst = new Image<Gray, Byte>( src.Width, src.Height );
StructuringElementEx element = new StructuringElementEx( 3, 3, 1, 1, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_CROSS );

CvInvoke.cvMorphologyEx( src, dst, IntPtr.Zero, element, CV_MORPH_OP.CV_MOP_OPEN, 1 );

ImageViewer.Show( dst, "Your morphed Image" );

To close, you just need to replace Enum

CV_MORPH_OP.CV_MOP_CLOSE

For more information on these features, visit the EmguCV Doc.

+3
source

I assume you are using EmguCV . You can use a method MorphologyExthat implements both simple and complex operations based on morphology

+1
source

All Articles