Example of a test. To be completed.
52{
53 unsigned int nbok = 0;
54 unsigned int nb = 0;
55
56 DGtal::trace.beginBlock (
"Testing 2D/3D Image Reader" );
57
60
61#ifdef DGTAL_WITH_ITK
63 Image3D16bits;
64#endif
65
69
70
71 std::string filenameImage1 = testPath + "samples/cat10.vol";
77 DGtal::trace.info()<<
"Vol image read: size[0]:" << size0Img1 ;
79 DGtal::trace.info()<<
"size[2]: " << size2Img1 << std::endl;
80 nbok += (size0Img1==40 && size1Img1==40 && size2Img1==40) ? 1 : 0;
81 nb++;
82 std::string filenameImage0 = testPath + "samples/test.longvol";
88 DGtal::trace.info()<<
"Longvol image read: size[0]:" << size0Img0 ;
90 DGtal::trace.info()<<
"size[2]: " << size2Img0 << std::endl;
91 nbok += (size0Img0==16 && size1Img0==16 && size2Img0==16) ? 1 : 0;
92 nb++;
93 std::string filenameImage2 = testPath + "samples/cat10.pgm3d";
99 DGtal::trace.info()<<
"Pgm3D image read: size[0]:" << size0Img2 ;
101 DGtal::trace.info()<<
"size[2]: " << size2Img2 << std::endl;;
102 nbok += (size0Img2==40 && size1Img2==40 && size2Img2==40) ? 1 : 0;
103 nb++;
104
107 0, 255) );
108 domain2 = anImportedImage2.domain();
112 DGtal::trace.info()<<
"Pgm3D image read (with scale functor) : size[0]:" << size0Img2 ;
114 DGtal::trace.info()<<
"size[2]: " << size2Img2 << std::endl;;
115 nbok += (size0Img2==40 && size1Img2==40 && size2Img2==40) ? 1 : 0;
116 nb++;
117
118
119#ifdef DGTAL_WITH_HDF5
120 std::string filenameImageh5 = testPath + "samples/cat10.h5";
126 DGtal::trace.info()<<
"HDF5 3D image read: size[0]:" << size0Imgh5;
128 DGtal::trace.info()<<
"size[2]: " << size2Imgh5 << std::endl;;
129 nbok += (size0Imgh5==40 && size1Imgh5==40 && size2Imgh5==40) ? 1 : 0;
130 nb++;
131#endif
132 std::string filenameImage3 = testPath + "samples/contourS.pgm";
137
138 DGtal::trace.info()<<
"Pgm image read: size[0]:" << size0Img3 ;
139 DGtal::trace.info()<<
"size[1]: " << size1Img3 << std::endl;;
140 nbok += (size0Img3==185 && size1Img3==85 ) ? 1 : 0;
141 nb++;
142
143 std::string filenameImage4 = testPath + "samples/raw32bits5x5x5.raw";
149 DGtal::trace.info()<<
"Raw32 bits 3D image read: size[0]:" << size0Img4;
151 DGtal::trace.info()<<
"size[2]: " << size2Img4 << std::endl;
152 DGtal::trace.info()<<
"Image value of Point (2,3,4): " << anImportedImage4(
DGtal::Z3i::Point(2,3,4)) <<
" (should be 250000*2*3*4) "<<std::endl;
153 nbok += (size0Img4==5 && size1Img4==5 && size2Img4==5 && anImportedImage4(
DGtal::Z3i::Point(2,3,4))==250000*2*3*4) ? 1 : 0;
154 nb++;
155
156 std::string filenameImage5 = testPath + "samples/raw32bits5x5.raw";
161 DGtal::trace.info()<<
"Raw32 bits 3D image read: size[0]:" << size0Img4;
162 DGtal::trace.info()<<
"size[1]: " << size1Img5 << std::endl;
164 nbok += (size0Img5==5 && size1Img5==5 && anImportedImage5(
DGtal::Z2i::Point(2,3))==250000*2*3*4) ? 1 : 0;
165 nb++;
166
167#ifdef DGTAL_WITH_ITK
168 std::string filenameImage6 = testPath + "samples/lobsterCroped16b.mhd";
170 RescalFCT2 resc2 = RescalFCT2( 0, 65535, 0, 255 );
171 Image3D anImportedImage6 =
173 resc2 );
175 unsigned int size0Img6 =
177 unsigned int size1Img6 =
179 unsigned int size2Img6 =
181
182 DGtal::trace.info() <<
"mhd 16 bits 3D image read: size[0]:" << size0Img6;
183 DGtal::trace.info() <<
"size[1]: " << size1Img6 << std::endl;
184 DGtal::trace.info() <<
"Image value of Point (35,29, 3): "
186 << " (should be" << resc2( 60400 ) << std::endl;
187 nbok +=
188 ( size0Img6 == 51 && size1Img6 == 91 && size2Img6 == 31 &&
190 ? 1
191 : 0;
192 nb++;
193
194 Image3D16bits anImportedImage7 =
196 DGtal::trace.info() <<
"Image value of Point (35,29, 3): "
198 << " (should be" << 60400 << " )" << std::endl;
199 nbok +=
201 nb++;
202#endif
203
204 DGtal::trace.info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
206
207 return nbok == nb;
208}
const Point & lowerBound() const
const Point & upperBound() const
HyperRectDomain< Space > Domain
HyperRectDomain< Space > Domain
static TContainer import(const std::string &filename, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
static TContainer importWithValueFunctor(const std::string &filename, const TFunctor &aFunctor, std::vector< unsigned int > dimSpace=std::vector< unsigned int >())
Aim: Functor allowing to rescale a value. Values of the initial scale [initMin,initMax] are rescaled ...