DGtal  1.0.0
Functions
testITKReader.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "ConfigTest.h"
#include "DGtalCatch.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/images/ImageContainerBySTLVector.h"
#include "DGtal/io/readers/ITKReader.h"
Include dependency graph for testITKReader.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("Testing ITKReader")
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Lorraine, France
Date
2017/04/02

Functions for testing class ITKReader.

This file is part of the DGtal library.

Definition in file testITKReader.cpp.

Function Documentation

◆ TEST_CASE()

TEST_CASE ( "Testing ITKReader )

Definition at line 47 of file testITKReader.cpp.

48 {
49  // Default image selector = STLVector
52 
53  SECTION(
54  "Testing feature io/readers of ITKReader with 16 bits (unit16) images" )
55  {
56  Image3D16b im = ITKReader<Image3D16b>::importITK(
57  testPath + "samples/lobsterCroped16b.mhd" );
58  REQUIRE( ( im( Z3i::Point( 35, 29, 3 ) ) == 60400 ) );
59  }
60 
61  SECTION(
62  "Testing feature io/readers of ITKReader with rescaled 16 bits (unit16) "
63  "images" )
64  {
66  RescalFCT resc = RescalFCT( 0, 65535, 0, 255 );
67  Image3DUC im = ITKReader<Image3DUC>::importITK(
68  testPath + "samples/lobsterCroped16b.mhd", resc );
69  REQUIRE( ( im( Z3i::Point( 35, 29, 3 ) ) == resc( 60400 ) ) );
70  }
71  SECTION(
72  "Testing behavior of ITKReader on non existent image file" )
73  {
74  bool caughtException = false;
75  const std::string filename = testPath + "samples/null.mhd"; //non existent file
76  try
77  {
78  Image3DUC im = ITKReader<Image3DUC>::importITK(filename);
79  }
80  catch(exception &)
81  {
82  caughtException = true;
83  trace.info() <<"Exception was correctly caught" << std::endl;
84  }
85  REQUIRE( caughtException == true);
86  }
87 
88 
89 }
Trace trace
Definition: Common.h:144
REQUIRE(domain.isInside(aPoint))
Aim: Import a 2D/3D Image using the ITK formats.
Definition: ITKReader.h:78
Aim: Functor allowing to rescale a value. Values of the initial scale [initMin,initMax] are rescaled ...
std::ostream & info()
SECTION("Testing constant forward iterators")

References DGtal::Trace::info(), REQUIRE(), SECTION(), and DGtal::trace.