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>
93 std::map<float, ScaleLevel<Geom, Text>*>
scales;
120 {
float t;
for (t=1; t<=tmax; t=t*2) { std::cout <<
"Adding scale " << t << std::endl;
AddScale(t); } }
148 {
PutSmoother(smoother); PutOriginalImage(originalImage); }
185 for ( t = 1 ; t <= tmax ; t = t*2 ) {
186 std::cout <<
"Adding scale " << t << std::endl;
189 std::cout <<
"Adding scale" << tmax << std::endl;
195 void Write(std::string name);
200 std::cout <<
"Adding scale " << t << std::flush;
205 scale( x, y, z, 0 ) = scale_space( x, y, z, i );
208 std::cout <<
" OK" << std::endl;
216 template<
int D,
typename T>
231 _smoother=NULL; _auxmesh=NULL; _coordinates=NULL;
240 PutOriginalImage(originalTexture);
249 for (
uint i = 1 ; i < tex.size() ; i++ ) {
250 std::cout <<
"Adding scale " << t << std::flush;
253 std::cout <<
" OK" << std::endl;
295 for (t=1; t<=tmax; t=t*2)
297 std::cout <<
"Adding scale " << t << std::endl;
300 std::cout <<
"Checking last scale level : " << tmax << std::endl;
307 void Write(std::string name);
318 if (scales.find(t) == scales.end())
329 std::cout <<
"Scale " << t <<
" already computed... " << std::endl;
337 if (scales.find(t) == scales.end())
348 std::cout <<
"Scale " << t <<
" already computed... " << std::endl;
355 if (scales.find(t) == scales.end())
357 if (!(_smoother->optimal()))
359 std::cout <<
"Smoothing from original image" << std::endl;
360 int time = this->get_timediff(0, t);
369 std::cout <<
"Smoothing from previous scale " << std::flush;
371 float tlow = 0.0f, tmax = 0.0f;
375 for ( ; itS!=scales.end(); ++itS)
385 for ( ; itscales != scales.end(); ++itscales)
387 if ((*itscales).first >= tmax)
392 imageLow=nivEch->Level();
399 for ( ; itnext != scales.end(); ++itscales)
403 if (((*itscales).first < t) && ((*itnext).first > t))
405 tlow=(*itscales).first;
407 imageLow=nivEch->Level();
412 std::cout <<
"t=" << tlow <<
", image: " << imageLow.
getSizeX() <<
"x" << imageLow.
getSizeY() <<
"x" << imageLow.
getSizeZ() <<
"x" << imageLow.
getSizeT() << std::endl;
414 int time = this->get_timediff(tlow, t);
430 if (scales.find(t) == scales.end())
432 if (!(_smoother->optimal()))
434 std::cout <<
"Smoothing from original image" << std::endl;
435 int time = this->get_timediff(0, t);
436 Texture<T> lisse=_smoother->doSmoothing(GetOriginalImage(), time);
443 std::cout <<
"Smoothing from previous scale " << std::flush;
445 float tlow = 0.0f, tmax = 0.0f;
448 for ( ; itS!=scales.end(); ++itS)
456 itscales = scales.begin();
459 for ( ; itscales != scales.end(); ++itscales)
461 if ((*itscales).first >= tmax)
468 imageLow=nivEch->Level();
473 itscales = scales.begin();
477 for ( ; itnext != scales.end(); ++itscales)
482 if (((*itscales).first < t) && ((*itnext).first > t))
484 tlow=(*itscales).first;
486 imageLow=nivEch->Level();
491 std::cout <<
"t = " << tlow << std::endl;
493 int time = this->get_timediff(tlow, t);
495 Texture<T> lisse = _smoother->doSmoothing(imageLow, time);
504 std::cout <<
"Scale " << t <<
" already computed... " << std::endl;
516 if ((itscales=scales.find(t)) != scales.end())
519 dataW.
write(((*itscales).second)->Level());
523 std::cout <<
"Can't write scale " << t <<
" that does not exist..." << std::endl;
532 if ((itscales=scales.find(t)) != scales.end())
540 std::cout <<
"Can't write scale " << t <<
" that does not exist..." << std::endl;
549 int nbScales=scales.size();
550 int sx=GetOriginalImage().getSizeX(), sy=GetOriginalImage().getSizeY(), sz=GetOriginalImage().getSizeZ(), x, y, z;
554 for ( ; itscales!=scales.end(); ++itscales)
556 tmpIma=((*itscales).second)->Level();
563 multiEch(x,y,z,t)=tmpIma(x,y,z);
570 multiEch.setVoxelSize(GetOriginalImage().getVoxelSize());
572 dataW.
write(multiEch);
579 typename std::map<float, ScaleLevel<AimsSurface<D, Void>,
Texture<T> >*>
::iterator itscales=scales.begin();
582 for ( ; itscales!=scales.end(); ++itscales)
584 multiEch[t]=((*itscales).second)->Level();
593 typename std::map<float, ScaleLevel<AimsSurface<D, Void>,
Texture<T> >*>
::iterator itscales=scales.begin();
596 dataW.
write(multiEch);
603 typename std::map<float, ScaleLevel<AimsSurface<D, Void>,
Texture<T> >*>
::iterator itscales=scales.begin();
604 std::set<float> setScales;
605 for ( ; itscales!=scales.end(); ++itscales)
607 setScales.insert((*itscales).first);
617 std::set<float> setScales;
618 for ( ; itscales!=scales.end(); ++itscales)
620 setScales.insert((*itscales).first);
virtual ~BaseScaleSpace()
int get_timediff(float t1, float t2)
void PutMesh(AimsSurface< D, Void > *mesh)
Smoother< AimsSurface< D, Void >, Texture< T > > * _smoother
std::map< float, ScaleLevel< AimsSurface< D, Void >, Texture< T > > * > scales
void uploadPreviouslyComputedScaleSpace(TimeTexture< float > &tex)
ScaleSpace(AimsSurface< D, Void > *mesh, Texture< T > *originalTexture, Smoother< AimsSurface< D, Void >, Texture< T > > *smoother)
AimsSurface< D, Void > * _mesh
void GenerateDefaultScaleSpace(float tmax)
std::map< float, ScaleLevel< AimsSurface< D, Void >, Texture< T > > * > GetScaleLevels()
Texture< T > & GetOriginalImage()
std::vector< Point3df > * _coordinates
Smoother< AimsSurface< D, Void >, Texture< T > > * smoother()
void PutOriginalImage(Texture< T > *originalTexture)
void RemoveScale(float t)
void PutAuxMesh(AimsSurfaceTriangle *auxmesh)
ScaleLevel< AimsSurface< D, Void >, Texture< T > > * Scale(float t)
AimsSurfaceTriangle * _auxmesh
void PutSmoother(Smoother< AimsSurface< D, Void >, Texture< T > > *smoother)
AimsSurface< D, Void > * Mesh()
Texture< T > & GetScaleImage(float t)
AimsSurfaceTriangle * AuxMesh()
void PutCoordinates(std::vector< Point3df > *coord)
Smoother< carto::VolumeRef< T >, carto::VolumeRef< T > > * smoother()
std::map< float, ScaleLevel< carto::VolumeRef< T >, carto::VolumeRef< T > > * > scales
ScaleSpace(carto::VolumeRef< T > *originalImage, Smoother< carto::VolumeRef< T >, carto::VolumeRef< T > > *smoother)
ScaleLevel< carto::VolumeRef< T >, carto::VolumeRef< T > > * Scale(float t)
carto::VolumeRef< T > & GetScaleImage(float t)
Smoother< carto::VolumeRef< T >, carto::VolumeRef< T > > * _smoother
carto::VolumeRef< T > & GetOriginalImage()
void uploadPreviouslyComputedScaleSpace(carto::VolumeRef< float > &scale_space)
void PutOriginalImage(carto::VolumeRef< T > *originalImage)
void PutSmoother(Smoother< carto::VolumeRef< T >, carto::VolumeRef< T > > *smoother)
void GenerateDefaultScaleSpace(float tmax)
void RemoveScale(float t)
std::map< float, ScaleLevel< carto::VolumeRef< T >, carto::VolumeRef< T > > * > GetScaleLevels()
Smoother< Geom, Text > * _smoother
Text & GetScaleImage(float t)
std::map< float, ScaleLevel< Geom, Text > * > scales
void RemoveScale(float t)
void GenerateDefaultScaleSpace(float tmax)
std::set< float > GetScaleList()
void PutSmoother(Smoother< Geom, Text > *blur)
ScaleLevel< Geom, Text > * Scale(float t)
Text & GetOriginalImage()
void WriteScaleSpace(std::string name)
void WriteScale(float t, std::string name)
std::map< float, ScaleLevel< Geom, Text > * > GetScaleLevels()
virtual bool write(const T &obj, bool ascii=false, const std::string *format=0)
AIMSDATA_API AimsTimeSurface< 3, Void > AimsSurfaceTriangle