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>
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 );
188template <
typename Image >
196 static inline bool write( std::string
const& filename,
Image const& anImage )
202template <
typename Image >
210 static inline bool write( std::string
const& filename,
Image const& anImage )
216template <
typename Image >
224 static inline bool write( std::string
const& filename,
Image const& anImage )
230template <
typename Image >
238 static inline bool write( std::string
const& filename,
Image const& anImage )
246TEST_CASE(
"Checking RawReader with reference files in 2D",
"[reader][2D][raw][raw32][uint32]" )
251TEST_CASE(
"Checking RawReader with reference files in 3D",
"[reader][3D][raw][raw32][uint32]" )
257TEST_CASE(
"Checking writing & reading uint8 in 2D with generic IO",
"[reader][writer][2D][raw][uint8]" )
262TEST_CASE(
"Checking writing & reading uint8 in 2D with 8bits IO",
"[reader][writer][2D][raw8][uint8]" )
267TEST_CASE(
"Checking writing & reading int8 in 2D with generic IO",
"[reader][writer][2D][raw][int8]" )
273TEST_CASE(
"Checking writing & reading uint16 in 2D with generic IO",
"[reader][writer][2D][raw][uint16]" )
278TEST_CASE(
"Checking writing & reading uint16 in 2D with 16bits IO",
"[reader][writer][2D][raw16][uint16]" )
283TEST_CASE(
"Checking writing & reading int16 in 2D with generic IO",
"[reader][writer][2D][raw][int16]" )
289TEST_CASE(
"Checking writing & reading uint32 in 2D with generic IO",
"[reader][writer][2D][raw][uint32]" )
294TEST_CASE(
"Checking writing & reading uint32 in 2D with 32bits IO",
"[reader][writer][2D][raw32][uint32]" )
299TEST_CASE(
"Checking writing & reading int32 in 2D with generic IO",
"[reader][writer][2D][raw][int32]" )
305TEST_CASE(
"Checking writing & reading uint64 in 2D with generic IO",
"[reader][writer][2D][raw][uint64]" )
310TEST_CASE(
"Checking writing & reading int64 in 2D with generic IO",
"[reader][writer][2D][raw][int64]" )
316TEST_CASE(
"Checking writing & reading double in 1D with generic IO",
"[reader][writer][1D][raw][double]" )
321TEST_CASE(
"Checking writing & reading double in 2D with generic IO",
"[reader][writer][2D][raw][double]" )
326TEST_CASE(
"Checking writing & reading double in 3D with generic IO",
"[reader][writer][3D][raw][double]" )
Iterator for HyperRectDomain.
const ConstIterator & begin() const
const ConstIterator & end() 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))