Пример #1
0
void BiScroller::MasqMakeOneLine
     (
           U_INT1 * aDataImR,
           U_INT1 * aDataImG,
           U_INT1 * aDataImB,
           INT      aY,
           INT      anX0,
           INT      anX1,
           U_INT1 * aLine1,
           U_INT1 * aLine2
     )
{
   static U_INT1 * aLR=0;
   static U_INT1 * aLG=0;
   static U_INT1 * aLB=0;
   if (aLR==0)
   {
       aLR = new U_INT1 [256] ;
       aLG = new U_INT1 [256] ;
       aLB = new U_INT1 [256] ;

        // Pt3dr aP0(128,0,0);
        // Pt3dr aP1(255,128,255);
        // Pt3dr aP0(0,0,128);
        // Pt3dr aP1(255,128,255);
        Pt3dr aP0(0,80,0);
        Pt3dr aP1(255,255,128);

        for (int aK=0 ; aK< 256 ; aK++)
        {
          double aPds0 = 1- aK /255.0;
          double aPds1 = 1-aPds0;
          Pt3dr aCol = aP0 *aPds0 +  aP1*aPds1;
          aLR[aK] = round_ni(aCol.x);
          aLG[aK] = round_ni(aCol.y);
          aLB[aK] = round_ni(aCol.z);
        }
   }


   TIm2D<U_INT1,INT> aTM(mImMasq);
   Pt2di aP(anX0,aY);

   Pt2dr aQ0 = mScrGray->to_user(Pt2dr(aP));
   Pt2dr aQ1 = mScrGray->to_user(Pt2dr(aP)+Pt2dr(1,0));
   double aDx = aQ1.x -aQ0.x;
   double aXQ0 = aQ0.x;
   int aYQ0 = round_ni(aQ0.y);

   for (; aP.x<anX1 ; aP.x++)
   {
       bool inM = (aTM.get(Pt2di(round_ni(aXQ0),aYQ0),0)!=0);
       int aCoul = aLine1[aP.x];

       aDataImR[aP.x] = inM?aLR[aCoul]:aCoul ;
       aDataImG[aP.x] = inM?aLG[aCoul]:aCoul ;
       aDataImB[aP.x] = inM?aLB[aCoul]:aCoul ;
        aXQ0 +=aDx;
   }
}
Пример #2
0
void BiScroller::LutMakeOneLine
     (
           U_INT1 * aDataImR,
           U_INT1 * aDataImG,
           U_INT1 * aDataImB,
           INT      aY,
           INT      anX0,
           INT      anX1,
           U_INT1 * aLineGr,
           U_INT1 * aLineCol
     )
{
/*
    U_INT1 * aRGB;
    for (INT x= anX0; x<anX1 ; x++)
    {
        aRGB = RGBEntry(aLineGr[x],aLineCol[x]);
        aDataImR[x] = aRGB[eIndR];
        aDataImG[x] = aRGB[eIndG];
        aDataImB[x] = aRGB[eIndB];
    }
*/
   TIm2D<U_INT1,INT> aTM(mImMasq);
   Pt2di aP(anX0,aY);

   Pt2dr aQ0 = mScrGray->to_user(Pt2dr(aP));
   Pt2dr aQ1 = mScrGray->to_user(Pt2dr(aP)+Pt2dr(1,0));
   double aDx = aQ1.x -aQ0.x;
   double aXQ0 = aQ0.x;
   int aYQ0 = round_ni(aQ0.y);

   for (; aP.x<anX1 ; aP.x++)
   {
       int  indCoul  = aTM.get(Pt2di(round_ni(aXQ0),aYQ0),0);
       int aGray = aLineGr[aP.x];

       U_INT1 * aRGB = RGBEntry(aGray,indCoul);

        aDataImR[aP.x] = aRGB[eIndR];
        aDataImG[aP.x] = aRGB[eIndG];
        aDataImB[aP.x] = aRGB[eIndB];
       // aDataImR[aP.x] = inM?aLR[aCoul]:aCoul ;
       // aDataImG[aP.x] = inM?aLG[aCoul]:aCoul ;
       // aDataImB[aP.x] = inM?aLB[aCoul]:aCoul ;
        aXQ0 +=aDx;
   }
}
Пример #3
0
void  cAppliMICMAC::DoMasqueAutoByTieP(const Box2di& aBoxLoc,const cMasqueAutoByTieP & aMATP)
{

   std::cout << "cAppliMICMAC::DoMasqueAutoByTieP " << aBoxLoc << "\n";

   // std::cout <<  "*-*-*-*-*-*- cAppliMICMAC::DoMasqueAutoByTieP    "<< mImSzWCor.sz() << " " << aBox.sz() << mCurEtUseWAdapt << "\n";


   ElTimer aChrono;
   mMMTP = new cMMTP(aBoxLoc,mBoxIn,mBoxOut,*this);

    // Si il faut repartir d'un masque initial calcule a un de zool anterieur
    if (aMATP.TiePMasqIm().IsInit())
    {
       int aDZ = aMATP.TiePMasqIm().Val().DeZoomRel();
       int aDil = aMATP.TiePMasqIm().Val().Dilate();

       std::string aNameMasq = NameImageMasqOfResol(mCurEtape->DeZoomTer()*aDZ);
       Tiff_Im aTM(aNameMasq.c_str());
       Pt2di aSZM = aTM.sz();
       Im2D_Bits<1> aM(aSZM.x,aSZM.y);
       ELISE_COPY(aM.all_pts(),aTM.in(),aM.out());

       Im2D_Bits<1> aNewM = mMMTP->ImMasquageInput();
       ELISE_COPY
       (
             aNewM.all_pts(),
             dilat_32(aM.in(0)[Virgule(FX,FY)/double(aDZ)],aDil*3),
              aNewM.out()
       );
    }

    if (aMATP.mmtpFilterSky().IsInit())
    {
         Im2D_REAL4 * anIm = mPDV1->LoadedIm().FirstFloatIm();
         ELISE_ASSERT(anIm!=0,"Incohe in mmtpFilterSky");
         // Pt2di aSz = anIm->sz();
         Pt2di aSz = mMMTP->ImMasquageInput().sz();

         const cmmtpFilterSky & aFS = aMATP.mmtpFilterSky().Val();
         int aSeuilNbPts = round_ni(aSz.x*aSz.y*aFS.PropZonec().Val());

         Im2D_U_INT1 aImLabel(aSz.x,aSz.y);
         TIm2D<U_INT1,INT> aTLab(aImLabel);

         Fonc_Num FHGlob = FoncHomog(*anIm,aFS.SzKernelHom().Val(),aFS.PertPerPix().Val());
         ELISE_COPY(aImLabel.all_pts(),FHGlob,aImLabel.out());
         FiltrageCardCC(true,aTLab,1,2,aSeuilNbPts);

         Im2D_Bits<1> aNewM = mMMTP->ImMasquageInput();
         ELISE_COPY(select(aImLabel.all_pts(),aImLabel.in()==1),0,aNewM.out());
/*
         Video_Win * aW = Video_Win::PtrWStd(anIm->sz());
         ELISE_COPY(anIm->all_pts(),aImLabel.in(), aW->odisc());
         std::cout << "AAAAAAAAAAAAAAAAAaaaSkkkkkkYYyyyyy\n"; getchar();
*/
          
    }

 #ifdef ELISE_X11
   if (aMATP.Visu().Val())
   {
       Pt2dr aSzW = Pt2dr(aBoxLoc.sz());
       TheScaleW = ElMin(1000.0,ElMin(TheMaxSzW.x/aSzW.x,TheMaxSzW.y/aSzW.y));  // Pour l'instant on accepts Zoom>1 , donc => 1000

       // TheScaleW = 0.635;
       aSzW = aSzW * TheScaleW;

       TheWTiePCor= Video_Win::PtrWStd(round_ni(aSzW));
       TheWTiePCor=  TheWTiePCor->PtrChc(Pt2dr(0,0),Pt2dr(TheScaleW,TheScaleW),true);
       for (int aKS=0 ; aKS<mVLI[0]->NbScale() ; aKS++)
       {
           Im2D_REAL4 * anI = mVLI[0]->FloatIm(aKS);
           ELISE_COPY(anI->all_pts(),Max(0,Min(255,anI->in()/50)),TheWTiePCor->ogray());
       }
/*
       {
           ELISE_COPY(TheWTiePCor->all_pts(),mMMTP->ImMasquageInput().in(),TheWTiePCor->odisc());
           std::cout << "HERISE THE MAKSE \n"; getchar();
       }
*/
   }
#endif 
   std::string  aNamePts = mICNM->Assoc1To1
                           (
                              aMATP.KeyImFilePt3D(),
                              PDV1()->Name(),
                              true
                           );
   mTP3d = StdNuage3DFromFile(WorkDir()+aNamePts);

   cMasqBin3D * aMasq3D = 0;
//#if (ELISE_QT_VERSION >= 4)
   if (aMATP.Masq3D().IsInit())
   {
         aMasq3D  = cMasqBin3D::FromSaisieMasq3d(WorkDir()+aMATP.Masq3D().Val());
         std::vector<Pt3dr> aNewVec;
         for (int aK=0 ; aK<int(mTP3d->size()) ; aK++)
         {
              Pt3dr aP = (*mTP3d)[aK];
              if (aMasq3D->IsInMasq(aP))
                aNewVec.push_back(aP);
         }
         *mTP3d = aNewVec;
   }
// #endif

   std::cout << "== cAppliMICMAC::DoMasqueAutoByTieP " << aBoxLoc._p0 << " " << aBoxLoc._p1 << " Nb=" << mTP3d->size() << "\n"; 
   std::cout << " =NB Im " << mVLI.size() << "\n";


   cXML_ParamNuage3DMaille aXmlN =  mCurEtape->DoRemplitXML_MTD_Nuage();


   {
       cElNuage3DMaille *  aNuage = cElNuage3DMaille::FromParam(mPDV1->Name(),aXmlN,FullDirMEC());
       if (aMasq3D)
       {
           mMMTP->SetMasq3D(aMasq3D,aNuage,Pt2dr(mBoxIn._p0));
           mGLOBMasq3D = aMasq3D;
           mGLOBNuage = aNuage;
       }

       for (int aK=0 ; aK<int(mTP3d->size()) ; aK++)
       {
           Pt3dr aPE = (*mTP3d)[aK];
           Pt3dr aPL2 = aNuage->Euclid2ProfPixelAndIndex(aPE);


           int aXIm = round_ni(aPL2.x) - mBoxIn._p0.x;
           int aYIm = round_ni(aPL2.y) - mBoxIn._p0.y;
           int aZIm = round_ni(aPL2.z) ;


           MakeDerivAllGLI(aXIm,aYIm,aZIm);
           CTPAddCell(aMATP,aXIm,aYIm,aZIm,false);

           ShowPoint(Pt2dr(aXIm,aYIm),P8COL::red,0);
       }
   }



   OneIterFinaleMATP(aMATP,false);
   mMMTP->ExportResultInit();
   mMMTP->FreeCel();
 #ifdef ELISE_X11
   if (TheWTiePCor)
   {
       std::cout << "End croissance \n";
       TheWTiePCor->clik_in();
   }
 #endif
   const cComputeAndExportEnveloppe * aCAEE = aMATP.ComputeAndExportEnveloppe().PtrVal();


   if (aMATP.ParamFiltreRegProf().IsInit())
      mMMTP->MaskRegulMaj(aMATP.ParamFiltreRegProf().Val());
   mMMTP->ContAndBoucheTrou();
   if (aMATP.FilterPrgDyn().IsInit())
      mMMTP->MaskProgDyn(aMATP.FilterPrgDyn().Val());


   if (aCAEE)
   {
       mMMTP->ConputeEnveloppe(*aCAEE,aXmlN);
       if (aCAEE->EndAfter().Val()) return;
   }


/*
   if (aMATP.ParamFiltreRegProf().IsInit())
      mMMTP->MaskRegulMaj(aMATP.ParamFiltreRegProf().Val());
   mMMTP->ContAndBoucheTrou();
   if (aMATP.FilterPrgDyn().IsInit())
      mMMTP->MaskProgDyn(aMATP.FilterPrgDyn().Val());
*/



   // A CONSERVER , SAUV FINAL ...:

   std::string aNameMasq =  NameImageMasqOfResol(mCurEtape->DeZoomTer());

   Im2D_Bits<1> aImMasq0 = mMMTP->ImMasqFinal();
   ELISE_COPY(aImMasq0.all_pts(), aImMasq0.in(), Tiff_Im(aNameMasq.c_str()).out());
   
   std::string aNameImage = FullDirMEC() +aXmlN.Image_Profondeur().Val().Image();
   // Pour forcer le resultat flotant 
   Tiff_Im::CreateFromIm(mMMTP->ImProfFinal(),aNameImage.c_str());
/*
   ELISE_COPY(aImProf.all_pts(), aImProf.in(), Tiff_Im(aNameImage.c_str()).out());

       Im2D_REAL4   ImProfFinal() {return  mContBT;}   // image dequant et trous bouches
*/


}
Пример #4
0
cAppli_LumRas::cAppli_LumRas(int argc,char ** argv) :
   cAppliWithSetImage(argc-2,argv +2,TheFlagNoOri|TheFlagDev16BGray),
   // mTifBaseGr   (0),
   mTifBaseCoul (0),
   mImGr        (1,1),
   mImMasq      (1,1)

{
     std::vector<double> aPdsI;
     ElInitArgMain
     (
           argc,argv,
           LArgMain() << EAM(mNameImBase, "Image name",  true, "Image name", eSAM_IsExistFile)
                      << EAM(mPatImRas, "Image pattern", true, "Pattern", eSAM_IsPatFile) ,
           LArgMain() << EAM(mPostMasq,"Masq",true,"Mask for computation", eSAM_NoInit)
                      << EAM(aPdsI,"PdsIn",true,"Pds on RGB Input, def=[1,1,1]", eSAM_NoInit)
                      << EAM(mNameTargSh,"TargShade",true,"Targeted Shade", eSAM_NoInit)
    );


    if (!MMVisualMode)
    {
        for (int aK=(int)aPdsI.size() ; aK<3 ; aK++)
            aPdsI.push_back(1);
        // mTifBaseGr =   new  Tiff_Im (Tiff_Im::StdConvGen(mNameImBase,1,true));
        mTifBaseCoul = new  Tiff_Im (Tiff_Im::StdConvGen(mNameImBase,3,true));

        mSz =  mTifBaseCoul->sz();
        mImGr.Resize(mSz);
        Symb_FNum aFCoul(mTifBaseCoul->in());
        Fonc_Num aFGr =  (aPdsI[0]*aFCoul.v0()+aPdsI[1]*aFCoul.v1()+aPdsI[2]*aFCoul.v2())/(aPdsI[0]+aPdsI[1]+aPdsI[2]);

        ELISE_COPY(mImGr.all_pts(),aFGr,mImGr.out());


        mImMasq = Im2D_Bits<1>(mSz.x,mSz.y,1);
        if (EAMIsInit(&mPostMasq))
        {
            CorrecNameMasq(mEASF.mDir,NameWithoutDir(mNameImBase),mPostMasq);
            std::string aNameMasq = StdPrefix(mNameImBase)+mPostMasq+".tif";
            Tiff_Im aTM(aNameMasq.c_str());
            ELISE_COPY(mImMasq.all_pts(),aTM.in(0),mImMasq.out());
        }
        ELISE_COPY(mImMasq.border(1),0,mImMasq.out());

        mKeyHom = "NKS-Assoc-CplIm2Hom@@dat";
        // mKeyHom = "";

        Fonc_Num aGlobSh;
        for (int aK=0 ; aK<int(mVSoms.size()) ; aK++)
        {
            std::string aName = mVSoms[aK]->attr().mIma->mNameIm;
            mVIm.push_back(new cImage_LumRas(mEASF.mDir+aName,*this));
            //Fonc_Num aFShade = mVIm.back()->mImShade.in();



            // aGlobSh = (aK==0) ? aFShade : Virgule(aGlobSh,aFShade);
        }


        if (EAMIsInit(&mNameTargSh))
        {
            DoShadeByLeastSquare();
        }
        else
        {
             for (int aK=0 ; aK<int(mVIm.size()) ; aK++)
                mVIm[aK]->CalculShadeByDiff();
        }
/* 
  // RGB 

       std::string aNameOut = mEASF.mDir+ "LumRas_"+StdPrefix(mNameImBase) + ".tif";
       Tiff_Im TifTest
               (
                     aNameOut.c_str(),
                     mSz,
                     GenIm::u_int1,
                     Tiff_Im::No_Compr,
                     Tiff_Im::RGB
               );


       ELISE_COPY
       (
             TifTest.all_pts(),
             // Max(0,Min(255,128 * (1 + 5*aGlobSh))),
             Max(0,Min(255,aFCoul+ 20*aGlobSh)),
             TifTest.out()
       );
*/
    }
}