IPSDK 0.2
IPSDK : Image Processing Software Development Kit
IPSDK Concepts documentation See full documentation

Image creation

Image creation in C++

The main image structure is ipsdk::image::BaseImage. The easiest way to create an IPSDK image is to define a geometry and initialize a ipsdk::image::MemoryImage, a class inheriting the ipsdk::image::BaseImage class, with this geometry.

Typically, it is possible to initialize a 2d RGB image, with float data type, in C++ with the following lines :

ImageGeometryPtr pImageGeometry = geometryRgb2d(eImageBufferType::eIBT_Real32, sizeX, sizeY);
boost::shared_ptr<MemoryImage> pImg(boost::make_shared<MemoryImage>());
pImg->init(*pImageGeometry);

Where sizeX and sizeY are the image dimensions respectively along the x and y axis.

Image creation in Python

In Python, several wrappers allow to create an image, giving the image dimensions and the buffer type. Typically, the equivalent code in Python of the C++ sample above is :

img = PyIPSDK.createImageRgb(PyIPSDK.eImageBufferType.eIBT_Real32, sizeX, sizeY)

Wrappers are available so that images with simple and frequently used geometry can be directly created :

# Create a 2d grey level image with size 256x128 respectively along the x and y-axis, with type unsigned 8-bits integer
img = PyIPSDK.createImage(PyIPSDK.eImageBufferType.eIBT_UInt8, 256, 128)
# Create a 2d RGB image with size 256x128 respectively along the x and y-axis, with type unsigned 8-bits integer
img = PyIPSDK.createImageRgb(PyIPSDK.eImageBufferType.eIBT_UInt8, 256, 128)
# Create a 2d RGB image sequence of 20 frames with size 256x128 respectively along the x and y-axis, with type unsigned 8-bits integer
img = PyIPSDK.createImageSeq(PyIPSDK.eImageBufferType.eIBT_UInt8, 256, 128, 20)
# Create a 3d grey level image with size 256x128x64 respectively along the x, y and z-axis, with type unsigned 8-bits integer
img = PyIPSDK.createImage(PyIPSDK.eImageBufferType.eIBT_UInt8, 256, 128, 64)

Less usual geometries can be specified by passing it directly as input parameter of the function createImage. For instance, the example given in C++ can also be translated in Python by the command :

img = PyIPSDK.createImage(PyIPSDK.geometryRgb2d(PyIPSDK.eImageBufferType.eIBT_Real32, sizeX, sizeY))

Please, see Image geometry concepts in IPSDK for more details about the image geometry.

Note
The package PyIPSDK has to be imported.

Retrieve the image geometry information

It is possible to retrieve the geometry from an existing image. In this way, we can get the geometry component (color, temporal or volume geometry) or directly the geometry information : the size along the x, y or z axis, the number of channels, the number of frames and the image buffer type.

Here are two examples of information extraction in C++ :

const ipUInt32 sizeX = pImg->getSizeX();
const eImageBuffertype imageBufferType = pImg->getBufferType();

The equivalent in Python is :

sizeX = img.getSizeX()
imageBufferType = img.getBufferType()

Image geometric calibration

IPSDK images can be associated to a geometric calibration. This object allows to define :

The user can check whether an image has been associated to a geometric calibration using the method ipsdk::image::BaseImage::hasGeometricCalibration() const. Image geometric calibration can be retrieved using the method ipsdk::image::BaseImage::getGeometricCalibration() const and updated using the method ipsdk::image::BaseImage::setGeometricCalibration(). For more informations on geometric calibration please see Image calibration concepts in IPSDK.

Note
some file format contains an image geometric calibration. In this case, it will be automatically loaded with image data (see Tiff image files for example).