int computeStackLevels_Gauss(MultiDimFloatTexture tex, ref MultiDimFloatTexture[] _lvls) { Globals.Assert(false); /* * static char str[256]; * //SimpleTimer tm("\n[Exemplar::computeStackLevels] %02d min %02d sec %d ms\n"); * * List<MultiDimFloatTexture > tmplvls; * * // compute stack of averages on large texture * * // . finest level * MultiDimFloatTexture first=tex; * MultiDimFloatTexture lvl =first; * tmplvls.clear(); * tmplvls.push_back(tex); * * int numlvl=(int)(0.01 + log2((float)lvl.width())); * int l=0; * // . compute successive filtered versions - FIXME: stack alignement ?? * do * { * MultiDimFloatTexture *next=first.applyGaussianFilter_Separable((1 << l)*2+1); // FIXME size ? * if (lvl != first) * delete (lvl); * lvl=next; * * tmplvls.push_back(lvl); * * l++; * } while ((1 << l) < lvl.width()); * * // clamp stack * int w=tex.getWidth()/2; * int h=tex.getHeight()/2; * _lvls.clear(); * * int sz=w; * l=0; * for (vector<MultiDimFloatTexture *>::iterator L=tmplvls.begin();L!=tmplvls.end();L++) * { * int oi=0,oj=0; * * * MultiDimFloatTexture *clamped=(*L).extract<MultiDimFloatTexture>(w/2+oi,h/2+oj,w,h); * _lvls.push_back(clamped); #ifdef SAVE_STACK * CTexture *tmp=clamped.toRGBTexture(); * sprintf(str,"__stack_gauss_clamped_%d.png",l); * CTexture::saveTexture(tmp,str); * delete (tmp); #endif * l++; * sz >>= 1; * if (sz < 1) * break; * } * * // free memory * for (vector<MultiDimFloatTexture *>::iterator L=tmplvls.begin();L!=tmplvls.end();L++) * if ((*L) != tex) * delete ((*L)); * * return ((int)_lvls.size()); * */ return(0); }
bool loadAnalysisFile(StreamReader f) { // compatibility check //CLM this seems like a bunch of shit...... //this should be a per-exemplar dataset, not global? //and it should actually be goddamn used! //or alteast just a goddamn header version cehck? int v; v = Convert.ToInt32(f.ReadLine()); Globals.Assert(v >= Globals.K_NEAREST);//return (eAnalyserLoadResult.ANALYSER_DATA_EXISTS); v = Convert.ToInt32(f.ReadLine()); Globals.Assert(v == 0);// (eAnalyserLoadResult.ANALYSER_DATA_EXISTS); v = Convert.ToInt32(f.ReadLine()); Globals.Assert(v == Globals.NEIGHBORHOOD_RADIUS_RECOLOR);// (eAnalyserLoadResult.ANALYSER_DATA_EXISTS); v = Convert.ToInt32(f.ReadLine()); v = Convert.ToInt32(f.ReadLine()); Globals.Assert(v == Globals.NUM_RECOLORED_PCA_COMPONENTS);// (eAnalyserLoadResult.ANALYSER_DATA_EXISTS); v = Convert.ToInt32(f.ReadLine()); Globals.Assert(v == Globals.NUM_RUNTIME_PCA_COMPONENTS);// (eAnalyserLoadResult.ANALYSER_DATA_EXISTS); v = Convert.ToInt32(f.ReadLine()); Globals.Assert(v == 1); // (eAnalyserLoadResult.ANALYSER_DATA_EXISTS); v = Convert.ToInt32(f.ReadLine()); Globals.Assert(v == 1); // (eAnalyserLoadResult.ANALYSER_DATA_EXISTS); //read number of levels m_iNbLevels = Convert.ToInt32(f.ReadLine()); m_PCASynth = new List <PCA /*PCA_SYNTH*/>(m_iNbLevels); m_PCASynth_4Drecoloring = new List <PCA /*PCA_SYNTH*/>(m_iNbLevels); int nbex = Convert.ToInt32(f.ReadLine()); // for backward compatibility Globals.Assert(nbex == 1); //return false;// eAnalyserLoadResult.ANALYSER_DATA_EXISTS; //load our PCA Synth Vectors for (int i = 0; i < m_iNbLevels; i++) { m_PCASynth.Add(new PCA() /*PCA_synth*/); bool success = m_PCASynth[i].load(f); Globals.Assert(success); } //load our exemplar loadExemplarData(f); //load our PCA synth 4d recolored data bool recompute = false; bool updated = false; for (int l = 0; l < (int)m_iNbLevels; l++) { m_PCASynth_4Drecoloring.Add(new PCA() /*PCA_synth*/); bool success = m_PCASynth_4Drecoloring[l].load(f); Globals.Assert(success); } computeRuntimeNeighborhoods(pcaSynth()); generateD3DLevelData(); return(true);// eAnalyserLoadResult.ANALYSER_DONE; }
bool loadExemplarData(StreamReader f) { //grab our ID m_iExemplarId = Convert.ToInt32(f.ReadLine()); // read exemplar flags int flags = Convert.ToInt32(f.ReadLine()); m_bToroidal = (flags & (int)eExemplarFlags.EXEMPLAR_TOROIDAL_FLAG) != 0 ? true : false; // read periods m_iPeriodX = Convert.ToInt32(f.ReadLine()); m_iPeriodY = Convert.ToInt32(f.ReadLine()); // read number of levels m_iNbLevels = Convert.ToInt32(f.ReadLine()); // read exemplar name & load our image stack String exname = f.ReadLine(); MultiDimFloatTexture image = new MultiDimFloatTexture(exname); { bool succede = computeStackLevels(image, m_bToroidal, ref m_Stack) == m_iNbLevels; Globals.Assert(succede); } m_Stack[0].setName(image.getName()); //read our presentation flagss String name = null; int present = Convert.ToInt32(f.ReadLine()); if ((present & (int)eExemplarFlags.FLAG_CONSTRAINT) != 0) { // read constraint texture name name = f.ReadLine(); MultiDimFloatTexture constraint = new MultiDimFloatTexture(name); { bool succede = (computeStackLevels(constraint, m_bToroidal, ref m_Constraints) == m_iNbLevels); Globals.Assert(succede); } m_Constraints[0].setName(constraint.getName()); } if ((present & (int)eExemplarFlags.FLAG_FMAP) != 0) { // NOTE: feature map is no longer saved // this is done for backward comp. name = f.ReadLine(); } if ((present & (int)eExemplarFlags.FLAG_PRTCOLORMAP) != 0) { name = f.ReadLine(); //m_PRTColorMap=CTexture::loadTexture(name.c_str()); } //load our Knearest neighbors (see TONG et al. 2002 "Synthesis of bidirectional texture functions on arbitrary surfaces.") mKNS = new KNearestSimilartySet(f, this, m_iNbLevels); // load recolored exemplar (see HOPPE et al. 2006 "Appearance Space Texture Synthesis") m_RecoloredStack = new MultiDimFloatTexture[m_iNbLevels]; for (int l = 0; l < m_iNbLevels; l++) { name = f.ReadLine(); m_RecoloredStack[l] = new MultiDimFloatTexture(name); } loadHighResExemplarImg(m_name); loadRandomTexture(m_name); return(true); }
void computeSynthNeighborhoods() { ScopeTimer tm = new ScopeTimer("[computeSynthNeighborhoods]"); m_SynthNeighborhoods = new NeighborhoodSynth[mNumLevels][]; // foreach level for (int level = 0; level < mNumLevels; level++) { MultiDimFloatTexture recolored_level = null; if (Globals.isDefined("4D")) { // . keep only 4 dimension from recolored exemplar MultiDimFloatTexture level_4D = new MultiDimFloatTexture(mOwner.recoloredStack(level).width(), mOwner.recoloredStack(level).height(), mOwner.recoloredStack(level).numComp()); int w = level_4D.getWidth(); int h = level_4D.getHeight(); Globals.Assert(w == mOwner.stack(level).getWidth() && h == mOwner.stack(level).height()); Globals.Assert(level_4D.numComp() == Globals.NUM_RECOLORED_PCA_COMPONENTS); for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { // . copy first four channels for (int c = 0; c < 4; c++) { level_4D.set(mOwner.recoloredStack(level).get(i, j, c), i, j, c); } // . zero out all channels above 4 for (int c = 4; c < level_4D.numComp(); c++) { level_4D.set(0, i, j, c); } } } recolored_level = level_4D; } else { // . keep all dimensions recolored_level = mOwner.recoloredStack(level); } m_SynthNeighborhoods[level] = new NeighborhoodSynth[recolored_level.width() * recolored_level.height()]; stack_accessor_v2 access = new stack_accessor_v2(level); for (int j = 0; j < recolored_level.height(); j++) { for (int i = 0; i < recolored_level.width(); i++) { int index = i + j * recolored_level.width(); m_SynthNeighborhoods[level][index] = new NeighborhoodSynth(); m_SynthNeighborhoods[level][index].construct( recolored_level, access, (!mOwner.isToroidal()) && level < (mNumLevels - Globals.NUM_LEVELS_WITHOUT_BORDER), //(!m_bToroidal) && l < FIRST_LEVEL_WITH_BORDER, level, i, j); } } } tm.destroy(); tm = null; }