Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opening and closing using OpenCV

Tags:

c#

opencv

How do you implement the techniques of image processing, opening, and closing using OpenCV with C#? Can anyone give me an example?

thank you

like image 554
Rafael Arthur Avatar asked Oct 08 '22 04:10

Rafael Arthur


2 Answers

If you are using EmguCV (as go4sri assumed) the Code snippet for Opening EmguCV would 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" );

For Closing you would just need to replace the Enum

CV_MORPH_OP.CV_MOP_CLOSE

For more Information about these functions visit EmguCV Doc

like image 136
Arndt Bieberstein Avatar answered Oct 23 '22 22:10

Arndt Bieberstein


I am assuming that you are using EmguCV. You can use the MorphologyEx method which implements both simple and complex morphology based operations

like image 45
go4sri Avatar answered Oct 23 '22 22:10

go4sri