[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]

details Import/export of the TIFF format VIGRA


Functions

template<...> void importTiffImage (TiffImage *tiff, ImageIterator iter, Accessor a)
 Convert given TiffImage into image specified by iterator range.

template<...> void tiffToScalarImage (TiffImage *tiff, ImageIterator iter, Accessor a)
 Convert single-band TiffImage to scalar image.

template<...> void tiffToRGBImage (TiffImage *tiff, RGBImageIterator iter, RGBAccessor a)
 Convert RGB (3-band or color-mapped) TiffImage to RGB image.

template<...> void createTiffImage (ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage *tiff)
 Create a TiffImage from the given iterator range.

template<...> void createScalarTiffImage (ImageIterator upperleft, ImageIterator lowerright, Accessor a, TiffImage *tiff)
 Create a single-band TiffImage from the given scalar image.

template<...> void createRGBTiffImage (RGBImageIterator upperleft, RGBImageIterator lowerright, RGBAccessor a, TiffImage *tiff)
 Create a 3-band TiffImage from the given RGB image.



Detailed Description


TIFF conversion and file export/import.

Normally, you need not call the TIFF functions directly. They are available much more conveniently via importImage() and exportImage()

TIFF (Tagged Image File Format) is a very versatile image format - one can store different pixel types (byte, integer, float, double) and color models (black and white, RGB, mapped RGB, other color systems). For more details and information on how to create a TIFF image, refer to the TIFF documentation at http://www.libtiff.org/ for details.


Function Documentation


  void createRGBTiffImage (...)
 
 

Create a 3-band TiffImage from the given RGB image.

Type and size of the TiffImage are determined by the input image (may be one of unsigned char, int, float, or double). This function uses RGBAccessor to read the data. A RGBImageIterator is an iterator that is associated with a RGBAccessor.

Declarations:

pass arguments explicitly:

    namespace vigra {
        template <class RGBImageIterator, class RGBAccessor>
        TiffImage *
        createRGBTiffImage(RGBImageIterator upperleft, RGBImageIterator lowerright,
                   RGBAccessor a)
                }

use argument objects in conjunction with Argument Object Factories:

    namespace vigra {
        template <class RGBImageIterator, class RGBAccessor>
        inline TiffImage *
        createRGBTiffImage(triple<RGBImageIterator, RGBImageIterator, RGBAccessor> src)
    }

Usage:

#include "vigra/tiff.hxx"

    vigra::BRGBImage img(width, height);
    
    ...
    
    TiffImage * tiff = TIFFOpen(("tiffimage.tiff", "w");

    vigra::createRGBTiffImage(srcImageRange(img), tiff);

    TIFFClose(tiff);   // implicitly writes the image to the disk

Required Interface:

    ImageIterator upperleft;
    RGBAccessor accessor;
                           
    accessor.red(upperleft);     // result written into TiffImage
    accessor.green(upperleft);   // result written into TiffImage
    accessor.blue(upperleft);    // result written into TiffImage


  void createScalarTiffImage (...)
 
 

Create a single-band TiffImage from the given scalar image.

Type and size of the TiffImage are determined by the input image (may be one of unsigned char, short, int, float, or double). This function uses accessors to read the data.

Declarations:

pass arguments explicitly:

    namespace vigra {
        template <class ImageIterator, class Accessor>
        inline TiffImage *
        createScalarTiffImage(ImageIterator upperleft, ImageIterator lowerright, 
                  Accessor a)
    }

use argument objects in conjunction with Argument Object Factories:

    namespace vigra {
        template <class ImageIterator, class Accessor>
        inline TiffImage *
        createScalarTiffImage(triple<ImageIterator, ImageIterator, Accessor> src)
    }

Usage:

#include "vigra/tiff.hxx"

    vigra::BImage img(width, height);
    
    ...
    
    TiffImage * tiff = TIFFOpen(("tiffimage.tiff", "w");

    vigra::createScalarTiffImage(srcImageRange(img), tiff);

    TIFFClose(tiff);   // implicitly writes the image to the disk

Required Interface:

    ImageIterator upperleft;
    Accessor accessor;
                           
    accessor(upperleft);   // result written into TiffImage


  void createTiffImage (...)
 
 

Create a TiffImage from the given iterator range.

Type and size of the TiffImage are determined by the input image. Currently, the function can create scalar images and RGB images of type unsigned char, short, int, float, and double. This function uses accessors to read the data.

Declarations:

pass arguments explicitly:

    namespace vigra {
        template <class ImageIterator, class Accessor>
        inline TiffImage *
        createTiffImage(ImageIterator upperleft, ImageIterator lowerright, 
                        Accessor a)
    }

use argument objects in conjunction with Argument Object Factories:

    namespace vigra {
        template <class ImageIterator, class Accessor>
        inline TiffImage *
        createTiffImage(triple<ImageIterator, ImageIterator, Accessor> src)
    }

Usage:

#include "vigra/tiff.hxx"

    vigra::BImage img(width, height);
    
    ...
    
    TiffImage * tiff = TIFFOpen(("tiffimage.tiff", "w");

    vigra::createTiffImage(srcImageRange(img), tiff);

    TIFFClose(tiff);   // implicitly writes the image to the disk

Required Interface:

    ImageIterator upperleft;
    Accessor accessor;
                           
    accessor(upperleft);   // result written into TiffImage


  void importTiffImage (...)
 
 

Convert given TiffImage into image specified by iterator range.

Accessors are used to write the data. This function calls tiffToScalarImage() or tiffToRGBImage(), depending on the accessor's value_type.

Declarations:

pass arguments explicitly:

    namespace vigra {
        template <class ImageIterator, class Accessor>
        void
        importTiffImage(TiffImage * tiff, ImageIterator iter, Accessor a)
    }

use argument objects in conjunction with Argument Object Factories:

    namespace vigra {
        template <class ImageIterator, class Accessor>
        void
        importTiffImage(TiffImage * tiff, pair<ImageIterator, Accessor> dest)
    }

Usage:

#include "vigra/tiff.hxx"

    uint32 w, h;
    TiffImage * tiff = TIFFOpen("tiffimage.tiff", "r");
    TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w);
    TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h);
    
    vigra::BImage img(w,h);
    
    vigra::importTiffImage(tiff, destImage(img));
    
    TIFFClose(tiff);

Required Interface:

see tiffToScalarImage() and tiffToRGBImage()

Preconditions:

see tiffToScalarImage() and tiffToRGBImage()


  void tiffToRGBImage (...)
 
 

Convert RGB (3-band or color-mapped) TiffImage to RGB image.

This function uses RGBAccessor to write the data. A RGBImageIterator is an iterator which is associated with a RGBAccessor.

Declarations:

pass arguments explicitly:

    namespace vigra {
        template <class RGBImageIterator, class RGBAccessor>
        void
        tiffToRGBImage(TiffImage * tiff, RGBImageIterator iter, RGBAccessor a)
    }

use argument objects in conjunction with Argument Object Factories:

    namespace vigra {
        template <class RGBImageIterator, class RGBAccessor>
        void
        tiffToRGBImage(TiffImage * tiff, pair<RGBImageIterator, RGBAccessor> dest)
    }

Usage:

#include "vigra/tiff.hxx"

    uint32 w, h;
    uint16 photometric
    TiffImage * tiff = TIFFOpen("tiffimage.tiff", "r");
    TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w);
    TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h);
    TIFFGetField(tiff_, TIFFTAG_PHOTOMETRIC, &photometric);
        
    if(photometric != PHOTOMETRIC_RGB &&
       photometric != PHOTOMETRIC_PALETTE)
    {
        // not an RGB image - handle error
    }
    
    vigra::BRGBImage img(w, h);
    
    vigra::tiffToRGBImage(tiff, destImage(img));
    
    TIFFClose(tiff);

Required Interface:

    ImageIterator upperleft;
    <unsigned char, short, long, float, double> rvalue, gvalue, bvalue;
    
    RGBAccessor accessor;
                           
    accessor.setRed(rvalue, upperleft);
    accessor.setGreen(gvalue, upperleft);
    accessor.setBlue(bvalue, upperleft);

Preconditions:

ImageIterator must refer to a large enough image.

    uint16 sampleFormat, samplesPerPixel, bitsPerSample, photometric;
           
    TIFFGetField(tiff, TIFFTAG_SAMPLEFORMAT, &sampleFormat);
    TIFFGetField(tiff, TIFFTAG_SAMPLESPERPIXEL, &samplesPerPixel);
    TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bitsPerSample);
    TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric);

    sampleFormat != SAMPLEFORMAT_VOID
    samplesPerPixel == 3 // unlass photometric == PHOTOMETRIC_PALETTE
    photometric == PHOTOMETRIC_RGB ||
       photometric == PHOTOMETRIC_PALETTE
    bitsPerSample == 1 || 
       bitsPerSample == 8 || 
       bitsPerSample == 16 || 
       bitsPerSample == 32 || 
       bitsPerSample == 64


  void tiffToScalarImage (...)
 
 

Convert single-band TiffImage to scalar image.

This function uses accessors to write the data.

Declarations:

pass arguments explicitly:

    namespace vigra {
        template <class ImageIterator, class Accessor>
        void
        tiffToScalarImage(TiffImage * tiff, ImageIterator iter, Accessor a)
    }

use argument objects in conjunction with Argument Object Factories:

    namespace vigra {
        template <class ImageIterator, class Accessor>
        void
        tiffToScalarImage(TiffImage * tiff, pair<ImageIterator, Accessor> dest)
    }

Usage:

#include "vigra/tiff.hxx"

    uint32 w, h;
    uint16 photometric
    TiffImage * tiff = TIFFOpen("tiffimage.tiff", "r");
    TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w);
    TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h);
    TIFFGetField(tiff_, TIFFTAG_PHOTOMETRIC, &photometric);
        
    if(photometric != PHOTOMETRIC_MINISWHITE &&
       photometric != PHOTOMETRIC_MINISBLACK)
    {
        // not a scalar image - handle error
    }
    
    vigra::BImage img(w,h);
    
    vigra::tiffToScalarImage(tiff, destImage(img));
    
    TIFFClose(tiff);

Required Interface:

    ImageIterator upperleft;
    <unsigned char, short, long, float, double> value;
    
    Accessor accessor;
               
    accessor.set(value, upperleft);

Preconditions:

ImageIterator must refer to a large enough image.

    uint16 sampleFormat, samplesPerPixel, bitsPerSample, photometric;
           
    TIFFGetField(tiff, TIFFTAG_SAMPLEFORMAT, &sampleFormat);
    TIFFGetField(tiff, TIFFTAG_SAMPLESPERPIXEL, &samplesPerPixel);
    TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bitsPerSample);
    TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric);

    sampleFormat != SAMPLEFORMAT_VOID
    samplesPerPixel == 1
    photometric == PHOTOMETRIC_MINISWHITE ||
       photometric == PHOTOMETRIC_MINISBLACK
    bitsPerSample == 1 || 
       bitsPerSample == 8 || 
       bitsPerSample == 16 || 
       bitsPerSample == 32 || 
       bitsPerSample == 64

© Ullrich Köthe (koethe@informatik.uni-hamburg.de)
Cognitive Systems Group, University of Hamburg, Germany

html generated using doxygen and Python
VIGRA 1.3.3 (18 Aug 2005)