DGtal 1.3.0
Loading...
Searching...
No Matches
extract2DImagesFrom3D.cpp
Go to the documentation of this file.
1
42#include <iostream>
43#include <sstream>
44#include "DGtal/kernel/BasicPointFunctors.h"
45#include "DGtal/base/Common.h"
46#include "DGtal/helpers/StdDefs.h"
47#include "DGtal/io/readers/VolReader.h"
48#include "DGtal/io/writers/PGMWriter.h"
49#include "DGtal/images/ImageSelector.h"
50#include "DGtal/images/ConstImageAdapter.h"
51#include "ConfigExamples.h"
53
54using namespace std;
55using namespace DGtal;
56
58
59const int IMAGE_PATCH_WIDTH = 70;
60
61int main( int /*argc*/, char** /*argv*/ )
62{
66 Image3D::Value, DGtal::functors::Identity > ImageAdapterExtractor;
68
70 DGtal::Z3i::Point origin(150, 150, 10);
71 DGtal::Z3i::Point ptUpper1(220, 220, 10);
72 DGtal::Z3i::Point ptUpper2(150, 150, 50);
73 DGtal::Z2i::Domain domainImage2D (DGtal::Z2i::Point(0,0),
74 DGtal::Z2i::Point(static_cast<int>((ptUpper1-origin).norm()),
75 static_cast<int>((ptUpper2-origin).norm())));
77 DGtal::Z3i::Point ptCenter(175, 175, 20);
78 DGtal::Z2i::Domain domainImage2D2 (DGtal::Z2i::Point(0,0),
80
81
82 // Importing a 3D image
83 std::string filename = examplesPath + "samples/lobster.vol";
84 Image3D image = VolReader<Image3D>::importVol( filename );
85 DGtal::Z3i::Domain domainImage3D = image.domain();
87
88 trace.beginBlock ( "Example extract2DImagesFrom3D" );
89
90 // Extracting 2D images ... and export them in the pgm format.
91 for (unsigned int i=0; i<30; i+=10){
92 std::stringstream name;
93 name << "lobsterExtracted_" << i << ".pgm";
94 std::stringstream name2;
95 name2 << "lobsterExtracted_" << i << "V2.pgm";
96
99 ptUpper1+DGtal::Z3i::Point(i,i,0),
100 ptUpper2+DGtal::Z3i::Point(i,i,0));
101
102 ImageAdapterExtractor extractedImage(image, domainImage2D, embedder, idV);
104
107 DGtal::Z3i::RealPoint(1,-1,0),
109 ImageAdapterExtractor extractedImage2(image, domainImage2D2, embedder2, idV);
111
112 PGMWriter< ImageAdapterExtractor>::exportPGM(name.str(), extractedImage);
113 PGMWriter< ImageAdapterExtractor>::exportPGM(name2.str(), extractedImage2);
114 }
115
116 // trace.endBlock();
117 return 0;
118}
119// //
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
void beginBlock(const std::string &keyword="")
Aim: Functor that embeds a 2D point into a 3D space from two axis vectors and an origin point given i...
const int IMAGE_PATCH_WIDTH
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:154
STL namespace.
ImageContainerBySTLVector< Domain, Value > Type
Definition: ImageSelector.h:78
static bool exportPGM(const std::string &filename, const Image &aImage, const Functor &aFunctor=Functor(), bool saveASCII=false, bool topbotomOrder=true)
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
Aim: Define a simple default functor that just returns its argument.
int main()
Definition: testBits.cpp:56