35#ifndef AIMS_PRIMALSKETCH_SCALESPACE_H
36#define AIMS_PRIMALSKETCH_SCALESPACE_H
42#include <aims/mesh/surface.h>
43#include <aims/mesh/texture.h>
44#include <cartodata/volume/volume.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); } }
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>
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);
329 std::cout <<
"Scale " << t <<
" already computed... " << std::endl;
348 std::cout <<
"Scale " << t <<
" already computed... " << std::endl;
359 std::cout <<
"Smoothing from original image" << std::endl;
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;
434 std::cout <<
"Smoothing from original image" << std::endl;
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;
504 std::cout <<
"Scale " << t <<
" already computed... " << std::endl;
519 dataW.
write(((*itscales).second)->Level());
523 std::cout <<
"Can't write scale " << t <<
" that does not exist..." << std::endl;
540 std::cout <<
"Can't write scale " << t <<
" that does not exist..." << std::endl;
549 int nbScales=
scales.size();
554 for ( ; itscales!=
scales.end(); ++itscales)
556 tmpIma=((*itscales).second)->Level();
563 multiEch(x,y,z,t)=tmpIma(x,y,z);
572 dataW.
write(multiEch);
582 for ( ; itscales!=
scales.end(); ++itscales)
584 multiEch[t]=((*itscales).second)->Level();
596 dataW.
write(multiEch);
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)
std::set< float > GetScaleList()
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)
Texture< T > & GetScaleImage(float t)
TimeTexture< T > getScaleSpaceTexture()
Texture< T > & GetOriginalImage()
std::vector< Point3df > * _coordinates
void PutOriginalImage(Texture< T > *originalTexture)
void RemoveScale(float t)
void PutAuxMesh(AimsSurfaceTriangle *auxmesh)
AimsSurface< D, Void > * Mesh()
void WriteScale(float t, std::string name)
AimsSurfaceTriangle * AuxMesh()
std::map< float, ScaleLevel< AimsSurface< D, Void >, Texture< T > > * > GetScaleLevels()
Smoother< AimsSurface< D, Void >, Texture< T > > * smoother()
void Write(std::string name)
AimsSurfaceTriangle * _auxmesh
void PutSmoother(Smoother< AimsSurface< D, Void >, Texture< T > > *smoother)
ScaleLevel< AimsSurface< D, Void >, Texture< T > > * Scale(float t)
void PutCoordinates(std::vector< Point3df > *coord)
void WriteScale(float t, std::string name)
carto::VolumeRef< T > & GetOriginalImage()
std::map< float, ScaleLevel< carto::VolumeRef< T >, carto::VolumeRef< T > > * > scales
ScaleSpace(carto::VolumeRef< T > *originalImage, Smoother< carto::VolumeRef< T >, carto::VolumeRef< T > > *smoother)
std::set< float > GetScaleList()
Smoother< carto::VolumeRef< T >, carto::VolumeRef< T > > * _smoother
Smoother< carto::VolumeRef< T >, carto::VolumeRef< T > > * smoother()
void uploadPreviouslyComputedScaleSpace(carto::VolumeRef< float > &scale_space)
carto::VolumeRef< T > & GetScaleImage(float t)
void PutOriginalImage(carto::VolumeRef< T > *originalImage)
std::map< float, ScaleLevel< carto::VolumeRef< T >, carto::VolumeRef< T > > * > GetScaleLevels()
void PutSmoother(Smoother< carto::VolumeRef< T >, carto::VolumeRef< T > > *smoother)
ScaleLevel< carto::VolumeRef< T >, carto::VolumeRef< T > > * Scale(float t)
void GenerateDefaultScaleSpace(float tmax)
void RemoveScale(float t)
void Write(std::string name)
std::set< float > GetScaleList()
ScaleLevel< Geom, Text > * Scale(float t)
Smoother< Geom, Text > * _smoother
std::map< float, ScaleLevel< Geom, Text > * > scales
void RemoveScale(float t)
void GenerateDefaultScaleSpace(float tmax)
Text & GetOriginalImage()
std::map< float, ScaleLevel< Geom, Text > * > GetScaleLevels()
void PutSmoother(Smoother< Geom, Text > *blur)
void WriteScaleSpace(std::string name)
void WriteScale(float t, std::string name)
Text & GetScaleImage(float t)
virtual bool write(const T &obj, bool ascii=false, const std::string *format=0)
void setVoxelSize(float vx, float vy=1., float vz=1., float vt=1.)
AIMSDATA_API AimsTimeSurface< 3, Void > AimsSurfaceTriangle