DGtal  1.4.beta
DGtal::PPMReader< TImageContainer, TFunctor > Struct Template Reference

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

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

Public Types

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

Public Member Functions

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

Static Public Member Functions

static ImageContainer importPPM (const std::string &aFilename, const Functor &aFunctor=functors::ColorRGBEncoder< Value >(), bool topbotomOrder=true)
 

Detailed Description

template<typename TImageContainer, typename TFunctor = functors::ColorRGBEncoder<typename TImageContainer::Value>>
struct DGtal::PPMReader< TImageContainer, TFunctor >

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

Description of class 'PPMReader'

  • PPM: RGB

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

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

#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/readers/PPMReader.h"
#include "DGtal/kernel/images/ImageSelector.h"
...
string filename = "test.pgm";
Image image = PPMReader<Image>::importPGMImage( filename );
ImageContainerBySTLVector< Domain, Value > Type
Definition: ImageSelector.h:78
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 the functor to transform the source image color into scalar value. This functor should follows the concept CUnaryFunctor<TFunctor, DGtal::Color, TImageContainer::Value>

Definition at line 98 of file PPMReader.h.

Member Typedef Documentation

◆ Functor

template<typename TImageContainer , typename TFunctor = functors::ColorRGBEncoder<typename TImageContainer::Value>>
typedef TFunctor DGtal::PPMReader< TImageContainer, TFunctor >::Functor

Definition at line 106 of file PPMReader.h.

◆ ImageContainer

template<typename TImageContainer , typename TFunctor = functors::ColorRGBEncoder<typename TImageContainer::Value>>
typedef TImageContainer DGtal::PPMReader< TImageContainer, TFunctor >::ImageContainer

Definition at line 103 of file PPMReader.h.

◆ Value

template<typename TImageContainer , typename TFunctor = functors::ColorRGBEncoder<typename TImageContainer::Value>>
typedef TImageContainer::Value DGtal::PPMReader< TImageContainer, TFunctor >::Value

Definition at line 105 of file PPMReader.h.

◆ Vector

template<typename TImageContainer , typename TFunctor = functors::ColorRGBEncoder<typename TImageContainer::Value>>
typedef TImageContainer::Domain::Vector DGtal::PPMReader< TImageContainer, TFunctor >::Vector

Definition at line 104 of file PPMReader.h.

Member Enumeration Documentation

◆ MagicNumber

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

Definition at line 108 of file PPMReader.h.

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT()

template<typename TImageContainer , typename TFunctor = functors::ColorRGBEncoder<typename TImageContainer::Value>>
DGtal::PPMReader< TImageContainer, TFunctor >::BOOST_CONCEPT_ASSERT ( (concepts::CUnaryFunctor< TFunctor, DGtal::Color, Value >)  )

◆ BOOST_STATIC_ASSERT()

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

◆ importPPM()

template<typename TImageContainer , typename TFunctor = functors::ColorRGBEncoder<typename TImageContainer::Value>>
static ImageContainer DGtal::PPMReader< TImageContainer, TFunctor >::importPPM ( const std::string &  aFilename,
const Functor aFunctor = functors::ColorRGBEncoderValue >(),
bool  topbotomOrder = true 
)
static

Main method to import a PPM (24bit, 8bits per channel) into an instance of the template parameter ImageContainer.

Parameters
aFilenamethe file name to import.
aFunctorthe functor that from a given color return it associated code (by default set to BasicColorToScalarFunctors::ColorRGBEncoder).
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.

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


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