[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