32 #include "DGtal/base/Common.h"
34 #include "DGtal/io/boards/Board2D.h"
35 #include "DGtal/io/colormaps/HueShadeColorMap.h"
36 #include "DGtal/io/colormaps/GrayscaleColorMap.h"
37 #include "DGtal/io/colormaps/GradientColorMap.h"
38 #include "DGtal/io/colormaps/ColorBrightnessColorMap.h"
40 #include "DGtal/kernel/SpaceND.h"
41 #include "DGtal/kernel/domains/HyperRectDomain.h"
42 #include "DGtal/images/ImageContainerByHashTree.h"
43 #include "DGtal/images/ImageContainerBySTLVector.h"
48 using namespace DGtal;
59 unsigned int nbok = 0;
67 typedef TDomain::Point
Point;
68 typedef Space4Type::Integer
Integer;
73 const Integer t[ ] = { 1, 2, 3 ,4};
74 const Integer t2[ ] = { 5, 5, 3 ,4};
79 Image myImage ( 3, 3,0 );
82 Image myImage2 ( TDomain(a,b) );
87 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
88 <<
"true == true" << std::endl;
101 unsigned int nbok = 0;
106 typedef TDomain::Point Point;
126 Image myImage ( 3, 8, 0 );
128 ImageVector myImageV(TDomain(l,u));
135 for( a[1] = 0; a[1] < 256; a[1]++)
136 for( a[0] = 0; a[0] < 256; a[0]++)
138 if ( pow((
double)(a[0]-128),3.0) - pow((
double)(a[1]-128),3.0) < pow(32.0,3.0))
140 myImage.setValue(a, 30);
141 myImageV.setValue(a,30);
145 if ( pow((
double)(a[0]-128),3.0) - pow((
double)(a[1]-128),3.0) < pow(64.0,3.0))
147 myImage.setValue(a, 10);
148 myImageV.setValue(a,10);
156 for( a[1] = 0; a[1] < 256; a[1]++)
157 for( a[0] = 0; a[0] < 256; a[0]++)
159 if ( pow((a[0]-128),3.0) - pow((a[1]-128),3.0) < pow(32,3.0))
160 result = result && (myImage(a) == 30);
162 if ( pow((a[0]-128),3.0) - pow((a[1]-128),3.0) < pow(64,3.0))
163 result = result && (myImage(a) == 10);
168 trace.
info() <<
"Get/Set test passed"<<endl;
171 nbok += result ? 1 : 0;
177 Display2DFactory::drawImageHashTree<HueTwice>(board, myImage, 0, 255);
178 board.saveSVG(
"hashtree.svg" );
180 Display2DFactory::drawImage<HueTwice>(board, myImageV, 0, 255);
181 board.saveSVG(
"hashtree-vector.svg" );
185 Image myImage2 ( 5, 8, 0 );
188 for( a[1] = 0; a[1] < 256; a[1]++)
189 for( a[0] = 0; a[0] < 256; a[0]++)
191 if ( pow((a[0]-128),3.0) - pow((a[1]-128),3.0) < pow(32,3.0))
192 myImage2.setValue(a, 30);
194 if ( pow((a[0]-128),3.0) - pow((a[1]-128),3.0) < pow(64,3.0))
195 myImage2.setValue(a, 10);
202 for( a[1] = 0; a[1] < 256; a[1]++)
203 for( a[0] = 0; a[0] < 256; a[0]++)
205 if ( pow((a[0]-128),3.0) - pow((a[1]-128),3.0) < pow(32,3.0))
206 result = result && (myImage2(a) == 30);
208 if ( pow((a[0]-128),3.0) - pow((a[1]-128),3.0) < pow(64,3.0))
209 result = result && (myImage2(a) == 10);
214 trace.
info() <<
"Get/Set test passed"<<endl;
217 nbok += result ? 1 : 0;
221 <<
"true == true" << std::endl;
228 bool testBadKeySizes()
232 typedef TDomain::Point Point;
235 board.
setUnit(Board2D::UCentimeter);
242 trace.
beginBlock (
"Test maximal depth > number of bits of the HashKey type" );
243 Image myImage ( 3, 80, 0 );
247 trace.
beginBlock (
"Test morton hash size > number of bits of the HashKey type" );
256 Image2 myImage3( 3, 80, 0 );
267 int main(
int argc,
char** argv )
271 for (
int i = 0; i < argc; ++i )
275 bool res = testHashTree() && testGetSetVal() && testBadKeySizes();
276 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;