- Connected domain Inverse selection
When you use the Findcontours function of OpenCV to find a connected domain outline, you may need to use a selection counter-selection function similar to PS.
This section is described below:
In the Findcontours function, select the Cv_retr_ccomp two-level contour lookup in the mode parameter,
To construct a selection range for an inverse selection of image size
VECTOR<CV::P oint> boundcontours (4); boundcontours[0] = CV::P oint (00); boundcontours[1] = CV::P oint (0, src.rows-1); boundcontours[2] = CV::P oint (src.cols-1, src.rows-1); boundcontours[3] = CV::P oint (src.cols-10);
intMain () {cv::mat src= Imread ("original. PNG",0); Vector<VECTOR<CV::P oint>>linecontours; Vector<cv::Vec4i>hierarchy; Findcontours (SRC, linecontours, hierarchy, Cv_retr_ccomp, cv_chain_approx_simple); linecontours[0].clear (); Vector<CV::P oint> boundcontours (4); boundcontours[0] = CV::P oint (0,0); boundcontours[1] = CV::P oint (0, src.rows-1); boundcontours[2] = CV::P oint (src.cols-1, src.rows-1); boundcontours[3] = CV::P oint (src.cols-1,0); linecontours[0] =boundcontours; Cv::mat temptimg (Scr.size (), Cv_8uc1,scalar (0)); Drawcontours (temptimg, Linecontours,-1, Scalar (255), -1);}
Original:
The results are as follows:
OPENCV connected domain related operations