35 #include "DGtalCatch.h"
36 #include <DGtal/base/Common.h>
37 #include <DGtal/kernel/SpaceND.h>
38 #include <DGtal/kernel/domains/HyperRectDomain.h>
39 #include <DGtal/images/ImageSelector.h>
40 #include <DGtal/io/readers/RawReader.h>
41 #include <DGtal/io/writers/RawWriter.h>
42 #include <DGtal/kernel/domains/Linearizer.h>
44 #include <ConfigTest.h>
51 using namespace DGtal;
68 INFO(
"Checking domain" )
69 REQUIRE( anImage.
domain().lowerBound() == Point::diagonal(0) );
70 REQUIRE( anImage.
domain().upperBound() == Point::diagonal(4) );
73 INFO(
"Checking values" )
78 const unsigned int refValue = anImage.dimension == 2 ?
79 1000000 * pt[0] * pt[1]
80 : 250000 * pt[0] * pt[1] * pt[2];
82 INFO(
"At point " << pt );
83 REQUIRE( anImage( pt ) == refValue );
104 std::string fileName = testPath +
"samples/";
106 fileName +=
"raw32bits5x5.raw";
108 fileName +=
"raw32bits5x5x5.raw";
111 const Vector extent = Vector::diagonal(5);
113 INFO(
"Reading file with importRaw32" << fileName );
117 INFO(
"Reading file with importRaw" << fileName );
139 const Point pt = *it;
154 template<
typename>
class RawIO
166 upperPt[ i ] = upperPt[ i-1 ] * ( i == 1 ? 4 : 2 );
172 INFO(
"Writing image" );
173 RawIO<Image>::write(
"export-raw-writer.raw",
refImage );
175 INFO(
"Reading image" );
176 Image image = RawIO<Image>::read(
"export-raw-writer.raw", upperPt + Point::diagonal(1) );
178 INFO(
"Comparing image values" );
181 const Point pt = *it;
182 INFO(
"At point " << pt );
188 template <
typename Image >
196 static inline bool write( std::string
const& filename,
Image const& anImage )
202 template <
typename Image >
210 static inline bool write( std::string
const& filename,
Image const& anImage )
216 template <
typename Image >
224 static inline bool write( std::string
const& filename,
Image const& anImage )
230 template <
typename Image >
238 static inline bool write( std::string
const& filename,
Image const& anImage )
246 TEST_CASE(
"Checking RawReader with reference files in 2D",
"[reader][2D][raw][raw32][uint32]" )
248 testRawReaderOnRef<2>();
251 TEST_CASE(
"Checking RawReader with reference files in 3D",
"[reader][3D][raw][raw32][uint32]" )
253 testRawReaderOnRef<3>();
257 TEST_CASE(
"Checking writing & reading uint8 in 2D with generic IO",
"[reader][writer][2D][raw][uint8]" )
259 testWriteAndRead<2, DGtal::uint8_t, RawIO>( 1 );
262 TEST_CASE(
"Checking writing & reading uint8 in 2D with 8bits IO",
"[reader][writer][2D][raw8][uint8]" )
264 testWriteAndRead<2, DGtal::uint8_t, RawIO>( 1 );
267 TEST_CASE(
"Checking writing & reading int8 in 2D with generic IO",
"[reader][writer][2D][raw][int8]" )
269 testWriteAndRead<2, DGtal::int8_t, RawIO>( 1 );
273 TEST_CASE(
"Checking writing & reading uint16 in 2D with generic IO",
"[reader][writer][2D][raw][uint16]" )
275 testWriteAndRead<2, DGtal::uint16_t, RawIO>( 1 );
278 TEST_CASE(
"Checking writing & reading uint16 in 2D with 16bits IO",
"[reader][writer][2D][raw16][uint16]" )
280 testWriteAndRead<2, DGtal::uint16_t, RawIO>( 1 );
283 TEST_CASE(
"Checking writing & reading int16 in 2D with generic IO",
"[reader][writer][2D][raw][int16]" )
285 testWriteAndRead<2, DGtal::int16_t, RawIO>( 1 );
289 TEST_CASE(
"Checking writing & reading uint32 in 2D with generic IO",
"[reader][writer][2D][raw][uint32]" )
291 testWriteAndRead<2, DGtal::uint32_t, RawIO>( 1 );
294 TEST_CASE(
"Checking writing & reading uint32 in 2D with 32bits IO",
"[reader][writer][2D][raw32][uint32]" )
296 testWriteAndRead<2, DGtal::uint32_t, RawIO>( 1 );
299 TEST_CASE(
"Checking writing & reading int32 in 2D with generic IO",
"[reader][writer][2D][raw][int32]" )
301 testWriteAndRead<2, DGtal::int32_t, RawIO>( 1 );
305 TEST_CASE(
"Checking writing & reading uint64 in 2D with generic IO",
"[reader][writer][2D][raw][uint64]" )
307 testWriteAndRead<2, DGtal::uint64_t, RawIO>( 1 );
310 TEST_CASE(
"Checking writing & reading int64 in 2D with generic IO",
"[reader][writer][2D][raw][int64]" )
312 testWriteAndRead<2, DGtal::int64_t, RawIO>( 1 );
316 TEST_CASE(
"Checking writing & reading double in 1D with generic IO",
"[reader][writer][1D][raw][double]" )
318 testWriteAndRead<1, double, RawIO>( 1.23456789 );
321 TEST_CASE(
"Checking writing & reading double in 2D with generic IO",
"[reader][writer][2D][raw][double]" )
323 testWriteAndRead<2, double, RawIO>( 1.23456789 );
326 TEST_CASE(
"Checking writing & reading double in 3D with generic IO",
"[reader][writer][3D][raw][double]" )
328 testWriteAndRead<3, double, RawIO>( 1.23456789 );
Iterator for HyperRectDomain.
const ConstIterator & end() const
const ConstIterator & begin() const
Aim: implements association bewteen points lying in a digital domain and values.
const Domain & domain() const
void setValue(const Point &aPoint, const Value &aValue)
DigitalPlane::Point Vector
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::uint32_t Dimension
Aim: Linearization and de-linearization interface for domains.
Aim: Raw binary import of an Image.
static ImageContainer importRaw8(const std::string &filename, const Vector &extent, const Functor &aFunctor=Functor())
static ImageContainer importRaw16(const std::string &filename, const Vector &extent, const Functor &aFunctor=Functor())
static ImageContainer importRaw32(const std::string &filename, const Vector &extent, const Functor &aFunctor=Functor())
Aim: Raw binary export of an Image.
static bool exportRaw32(const std::string &filename, const Image &anImage, const Functor &aFunctor=Functor())
static bool exportRaw8(const std::string &filename, const Image &anImage, const Functor &aFunctor=Functor())
static bool exportRaw16(const std::string &filename, const Image &anImage, const Functor &aFunctor=Functor())
void testWriteAndRead(T aSeed)
void testRawReaderOnRef()
void testImageOnRef(Image const &anImage)
TEST_CASE("Checking RawReader with reference files in 2D", "[reader][2D][raw][raw32][uint32]")
void generateRefImage(Image &anImage, typename Image::Value aSeed)
ImageContainerBySTLVector< Domain, Value > Image
HyperRectDomain< Space > Domain
REQUIRE(domain.isInside(aPoint))