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

Go to the source code of this file.

Functions

int main (int, char **)
 

Variables

const int IMAGE_PATCH_WIDTH = 70
 

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/10/15

An example file named extract2DImagesFrom3D.

This file is part of the DGtal library.

Definition in file extract2DImagesFrom3D.cpp.

Function Documentation

◆ main()

int main ( int  ,
char **   
)

[extract2DImagesFrom3DType]

[extract2DImagesFrom3DType]

[extract2DImagesFrom3DOrigin3D]

[extract2DImagesFrom3DOrigin3D]

[extract2DImagesFrom3DOExtract]

[extract2DImagesFrom3DOExtract]

[extract2DImagesFrom3DOExtract2]

[extract2DImagesFrom3DOExtract2]

Definition at line 61 of file extract2DImagesFrom3D.cpp.

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 
106  DGtal::functors::Point2DEmbedderIn3D<DGtal::Z3i::Domain > embedder2(domainImage3D, ptCenter+DGtal::Z3i::Point(i,i,0),
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 }
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
Trace trace
Definition: Common.h:153
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.

References DGtal::Trace::beginBlock(), IMAGE_PATCH_WIDTH, and DGtal::trace.

Variable Documentation

◆ IMAGE_PATCH_WIDTH

const int IMAGE_PATCH_WIDTH = 70