DGtal  1.5.beta
DGtal::PGMReader< TImageContainer, TFunctor > Struct Template Reference

Aim: Import a 2D or 3D using the Netpbm formats (ASCII mode). More...

#include <DGtal/io/readers/PGMReader.h>

Public Types

enum  MagicNumber {
  P1 , P2 , P3 , P4 ,
  P5 , P6
}
 
typedef TImageContainer ImageContainer
 
typedef TImageContainer::Value Value
 
typedef TImageContainer::Domain::Vector Vector
 
typedef TFunctor Functor
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CUnaryFunctor< TFunctor, unsigned char, Value >))
 
 BOOST_STATIC_ASSERT ((ImageContainer::Domain::dimension==2)||(ImageContainer::Domain::dimension==3))
 

Static Public Member Functions

static ImageContainer importPGM (const std::string &aFilename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
 
static ImageContainer importPGM3D (const std::string &aFilename, const Functor &aFunctor=Functor())
 

Detailed Description

template<typename TImageContainer, typename TFunctor = functors::Cast<typename TImageContainer::Value>>
struct DGtal::PGMReader< TImageContainer, TFunctor >

Aim: Import a 2D or 3D using the Netpbm formats (ASCII mode).

Description of class 'PGMReader'

  • PPM: RGB

    • PGM: grayscale
    • PPM3D: 3D variant of PPM
    • PGM3D: 3D variant of PGM

    Simple example: (extract from test file testPGMReader.cpp)

#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/readers/PGMReader.h"
#include "DGtal/kernel/images/ImageSelector.h"
...
string filename = "test.pgm";
Image image = PGMReader<Image>::importPGM( filename );
ImageContainerBySTLVector< Domain, Value > Type
Definition: ImageSelector.h:78
static ImageContainer importPGM(const std::string &aFilename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
ImageContainerBySTLVector< Domain, Value > Image

You can then for instance display a threshold part of the image:

#include "DGtal/kernel/imagesSetsUtils/SetFromImage.h"
...
Z2i::DigitalSet set2d (image.domain());
// Threshold all pixel in ]0, 255] in a DigitalSet
SetFromImage<Z2i::DigitalSet>::append<Image>(set2d, image, 0, 255);
Board2D board;
board << image.domain() << set2d; // display domain and set
Template Parameters
TImageContainerthe type of the image container
TFunctorthe type of functor used in the import (by default set to functors::Cast< TImageContainer::Value>) .

Definition at line 97 of file PGMReader.h.

Member Typedef Documentation

◆ Functor

template<typename TImageContainer , typename TFunctor = functors::Cast<typename TImageContainer::Value>>
typedef TFunctor DGtal::PGMReader< TImageContainer, TFunctor >::Functor

Definition at line 106 of file PGMReader.h.

◆ ImageContainer

template<typename TImageContainer , typename TFunctor = functors::Cast<typename TImageContainer::Value>>
typedef TImageContainer DGtal::PGMReader< TImageContainer, TFunctor >::ImageContainer

Definition at line 102 of file PGMReader.h.

◆ Value

template<typename TImageContainer , typename TFunctor = functors::Cast<typename TImageContainer::Value>>
typedef TImageContainer::Value DGtal::PGMReader< TImageContainer, TFunctor >::Value

Definition at line 103 of file PGMReader.h.

◆ Vector

template<typename TImageContainer , typename TFunctor = functors::Cast<typename TImageContainer::Value>>
typedef TImageContainer::Domain::Vector DGtal::PGMReader< TImageContainer, TFunctor >::Vector

Definition at line 104 of file PGMReader.h.

Member Enumeration Documentation

◆ MagicNumber

template<typename TImageContainer , typename TFunctor = functors::Cast<typename TImageContainer::Value>>
enum DGtal::PGMReader::MagicNumber
Enumerator
P1 
P2 
P3 
P4 
P5 
P6 

Definition at line 108 of file PGMReader.h.

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT()

template<typename TImageContainer , typename TFunctor = functors::Cast<typename TImageContainer::Value>>
DGtal::PGMReader< TImageContainer, TFunctor >::BOOST_CONCEPT_ASSERT ( (concepts::CUnaryFunctor< TFunctor, unsigned char, Value >)  )

◆ BOOST_STATIC_ASSERT()

template<typename TImageContainer , typename TFunctor = functors::Cast<typename TImageContainer::Value>>
DGtal::PGMReader< TImageContainer, TFunctor >::BOOST_STATIC_ASSERT ( (ImageContainer::Domain::dimension==2)||(ImageContainer::Domain::dimension==3)  )

◆ importPGM()

template<typename TImageContainer , typename TFunctor = functors::Cast<typename TImageContainer::Value>>
static ImageContainer DGtal::PGMReader< TImageContainer, TFunctor >::importPGM ( const std::string &  aFilename,
const Functor aFunctor = Functor(),
bool  topbotomOrder = true 
)
static

Main method to import a Pgm (8bits) into an instance of the template parameter ImageContainer.

Parameters
aFilenamethe file name to import.
aFunctorthe functor used to import and cast the source image values into the type of the image container value (by default set to functors::Cast < TImageContainer::Value > .
topbotomOrderif true, the point of coordinate (0,0) will be the bottom left corner image point (default) else the center of image coordinate will be the top left of the image (not usual).
Returns
an instance of the ImageContainer.
Examples
tutorial-examples/freemanChainFromImage.cpp.

Referenced by DGtal::GenericReader< TContainer, 2, TValue >::importWithValueFunctor(), DGtal::GenericReader< TContainer, 2, DGtal::uint32_t >::importWithValueFunctor(), main(), and testRWIssue254().

◆ importPGM3D()

template<typename TImageContainer , typename TFunctor = functors::Cast<typename TImageContainer::Value>>
static ImageContainer DGtal::PGMReader< TImageContainer, TFunctor >::importPGM3D ( const std::string &  aFilename,
const Functor aFunctor = Functor() 
)
static

Main method to import a Pgm3D (8bits) into an instance of the template parameter ImageContainer.

Parameters
aFilenamethe file name to import.
aFunctorthe functor used to import and cast the source image values into the type of the image container value (by default set to functors::Cast < TImageContainer::Value > .
Returns
an instance of the ImageContainer.

Referenced by DGtal::GenericReader< TContainer, 3, TValue >::importWithValueFunctor().


The documentation for this struct was generated from the following file: