void bench_flag_front (Pt2di sz,bool FN) { Neighbourhood V4 = Neighbourhood::v4(); Neighbourhood V8 = Neighbourhood::v8(); Im2D_U_INT1 Im(sz.x,sz.y,0); Liste_Pts_INT4 ListTrou(2); ELISE_COPY ( Im.all_pts(), frandr() > 0.5, Im.out() ); ELISE_COPY(Im.border(2),0,Im.out()); ELISE_COPY ( select ( select(Im.all_pts(),Im.in()), Neigh_Rel(V8).red_max(Im.in()) == 0 ), 2, ListTrou | Im.out() ); INT nbZ1 = 0; INT nbZ0 = -1; // pour tenir compte de la zone externe { Im2D_U_INT1 ImZ(sz.x,sz.y); ELISE_COPY(ImZ.all_pts(),Im.in()==1,ImZ.out()); ELISE_COPY(ImZ.border(1),2,ImZ.out()); U_INT1 ** z = ImZ.data(); for (INT x=0 ; x<sz.x ; x++) for (INT y=0 ; y<sz.y ; y++) if (z[y][x] != 2) { if (z[y][x] == 1) nbZ1 ++; else nbZ0++; Neighbourhood neigh = ((z[y][x] == 1) ? V8 : V4); ELISE_COPY ( conc(Pt2di(x,y),ImZ.neigh_test_and_set(neigh,z[y][x],2,10)), 2, ImZ.out() ); } } Im2D_U_INT1 IFront(sz.x,sz.y); ELISE_COPY ( Im.all_pts(), flag_front8(Im.in(0)), IFront.out() ); Im2D_U_INT1 check(sz.x,sz.y,0); ElFifo<Pt2di> pts; WCEP wcep(check); if (FN) { ELISE_COPY ( Im.all_pts(), cont_vect (Im.in(),&wcep,true), Output::onul() ); } else explore_cyle(&wcep,pts,IFront); ELISE_COPY(ListTrou.all_pts(),check.in()+2,check.out()); INT dif; ELISE_COPY(Im.all_pts(),Abs(Im.in()-check.in()),sigma(dif)); BENCH_ASSERT(dif==0); BENCH_ASSERT(nbZ0 == wcep._nb_int); BENCH_ASSERT(nbZ1 == wcep._nb_ext); }
void FiltreRemoveBorderHeter(Im2D_REAL4 anIm,Im2D_U_INT1 aImMasq,double aCostRegul,double aCostTrans) { Pt2di aSz = anIm.sz(); double aVMax,aVMin; ELISE_COPY(aImMasq.border(1),0,aImMasq.out()); ELISE_COPY(aImMasq.all_pts(),aImMasq.in()!=0,aImMasq.out()); ELISE_COPY(anIm.all_pts(),anIm.in(),VMax(aVMax)|VMin(aVMin)); Video_Win * aW = Video_Win::PtrWStd(aSz); ELISE_COPY(anIm.all_pts(),(anIm.in()-aVMin) * (255.0/(aVMax-aVMin)),aW->ogray()); std::cout << "VMAX " << aVMax << "\n"; //ELISE_COPY(aW->all_pts(),aImMasq.in(),aW->odisc()); //aW->clik_in(); ELISE_COPY ( aW->all_pts(), nflag_close_sym(flag_front8(aImMasq.in_proj()!=0)), aW->out_graph(Line_St(aW->pdisc()(P8COL::red))) ); cParamFiltreDepthByPrgDyn aParam = StdGetFromSI(Basic_XML_MM_File("DefFiltrPrgDyn.xml"),ParamFiltreDepthByPrgDyn); aParam.CostTrans() = aCostTrans; aParam.CostRegul() = aCostRegul; Im2D_Bits<1> aNewMasq = FiltrageDepthByProgDyn(anIm,aImMasq,aParam); ELISE_COPY ( select(aNewMasq.all_pts(),aNewMasq.in()), 2, aImMasq.out() ); TIm2D<U_INT1,INT> aTMasq(aImMasq); FiltrageCardCC(false,aTMasq,2,0,100); Neighbourhood aNV4=Neighbourhood::v4(); Neigh_Rel aNrV4 (aNV4); ELISE_COPY ( conc ( select(select(aImMasq.all_pts(),aImMasq.in()==1),aNrV4.red_sum(aImMasq.in()==0)), aImMasq.neigh_test_and_set(aNV4,1,0,256) ), 3, Output::onul() ); ELISE_COPY ( aNewMasq.all_pts(), aImMasq.in(), aW->odisc() ); /* ELISE_COPY ( aW->all_pts(), nflag_close_sym(flag_front8(aNewMasq.in_proj())), aW->out_graph(Line_St(aW->pdisc()(P8COL::green))) ); */ aW->clik_in(); }