Only with area with the general integral algorithm, but how to through the incoming polygon area by using integral?
CodePudding user response:
The realization of the reference source OpenCV projects cvContourArea function,CodePudding user response:
https://blog.csdn.net/langmanqishizaijia/article/details/51097364CodePudding user response:
Shoelaces by formula are available, and the specific reference: https://blog.csdn.net/yang_deyuan/article/details/78863424CodePudding user response:
We are made of numerical integration method, all the parameters of the curve can be used,CodePudding user response:
Void CFillTudouDlg: : OnButton1 ()
{
//TODO: Add your the control notification handler code here
BOOL start=FALSE;
Int the end=0;
The CDC * pDC=m_Pic. GetDC ();
CRect rc;
M_Pic. GetClientRect (rc);
CRgn allRgn tmpRgn;
AllRgn. CreateRectRgn (0,0,0,0);
//
For (int y=0; Y & lt; Rc. Height (); Y++)
{
For (int x=0; X & lt; Rc. Width (); X++)
{
COLORREF col=pDC - & gt; GetPixel (x, y);
if((! Start) & amp; & (col==RGB (0, 0)))
{//once a line
Start=TRUE;
//find the end
Int e=x;
Int repeat=x;
//the skip the as many as black points
While ((pDC - & gt; GetPixel (e, y)==RGB (0, 0)) & amp; & (e & lt; Rc. Width ()))
{
E++;
Repeat++;
}
//search end
While ((pDC - & gt; GetPixel (e, y)!=RGB (0, 0)) & amp; & (e & lt; Rc. Width ()))
{
E++;
}
//if after the end, still black points
While ((pDC - & gt; GetPixel (e, y)==RGB (0, 0)) & amp; & (e & lt; Rc. Width ()))
{
E++;
}
//check valid x
If (e==rc. Width ())
{//not found
End=repeat;
}
The else
{//found
End=e;
}
}//end the if ((! Start) & amp; & (col==RGB (0, 0)))
//add RGN
If (start & amp; & (x & lt; End))
{
If # 1//not use RGN
PDC - & gt; SetPixel (x, y, RGB (0, 255));
# the else
TmpRgn. CreateRectRgn (x, y, x + 1, y + 1);
AllRgn.Com bineRgn (& amp; AllRgn, & amp; TmpRgn RGN_OR);
TmpRgn. DeleteObject ();
# endif
}
}//end for x
//reset flag
Start=FALSE;
}//end for y
# if 0
//the draw RGN
The CBrush br;
Br. CreateSolidBrush (RGB (0, 255));
PDC - & gt; FillRgn (& amp; AllRgn, & amp; Br);
The ReleaseDC (pDC);
# endif
}
Record the pDC - & gt; SetPixel (x, y, RGB (0, 255)); The point is the area