Status of Edge detection:
Edge detection is an important preprocessing method for digital image processing to recognize objects, sobel,robert,prewitt,log and so on are easy to implement and processing quickly, but it is easy to be affected by noise. The application noise of the real scene is many, the Canny operator joins the smoothing filter to be very effective in this aspect problem, the smoothing filter will directly influence the result of the Canny algorithm. Smaller filters produce less blurring, which allows the detection of smaller, more pronounced thin lines. Larger filters produce more blurring effects, and the larger piece of image is painted with a color value at a specific point. Canny details remain very complete, but this advantage sometimes becomes the bottleneck of identification, so that the recognition target is not outstanding.
To deal with these problems, I read some relevant literatures and realized the morphological edge detection method.
commonly used edge detection operators:
⒈sobel operator
2.Robert operator
3.Prewit operator
4.Laplace operator
5.Canny operator
Morphological Edge detection methods:
Implementation code:
1 Private voidMorphological (Image<gray, byte> SRC,floatTheta)2 {3 int[,] Mask1 = {{1,2,1},{2,8,2},{1,2,1}};4 int[,] Mask2 = {{0,1,0},{1,1,1},{0,1,0}};5 int[,] Mask3 = {{1,0,1},{0,1,0},{1,0,1}};6 7Structuringelementex Ele1 =NewStructuringelementex (Mask1,1,1);8Structuringelementex Ele2 =NewStructuringelementex (Mask2,1,1);9Structuringelementex Ele3 =NewStructuringelementex (MASK3,1,1);Ten OneImage<gray, byte> dst1 =NewImage<gray, byte> (src. Size);//first corrosion and then expansion AImage<gray, byte> dst2 =NewImage<gray, byte> (src. Size);//first expansion and then corrosion -Cvinvoke.cverode (SRC, dst1, Ele1,1); -Cvinvoke.cvdilate (Dst1, Dst1, Ele2,1); theCvinvoke.cvdilate (SRC, dst2, Ele1,1); -Cvinvoke.cverode (Dst2, Dst2, Ele2,1); - -Image<gray, byte> G12 =NewImage<gray,byte>(src. Size); +Image<gray, byte> G22 =NewImage<gray,byte>(src. Size); -Image<gray, byte> G32 =NewImage<gray,byte>(src. Size); +Image<gray, byte> G1 =NewImage<gray,byte>(src. Size); AImage<gray, byte> G2 =NewImage<gray,byte>(src. Size); atImage<gray, byte> G3 =NewImage<gray,byte>(src. Size); - - //G1 = imdilate (Imdilate (Imerode (F, B1), B2), B3)-Imclose (Imdilate (Imerode (F, B1), B2), B3); -Cvinvoke.cvdilate (Dst1, G1, Ele3,1); -Cvinvoke.cvmorphologyex (Dst1, G12,NewIntPtr (), Ele3, Emgu.CV.CvEnum.CV_MORPH_OP. Cv_mop_close,1); -G1 = G1-G12; in - //G2 = Imopen (Imerode (Imdilate (F, B1), B2), B3)-Imerode (Imerode (Imdilate (F, B1), B2), B3); toCvinvoke.cvmorphologyex (Dst2, G2,NewIntPtr (), Ele3, Emgu.CV.CvEnum.CV_MORPH_OP. Cv_mop_open,1); +Cvinvoke.cverode (Dst2, G22, Ele3,1); -G2 = G2-G22; the * //G3 = imdilate (Imdilate (Imerode (F, B1), B2), B3)-Imerode (Imerode (Imdilate (F, B1), B2), B3); $Cvinvoke.cvdilate (Dst1, G3, Ele3,1);Panax NotoginsengCvinvoke.cverode (Dst2, G32, Ele3,1); -G3 = G3-G32; the //matsub (G3, G32, G3); + A //Gmin = min (G1, G2); the //Gmax = max (G1, G2); +Image<gray, byte> Gmin =NewImage<gray,byte>(src. Size); -Image<gray, byte> Gmax =NewImage<gray,byte>(src. Size); $Gmin =G1. Min (G2); $Gmax =G1. Max (G2); - /* - int row = 0,col = 0; the For (; row < gmin.rows; row++) - {Wuyi For (; col < gmin.cols; col++) the { - Gmin.data[row, col, 0] = Math.min (G1. Data[row, col, 0], G2. Data[row, col, 0]); Wu Gmax.data[row, col, 0] = Math.max (G1. Data[row, col, 0], G2. Data[row, col, 0]); - } About }*/ $ -Gmax = Gmax-Gmin; - //matsub (Gmax, Gmin, Gmax); - //G = G3 + Theta*deltag; Asrc = G3 + theta *Gmax; + /* the For (row = 0; row < src. Rows; row++) - { $ For (col = 0; col < src. Cols; col++) the { the src. Data[row, col, 0] = (byte) (G3. Data[row, col, 0] + theta * gmax.data[row, col, 0]); the } the } - imagebox1.image = src;*/ in the}Implementation results:
Morphological Edge Detection
Morphological Edge detection method