bool MultiChannel<tData>::read_tiff( Tiff_Im &i_tiff ) // Tiff_Im is not const because of ReadVecOfIm { if ( i_tiff.type_el()!=typeEl() ) return false; vector<Im2DGen *> tiffChannels = i_tiff.ReadVecOfIm(); resize( i_tiff.sz().x, i_tiff.sz().y, i_tiff.nb_chan() ); for ( size_t i=0; i<mChannels.size(); i++ ) set( i, *(Im2D<tData,tBase>*)tiffChannels[i] ); return true; }
int ConvertIm_main(int argc,char ** argv) { MMD_InitArgcArgv(argc,argv); Tiff_Im::SetDefTileFile(1000000); std::string aNameIn ; INT aReducX=0; INT aReducY=0; INT aReducXY=0; INT aVisu=0; GenIm::type_el aTypeOut ; std::string aNameTypeOut =""; Tiff_Im::PH_INTER_TYPE aPhInterpOut ; std::string aNamePITOut =""; std::string PITOut[] = {"RGB","BW"}; std::list<std::string> lOut(PITOut, PITOut + sizeof(PITOut) / sizeof(std::string) ); std::string aNameOut; std::string anExt; Pt2di aP0(0,0); Pt2di aSzOut ; Pt2di aSzTF(-1,-1); REAL aDyn=1.0; Pt2di aSzTileInterne(-1,-1); int aKCh = -1; std::vector<int> aVPermut; int aNoTile = 0; std::string aF2 =""; ElInitArgMain ( argc,argv, LArgMain() << EAMC(aNameIn, "Image", eSAM_IsExistFile), LArgMain() << EAM(aNameOut,"Out",true) << EAM(anExt,"Ext",true) << EAM(aSzOut,"SzOut",true, "Size out", eSAM_NoInit) << EAM(aP0,"P0",true) << EAM(aNameTypeOut,"Type",true, "TypeMNT", eSAM_None, ListOfVal(GenIm::bits1_msbf, "")) << EAM(aNamePITOut,"Col",true, "Col", eSAM_None,lOut) << EAM(aReducXY,"ReducXY",true) << EAM(aReducX,"ReducX",true) << EAM(aReducY,"ReducY",true) << EAM(aVisu,"Visu",true) << EAM(aSzTF,"SzTifTile",true) << EAM(aSzTileInterne,"SzTileInterne",true) << EAM(aDyn,"Dyn",true) << EAM(aKCh,"KCh",true) << EAM(aNoTile,"NoTile",true) << EAM(aVPermut,"Permut",true, "Permut", eSAM_NoInit) << EAM(aF2,"F2",true) ); if (!MMVisualMode) { // Tiff_Im aTifIn = Tiff_Im::BasicConvStd(aNameIn); Tiff_Im aTifIn = Tiff_Im::UnivConvStd(aNameIn); INT aNbChIn = aTifIn.nb_chan(); if (! EAMIsInit(&aTypeOut)) aTypeOut =aTifIn.type_el(); if (! EAMIsInit(&aPhInterpOut)) aPhInterpOut = aTifIn.phot_interp(); if (! EAMIsInit(&aSzOut)) aSzOut = aTifIn.sz(); if (aReducXY) { aReducX = 1; aReducY = 1; } if (aNameOut=="") { if (anExt=="") { if (aReducX && aReducY) anExt = "_RXY"; else if (aReducX) anExt = "_RX"; else if (aReducY) anExt = "_RY"; else anExt= "_Out"; } if (IsPostfixed(aNameIn)) aNameOut = StdPrefix(aNameIn) + anExt +"." + StdPostfix(aNameIn); else aNameOut = aNameIn + anExt + "tif"; } Pt2di aCoefReduc(aReducX != 0 ? 2 : 1, aReducY != 0 ? 2 : 1); aSzOut = aSzOut.dcbyc(aCoefReduc); if (aNameTypeOut != "") aTypeOut = type_im(aNameTypeOut); if (aKCh != -1) aNamePITOut="BW"; if ( aVPermut.size() !=0) { if ( aVPermut.size() ==1) aPhInterpOut = Tiff_Im::BlackIsZero; else if ( aVPermut.size() ==3) aPhInterpOut = Tiff_Im::RGB; else { ELISE_ASSERT(aNamePITOut=="","Nb Canaux incoherents"); } } else { if (aNamePITOut=="RGB") aPhInterpOut = Tiff_Im::RGB; else if (aNamePITOut=="BW") aPhInterpOut = Tiff_Im::BlackIsZero; else { ELISE_ASSERT(aNamePITOut=="","Mode Couleur Inconnu"); } } Tiff_Im::COMPR_TYPE aComprOut = Tiff_Im::No_Compr; L_Arg_Opt_Tiff aLArg = Tiff_Im::Empty_ARG; if (! aNoTile) { if (aSzTileInterne != Pt2di(-1,-1)) aLArg = aLArg + Arg_Tiff(Tiff_Im::ATiles(aSzTileInterne)); if (aSzTF != Pt2di(-1,-1)) aLArg = aLArg + Arg_Tiff(Tiff_Im::AFileTiling(aSzTF)); } else { aLArg = aLArg + Arg_Tiff(Tiff_Im::ANoStrip()); aLArg = aLArg + Arg_Tiff(Tiff_Im::AFileTiling(Pt2di(-1,-1))); } Tiff_Im aTifOut ( aNameOut.c_str(), aSzOut, aTypeOut, aComprOut, aPhInterpOut, aLArg ); INT aNbChOut = aTifOut.nb_chan(); Pt2di aSzROut = aSzOut; Output anOut = aTifOut.out(); Fonc_Num aFin = aTifIn.in_proj(); if (aF2!="") { Tiff_Im aT2 = Tiff_Im::BasicConvStd(DirOfFile(aNameIn)+aF2); aFin = Virgule(aFin,aT2.in(0)); } if (aVPermut.size() != 0) aFin = aFin.permut(aVPermut); if (type_im_integral( aTypeOut)) { } else { aFin = Rconv(aFin); } aFin = reduc_binaire_gen(aFin, aReducX != 0, aReducY != 0, 16, true, 0); anOut = Filtre_Out_RedBin_Gen(anOut, aReducX != 0, aReducY != 0); aSzROut = aSzOut.mcbyc(aCoefReduc); aFin = trans(aFin,aP0); if (aKCh!=-1) aFin = aFin.kth_proj(aKCh); else { if ((aNbChOut==1) && (aNbChIn==3)) aFin = (aFin.v0() + aFin.v1() + aFin.v2()) / 3.0; if ((aNbChOut==3) && (aNbChIn==1)) aFin = Virgule(aFin,aFin,aFin); } if (aVisu) anOut = anOut | Video_Win::WiewAv(aSzROut); if (aDyn != 1.0) aFin = aFin * aDyn; if (type_im_integral(aTypeOut) && (aTypeOut!=GenIm::int4)) { int aVMin,aVMax; min_max_type_num(aTypeOut,aVMin,aVMax); aFin = Max(aVMin,Min(aVMax-1,aFin)); } ELISE_COPY(rectangle(Pt2di(0,0),aSzROut),aFin,anOut); return EXIT_SUCCESS; } else return EXIT_SUCCESS; }