DGtal  0.9.3
Functions
testDicomReader.cpp File Reference
#include <iostream>
#include "DGtal/images/ImageContainerBySTLVector.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/readers/DicomReader.h"
#include "ConfigTest.h"
Include dependency graph for testDicomReader.cpp:

Go to the source code of this file.

Functions

bool testDicomReader ()
 
bool testIOException ()
 
int main (int argc, char **argv)
 

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
Adrien Krähenbühl (adrie.nosp@m.n.kr.nosp@m.ahenb.nosp@m.uhl@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), Université de Lorraine, France
Date
2013/10/14

Functions for testing class DicomReader.

This file is part of the DGtal library.

Definition in file testDicomReader.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 94 of file testDicomReader.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testDicomReader(), testIOException(), and DGtal::trace.

95 {
96  trace.beginBlock ( "Testing class DicomReader" );
97  trace.info() << "Args:";
98  for ( int i = 0; i < argc; ++i )
99  trace.info() << " " << argv[ i ];
100  trace.info() << endl;
101 
102  bool res = testDicomReader() && testIOException();
103  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
104  trace.endBlock();
105 
106  return !res;
107 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
bool testDicomReader()
double endBlock()
bool testIOException()
std::ostream & emphase()
std::ostream & info()

◆ testDicomReader()

bool testDicomReader ( )

Example of a test. To be completed.

Definition at line 51 of file testDicomReader.cpp.

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

Referenced by main().

52 {
53  //Default image selector = STLVector
55 
56  std::string filename = testPath + "samples/dicomSample/1629.dcm";
57  Image3D image = DicomReader< Image3D >::importDicom( filename );
58 
59  trace.info() << image <<endl;
60 
61  unsigned int nbVal=0, nbPos = 0;
62  for ( Image3D::ConstIterator it=image.begin(), itend=image.end() ; it != itend ; ++it )
63  {
64  nbVal++;
65  if ( (*it) > 0 ) nbPos++;
66  }
67 
68  trace.info() << "Number of points with (val>0) = " << nbVal << endl;
69 
70  return nbVal==2130048 && nbPos==296030;
71 }
MyDigitalSurface::ConstIterator ConstIterator
Trace trace
Definition: Common.h:137
Aim: Import a 3D DICOM image from file series.
Definition: DicomReader.h:90
std::ostream & info()

◆ testIOException()

bool testIOException ( )

Definition at line 74 of file testDicomReader.cpp.

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

Referenced by main().

75 {
76  //Default image selector = STLVector
78 
79  std::string filename = testPath + "samples/null.dcm";
80  try {
81  Image3D image = DicomReader< Image3D >::importDicom( filename );
82  }
83  catch(exception& e) {
84  trace.info() << "Exception catched. Message : " << e.what()<<endl;
85  return true;
86  }
87 
88  return false;
89 }
Trace trace
Definition: Common.h:137
Aim: Import a 3D DICOM image from file series.
Definition: DicomReader.h:90
std::ostream & info()