DGtal  1.5.beta
testSliceImageFromFunctor.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/kernel/BasicPointFunctors.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/writers/PGMWriter.h"
#include "DGtal/images/ImageContainerBySTLVector.h"
#include "DGtal/images/ConstImageAdapter.h"
#include "ConfigTest.h"
Include dependency graph for testSliceImageFromFunctor.cpp:

Go to the source code of this file.

Functions

bool testSliceImageFromFunctor ()
 
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
Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France
Date
2013/04/24

Functions for testing class ImageHelper.

This file is part of the DGtal library.

Definition in file testSliceImageFromFunctor.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 124 of file testSliceImageFromFunctor.cpp.

125 {
126  trace.beginBlock ( "Testing class ImageHelper" );
127  trace.info() << "Args:";
128  for ( int i = 0; i < argc; ++i )
129  trace.info() << " " << argv[ i ];
130  trace.info() << endl;
131 
132  bool res = testSliceImageFromFunctor(); // && ... other tests
133  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
134  trace.endBlock();
135  return res ? 0 : 1;
136 }
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition: Common.h:153
bool testSliceImageFromFunctor()

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

◆ testSliceImageFromFunctor()

bool testSliceImageFromFunctor ( )

Test of the function extractLowerDimImage for the extraction of 2D images from 3D image.

Definition at line 56 of file testSliceImageFromFunctor.cpp.

57 {
58  unsigned int nbok = 0;
59  unsigned int nb = 0;
60  std::string filename = testPath + "samples/cat10.vol";
61  trace.beginBlock ( "Testing block ..." );
63 
65  Image3D::Value, DGtal::functors::Identity > MySliceImageAdapter;
66 
68  Image3D::Value, DGtal::functors::Identity > MyRotatorSliceImageAdapter;
69 
70  bool res= true;
71  Image3D image = VolReader<Image3D>::importVol( filename );
72  DGtal::functors::Projector<DGtal::Z2i::Space> projX(0); projX.initRemoveOneDim(0);
73  DGtal::Z2i::Domain domainX(projX(image.domain().lowerBound()),
74  projX(image.domain().upperBound()));
75 
76 
77  DGtal::functors::Projector<DGtal::Z3i::Space> aSliceFunctor(0); aSliceFunctor.initAddOneDim(0);
78  const auto identityFunctor = DGtal::functors::Identity();
79  MySliceImageAdapter sliceImageX(image, domainX, aSliceFunctor, identityFunctor);
80  res &= PGMWriter<MySliceImageAdapter>::exportPGM("exportedSlice2DDimX.pgm",sliceImageX);
81 
82  DGtal::functors::Projector<DGtal::Z2i::Space> projY(0); projY.initRemoveOneDim(1);
83  DGtal::Z2i::Domain domainY(projY(image.domain().lowerBound()),
84  projY(image.domain().upperBound()));
85 
86  DGtal::functors::Projector<DGtal::Z3i::Space> aSliceFunctor2(0); aSliceFunctor2.initAddOneDim(1);
87  MySliceImageAdapter sliceImageY(image, domainY, aSliceFunctor2, identityFunctor);
88  res &= PGMWriter<MySliceImageAdapter>::exportPGM("exportedSlice2DDimY.pgm",sliceImageY);
89 
90 
91  DGtal::functors::Projector<DGtal::Z2i::Space> projZ(0); projZ.initRemoveOneDim(2);
92  DGtal::Z2i::Domain domainZ(projZ(image.domain().lowerBound()),
93  projZ(image.domain().upperBound()));
94 
95 
96  DGtal::functors::Projector<DGtal::Z3i::Space> aSliceFunctor3(0); aSliceFunctor3.initAddOneDim(2);
97  MySliceImageAdapter sliceImageZ(image, domainZ, aSliceFunctor3, identityFunctor);
98  res &= PGMWriter<MySliceImageAdapter>::exportPGM("exportedSlice2DDimZ.pgm",sliceImageZ);
99 
100 
102  DGtal::functors::SliceRotator2D< HyperRectDomain< DGtal::Z3i::Space >, DGtal::Z3i::Integer> sliceRot(2, image.domain(), 0, 2, M_PI/4.0, center);
103 
104 
105  MyRotatorSliceImageAdapter sliceRotImageZ(image, domainZ, sliceRot, identityFunctor);
106  res &= PGMWriter<MyRotatorSliceImageAdapter>::exportPGM("exportedRotSliceZ.pgm",sliceRotImageZ);
107 
108 
109 
110 
111 
112  nbok += res ? 1 : 0;
113  nb++;
114  trace.info() << "(" << nbok << "/" << nb << ") "
115  << "true == true" << std::endl;
116  trace.endBlock();
117 
118  return nbok == nb;
119 }
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
Special Point Functor that adds one dimension to a 2D point and apply on it a rotation of angle alpha...
DGtal::int32_t Integer
Definition: StdDefs.h:143
Point center(const std::vector< Point > &points)
Aim: Export a 2D and a 3D Image using the Netpbm PGM formats (ASCII mode).
Definition: PGMWriter.h:89
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:90
Aim: Define a simple default functor that just returns its argument.
Aim: Functor that maps a point P of dimension i to a point Q of dimension j. The member myDims is an ...

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), DGtal::functors::Projector< S >::initAddOneDim(), DGtal::functors::Projector< S >::initRemoveOneDim(), and DGtal::trace.

Referenced by main().