[ 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. More...
template<... >
void | createScalarTiffImage (...)
| Create a single-band TiffImage from the given scalar image. More...
template<... >
void | createTiffImage (...)
| Create a TiffImage from the given iterator range. More...
template<... >
void | importTiffImage (...)
| Read a given TIFF image. More...
template<... >
void | tiffToRGBImage (...)
| Import a RGB (3-band or color-mapped) TiffImage into a RGB image. More...
template<... >
void | tiffToScalarImage (...)
| Convert single-band TiffImage to scalar image. More...

## 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 | ( |  | ... | ) |

Read a given TIFF image.

This function calls tiffToScalarImage() or tiffToRGBImage(), depending on the destinations's value_type. Usually, it is better to use importImage(). importTiffImage() should only be used if explicit access to the TIFF object `TiffImage` is required.

Declarations:

pass 2D array views:

namespace vigra {
template <class T, class S>
void
importTiffImage(TiffImage * tiff, MultiArrayView<2, T, S> dest);
}

show deprecated declarations

pass Image Iterators and Data Accessors :
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>
Namespace: vigra

uint32 w, h;
TiffImage * tiff = TIFFOpen("tiffimage.tiff", "r");
TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w);
TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h);
MultiArray<2, unsigned char> img(w,h);
importTiffImage(tiff, img);
TIFFClose(tiff);

Required Interface:

see tiffToScalarImage() and tiffToRGBImage()

Preconditions:

see tiffToScalarImage() and tiffToRGBImage()

void vigra::tiffToScalarImage | ( |  | ... | ) |

Convert single-band TiffImage to scalar image.

Note that unexpected results can occur when the destination pixel type is weaker than the pixel type in the file (e.g. when a `float` file is imported into a `unsigned char` image).

Declarations:

pass 2D array views:

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

show deprecated declarations

pass Image Iterators and Data Accessors :
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>
Namespace: vigra

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
}
MultiArray<2, unsigned char> img(w,h);
tiffToScalarImage(tiff, img);
TIFFClose(tiff);

show deprecated examples

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:

The output array must have the correct shape.

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 | ( |  | ... | ) |

Import a RGB (3-band or color-mapped) TiffImage into a RGB image.

Note that unexpected results can occur when the destination pixel type is weaker than the pixel type in the file (e.g. when a `float` file is imported into a `unsigned char` image).

Declarations:

pass 2D array views:

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

show deprecated declarations

pass Image Iterators and Data Accessors :
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>
Namespace: vigra

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
}
MultiArray<2, RGBValue<unsigned char> > img(w, h);
tiffToRGBImage(tiff, img);
TIFFClose(tiff);

show deprecated examples

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:

The destination image must have the appropriate size.

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.

Usually, it is better to use exportImage(). createTiffImage() should only be used if explicit access to the TIFF object `TiffImage` is required.

Declarations:

pass 2D array views:

namespace vigra {
template <class T, class S>
void
createTiffImage(MultiArrayView<2, T, S> const & src, TiffImage * tiff);
}

show deprecated declarations

pass Image Iterators and Data Accessors :
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>
Namespace: vigra

MultiArray<2, float> img(width, height);
...
TiffImage * tiff = TIFFOpen(("tiffimage.tiff", "w");
createTiffImage(img, tiff);
TIFFClose(tiff); // implicitly writes the image to the disk

show deprecated examples

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).

Declarations:

pass 2D array views:

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

show deprecated declarations

pass Image Iterators and Data Accessors :
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>
Namespace: vigra

MultiArray<2, float> img(width, height);
...
TiffImage * tiff = TIFFOpen(("tiffimage.tiff", "w");
createScalarTiffImage(img, tiff);
TIFFClose(tiff); // implicitly writes the image to the disk

show deprecated examples

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).

Declarations:

pass 2D array views:

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

show deprecated declarations

pass Image Iterators and Data Accessors :
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>
Namespace: vigra

MultiArray<2, RGBValue<unsigned char> > img(width, height);
...
TiffImage * tiff = TIFFOpen(("tiffimage.tiff", "w");
createRGBTiffImage(img, tiff);
TIFFClose(tiff); // implicitly writes the image to the disk

show deprecated examples

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.11.1 (Fri May 19 2017)