Learn Erosion Or Dilation (Morphological Operations)

void erode(InputArray src, OutputArray dst, InputArray kernel, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )

Parameters:
  • src – input image; the release of channels tin last arbitrary, simply the depth should last i of CV_8U, CV_16U, CV_16S, CV_32F` or ``CV_64F.
  • dst – output picture of the same size too type every bit src.
  • element – structuring chemical cistron used for erosion; if element=Mat() , a 3 x 3 rectangular structuring chemical cistron is used.
  • anchor – seat of the anchor inside the element; default value (-1, -1) agency that the anchor is at the chemical cistron center.
  • iterations – release of times erosion is applied.
  • borderType – pixel extrapolation method (see borderInterpolate() for details).
  • borderValue – edge value inward instance of a constant edge (see createMorphologyFilter() for details).
void dilate(InputArray src, OutputArray dst, InputArray kernel, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )

Parameters: Same every bit erode(...)

Steps:

  1. Load an image 
  2. Create a structuring element
  3. Apply erosion or dilation on the image
  4. Show result

Functions:

Example:

--------------
#include "opencv2/highgui/highgui.hpp"" #include "opencv2/imgproc/imgproc.hpp" #include <iostream>  using namespace cv; using namespace std;  int main( ) {         Mat image,dst;        picture = imread("lena.jpg", CV_LOAD_IMAGE_COLOR);           // Create a structuring chemical cistron        int erosion_size = 6;          Mat chemical cistron = getStructuringElement(cv::MORPH_CROSS,               cv::Size(2 * erosion_size + 1, two * erosion_size + 1),               cv::Point(erosion_size, erosion_size) );         // Apply erosion or dilation on the picture        erode(image,dst,element);  // dilate(image,dst,element);               namedWindow( "Display window", CV_WINDOW_AUTOSIZE );          imshow( "Display window", picture );                          namedWindow( "Result window", CV_WINDOW_AUTOSIZE );           imshow( "Result window", dst );         waitKey(0);                                                 provide 0; }
--------------

Result:

Comments

Popular posts from this blog

Accueil Technologie Ct 1.2 - Frauder Une Ou Des Hypothèses Rasé Matérialiser À Une Croix Ou À Un Irradiant Démarquage

Accueil Technologie Ct 1.1 - Imaginer, Synthétiser, Formaliser Et Engorger Une Procédure, Un Protocole.

Accueil Technologie Satisfecit Exonérer Ma Spontanément ?