32#include "DGtal/base/Common.h"
33#include "DGtal/helpers/StdDefs.h"
35#include "DGtal/images/ImageContainerBySTLVector.h"
36#include "DGtal/images/ImageFactoryFromImage.h"
37#include "DGtal/images/TiledImage.h"
39#include "ConfigTest.h"
50 unsigned int nbok = 0;
59 for (VImage::Iterator it = image.begin(); it != image.end(); ++it)
62 trace.
info() <<
"ORIGINAL image: " << image << endl;
65 typedef MyImageFactoryFromImage::OutputImage OutputImage;
66 MyImageFactoryFromImage imageFactoryFromImage(image);
70 MyImageCacheReadPolicyFIFO imageCacheReadPolicyFIFO(imageFactoryFromImage, 2);
71 MyImageCacheWritePolicyWT imageCacheWritePolicyWT(imageFactoryFromImage);
75 MyTiledImage tiledImage(imageFactoryFromImage, imageCacheReadPolicyFIFO, imageCacheWritePolicyWT, 4);
77 typedef MyTiledImage::OutputImage OutputImage;
78 OutputImage::Value aValue;
81 nbok += (tiledImage(
Z2i::Point(4,2)) == 20) ? 1 : 0;
84 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
87 nbok += (tiledImage(
Z2i::Point(10,6)) == 90) ? 1 : 0;
90 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
92 aValue = 1; tiledImage.setValue(
Z2i::Point(11,7), aValue);
93 trace.
info() <<
"Write value for Point 11,7: " << aValue << endl;
94 nbok += (tiledImage(
Z2i::Point(11,7)) == 1) ? 1 : 0;
97 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
100 nbok += (tiledImage(
Z2i::Point(2,3)) == 34) ? 1 : 0;
103 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
106 nbok += (tiledImage(
Z2i::Point(16,1)) == 16) ? 1 : 0;
109 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
111 aValue = 128; tiledImage.setValue(
Z2i::Point(16,1), aValue);
112 trace.
info() <<
"Write value for Point 16,1: " << aValue << endl;
113 nbok += (tiledImage(
Z2i::Point(16,1)) == 128) ? 1 : 0;
116 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
118 trace.
info() <<
" Point 16,1 on ORIGINAL image, value: " << image(
Z2i::Point(16,1)) << endl;
119 nbok += (image(
Z2i::Point(16,1)) == 128) ? 1 : 0;
122 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
131 unsigned int nbok = 0;
140 for (VImage::Iterator it = image.begin(); it != image.end(); ++it)
143 trace.
info() <<
"ORIGINAL image: " << image << endl;
146 typedef MyImageFactoryFromImage::OutputImage OutputImage;
147 MyImageFactoryFromImage imageFactoryFromImage(image);
151 MyImageCacheReadPolicyFIFO imageCacheReadPolicyFIFO(imageFactoryFromImage, 2);
152 MyImageCacheWritePolicyWT imageCacheWritePolicyWT(imageFactoryFromImage);
156 MyTiledImage tiledImage(imageFactoryFromImage, imageCacheReadPolicyFIFO, imageCacheWritePolicyWT, 4);
158 typedef MyTiledImage::OutputImage OutputImage;
161 nbok += (tiledImage(
Z3i::Point(1,1,1)) == 1) ? 1 : 0;
164 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
167 nbok += (tiledImage(
Z3i::Point(4,4,4)) == 64) ? 1 : 0;
170 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
173 nbok += (tiledImage(
Z3i::Point(4,3,2)) == 28) ? 1 : 0;
176 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
185 unsigned int nbok = 0;
192 for (VImage::Iterator it = image.begin(); it != image.end(); ++it)
194 trace.
info() <<
"ORIGINAL image: " << image << endl;
196 typedef MyImageFactoryFromImage::OutputImage OutputImage;
197 MyImageFactoryFromImage imageFactoryFromImage(image);
201 MyImageCacheReadPolicyFIFO imageCacheReadPolicyFIFO(imageFactoryFromImage, 2);
202 MyImageCacheWritePolicyWT imageCacheWritePolicyWT(imageFactoryFromImage);
206 MyTiledImage tiledImage(imageFactoryFromImage, imageCacheReadPolicyFIFO, imageCacheWritePolicyWT, 4);
213 typedef MyTiledImage::OutputIterator OutputIterator;
216 trace.
info() <<
"Value at range begin (1) = "<< *itbegin << std::endl;
217 nbok += (*itbegin == 1) ? 1 : 0; nb++;
218 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
221 trace.
info() <<
"Value at range begin from point (42) = "<< *itbegin2 << std::endl;
222 nbok += (*itbegin2 == 42) ? 1 : 0; nb++;
223 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
225 OutputIterator itbegino = tiledImage.range().begin();
226 trace.
info() <<
"Value at range begin (1) = "<< *itbegino << std::endl;
227 nbok += (*itbegino == 1) ? 1 : 0; nb++;
228 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
231 trace.
info() <<
"Value at range begin after writing (5) = "<< *itbegino << std::endl;
232 nbok += (*itbegino == 5) ? 1 : 0; nb++;
233 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << endl;
242 unsigned int nbok = 0;
250 for (VImage::Iterator it = image.begin(); it != image.end(); ++it)
253 trace.
info() <<
"ORIGINAL image: " << image << endl;
256 typedef MyImageFactoryFromImage::OutputImage OutputImage;
257 MyImageFactoryFromImage imageFactoryFromImage(image);
262 MyImageCacheReadPolicyFIFO imageCacheReadPolicyFIFO(imageFactoryFromImage, 2);
264 MyImageCacheWritePolicyWB imageCacheWritePolicyWB(imageFactoryFromImage);
268 MyTiledImage tiledImage(imageFactoryFromImage, imageCacheReadPolicyFIFO, imageCacheWritePolicyWB, 4);
271 const int maximalValue = tiledImage.domain().size();
272 MyTiledImage::Range::OutputIterator it = tiledImage.range().outputIterator();
273 for (
int i = 0; i < maximalValue; ++i)
279 MyTiledImage::ConstRange r = tiledImage.constRange();
280 std::copy( r.begin(), r.end(), std::ostream_iterator<int>(cout,
", ") );
283 std::vector<int> to_vector(100);
284 std::copy(r.begin(), r.end(), to_vector.begin());
285 for (
int i = 0; i < 100; i++)
295 cout <<
"!ok -> " << to_vector[i] <<
", ";
304 std::copy( r.begin(
Z2i::Point(7,7)), r.end(), std::ostream_iterator<int>(cout,
", ") );
307 std::vector<int> to_vector2(28);
308 std::copy(r.begin(
Z2i::Point(7,7)), r.end(), to_vector2.begin());
309 for (
int i = 0; i < 28; i++)
311 if (to_vector2[i]==i+72)
319 cout <<
"!ok -> " << to_vector2[i] <<
", ";
333int main(
int argc,
char** argv )
337 for (
int i = 0; i < argc; ++i )
343 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: implements a 'FIFO' read policy cache.
Aim: implements a 'WB (Write-back or Write-behind)' write policy cache.
Aim: implements a 'WT (Write-through)' write policy cache.
Aim: implements a factory to produce images from a "bigger/original" one according to a given domain.
Aim: implements a tiled image from a "bigger/original" one from an ImageFactory.
void beginBlock(const std::string &keyword="")
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Defines the concept describing a read/write image, having an output iterator.
bool test_range_constRange()