35 #ifndef AIMS_PRIMALSKETCH_SCALESPACE_H 36 #define AIMS_PRIMALSKETCH_SCALESPACE_H 59 virtual float dt() = 0;
66 double dt = double(this->
dt());
67 if (dt) nbFloat = double(t) /
dt;
68 else nbFloat = int(rint(t));
70 if ((rint(nbFloat) - nbFloat) > 0.001 )
72 std::cerr <<
"diffusionSmoother::doSmoothing : t (=" 73 << t <<
") must be a multiple of dt (=" << dt
77 return int(rint(nbFloat));
87 template<
typename Geom,
typename Text>
91 float dt() {
return _smoother->dt(); };
93 std::map<float, ScaleLevel<Geom, Text>*>
scales;
106 if (scales.find(t) != scales.end())
return scales[t];
107 else { AddScale(t);
return scales[t]; }
116 void AddScale(
float t);
117 void RemoveScale(
float t);
120 {
float t;
for (t=1; t<=tmax; t=t*2) { std::cout <<
"Adding scale " << t << std::endl; AddScale(t); } }
122 std::set<float> GetScaleList();
124 void WriteScale(
float t, std::string name);
126 void WriteScaleSpace(std::string name);
137 float dt() {
return _smoother->dt(); };
146 { PutSmoother(smoother); PutOriginalImage(originalImage); }
151 { _smoother = smoother; }
160 if (scales.find(t) != scales.end())
return scales[t];
161 else { AddScale(t);
return scales[t];}
170 std::set<float> GetScaleList();
175 void AddScale (
float t );
182 for ( t = 1 ; t <= tmax ; t = t*2 ) {
183 std::cout <<
"Adding scale " << t << std::endl;
186 std::cout <<
"Adding scale" << tmax << std::endl;
190 void WriteScale(
float t, std::string name);
192 void Write(std::string name);
196 for (
uint i = 0 ; i < scale_space.
dimT() ; i++ ) {
197 std::cout <<
"Adding scale " << t << std::flush;
199 for (
uint x = 0 ; x < scale_space.
dimX() ; x++ )
200 for (
uint y = 0 ; y < scale_space.
dimY() ; y++ )
201 for (
uint z = 0 ; z < scale_space.
dimZ() ; z++ )
202 scale( x, y, z, 0 ) = scale_space( x, y, z, i );
203 AddScale( t, scale );
205 std::cout <<
" OK" << std::endl;
213 template<
int D,
typename T>
217 float dt() {
return _smoother->dt(); };
228 _smoother=NULL; _auxmesh=NULL; _coordinates=NULL;
235 PutSmoother(smoother);
237 PutOriginalImage(originalTexture);
246 for (
uint i = 1 ; i < tex.size() ; i++ ) {
247 std::cout <<
"Adding scale " << t << std::flush;
250 std::cout <<
" OK" << std::endl;
272 if (scales.find(t) != scales.end())
return scales[t];
273 else { AddScale(t);
return scales[t];}
279 std::set<float> GetScaleList();
285 void AddScale(
float t);
292 for (t=1; t<=tmax; t=t*2)
294 std::cout <<
"Adding scale " << t << std::endl;
297 std::cout <<
"Checking last scale level : " << tmax << std::endl;
301 void WriteScale(
float t, std::string name);
304 void Write(std::string name);
315 if (scales.find(t) == scales.end())
326 std::cout <<
"Scale " << t <<
" already computed... " << std::endl;
334 if (scales.find(t) == scales.end())
345 std::cout <<
"Scale " << t <<
" already computed... " << std::endl;
350 template<
typename T>
void ScaleSpace<AimsData<T>,
AimsData<T> >::AddScale(
float t)
352 if (scales.find(t) == scales.end())
354 if (!(_smoother->optimal()))
356 std::cout <<
"Smoothing from original image" << std::endl;
358 AimsData<T> lisse=_smoother->doSmoothing(GetOriginalImage(), time);
366 std::cout <<
"Smoothing from previous scale " << std::flush;
368 float tlow = 0.0f, tmax = 0.0f;
372 for ( ; itS!=scales.end(); ++itS)
382 for ( ; itscales != scales.end(); ++itscales)
384 if ((*itscales).first >= tmax)
389 imageLow=nivEch->Level();
396 for ( ; itnext != scales.end(); ++itscales)
400 if (((*itscales).first < t) && ((*itnext).first > t))
402 tlow=(*itscales).first;
404 imageLow=nivEch->Level();
409 std::cout <<
"t=" << tlow <<
", image: " << imageLow.
dimX() <<
"x" << imageLow.
dimY() <<
"x" << imageLow.
dimZ() <<
"x" << imageLow.
dimT() << std::endl;
412 AimsData<T> lisse=_smoother->doSmoothing(imageLow, time);
427 if (scales.find(t) == scales.end())
429 if (!(_smoother->optimal()))
431 std::cout <<
"Smoothing from original image" << std::endl;
433 Texture<T> lisse=_smoother->doSmoothing(GetOriginalImage(), time);
440 std::cout <<
"Smoothing from previous scale " << std::flush;
442 float tlow = 0.0f, tmax = 0.0f;
445 for ( ; itS!=scales.end(); ++itS)
453 itscales = scales.begin();
456 for ( ; itscales != scales.end(); ++itscales)
458 if ((*itscales).first >= tmax)
465 imageLow=nivEch->Level();
470 itscales = scales.begin();
474 for ( ; itnext != scales.end(); ++itscales)
479 if (((*itscales).first < t) && ((*itnext).first > t))
481 tlow=(*itscales).first;
483 imageLow=nivEch->Level();
488 std::cout <<
"t = " << tlow << std::endl;
492 Texture<T> lisse = _smoother->doSmoothing(imageLow, time);
501 std::cout <<
"Scale " << t <<
" already computed... " << std::endl;
510 template<
typename T>
void ScaleSpace<AimsData<T>,
AimsData<T> >::WriteScale(
float t, std::string name)
513 if ((itscales=scales.find(t)) != scales.end())
516 dataW.
write(((*itscales).second)->Level());
520 std::cout <<
"Can't write scale " << t <<
" that does not exist..." << std::endl;
526 template<
int D,
typename T>
void ScaleSpace<AimsSurface<D, Void>,
Texture<T> >::WriteScale(
float t, std::string name)
529 if ((itscales=scales.find(t)) != scales.end())
537 std::cout <<
"Can't write scale " << t <<
" that does not exist..." << std::endl;
543 template<
typename T>
void ScaleSpace<AimsData<T>,
AimsData<T> >::Write(std::string name)
546 int nbScales=scales.size();
547 int sx=GetOriginalImage().dimX(), sy=GetOriginalImage().dimY(), sz=GetOriginalImage().dimZ(), x, y, z;
548 float dx=GetOriginalImage().sizeX(),dy=GetOriginalImage().sizeY(),dz=GetOriginalImage().sizeZ();
549 AimsData<T> multiEch(sx, sy, sz, nbScales), tmpIma;
552 for ( ; itscales!=scales.end(); ++itscales)
554 tmpIma=((*itscales).second)->Level();
561 multiEch(x,y,z,t)=tmpIma(x,y,z);
568 multiEch.setSizeXYZT(dx, dy, dz, 1.0);
570 dataW.
write(multiEch);
577 typename std::map<float, ScaleLevel<AimsSurface<D, Void>,
Texture<T> >*>
::iterator itscales=scales.begin();
580 for ( ; itscales!=scales.end(); ++itscales)
582 multiEch[t]=((*itscales).second)->Level();
589 template<
int D,
typename T>
void ScaleSpace<AimsSurface<D, Void>,
Texture<T> >::Write(std::string name)
591 typename std::map<float, ScaleLevel<AimsSurface<D, Void>,
Texture<T> >*>
::iterator itscales=scales.begin();
594 dataW.
write(multiEch);
599 template<
int D,
typename T> std::set<float> ScaleSpace<AimsSurface<D, Void>,
Texture<T> >::GetScaleList()
601 typename std::map<float, ScaleLevel<AimsSurface<D, Void>,
Texture<T> >*>
::iterator itscales=scales.begin();
602 std::set<float> setScales;
603 for ( ; itscales!=scales.end(); ++itscales)
605 setScales.insert((*itscales).first);
612 template<
typename T> std::set<float> ScaleSpace<AimsData<T>,
AimsData<T> >::GetScaleList()
615 std::set<float> setScales;
616 for ( ; itscales!=scales.end(); ++itscales)
618 setScales.insert((*itscales).first);
std::map< float, ScaleLevel< AimsSurface< D, Void >, Texture< T > > * > GetScaleLevels()
ScaleSpace(AimsSurface< D, Void > *mesh, Texture< T > *originalTexture, Smoother< AimsSurface< D, Void >, Texture< T > > *smoother)
AimsSurfaceTriangle * _auxmesh
std::map< float, ScaleLevel< Geom, Text > * > GetScaleLevels()
AIMSDATA_API AimsTimeSurface< 3, Void > AimsSurfaceTriangle
Smoother< AimsData< T >, AimsData< T > > * smoother()
Smoother< AimsSurface< D, Void >, Texture< T > > * _smoother
Smoother< AimsData< T >, AimsData< T > > * _smoother
virtual ~BaseScaleSpace()
void PutAuxMesh(AimsSurfaceTriangle *auxmesh)
std::map< float, ScaleLevel< AimsSurface< D, Void >, Texture< T > > * > scales
void RemoveScale(float t)
void PutCoordinates(std::vector< Point3df > *coord)
Smoother< AimsSurface< D, Void >, Texture< T > > * smoother()
ScaleSpace(AimsData< T > *originalImage, Smoother< AimsData< T >, AimsData< T > > *smoother)
Smoother< Geom, Text > * _smoother
void RemoveScale(float t)
ScaleLevel< AimsSurface< D, Void >, Texture< T > > * Scale(float t)
ScaleLevel< Geom, Text > * Scale(float t)
void PutSmoother(Smoother< AimsData< T >, AimsData< T > > *smoother)
ScaleLevel< AimsData< T >, AimsData< T > > * Scale(float t)
void PutMesh(AimsSurface< D, Void > *mesh)
void GenerateDefaultScaleSpace(float tmax)
void GenerateDefaultScaleSpace(float tmax)
void PutSmoother(Smoother< AimsSurface< D, Void >, Texture< T > > *smoother)
virtual bool write(const T &obj, bool ascii=false, const std::string *format=0)
std::map< float, ScaleLevel< AimsData< T >, AimsData< T > > * > scales
std::map< float, ScaleLevel< AimsData< T >, AimsData< T > > * > GetScaleLevels()
void PutOriginalImage(AimsData< T > *originalImage)
std::map< float, ScaleLevel< Geom, Text > * > scales
void PutOriginalImage(Texture< T > *originalTexture)
std::vector< Point3df > * _coordinates
void GenerateDefaultScaleSpace(float tmax)
void uploadPreviouslyComputedScaleSpace(AimsData< float > &scale_space)
Text & GetOriginalImage()
int get_timediff(float t1, float t2)
Text & GetScaleImage(float t)
void PutSmoother(Smoother< Geom, Text > *blur)
AimsSurfaceTriangle * AuxMesh()
AimsData< T > & GetScaleImage(float t)
AimsSurface< D, Void > * Mesh()
AimsData< T > & GetOriginalImage()
void uploadPreviouslyComputedScaleSpace(TimeTexture< float > &tex)
Texture< T > & GetScaleImage(float t)
Texture< T > & GetOriginalImage()