Home > Software engineering >  Netizens question - hole extract?
Netizens question - hole extract?

Time:09-24

Netizens question - hole extract
Some netizens consulting related algorithm problem recently, I gave some help, feel more typical, after he has allowed the related information and ideas to sort, put out everyone learning together!
One problem:
Figure in the hole was two semicircle and straight lines, and is different from ordinary round and oval, with hough transform to detect the effect is not good, so is there any way I can give out the outline of the hole?

Second, analysis and disintegration:
If understanding of the principle and the use of comparison of hough (can read "learning OpenCV"), will know that want to use contour houghcircle out make impossible, this problem is to get the first key areas to strengthen, and then consider profile analysis method,
Based algorithm, based on the current level, take such a hole in the image, it is easy to shadow interference, need to pay attention to the image collection,
Connection diagram



 
# include "stdafx. H"
# include "opencv2/core/core HPP"
# include "opencv2/highgui/highgui. HPP"
# include "opencv2/imgproc/imgproc HPP"

# include & lt; Iostream>
# include & lt; Stdio. H>
# include & lt; Stdlib. H>
# include & lt; Math. H>

# include "GOCVHelper. H"

Using the namespace CV;
using namespace std;
Using the namespace GO;
RNG rng2 (12345);
//according to the characteristics of contour circle to choose
Vector SelectShapeCircularity (Mat SRC, Mat& The draw, vector Contours, float minvalue, float maxvalue);
Vector SelectShapeCircularity (vector Contours, float minvalue, float maxvalue);
//calculate contour round feature
Float calculateCircularity (VP contour);
//according to the characteristics of contour circle to choose
Vector SelectShapeCircularity (Mat SRC, Mat& The draw, vector Contours, float minvalue, float maxvalue) {
Vector Result_contours;
The draw=Mat: : zeros (SRC) rows, SRC, cols, CV_8UC3);
for (int i=0; iFloat fcompare=calculateCircularity (contours [I]);
If (fcompare & gt;=minvalue & amp; & Fcompare & lt;=maxvalue)
Result_contours. Push_back (contours [I]);
}
for (int i=0; iScalar color=Scalar (rng2. Uniform (0255), rng2. Uniform (0255), rng2. Uniform (0255));
DrawContours (the draw, result_contours, I, color, 1);
}
Return result_contours;
}
Vector SelectShapeCircularity (vector Contours, float minvalue, float maxvalue) {
Vector Result_contours;
for (int i=0; iFloat fcompare=calculateCircularity (contours [I]);
If (fcompare & gt;=minvalue & amp; & Fcompare & lt;=maxvalue)
Result_contours. Push_back (contours [I]);
}
Return result_contours;
}
//calculate contour round feature
{float calculateCircularity (VP contour)
Point2f center;
Float the radius=0;
MinEnclosingCircle ((Mat) contour, center, the radius).
//with the minimum circumscribed circle radius as the mathematical expectation, calculating the distance between the contour on each point to the center of the circle standard deviation
Float fsum=0;
Float fcompare=0;
for (int i=0; iPoint2f PTMP=contour [I];
Float fdistenct=SQRT ((float) (PTMP. X-ray center. (x) * (PTMP. X-ray center. X) + (PTMP. Y - center. Y) * (PTMP. Y - center. Y)));
Float fdiff=abs (fdistenct - the radius);
Fsum=fsum + fdiff;
}
Fcompare=fsum/(float) contour. The size ();
Return fcompare;
}

Int _tmain (int arg c, _TCHAR * argv [])
{
//read in the hands of gray-scale image
Mat SRC=https://bbs.csdn.net/topics/imread (" e:/sandbox/kong. JPG ");
Mat DST=SRC. Clone ();
Mat TMP.
Mat the draw.
Vector Contours.
Vector The results;
Vector Planes;
CvtColor (SRC, SRC, COLOR_BGR2HSV);
The split (SRC, planes);
//v channel
TMP=planes [2]. The clone ();
//remove burrs
GaussianBlur (TMP, TMP, Size (3, 3), 0).
//threshold processing
Threshold (TMP, TMP, 100255, THRESH_OTSU);
//reverse
Bitwise_not (TMP, TMP);
//morphology
Erode (TMP, TMP, Mat ());
Dilate (TMP, TMP, Mat ());
//draw the unicom area
Contours=GO: : connection2 (TMP, the draw);
//outline analysis (round)
Results=selectShapeCircularity (TMP, the draw, contours, 100500);
//the original map
DrawContours (DST, results, 0, Scalar,0,255 (0), 3);
Imshow (" result ", DST);
WaitKey ();
Return 0;
}

gocvhelpe can be used in my making https://github.com/jsxyhelu, my blog address to jsxyhelu.cnblogs.com

CodePudding user response:

Search "" halcon"?"

CodePudding user response:

Infrared camera look at the photos, it is difficult to extract

CodePudding user response:

You can make a gray, then the binarization, and then make appropriate expansion, corrosion, do it again then, use canny edge detection or sobel edge detection

Or binary figure of inflation and corrosion, a difference almost can come out a rough edges

CodePudding user response:

https://docs.opencv.org/3.4.0/d4/dc6/tutorial_py_template_matching.html

CodePudding user response:

"Search" halcon ""!!!!!!!!!!

CodePudding user response:

refer to 7th floor zhao4zhong1 response:
https://docs.opencv.org/3.4.0/d4/dc6/tutorial_py_template_matching.html

Over the years, zhao four teachers in the BBS to infuse water, drowned pig884, drowned "Madonna" again, is why?

CodePudding user response:

references to the tenth floor LLXXHM response:
Quote: refer to 7th floor zhao4zhong1 response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related