[Blog algorithm principle] Mach effect and coping method

Source: Internet
Author: User

[blog] Mach Effect and coping method //Create and analyze how to handle the Macheffect of a rectangleMat SrcRect1 (500,500,CV_8UC1);Mat SrcRect2 (500,500,CV_8UC1);For (int i=0;i<10;i++)    {For (int j=0;j<50;j++)        {Srcrect1.row (i*50+j) = i*25;        }    }imshow ("MachEffectRect1", SrcRect1);Is Macheffect, it's a way of knowing the structure of the data, and then building a continuous gradient for (int i=0;i<10;i++)     {For (int j=0;j<50;j++)        {Srcrect2.row (i*50+j) = i*25;        }    }For (int i=0;i<9;i++)    {    For (int j=0;j<50;j++)        {Srcrect2.row (25+i*50+j) = I*25+J/2;        }    }  imshow ("MachEffectRect2", srcRect2);The most difficult thing to do here is the "acquisition of structure", for example, in this case //Create macheffect for any situationMat srcrnd = Imread ("macheffect.bmp");Mat rncclone = Srcrnd.clone ();Mat Canny;Blur (Rncclone,rncclone,size (10,10));Mat srcRnd2 = Mat::zeros (500,500,CV_8UC1);STD::VECTOR<STD::VECTOR<CV::P oint>>contours; int imaxsize =-1; int imaxnum = 0;For (int i=0;i<10;i++)    {       dilate (Rncclone,rncclone,mat (10,10,CV_8UC1));threshold (RNCCLONE,CANNY,100,255,THRESH_BINARY_INV);Canny (canny,canny,0,255);findcontours (canny,contours,cv_retr_list,cv_chain_approx_none);For (int n=0;n<contours.size (); n++)        { int itmp = contours[n].size (); if (Itmp > Imaxsize)            {imaxsize = Contours[n].size ();imaxnum = n;            }        }drawcontours (Srcrnd2,contours,imaxnum,scalar (255-25*i), -1);imaxnum = 0;imaxsize =-1;contours.clear ();imshow ("Canny", canny);imshow ("Rncclone", Rncclone);imshow ("Srcrnd", srcrnd);imshow ("SrcRnd2", SrcRnd2); //srcrnd2 = Mat::zeros (500,500,CV_8UC1); Waitkey ();    }    He can still do it, because the structure is not complex, but if it comes to reality, its structure gets more complex. But in general, getting the structure and building a continuous gradient instead of jumping directly should be the solution to the problem.

From for notes (Wiz)

[Blog algorithm principle] Mach effect and coping method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.