This module import functions to manipulate images

image_wralea.serial.serial.wra_imread(filename)[source]

Reads an image file completely into memory.

It uses the file extension to determine how to read the file. It first tries some specific readers for volume images (Inrimages, TIFFs, LSMs, NPY) or falls back on PIL readers for common formats if installed.

In all cases the returned image is 3D (2D is upgraded to single slice 3D). If it has colour or is a vector field it is even 4D.

Parameters:
  • filename (str)
Returns Type:

|SpatialImage|

image_wralea.serial.serial.wra_imsave(filename, img)[source]

Save a |SpatialImage| to filename.

The filewriter is choosen according to the file extension. However all file extensions will not match the data held by img, in dimensionnality or encoding, and might raise `IOError`s.

For real volume data, Inrimage and NPY are currently supported. For |SpatialImage|s that are actually 2D, PNG, BMP, JPG among others are supported if PIL is installed.

Parameters:
image_wralea.serial.serial.wra_load(filename, mmap_mode)[source]

Load a pickled, .npy, or .npz binary file.

Parameters:
  • file (file or str)

  • mmap_mode (None, 'r+', 'r', 'w+', 'c') - optional

    If not None, then memory-map the file, using the given mode (see numpy.memmap). The mode has no effect for pickled or zipped files. A memory-mapped array is stored on disk, and not directly loaded into memory. However, it can be accessed and sliced like any ndarray. Memory mapping is especially useful for accessing small fragments of large files without reading the entire file into memory.

  • is_vectorial (bool) - specifically deal with file as if it was

    a 2D vectorial (RGB[A]) image so that it returns a 3D RGBA image and conforms to the contract.

Returns Type:

|SpatialImage|

image_wralea.serial.serial.wra_save(filename, img)[source]

Save an array to a binary file in numpy format with a |SpatialImage| header.

Warning

There is no way to distinguish a 2D RGB[A] image from a 3D scalar image. If img is a 2D RGB[A] image, make sure its shape is similar to (SX,SY,1,3) for RGB or (SX,SY,1,4) for RGBA.

Parameters:
  • filename (file or str) - Filename to which the data is saved.

    If the filename does not already have a ".npy" extension, it is added.

  • img (array)

  • is_vectorial (bool) - specifically deal with img as if it was

    a 2D vectorial (RGB[A]) image so that it saves it as a 3D RGBA image and conforms to the contract.

This Page