SMIL  1.0.3
IO and Image Formats

Detailed Description

Functions

RES_T getHttpFile (const char *url, const char *outfilename)
 Get a file from an URL. More...
 
string getHttpFile (const char *url)
 Get a file from an URL. More...
 
template<class T >
RES_T read (const char *filename, Image< T > &image)
 Read image file. More...
 
template<class T >
RES_T read (const vector< string > fileList, Image< T > &image)
 Read a stack of 2D images and convert then into a 3D image. More...
 
template<class T >
RES_T write (const Image< T > &image, const char *filename)
 Write image into file. More...
 
template<class T >
RES_T write (const Image< T > &image, const vector< string > fileList)
 Write a 3D image as a stack of 2D image files. More...
 
RES_T getFileInfo (const char *filename, ImageFileInfo &fInfo)
 Get information about an image file. More...
 
BaseImagecreateFromFile (const char *filename)
 createFromFile TBD
 
template<class T >
RES_T readRAW (const char *filename, size_t width, size_t height, size_t depth, Image< T > &image)
 Get an image saved in a RAW format. More...
 
template<class T >
RES_T writeRAW (Image< T > &image, const char *filename)
 Save an image in a RAW format. More...
 

Function Documentation

◆ getHttpFile() [1/2]

RES_T getHttpFile ( const char *  url,
const char *  outfilename 
)

Get a file from an URL.

Parameters
[in]url: URL where to get the file
[in]outfilename: name of the file where to save the file

◆ getHttpFile() [2/2]

string getHttpFile ( const char *  url)

Get a file from an URL.

Download file data into a string buffer.

Parameters
[in]url: URL where to get the file
Returns
string : a buffer with file content

◆ read() [1/2]

RES_T read ( const char *  filename,
Image< T > &  image 
)

Read image file.

Parameters
[in]filename: filename (with path) to read
[out]image: output image
Note
The following file types are recognized : BMP JPG PBM PNG TIFF VTK

Example

import smilPython as sp
img = sp.Image()
r = sp.getFileInfo("lena.jpg", img)
# Note, this is the same as :
img = sp.Image("lena.jpg")

◆ read() [2/2]

RES_T read ( const vector< string >  fileList,
Image< T > &  image 
)

Read a stack of 2D images and convert then into a 3D image.

Parameters
[in]fileList: list of 2D image files to read
[out]image: output image
Note
The output 3D image will have the width and height of the first (2D) image and the number of images for depth.
The following file types are recognized : BMP JPG PBM PNG TIFF VTK

◆ write() [1/2]

RES_T write ( const Image< T > &  image,
const char *  filename 
)

Write image into file.

Parameters
[in]image: image to write to file
[in]filename: file name

◆ write() [2/2]

RES_T write ( const Image< T > &  image,
const vector< string >  fileList 
)

Write a 3D image as a stack of 2D image files.

The file list must contain the same number of filenames as the 3D image depth.

Parameters
[in]image: image to write to file
[in]fileList: list of filenames.

Example:

im1 = Image("img3d.vtk")
fileNames = [ "img{:03d}.png".format(i) for i in range(im1.getDepth()) ]
write(im1, fileNames)
RES_T write(const Image< T > &image, const char *filename)
Write image into file.
Definition: DImageIO.hxx:184

◆ getFileInfo()

RES_T getFileInfo ( const char *  filename,
ImageFileInfo &  fInfo 
)

Get information about an image file.

Parameters
[in]filename: filename
[out]fInfo: struct ImageFileInfo with image information

◆ readRAW()

RES_T smil::readRAW ( const char *  filename,
size_t  width,
size_t  height,
size_t  depth,
Image< T > &  image 
)

Get an image saved in a RAW format.

Parameters
[in]filename: file name
[in]width,height,depth: image dimensions
[out]image: output image
Note
  • RAW format here means a format without metadata, i.e. just a stream of data and not the RAW format from camera makers (NEF, RAF, CR2, ...)
  • Pixel data type and image dimensions shall be known in advance as the file doesn't contains metadata
  • At some contexts data may need to be adapted. E.g. transformed from bigendian to littleendian or from float to UINT8.

Example

import smilPython as sp
fname = "imageraw.raw"
type = 'UINT16'
width = 256
height = 384
depth = 512
img = sp.Image(type)
sp.readRAW(fname, width, height, depth, img)

◆ writeRAW()

RES_T smil::writeRAW ( Image< T > &  image,
const char *  filename 
)

Save an image in a RAW format.

Parameters
[in]image: input image
[in]filename: file name
Note
RAW format here means a format without metadata, i.e. just a stream of data and not the RAW format from camera makers (NEF, RAF, CR2, ...)