IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Functions

Read and write a Tiff image using IPSDK. More...

Functions

IPSDKIMAGEFILE_API ImagePtr ipsdk::image::file::loadTiffImageFiles (const boost::filesystem::path &dirPath, const std::string &pattern="*.tif|*.tiff", const eTiffDirectoryMode &tiffDirectoryMode=eTiffDirectoryMode::eTDM_Volume, const eTiffBufferMode &tiffBufferMode=eTiffBufferMode::eTBM_Default)
 function allowing to load an image from tiff image files contained in a given directory More...
 
IPSDKIMAGEFILE_API DiskImagePtr ipsdk::image::file::openTiffImageFile (const boost::filesystem::path &tiffFilePath, const eTiffDirectoryMode &tiffDirectoryMode=eTiffDirectoryMode::eTDM_Volume, const eTiffBufferMode &tiffBufferMode=eTiffBufferMode::eTBM_Default)
 function allowing to open a tiff file as a disk image More...
 
IPSDKIMAGEFILE_API void ipsdk::image::file::saveTiffImageFile (const boost::filesystem::path &tiffFilePath, const ImageConstPtr &pImage, const eTiffCompression &tiffCompression=eTiffCompression::eTC_Lzw)
 function allowing to save a tiff image file More...
 
IPSDKIMAGEFILE_API ImagePtr ipsdk::image::file::loadTiffImageFile (const boost::filesystem::path &tiffFilePath, const eTiffDirectoryMode &tiffDirectoryMode=eTiffDirectoryMode::eTDM_Volume, const eTiffBufferMode &tiffBufferMode=eTiffBufferMode::eTBM_Default)
 function allowing to load a tiff image file More...
 
IPSDKIMAGEFILE_API void ipsdk::image::file::loadTiffImageFile (const boost::filesystem::path &tiffFilePath, ImagePtr &pOutImg, const eTiffDirectoryMode &tiffDirectoryMode=eTiffDirectoryMode::eTDM_Volume, const eTiffBufferMode &tiffBufferMode=eTiffBufferMode::eTBM_Default)
 function allowing to load a tiff image file More...
 
IPSDKIMAGEFILE_API ImagePtr ipsdk::image::file::loadTiffImageFile (const boost::filesystem::path &tiffFilePath, const eTiffBufferMode &tiffBufferMode)
 function allowing to load a tiff image file More...
 
IPSDKIMAGEFILE_API void ipsdk::image::file::loadTiffImageFile (const boost::filesystem::path &tiffFilePath, const eTiffBufferMode &tiffBufferMode, ImagePtr &pOutImg)
 function allowing to load a tiff image file More...
 

Detailed Description

Read and write a Tiff image using IPSDK.

This page briefly presents how to load an image from a TIFF file using IPSDK.

Read and write an image from a TIFF file in C++

First, the header to include to load and save an image from a TIFF file is :

To save an image in a TIFF file, only the following instruction is needed :

saveTiffImageFile(imageFilePath, pImg);

In the same way, these following instruction allows to load an image from a TIFF file :

ImagePtr pImg = loadTiffImageFile(imageFilePath);
Note
In the case of images saved by another environment than IPSDK, some flags must be missing in the header. In this case, it is necessary to specify the flags ipsdk::image::file::eTiffDirectoryMode and ipsdk::image::file::eTiffBufferMode to correctly read the image.
Tiff format allows to associate a resolution to image file. This resolution is defined by three flags :
  • TIFFTAG_RESOLUTIONUNIT which allows to associate a unit string ('cm' or 'inch') to image
  • TIFFTAG_XRESOLUTION and TIFFTAG_YRESOLUTION which define number of pixels per measure unit.
    If these information are provided with tiff image, the library will automatically associate a geometric calibration to image (see Basic image manipulation).

Read and write an image from a TIFF file in Python

In Python, an image can then be saved (or loaded) to (from) a TIFF file with the following instructions :

# Save an image
PyIPSDK.saveTiffImageFile(inputImgPath, img)
# Load an image
img = PyIPSDK.loadTiffImageFile(inputImgPath)

Read an image from several TIFF files

Because the large size of images, some acquisition devices store the images in several files (one slice or frame per file). IPSDK is able to load several TIFF image files and concatenate them into a single image, along the Z-axis or the temporal dimension. This is done by the function ipsdk::image::file::loadTiffImageFiles :

ImagePtr pImg = loadTiffImageFiles(dirPath);

In Python, this is done by the following command :

img = PyIPSDK.loadTiffImageFiles(dirPath);

Function Documentation

◆ loadTiffImageFile() [1/4]

IPSDKIMAGEFILE_API ImagePtr ipsdk::image::file::loadTiffImageFile ( const boost::filesystem::path &  tiffFilePath,
const eTiffDirectoryMode tiffDirectoryMode = eTiffDirectoryMode::eTDM_Volume,
const eTiffBufferMode tiffBufferMode = eTiffBufferMode::eTBM_Default 
)

function allowing to load a tiff image file

Note
tiffDirectoryMode and tiffBufferMode parameters will only be interpreted in case of external tiff images, IPSDK tiff images provided embedded image geometry
Exceptions
ipsdk::image::file::IPSDKImageFileExceptionon failure

◆ loadTiffImageFile() [2/4]

IPSDKIMAGEFILE_API ImagePtr ipsdk::image::file::loadTiffImageFile ( const boost::filesystem::path &  tiffFilePath,
const eTiffBufferMode tiffBufferMode 
)

function allowing to load a tiff image file

Note
tiffBufferMode parameter will only be interpreted in case of external tiff images, IPSDK tiff images provided embedded image geometry
Exceptions
ipsdk::image::file::IPSDKImageFileExceptionon failure

◆ loadTiffImageFiles()

IPSDKIMAGEFILE_API ImagePtr ipsdk::image::file::loadTiffImageFiles ( const boost::filesystem::path &  dirPath,
const std::string &  pattern = "*.tif|*.tiff",
const eTiffDirectoryMode tiffDirectoryMode = eTiffDirectoryMode::eTDM_Volume,
const eTiffBufferMode tiffBufferMode = eTiffBufferMode::eTBM_Default 
)

function allowing to load an image from tiff image files contained in a given directory

Note
tiffDirectoryMode parameter will only be interpreted in case of external tiff images, IPSDK tiff images provided embedded image geometry
Exceptions
ipsdk::image::file::IPSDKImageFileExceptionon failure
ipsdk::image::file::IPSDKImageFileExceptionif pattern string is invalid (see detailed description of the function)
Returns
Image loaded from files matching pattern; return an uninitialized pointer if no file has been found
Parameters
dirPathpath of the directory containing the files from which the image is built
patternfile pattern used to filter the set of files found in directory. See the detailed description below

This function loads an image from the TIFF files that are contained in the directory 'dirPath' and that match the pattern(s) specified by the user. Several patterns can be specified by the user, separated by the dedicated character '|'. In that case, for each file found in the directory, the function test the match with each pattern one by one, until a successful match is found. The files found are either sorted alphabetically or numerically, if the pattern string contains the string "<INDEX>". Here is a complete list of the reserved key characters and key words that can be used in the pattern string:

  • '*': stands for "any set of characters, of any size (0 or greater)"
  • '<INDEX>: wait for unsigned integer, that will be assigned to index argument Here are a few examples of pattern matching results:
  • matching "my_image_003.tif" with pattern "image" will return false
  • matching "my_image_003.tif" with pattern "*image*" will return true
  • matching "my_image_003.tif" with pattern "*image*.tif" will return true
  • matching "my_image_003.tif" with pattern "*image*.tiff" will return false
  • matching "my_image_003.tif" with pattern "m*image*$INDEX$.*" will return true,
  • matching a directory containing "image_100.tif", "image_90.tiff", image_91.tif" with pattern "image*.tif" will return, in order: ("image_100.tif", "image_91.tif") - matching a directory containing "image_100.tif", "image_90.tiff", image_91.tif" with pattern "image_<INDEX>.tif" will return, in order: ("image_91.tif", "image_100.tif")
  • matching a directory containing "image_100.tif", "image_90.tiff", image_91.tif" with pattern "image_<INDEX>.tiff" will return "image_90.tiff" - matching a directory containing "image_100.tif", "image_90.tiff", image_91.tif" with pattern "image*.tif|image*.tiff" will return, in order: ("image_100.tif", "image_90.tif", "image_91.tif")
  • matching a directory containing "image_100.tif", "image_90.tiff", image_91.tif" with pattern "image*<INDEX>.tif|image*<INDEX>.tiff" will return, in order: ("image_90.tif", "image_91.tif", "image_100.tif") \note if you specify several patterns in the 'pattern' argument, you cannot mix patterns including "<INDEX>" keyword with patterns not including it and value 3 will be assigned to index

◆ openTiffImageFile()

IPSDKIMAGEFILE_API DiskImagePtr ipsdk::image::file::openTiffImageFile ( const boost::filesystem::path &  tiffFilePath,
const eTiffDirectoryMode tiffDirectoryMode = eTiffDirectoryMode::eTDM_Volume,
const eTiffBufferMode tiffBufferMode = eTiffBufferMode::eTBM_Default 
)

function allowing to open a tiff file as a disk image

Exceptions
ipsdk::image::file::IPSDKImageFileExceptionon failure

◆ saveTiffImageFile()

IPSDKIMAGEFILE_API void ipsdk::image::file::saveTiffImageFile ( const boost::filesystem::path &  tiffFilePath,
const ImageConstPtr pImage,
const eTiffCompression tiffCompression = eTiffCompression::eTC_Lzw 
)

function allowing to save a tiff image file

Exceptions
ipsdk::image::file::IPSDKImageFileExceptionon failure

◆ loadTiffImageFile() [3/4]

IPSDKIMAGEFILE_API void ipsdk::image::file::loadTiffImageFile ( const boost::filesystem::path &  tiffFilePath,
ImagePtr pOutImg,
const eTiffDirectoryMode tiffDirectoryMode = eTiffDirectoryMode::eTDM_Volume,
const eTiffBufferMode tiffBufferMode = eTiffBufferMode::eTBM_Default 
)

function allowing to load a tiff image file

Note
tiffDirectoryMode and tiffBufferMode parameters will only be interpreted in case of external tiff images, IPSDK tiff images provided embedded image geometry
Exceptions
ipsdk::image::file::IPSDKImageFileExceptionon failure

◆ loadTiffImageFile() [4/4]

IPSDKIMAGEFILE_API void ipsdk::image::file::loadTiffImageFile ( const boost::filesystem::path &  tiffFilePath,
const eTiffBufferMode tiffBufferMode,
ImagePtr pOutImg 
)

function allowing to load a tiff image file

Note
tiffBufferMode parameter will only be interpreted in case of external tiff images, IPSDK tiff images provided embedded image geometry
Exceptions
ipsdk::image::file::IPSDKImageFileExceptionon failure