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

| Import/export of the TIFF format |

## Functions

template<... >
void | createRGBTiffImage (...)
| Create a 3-band TiffImage from the given RGB image.
template<... >
void | createScalarTiffImage (...)
| Create a single-band TiffImage from the given scalar image.
template<... >
void | createTiffImage (...)
| Create a TiffImage from the given iterator range.
template<... >
void | importTiffImage (...)
| Convert given TiffImage into image specified by iterator range.
template<... >
void | tiffToRGBImage (...)
| Convert RGB (3-band or color-mapped) TiffImage to RGB image.
template<... >
void | tiffToScalarImage (...)
| Convert single-band TiffImage to scalar 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 vigra::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 vigra::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

void vigra::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 // unless photometric == PHOTOMETRIC_PALETTE
        photometric == PHOTOMETRIC_RGB ||
           photometric == PHOTOMETRIC_PALETTE
        bitsPerSample == 1 ||
           bitsPerSample == 8 ||
           bitsPerSample == 16 ||
           bitsPerSample == 32 ||
           bitsPerSample == 64

void vigra::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>
            TiffImage *
            createTiffImage(ImageIterator upperleft, ImageIterator lowerright,
                            Accessor a)
        }

use argument objects in conjunction with Argument Object Factories :

        namespace vigra {
            template <class ImageIterator, class Accessor>
            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 vigra::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>
            TiffImage *
            createScalarTiffImage(ImageIterator upperleft, ImageIterator lowerright,
                      Accessor a)
        }

use argument objects in conjunction with Argument Object Factories :

        namespace vigra {
            template <class ImageIterator, class Accessor>
            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 vigra::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>
            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

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.9.0 (Tue Nov 6 2012)