Image Management
Images are a crucial type of objects in the SDK, especially concerning scene appearance, since they are used to define textures for model materials.
Read time 9 minutesLast updated 10 hours ago
material.blurImagematerial.clearImageRoImaterial.convertFloat32To8BitsImagematerial.convertImagematerial.createCheckerboardImagematerial.createImageFromDatamaterial.createImageFromDefinitionmaterial.createImagesFromDefinitionsmaterial.exportImagematerial.extractImageChannelsmaterial.extractImageComponentsmaterial.fillImageWithColormaterial.fillUnusedPixelsmaterial.flipImageYmaterial.getAllImagesmaterial.getExportImageFormatsmaterial.getImageColorRangematerial.getImageComponentTypematerial.getImageComponentTypeNamematerial.getImageDefinitionmaterial.getImageDefinitionsmaterial.getImageLayoutmaterial.getImagePixelColormaterial.getImagePixelInfomaterial.getImagePixelInfoFromDefinitionmaterial.getImagePixelInfoFromLayoutAndTypematerial.getImageSizematerial.getImagesSizesmaterial.getImportImageFormatsmaterial.getSubImagematerial.importImagematerial.invertImageColormaterial.overrideImageFormatmaterial.resizeImagematerial.rotateImagematerial.setImageRoImaterial.setSubImagematerial.stretchImagematerial.transformImagematerial.translateImagematerial.updateImageFromDefinitionmaterial.updateImagesFromDefinitions
Image formats
The pixel format of an image describes how its binary data must be interpreted in order to produce a color. A format is defined by:- a layout, saying how many channels the image is made of and which component is stored in each of them,
- a component type, describing how values of image components are encoded.
Layout
The layout describes which component is stored in each image channel. Each component can be either R (red), G (green), B (blue), A (alpha) or Lum (luminance, for gray scale images), and the layout is a combination of these values. It can be recovered by the functions material.getImageLayout and material.getImageDefinition. Note that the layout corresponds to the internal arrangement of the image data, but accessing image pixels via the material.getImagePixelColor function is agnostic to the internal representation and always returns a consistent color. The set of supported image layouts is listed in the following table:Layout | Number of | Color returned by |
|---|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 3 | |
| 4 | |
| 4 | |
| 1 | |
| 2 | |
material.ImageLayout.Component type
A component type is defined by four attributes:- a size (number of bits), which implicitely defines the numerical precision of the type,
- an internal representation (floating point or integer),
- a signedness flag, defining whether negative values are allowed or not,
- a normalization flag, indicating whether integers must be interpreted as reals or not.
Type | Size | Internal | Signed | Normalized |
|---|---|---|---|---|
| 1 | integer | ✔ | |
| 1 | integer | ||
| 1 | integer | ✔ | ✔ |
| 1 | integer | ✔ | |
| 2 | integer | ✔ | |
| 2 | integer | ||
| 2 | integer | ✔ | ✔ |
| 2 | integer | ✔ | |
| 2 | floating point | ✔ | |
| 4 | integer | ✔ | |
| 4 | integer | ||
| 4 | integer | ✔ | ✔ |
| 4 | integer | ✔ | |
| 4 | floating point | ✔ | |
| 8 | integer | ✔ | |
| 8 | integer | ||
| 8 | integer | ✔ | ✔ |
| 8 | integer | ✔ | |
| 8 | floating point | ✔ |
material.ImageComponentType.N[0, 2^N-1][-2^{N-1}, 2^{N-1}-1][0, 1][-1, 1]x_rx_iNx_r = \frac{x_i}{2^N - 1}x_r = \frac{x_i}{2^{N-1} - 1}x_i = -2^{N-1}-1-1Format conversion rules
The API provides functions for image conversions between different formats (material.convertImagematerial.convertImageToDefinitionmaterial.convertFloat32To8BitsImage- a component that exists in both source and destination layouts is transferred by converting the data type:
- out-of-bound values are clamped to the validity range of the destination type, if needed,
- reals are converted to integers by rounding them to the closest one.
- if a component in the destination does not exist in the source, a default value is assigned to it:
- default R, G, B or Lum = 0.0,
- default A = 1.0.
- the Lum component in the source is transferred to any of the destination component of type R, G or B.
- the R, G and B components in the source are converted to the Lum component in the destination by: .
Lum = (R + G + B) / 3 - if only the layout is modified and not the component type, channels are rearranged so as to match the destination format but their contents are left unchanged.
material.ImageLayout.Rmaterial.ImageLayout.B(R, 0, 0, 1)(0, 0, B = R, 1(0, 0, 0, 1)material.overrideImageFormatImage operations
Import / export
The list of image file formats and extensions available formaterial.importImagematerial.exportImageCreation
- can be used to create an image from the raw data corresponding to a valid image file format.
material.createImageFromData - /
material.createImageFromDefinitionmaterial.createImagesFromDefinitions - /
material.updateImageFromDefinitionhave the same behaviour asmaterial.updateImagesFromDefinitions, except that they replace existing images instead of creating a new ones.createImageFromDefinition - creates a bicolor checkerboard. Mainly useful for tests or debugging purposes.
material.createCheckerboardImage
Accessors
The two main structures that contain information about images are:- , which allows to access raw image pixel data, as well as image dimension and format,
material.ImageDefinition - , which gives additional details about the pixel format, like component count and size, and type attributes (internal representation, normalization, signedness).
material.PixelInfo
material.getImageComponentTypematerial.getImageComponentTypeNamematerial.getImageFormatNamematerial.getImageLayout- /
material.getImagePixelInfo/material.getImagePixelInfoFromDefinitionmaterial.getImagePixelInfoFromLayoutAndType
- returns the list of all images available in the current session.
material.getAllImages - /
material.getImageDefinitionreturns the definition (as described above) of one or multiple images.material.getImageDefinitions - /
material.getImageSizereturn the dimensions (width and height) of one or multiple images.material.getImagesSizes - returns the color quadruplet (R,G,B,A) of a single image pixel, converted from the raw data according to the image format.
material.getImagePixelColor - returns a bi-linearly interpolated color from image coordinates expressed as real numbers.
material.getImageColorBilinear - returns, for each color component, the min and max values of the whole image. This can be provided, for instance, to the function
material.getImageColorRangein order to remap from an unbound range to a valid 8bits range.convertFloat32To8BitsImage
Modifiers
Conversion and component manipulation:- enables to change the image format of an image without modifying its data, in order to change the way data are interpreted.
material.overrideImageFormat - /
material.convertImage/material.convertImageToDefinitionprovide a way to convert the image from one format to another.material.convertFloat32To8BitsImage - /
material.extractImageChannelsallow to decompose the different components the image is made of.material.extractImageComponents
- changes the image dimensions and rescales its content accordingly.
material.resizeImage - applies a rotation to the image content.
material.rotateImage - applies a non-uniform scaling to the image content.
material.stretchImage - applies a translation to the image content.
material.translateImage - applies a generic 3x3 matrix to the image content.
material.transformImage
- fills a sub-part or a whole image with a single color.
material.fillImageWithColor - replaces, for each pixel, the value V by 1 - V. This function is not expected to produce relevant results for images with non-normalized component types.
material.invertImageColor - /
material.setSubImagespecifies or extracts the sub-part of an image.material.getSubImage - applies a box or a Gaussian filter to the image.
material.blurImage - allows to fill pixels in areas considered as "invalid" by dilation of valid areas. The pixel validity state can be specified either by a background color or by a validity mask.
material.fillUnusedPixels - reverts the order of scanlines along the image Y axis.
material.flipImageY
Edge filters
Some of the image modifiers listed above accept an edge filter as argument (material.blurImage
|
|
|
|
|---|---|---|---|
![]() | ![]() | ![]() | ![]() |
The default color | The color of the closest valid boundary pixel is returned | The image is repeated by taking coordinates modulus | The image is repeated in a mirrored way |
Regions of interest
Sometimes, it may be desired to apply a modifier to only a sub-part of an image. This can be achieved by the mean of regions of interest (RoI). The functionmaterial.setImageRoImaterial.rotateImage![]() | ![]() | ![]() |
|---|---|---|
| Original image | Rotation without RoI | Rotation with RoI |






