41#include "DGtal/base/Common.h"
42#include "DGtal/helpers/StdDefs.h"
43#include "DGtal/images/ImageSelector.h"
44#include "DGtal/images/ImageFactoryFromImage.h"
45#include "DGtal/images/ImageFactoryFromHDF5.h"
46#include "DGtal/images/ImageCache.h"
47#include "DGtal/images/TiledImage.h"
49#include "ConfigExamples.h"
57#define H5FILE_NAME_3D_TILED "exampleImageFactoryFromHDF5_TILED_3D.h5"
59#define DATASETNAME_3D "UInt8Array3D"
60#define NX_3D_TILED 300
61#define NY_3D_TILED 300
62#define NZ_3D_TILED 300
63#define CHUNK_X_3D_TILED 50
64#define CHUNK_Y_3D_TILED 50
65#define CHUNK_Z_3D_TILED 50
66#define RANK_3D_TILED 3
75 hid_t datatype, dataspace;
98 if (i>=15 && j>=15 && k>=15 && i<35 && j<35 && k<35)
117 plist_id = H5Pcreate (H5P_DATASET_CREATE);
126 trace.
error() <<
" H5Dchunck error" << std::endl;
139 status = H5Pset_deflate (plist_id, 6);
142 trace.
error() <<
" H5Ddeflate error" << std::endl;
151 datatype = H5Tcopy(H5T_NATIVE_UINT8);
152 status = H5Tset_order(datatype, H5T_ORDER_LE);
155 trace.
error() <<
" H5Dsetorder error" << std::endl;
165 H5P_DEFAULT, plist_id, H5P_DEFAULT);
168 status = H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
171 trace.
error() <<
" H5Dwrite error" << std::endl;
202 typedef ImageV::Domain DomainV;
203 typedef ImageV::Point PointV;
205 ImageV imageV(domainV);
210 if (i>=15 && j>=15 && k>=15 && i<35 && j<35 && k<35)
211 imageV.setValue(PointV(i,j,k), 1);
213 imageV.setValue(PointV(i,j,k), 0);
217 for(ImageV::Domain::ConstIterator it = imageV.domain().begin(), itend = imageV.domain().end();
219 if (imageV( *it ) == 1)
221 trace.
info() <<
"imageV cpt: " << cpt << endl;
226 for(ImageV::Range::ConstIterator it = imageV.range().begin(), itend = imageV.range().end();
230 trace.
info() <<
"imageV cpt: " << cpt << endl;
243 trace.
beginBlock(
"Example : TiledImage with ImageFactoryFromImage - 1 block (3D)");
246 typedef ImageV::Domain DomainV;
247 typedef ImageV::Point PointV;
249 ImageV imageV(domainV);
254 if (i>=15 && j>=15 && k>=15 && i<35 && j<35 && k<35)
255 imageV.setValue(PointV(i,j,k), 1);
257 imageV.setValue(PointV(i,j,k), 0);
260 MyImageFactoryFromImage factImage(imageV);
262 typedef MyImageFactoryFromImage::OutputImage OutputImage;
268 MyImageCacheReadPolicyLAST imageCacheReadPolicyLAST(factImage);
269 MyImageCacheWritePolicyWT imageCacheWritePolicyWT(factImage);
273 MyTiledImage tiledImage1block(factImage, imageCacheReadPolicyLAST, imageCacheWritePolicyWT, 1);
275 typedef MyTiledImage::OutputImage OutputImage;
278 trace.
info() << tiledImage1block << std::endl;
281 trace.
beginBlock(
"Counting ones in the tiled image - 1x1x1 blocks - LAST/WT - TiledIterator");
282 for(MyTiledImage::TiledIterator it = tiledImage1block.begin(), itend = tiledImage1block.end();
286 trace.
info() <<
"Cpt: " << cpt <<
" - cacheMissRead:" << tiledImage1block.getCacheMissRead() <<
" - cacheMissWrite:" << tiledImage1block.getCacheMissWrite() << endl;
289 cpt=0; tiledImage1block.clearCacheAndResetCacheMisses();
290 trace.
beginBlock(
"Counting ones in the tiled image - 1x1x1 blocks - LAST/WT");
291 for(ImageV::Domain::ConstIterator it = tiledImage1block.domain().begin(), itend = tiledImage1block.domain().end();
293 if (tiledImage1block(*it) == 1)
295 trace.
info() <<
"Cpt: " << cpt <<
" - cacheMissRead:" << tiledImage1block.getCacheMissRead() <<
" - cacheMissWrite:" << tiledImage1block.getCacheMissWrite() << endl;
306 trace.
beginBlock(
"Example : TiledImage with ImageFactoryFromHDF5 - 1 block (3D)");
313 typedef MyImageFactoryFromHDF5::OutputImage OutputImage;
319 MyImageCacheReadPolicyLAST imageCacheReadPolicyLAST(factImage);
320 MyImageCacheWritePolicyWT imageCacheWritePolicyWT(factImage);
324 MyTiledImage tiledImage1block(factImage, imageCacheReadPolicyLAST, imageCacheWritePolicyWT, 1);
326 typedef MyTiledImage::OutputImage OutputImage;
329 trace.
info() << tiledImage1block << std::endl;
332 trace.
beginBlock(
"Counting ones in the tiled image - 1x1x1 blocks - LAST/WT - TiledIterator");
333 for(MyTiledImage::TiledIterator it = tiledImage1block.begin(), itend = tiledImage1block.end();
337 trace.
info() <<
"Cpt: " << cpt <<
" - cacheMissRead:" << tiledImage1block.getCacheMissRead() <<
" - cacheMissWrite:" << tiledImage1block.getCacheMissWrite() << endl;
340 cpt=0; tiledImage1block.clearCacheAndResetCacheMisses();
341 trace.
beginBlock(
"Counting ones in the tiled image - 1x1x1 blocks - LAST/WT");
344 if (tiledImage1block(*it) == 1)
346 trace.
info() <<
"Cpt: " << cpt <<
" - cacheMissRead:" << tiledImage1block.getCacheMissRead() <<
" - cacheMissWrite:" << tiledImage1block.getCacheMissWrite() << endl;
359 trace.
beginBlock(
"Example : TiledImage with ImageFactoryFromImage - 10 blocks (3D)");
362 typedef ImageV::Domain DomainV;
363 typedef ImageV::Point PointV;
365 ImageV imageV(domainV);
370 if (i>=15 && j>=15 && k>=15 && i<35 && j<35 && k<35)
371 imageV.setValue(PointV(i,j,k), 1);
373 imageV.setValue(PointV(i,j,k), 0);
376 MyImageFactoryFromImage factImage(imageV);
378 typedef MyImageFactoryFromImage::OutputImage OutputImage;
383 MyImageCacheReadPolicyFIFO imageCacheReadPolicyFIFO_A(factImage, 10);
384 MyImageCacheReadPolicyFIFO imageCacheReadPolicyFIFO_B(factImage, 5);
385 MyImageCacheReadPolicyLAST imageCacheReadPolicyLAST(factImage);
386 MyImageCacheWritePolicyWT imageCacheWritePolicyWT(factImage);
390 MyTiledImage tiledImage(factImage, imageCacheReadPolicyLAST, imageCacheWritePolicyWT, 10);
394 MyTiledImageFIFO tiledImageFIFO_A(factImage, imageCacheReadPolicyFIFO_A, imageCacheWritePolicyWT, 10);
395 MyTiledImageFIFO tiledImageFIFO_B(factImage, imageCacheReadPolicyFIFO_B, imageCacheWritePolicyWT, 10);
397 typedef MyTiledImage::OutputImage OutputImage;
401 trace.
beginBlock(
"Counting ones in the tiled image - 10x10x10 blocks - FIFO(10)/WT - TiledIterator");
402 for(MyTiledImageFIFO::TiledIterator it = tiledImageFIFO_A.begin(), itend = tiledImageFIFO_A.end();
410 cpt=0; tiledImageFIFO_A.clearCacheAndResetCacheMisses();
411 trace.
beginBlock(
"Counting ones in the tiled image - 10x10x10 blocks - FIFO(10)/WT");
412 for(ImageV::Domain::ConstIterator it = tiledImageFIFO_A.domain().begin(), itend = tiledImageFIFO_A.domain().end();
415 if (tiledImageFIFO_A(*it) == 1)
423 trace.
beginBlock(
"Counting ones in the tiled image - 10x10x10 blocks - FIFO(5)/WT - TiledIterator");
424 for(MyTiledImageFIFO::TiledIterator it = tiledImageFIFO_B.begin(), itend = tiledImageFIFO_B.end();
432 cpt=0; tiledImageFIFO_B.clearCacheAndResetCacheMisses();
433 trace.
beginBlock(
"Counting ones in the tiled image - 10x10x10 blocks - FIFO(5)/WT");
434 for(ImageV::Domain::ConstIterator it = tiledImageFIFO_B.domain().begin(), itend = tiledImageFIFO_B.domain().end();
437 if (tiledImageFIFO_B(*it) == 1)
445 trace.
beginBlock(
"Counting ones in the tiled image - 10x10x10 blocks - LAST/WT - TiledIterator");
446 for(MyTiledImage::TiledIterator it = tiledImage.begin(), itend = tiledImage.end();
454 cpt=0; tiledImage.clearCacheAndResetCacheMisses();
455 trace.
beginBlock(
"Counting ones in the tiled image - 10x10x10 blocks - LAST/WT");
456 for(ImageV::Domain::ConstIterator it = tiledImage.domain().begin(), itend = tiledImage.domain().end();
459 if (tiledImage(*it) == 1)
472 trace.
beginBlock(
"Example : TiledImage with ImageFactoryFromHDF5 - 10 blocks (3D)");
479 typedef MyImageFactoryFromHDF5::OutputImage OutputImage;
484 MyImageCacheReadPolicyFIFO imageCacheReadPolicyFIFO_A(factImage, 10);
485 MyImageCacheReadPolicyFIFO imageCacheReadPolicyFIFO_B(factImage, 5);
486 MyImageCacheReadPolicyLAST imageCacheReadPolicyLAST(factImage);
487 MyImageCacheWritePolicyWT imageCacheWritePolicyWT(factImage);
491 MyTiledImage tiledImage(factImage, imageCacheReadPolicyLAST, imageCacheWritePolicyWT, 10);
495 MyTiledImageFIFO tiledImageFIFO_A(factImage, imageCacheReadPolicyFIFO_A, imageCacheWritePolicyWT, 10);
496 MyTiledImageFIFO tiledImageFIFO_B(factImage, imageCacheReadPolicyFIFO_B, imageCacheWritePolicyWT, 10);
498 typedef MyTiledImage::OutputImage OutputImage;
502 trace.
beginBlock(
"Counting ones in the tiled image - 10x10x10 blocks - FIFO(10)/WT - TiledIterator");
503 for(MyTiledImageFIFO::TiledIterator it = tiledImageFIFO_A.begin(), itend = tiledImageFIFO_A.end();
511 cpt=0; tiledImageFIFO_A.clearCacheAndResetCacheMisses();
512 trace.
beginBlock(
"Counting ones in the tiled image - 10x10x10 blocks - FIFO(10)/WT");
516 if (tiledImageFIFO_A(*it) == 1)
524 trace.
beginBlock(
"Counting ones in the tiled image - 10x10x10 blocks - FIFO(5)/WT - TiledIterator");
525 for(MyTiledImageFIFO::TiledIterator it = tiledImageFIFO_B.begin(), itend = tiledImageFIFO_B.end();
533 cpt=0; tiledImageFIFO_B.clearCacheAndResetCacheMisses();
534 trace.
beginBlock(
"Counting ones in the tiled image - 10x10x10 blocks - FIFO(5)/WT");
538 if (tiledImageFIFO_B(*it) == 1)
546 trace.
beginBlock(
"Counting ones in the tiled image - 10x10x10 blocks - LAST/WT - TiledIterator");
547 for(MyTiledImage::TiledIterator it = tiledImage.begin(), itend = tiledImage.end();
555 cpt=0; tiledImage.clearCacheAndResetCacheMisses();
556 trace.
beginBlock(
"Counting ones in the tiled image - 10x10x10 blocks - LAST/WT");
560 if (tiledImage(*it) == 1)
Aim: implements a 'FIFO' read policy cache.
Aim: implements a 'LAST' read policy cache.
Aim: implements a 'WT (Write-through)' write policy cache.
std::vector< Value >::const_iterator ConstIterator
Aim: implements a factory from an HDF5 file.
Aim: implements a factory to produce images from a "bigger/original" one according to a given domain.
Aim: implements association bewteen points lying in a digital domain and values.
Aim: implements a tiled image from a "bigger/original" one from an ImageFactory.
void beginBlock(const std::string &keyword="")
bool exampleTiledImageFromHDF5_1block3D()
bool writeHDF5_3D_TILED()
bool exampleTiledImageFromImage_10blocks3D()
#define H5FILE_NAME_3D_TILED
bool exampleTiledImageFromImage_1block3D()
bool exampleTiledImageFromHDF5_10blocks3D()
DGtal is the top-level namespace which contains all DGtal functions and types.
boost::uint8_t uint8_t
unsigned 8-bit integer.
Aim: Defines the concept describing a read/write image, having an output iterator.