Vigranumpy Reference

Introduction

Vigranumpy exports the functionality of the C++ image processing library VIGRA to Python. It can be invoked by importing the vigra module:

import vigra

Vigranumpy is based on the popular numpy module and uses its ndarray data structure to represent image and volume data. Thus, it is fully interoperable with existing numpy functionality, including various tools for image display such as matplotlib. Since vigranumpy uses boost_python, it is able to support function overloading (which plain Python does not provide), so that calling syntax is largely uniform, regardless of the type and dimension of the input arguments.

Basic calling syntax is similar to C++, with one important difference: Arguments for output images are optional. If no output image is provided, vigranumpy will allocate it as appropriate. In either case, the output image will be returned by the function, for example:

# allocate new result image
smoothImage = vigra.gaussianSmoothing(inputImage, scale)

# reuse and overwrite existing result image
smoothImage = vigra.gaussianSmoothing(inputImage, scale, out=smoothImage)

Unless otherwise noted, all functions expect and create arrays with dtype=numpy.float32.

Another important property is vigranumpy’s indexing convention. In order to be compatible with the index order of the VIGRA C++ version and many other libraries (e.g. Qt and Image Magick), and with standard mathematical notation, images are indexed in the following order:

value = scalarImage[x, y]
value = multibandImage[x, y, channel]

value = scalarVolume[x, y, z]
value = multibandVolume[x, y, z, channel]

where x is the horizontal axis (increasing left to right), and y is the vertical axis (increasing top to bottom). This convention differs from the Python Imaging Library and Matlab, where the spatial indices must be given in reverse order (e.g. scalarImage[y, x]). Either convention has advantages and disadvantages. In the end, we considered compatibility between the Python and C++ versions of VIGRA to be a very critical feature in order to prevent subtle errors when porting from one language to the other, so we went with the [x, y] order described. Note that this convention does not change the internal representation of the data in memory. It only changes the indexing order, so that one can switch between the different conventions by simply swapping axes, for example:

vigraImage  = array2D.swapaxes(0, 1).view(vigra.ScalarImage)
array2D     = vigraImage.swapaxes(0, 1).view(numpy.ndarray)

vigraVolume = array3D.swapaxes(0, 2).view(vigra.ScalarVolume)
array3D     = vigraVolume.swapaxes(0, 2).view(numpy.ndarray)

In order to turn your own C++ VIGRA functions into Python modules, look at the VIGRA wrapper class NumpyArray and the source code of the existing vigranumpy modules.

Image and Volume Data Structures

Vigranumpy can work directly on numpy.ndarrays. However, plain ndarrays do not carry any information about the semantics of the different coordinate axes. For example, one cannot distinguish a 2-dimensional RGB image from a scalar volume data set that happens to contain only three slices. In order to distinguish between arrays that have the same structure but different interpretation, vigra.arraytypes provides the following array classes:

numpy.ndarray
    Image
        ScalarImage
        Vector2Image
        Vector3Image
            RGBImage
        Vector4Image
    Volume
        ScalarVolume
        Vector2Volume
        Vector3Volume
            RGBVolume
        Vector4Volume
        Vector6Volume

list
    ImagePyramid

where indentation encodes inheritance. Below, we describe Image, ScalarImage, RGBImage, and ImagePyramid in detail, the other classes work analogously. The new array classes serve several purposes:

  • Semantic interpretation improves code readability.

  • vigra.arraytypes maximize compatibility with corresponding VIGRA C++ types. In particular, vigra.arraytype constructors ensure that arrays are created with the most appropriate memory layout on the Python side. For example, RGBImage (with dtype=numpy.float32) can be mapped to MultiArrayView<2, RGBValue<float> >.

  • The distinction of different array types allows for more fine-grained overload resolution and thus improves mapping from Python to C++. For example, gaussianSmoothing() works differently for 2D RGBImages and 3D ScalarVolumes, although both kinds of arrays have the same 3-dimensional memory layout.

  • The array types help simplify use of the vigranumpy indexing convention:

    image[x, y, channel]
    volume[x, y, z, channel]
    

    In particular, they overload ‘__str__’ and ‘__repr__’ (used in print), ‘flatten’, and ‘imshow’ (for matplotlib-based image display) so that these functions work in the expected way (i.e. images are printed in horizontal scan order and are displayed upright). Note that other Python imaging modules (such as PIL) use a different indexing convention (namely image[y, x, channel]).

  • vigra.arraytypes and vigra.ufunc overload numpy.ufunc (i.e. basic mathematical functions for arrays). See Mathematical Functions and Type Coercion for details.

Mapping between C++ types and Python types is controlled by the following two functions:

vigra.registerPythonArrayType()
registerPythonArrayType( (str)key, (object)typeobj [, (object)typecheck=None]) -> None :

registerPythonArrayType(key, typeobj, typecheck = None)

Register a mapping from a C++ type (identified by its string ‘key’) to a Python-defined array type ‘typeobj’. This mapping is applied whenever an object of this C++ type is contructed or returned to Python. The registered ‘typeobj’ must be a subclass of numpy.ndarray.

‘key’ can be a fully qualified type (e.g. ‘NumpyArray<2, RGBValue<float32> >’), or it can contain ‘*’ as a placeholder for the value type (e.g. ‘NumpyArray<2, RGBValue<*> >’). The fully qualified key takes precedence over the placeholder key when both have been registered. If no key was registered for a particular C++ type, it is always handled as a plain numpy ndarray. Call ‘listExportedArrayKeys()’ for the list of recognized keys.

Optionally, you can pass a ‘typecheck’ function. This function is executed when an instance of ‘typeobj’ is passed to C++ in order to find out whether conversion into the C++ type identified by ‘key’ is allowed. The function must return ‘True’ or ‘False’. This functionality is useful to distinguish object (e.g. during overload resolution) that have identical memory layout, but different semantics, such as a multiband image (two spatial dimensions and one spectral dimension) vs. a singleband volume (three spatial dimensions).

Usage (see vigra/arraytypes.py for a more realistic example):

class Image(numpy.ndarray):
   spatialDimensions = 2
class Volume(numpy.ndarray):
   spatialDimensions = 3

def checkImage(obj):
   return obj.spatialDimensions == 2
def checkVolume(obj):
   return obj.spatialDimensions == 3

registerPythonArrayType('NumpyArray<2, RGBValue<*> >', Image, checkImage)
registerPythonArrayType('NumpyArray<3, Singleband<*> >', Volume, checkVolume)

The current mapping configuration can be obtained by calling listExportedArrayKeys().

vigra.listExportedArrayKeys()
listExportedArrayKeys() -> list :
List the currently active type mappings between C++ NumpyArray and Python array types. This provides status information for registerPythonArrayType().

class vigra.Image

Bases: vigra.arraytypes._VigraArray

Constructor:

Image(obj, dtype=numpy.float32, order='V', init = True, value = None)
Parameters:
  • obj – a data or shape object (see below)
  • dtype – desired element type
  • order – desired memory layout (see below)
  • init (boolean) – True: initialize the image with zeros; False: do not initialize the image
  • value (convertible to dtype) – initialize the image with this value (overrides init)

obj may be one of the following

  • If obj is a vigra.Image or a subclass, a copy of obj with the given dtype and order is created, and obj’s class is transferred.
  • If obj is another subtype of numpy.ndarray with compatible shape, a transposed copy of obj with the given dtype, order and class vigra.Image is created. Transposition changes the order of the spatial dimensions (and therefore the index order for element access) from [x,y] or [z,y,x] to the VIGRA convention [x,y] and [x,y,z] respectively. The channel dimension is assumed to be the last dimension and remains in that position. (Use numpy.rollaxis() to adjust the input if necessary.)
  • If obj is a sequence, it is interpreted as a shape. When the shape is compatible, a new vigra.Image with the given dtype and order is created.
  • Otherwise, or if the shape is not compatible, an exception is raised.

A shape is compatible when it has two dimensions (width, height) or three dimensions (width, height, channels).

order can be ‘C’ (C order), ‘F’ (Fortran order), ‘V’ (vector-valued order), and ‘A’.

‘C’ and ‘F’ order:
have the usual numpy meaning
‘V’ order:
is an interleaved memory layout that simulates vector- valued pixels or voxels: while the spatial dimensions are arranged as in Fortran order, the major memory-aligned dimension is the channel (i.e. last) dimension. Arrays in ‘V’-order are compatible with vector-valued NumpyArrays. For example, an RGBImage((4,3), uint8) has strides (3, 12, 1) and is compatible with NumpyArray<2, RGBValue<UInt8>, UnstridedArrayTag>.
‘A’ order:
defaults to ‘V’ when a new array is created, and means ‘preserve order’ when an existing array is copied.

In particular, the following compatibility rules apply (Note that compatibility with ‘UnstridedArrayTag’ implies compatibility with ‘StridedArrayTag’. Due to their loop order, VIGRA algorithms are generally more efficient when the memory layout is compatible with ‘UnstridedArrayTag’. T is the array’s dtype.):

‘C’:
NumpyArray<2, T, StridedArrayTag> (if channels=1),
NumpyArray<3, T, StridedArrayTag>,
NumpyArray<4, T, StridedArrayTag> (if channels>1),
NumpyArray<2, TinyVector<T, M>, StridedArrayTag> (if channels=M),
NumpyArray<2, RGBValue<T>, StridedArrayTag> (if channels=3),
NumpyArray<2, Singleband<T>, StridedArrayTag> (if channels=1),
NumpyArray<3, Multiband<T>, StridedArrayTag>
‘F’:
NumpyArray<2, T, UnstridedArrayTag> (if channels=1),
NumpyArray<3, T, UnstridedArrayTag>,
NumpyArray<4, T, UnstridedArrayTag> (if channels>1),
NumpyArray<2, Singleband<T>, UnstridedArrayTag> (if channels=1),
NumpyArray<3, Multiband<T>, UnstridedArrayTag>
‘V’:
NumpyArray<2, T, UnstridedArrayTag> (if channels=1),
NumpyArray<3, T, UnstridedArrayTag> (if channels=1),
NumpyArray<3, T, StridedArrayTag> (if channels>1),
NumpyArray<4, T, StridedArrayTag> (if channels>1),
NumpyArray<2, Singleband<T>, UnstridedArrayTag> (if channels=1),
NumpyArray<2, TinyVector<T, M>, UnstridedArrayTag> (if channels=M),
NumpyArray<2, RGBValue<T>, UnstridedArrayTag> (if channels=3),
NumpyArray<3, Multiband<T>, UnstridedArrayTag> (if channels=1),
NumpyArray<3, Multiband<T>, StridedArrayTag> (if channels>1)
channels

the number of channels of this image (e.g. RGB has three channels)

spatialDimensions

number of spatial dimensions (always 2 for images). This is useful for distinguishing RGBImage from ScalarVolume in overload resolution.

height

the image’s height

qimage(normalize=True)

Convert this image to a Qt QImage (mainly for display purposes). The present image must have 1, 2, 3, or 4 channels, and the resulting QImage will have QImage.Format_Indexed8 iff there was only one channel and QImage.Format_[A]RGB32 otherwise (with the last of 2/4 channels being used as alpha channel).

The parameter normalize can be used to normalize an image’s value range to 0..255:

normalize = (nmin, nmax):
scale & clip image values from nmin..nmax to 0..255
normalize = nmax:
lets nmin default to zero, i.e. scale & clip the range 0..nmax to 0..255
normalize = True: (default)
scale the image’s actual range min()..max() to 0..255
normalize = False:
don’t scale the image’s values
show(normalize=True)

Display this image in a vigra.pyqt.ImageWindow.

The parameter normalize can be used to normalize an image’s value range to 0..255:

normalize = (nmin, nmax):
scale & clip image values from nmin..nmax to 0..255
normalize = nmax:
lets nmin default to zero, i.e. scale & clip the range 0..nmax to 0..255
normalize = True: (default)
scale the image’s actual range min()..max() to 0..255
normalize = False:
don’t scale the image’s values
width

the image’s width

write(filename, dtype='', compression='')

Write an image to a file. Consult vigra.impex.writeImage() for detailed documentation

writeHDF5(filename, pathInFile, dtype='')

Write an image to a HDF5 file. Consult vigra.impex.writeImageToHDF5() for detailed documentation

vigra.imshow(image)

Display a scalar or RGB image by means of matplotlib. If the image does not have one or three channels, an exception is raised. The image will be automatically scaled to the range 0...255.


class vigra.ScalarImage

Bases: vigra.arraytypes.Image

Constructor:

ScalarImage(obj, dtype=numpy.float32, order='V', init = True, value = None)
Parameters:
  • obj – a data or shape object (see below)
  • dtype – desired element type
  • order – desired memory layout (see below)
  • init (boolean) – True: initialize the image with zeros; False: do not initialize the image
  • value (convertible to dtype) – initialize the image with this value (overrides init)

obj may be one of the following

  • If obj is a vigra.ScalarImage or a subclass, a copy of obj with the given dtype and order is created, and obj’s class is transferred.
  • If obj is another subtype of numpy.ndarray with compatible shape, a transposed copy of obj with the given dtype, order and class vigra.ScalarImage is created. Transposition changes the order of the spatial dimensions (and therefore the index order for element access) from [x,y] or [z,y,x] to the VIGRA convention [x,y] and [x,y,z] respectively. The channel dimension is assumed to be the last dimension and remains in that position. (Use numpy.rollaxis() to adjust the input if necessary.)
  • If obj is a sequence, it is interpreted as a shape. When the shape is compatible, a new vigra.ScalarImage with the given dtype and order is created.
  • Otherwise, or if the shape is not compatible, an exception is raised.

A shape is compatible when it has two dimensions (width, height) or three dimensions (width, height, 1).

order can be ‘C’ (C order), ‘F’ (Fortran order), ‘V’ (vector-valued order), and ‘A’.

‘C’ and ‘F’ order:
have the usual numpy meaning
‘V’ order:
is an interleaved memory layout that simulates vector- valued pixels or voxels: while the spatial dimensions are arranged as in Fortran order, the major memory-aligned dimension is the channel (i.e. last) dimension. Arrays in ‘V’-order are compatible with vector-valued NumpyArrays. For example, an RGBImage((4,3), uint8) has strides (3, 12, 1) and is compatible with NumpyArray<2, RGBValue<UInt8>, UnstridedArrayTag>.
‘A’ order:
defaults to ‘V’ when a new array is created, and means ‘preserve order’ when an existing array is copied.

In particular, the following compatibility rules apply (Note that compatibility with ‘UnstridedArrayTag’ implies compatibility with ‘StridedArrayTag’. Due to their loop order, VIGRA algorithms are generally more efficient when the memory layout is compatible with ‘UnstridedArrayTag’. T is the array’s dtype.):

‘C’:
NumpyArray<2, T, StridedArrayTag>,
NumpyArray<3, T, StridedArrayTag>,
NumpyArray<2, Singleband<T>, StridedArrayTag>,
NumpyArray<3, Multiband<T>, StridedArrayTag>
‘F’:
NumpyArray<2, T, UnstridedArrayTag>,
NumpyArray<3, T, UnstridedArrayTag>,
NumpyArray<2, Singleband<T>, UnstridedArrayTag>,
NumpyArray<3, Multiband<T>, UnstridedArrayTag>
‘V’:
like ‘F’

class vigra.RGBImage

Bases: vigra.arraytypes.Vector3Image

Constructor:

RGBImage(obj, dtype=numpy.float32, order='V', init = True, value = None)
Parameters:
  • obj – a data or shape object (see below)
  • dtype – desired element type
  • order – desired memory layout (see below)
  • init (boolean) – True: initialize the image with zeros; False: do not initialize the image
  • value (convertible to dtype) – initialize the image with this value (overrides init)

obj may be one of the following

  • If obj is a vigra.RGBImage or a subclass, a copy of obj with the given dtype and order is created, and obj’s class is transferred.
  • If obj is another subtype of numpy.ndarray with compatible shape, a transposed copy of obj with the given dtype, order and class vigra.RGBImage is created. Transposition changes the order of the spatial dimensions (and therefore the index order for element access) from [x,y] or [z,y,x] to the VIGRA convention [x,y] and [x,y,z] respectively. The channel dimension is assumed to be the last dimension and remains in that position. (Use numpy.rollaxis() to adjust the input if necessary.)
  • If obj is a sequence, it is interpreted as a shape. When the shape is compatible, a new vigra.RGBImage with the given dtype and order is created.
  • Otherwise, or if the shape is not compatible, an exception is raised.

A shape is compatible when it has two dimensions (width, height) or three dimensions (width, height, 3).

order can be ‘C’ (C order), ‘F’ (Fortran order), ‘V’ (vector-valued order), and ‘A’.

‘C’ and ‘F’ order:
have the usual numpy meaning
‘V’ order:
is an interleaved memory layout that simulates vector- valued pixels or voxels: while the spatial dimensions are arranged as in Fortran order, the major memory-aligned dimension is the channel (i.e. last) dimension. Arrays in ‘V’-order are compatible with vector-valued NumpyArrays. For example, an RGBImage((4,3), uint8) has strides (3, 12, 1) and is compatible with NumpyArray<2, RGBValue<UInt8>, UnstridedArrayTag>.
‘A’ order:
defaults to ‘V’ when a new array is created, and means ‘preserve order’ when an existing array is copied.

In particular, the following compatibility rules apply (Note that compatibility with ‘UnstridedArrayTag’ implies compatibility with ‘StridedArrayTag’. Due to their loop order, VIGRA algorithms are generally more efficient when the memory layout is compatible with ‘UnstridedArrayTag’. T is the array’s dtype.):

‘C’:
NumpyArray<3, T, StridedArrayTag>,
NumpyArray<4, T, StridedArrayTag>,
NumpyArray<2, RGBValue<T>, StridedArrayTag>,
NumpyArray<2, TinyVector<T, 3>, StridedArrayTag>,
NumpyArray<3, Multiband<T>, StridedArrayTag>
‘F’:
NumpyArray<3, T, UnstridedArrayTag>,
NumpyArray<4, T, UnstridedArrayTag>,
NumpyArray<3, Multiband<T>, UnstridedArrayTag>
‘V’:
NumpyArray<3, T, StridedArrayTag>,
NumpyArray<4, T, StridedArrayTag>,
NumpyArray<2, RGBValue<T>, UnstridedArrayTag>,
NumpyArray<2, TinyVector<T, 3>, UnstridedArrayTag>,
NumpyArray<3, Multiband<T>, StridedArrayTag>

class vigra.ImagePyramid(image, copyImagedestLevel=0, lowestLevel=0, highestLevel=0)

Bases: list

Create a new pyramid. The new pyramid levels range from ‘lowestLevel’ to ‘highestLevel’ (inclusive), and the given ‘image’ is copied to ‘copyImagedestLevel’. The images at other levels are filled with zeros and sized so that the shape is reduced by half when going up (to higher levels), and doubled when going down.

createLevel(level)

Make sure that ‘level’ exists. If ‘level’ is outside the current range of levels, empty images of the appropriate shape are inserted into the pyramid.

expand(srcLevel, destLevel, centerValue=0.42)

Expand the image at ‘srcLevel’ to ‘destLevel’, using the Burt smoothing filter with the given ‘centerValue’. srcLevel must be larger than destLevel.

For more details, see pyramidExpandBurtFilter in the C++ documentation.

expandLaplacian(srcLevel, destLevel, centerValue=0.42)

Expand the image at ‘srcLevel’ to ‘destLevel’, using the Burt smoothing filter with the given ‘centerValue’, and reconstruct the images for the levels srcLevel-1 ... destLevel from their Laplacian images. srcLevel must be larger than destLevel.

For more details, see pyramidExpandBurtLaplacian in the C++ documentation.

highestLevel

The pyramids highest level (inclusive).

lowestLevel

The pyramids lowest level.

reduce(srcLevel, destLevel, centerValue=0.42)

Reduce the image at ‘srcLevel’ to ‘destLevel’, using the Burt smoothing filter with the given ‘centerValue’. srcLevel must be smaller than destLevel.

For more details, see pyramidReduceBurtFilter in the C++ documentation.

reduceLaplacian(srcLevel, destLevel, centerValue=0.42)

Reduce the image at ‘srcLevel’ to ‘destLevel’, using the Burt smoothing filter with the given ‘centerValue’, and compute Laplacian images for the levels srcLevel ... destLevel-1. srcLevel must be smaller than destLevel.

For more details, see pyramidReduceBurtLaplacian in the C++ documentation.

Import and Export Functions

The module vigra.impex defines read and write functions for image and volume data. Note that the contents of this module are automatically imported into the vigra module, so you may call ‘vigra.readImage(...)’ instead of ‘vigra.impex.readImage(...)’ etc.

vigra.impex.isImage()
isImage( (str)filename) -> bool :

Check whether the given file name contains image data:

isImage(filename) -> bool

This function tests whether a file has a supported image format. It checks the first few bytes of the file and compares them with the “magic strings” of each recognized image format. If the image format is supported it returns True otherwise False.

vigra.impex.listExtensions()
listExtensions() -> str :

Ask for the image file extensions that vigra.impex understands:

listExtensions() -> string

This function returns a string containing the supported image file extensions for reading and writing with the functions readImage() and writeImage().

vigra.impex.listFormats()
listFormats() -> str :

Ask for the image file formats that vigra.impex understands:

listFormats() -> string

This function returns a string containing the supported image file formats for reading and writing with the functions readImage() and writeImage().

vigra.impex.readImage()
readImage( (str)filename [, (object)dtype=’FLOAT’]) -> object :

Read an image from a file:

readImage(filename, dtype = 'FLOAT') -> Image

When import_type is ‘UINT8’, ‘INT16’, ‘UINT16’, ‘INT32’, ‘UINT32’, ‘FLOAT’, ‘DOUBLE’, or one of the corresponding numpy dtypes (numpy.uint8 etc.), the returned image will have the requested pixel type. If dtype is ‘NATIVE’ or ‘’ (empty string), the image is imported with the original type of the data in the file. Caution: If the requested dtype is smaller than the original type in the file, values will be clipped at the bounds of the representable range, which may not be the desired behavior.

Supported file formats are listed by the function vigra.impexListFormats(). When filename does not refer to a recognized image file format, an exception is raised. The file can be checked beforehand with the function :func:`isImage`(filename).

vigra.impex.readVolume()
readVolume( (str)filename [, (object)dtype=’FLOAT’]) -> object :

Read a 3D volume from a directory:

readVolume(filename, dtype = 'FLOAT') -> Volume

If the volume is stored in a by-slice manner (e.g. one image per slice), the ‘filename’ can refer to an arbitrary image from the set. readVolume() then assumes that the slices are enumerated like:

name_base+[0-9]+name_ext

where name_base, the index, and name_ext are determined automatically. All slice files with the same name base and extension are considered part of the same volume. Slice numbers must be non-negative, but can otherwise start anywhere and need not be successive. Slices will be read in ascending numerical (not lexicographic) order. All slices must have the same size.

Otherwise, readVolume() will try to read ‘filename’ as an info text file with the following key-value pairs:

name = [short descriptive name of the volume] (optional)
filename = [absolute or relative path to raw voxel data file] (required)
gradfile =  [abs. or rel. path to gradient data file] (currently ignored)
description =  [arbitrary description of the data set] (optional)
width = [positive integer] (required)
height = [positive integer] (required)
depth = [positive integer] (required)
datatype = [UNSIGNED_CHAR | UNSIGNED_BYTE] (default: UNSIGNED_CHAR)

Lines starting with # are ignored. When import_type is ‘UINT8’, ‘INT16’, ‘UINT16’, ‘INT32’, ‘UINT32’, ‘FLOAT’, ‘DOUBLE’, or one of the corresponding numpy dtypes (numpy.uint8 etc.), the returned volume will have the requested pixel type. For details see the help for readImage().

vigra.impex.writeImage()
writeImage( (object)image, (str)filename [, (object)dtype=’’ [, (str)compression=’‘]]) -> None :

Save an image to a file:

writeImage(image, filename, dtype = '', compression = '')

Parameters:

image:
the image to be saved
filename:
the file name to save to. The file type will be deduced from the file name extension (see vigra.impexListExtensions() for a list of supported extensions).
dtype:

the pixel type written to the file. Possible values:

‘’ or ‘NATIVE’:
save with original pixel type, or convert automatically when this type is unsupported by the target file format
‘UINT8’, ‘INT16’, ‘UINT16’, ‘INT32’, ‘UINT32’, ‘FLOAT’, ‘DOUBLE’:
save as specified, or raise exception when this type is not supported by the target file format (see list below)
‘NBYTE’:
normalize to range 0...255 and then save as ‘UINT8’
numpy.uint8, numpy.int16 etc.:
behaves like the corresponding string argument
compression:

how to compress the data (ignored when compression type is unsupported by the file format). Possible values:

‘’ or not given:
save with the native compression of the target file format
‘RLE’, ‘RunLength’:
use run length encoding (native in BMP, supported by TIFF)
‘DEFLATE’:
use deflate encoding (only supported by TIFF)
‘LZW’:
use LZW algorithm (only supported by TIFF with LZW enabled)
‘ASCII’:
write as ASCII rather than binary file (only supported by PNM)
‘1’ ... ‘100’:
use this JPEG compression level (only supported by JPEG and TIFF)

Supported file formats are listed by the function vigra.impexListFormats(). The different file formats support the following pixel types:

BMP:
Microsoft Windows bitmap image file (pixel type: UINT8 as gray and RGB).
GIF:
CompuServe graphics interchange format; 8-bit color (pixel type: UINT8 as gray and RGB).
JPEG:
Joint Photographic Experts Group JFIF format; compressed 24-bit color (pixel types: UINT8 as gray and RGB). (only available if libjpeg is installed)
PNG:
Portable Network Graphic (pixel types: UINT8 and UINT16 with up to 4 channels). (only available if libpng is installed)
PBM:
Portable bitmap format (black and white).
PGM:
Portable graymap format (pixel types: UINT8, INT16, INT32 as gray scale)).
PNM:
Portable anymap (pixel types: UINT8, INT16, INT32, gray and RGB)
PPM:
Portable pixmap format (pixel types: UINT8, INT16, INT32 as RGB)
SUN:
SUN Rasterfile (pixel types: UINT8 as gray and RGB).
TIFF:
Tagged Image File Format (pixel types: UINT8, INT16, INT32, FLOAT, DOUBLE with up to 4 channels). (only available if libtiff is installed.)
VIFF:
Khoros Visualization image file (pixel types: UINT8, INT16 INT32, FLOAT, DOUBLE with arbitrary many channels).

writeImage( (object)image, (str)filename [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeImage( (object)image, (str)filename [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeImage( (object)image, (str)filename [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeImage( (object)image, (str)filename [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeImage( (object)image, (str)filename [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeImage( (object)image, (str)filename [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeImage( (object)image, (str)filename [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeImage( (object)image, (str)filename [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeImage( (object)image, (str)filename [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

vigra.impex.writeVolume()
writeVolume( (object)volume, (str)filename_base, (str)filename_ext [, (object)dtype=’’ [, (str)compression=’‘]]) -> None :

Wrtie a volume as a sequence of images:

writeVolume(volume, filename_base, filename_ext, dtype = '', compression = '')

The resulting image sequence will be enumerated in the form:

filename_base+[0-9]+filename_ext

Parameters ‘dtype’ and ‘compression’ will be handled as in writeImage().

writeVolume( (object)volume, (str)filename_base, (str)filename_ext [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeVolume( (object)volume, (str)filename_base, (str)filename_ext [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeVolume( (object)volume, (str)filename_base, (str)filename_ext [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeVolume( (object)volume, (str)filename_base, (str)filename_ext [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeVolume( (object)volume, (str)filename_base, (str)filename_ext [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeVolume( (object)volume, (str)filename_base, (str)filename_ext [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeVolume( (object)volume, (str)filename_base, (str)filename_ext [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeVolume( (object)volume, (str)filename_base, (str)filename_ext [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

writeVolume( (object)volume, (str)filename_base, (str)filename_ext [, (object)dtype=’’ [, (str)compression=’‘]]) -> None

Mathematical Functions and Type Coercion

Vigra images and volumes support all arithmetic and algebraic functions defined in numpy.ufunc.

The following mathematical functions are available in this module:

absolute   absolute   add   arccos   arccosh   arcsin   arcsinh
arctan   arctan2   arctanh   bitwise_and   bitwise_or   bitwise_xor   ceil
conjugate   conjugate   copysign   cos   cosh   deg2rad   degrees
divide   equal   exp   exp2   expm1   fabs   floor
floor_divide   fmax   fmin   fmod   frexp   greater   greater_equal
hypot   invert   invert   isfinite   isinf   isnan   ldexp
left_shift   less   less_equal   log   log10   log1p   log2
logaddexp   logaddexp2   logical_and   logical_not   logical_or   logical_xor   maximum
minimum   modf   multiply   negative   nextafter   not_equal   ones_like
power   rad2deg   radians   reciprocal   remainder   remainder   right_shift
rint   sign   signbit   sin   sinh   spacing   sqrt
square   subtract   tan   tanh   true_divide   trunc

Some of these functions are also provided as member functions of the vigra array types:

__abs__   __add__   __and__   __div__   __divmod__   __eq__   __floordiv__
__ge__   __gt__   __invert__   __le__   __lshift__   __lt__   __mod__
__mul__   __ne__   __neg__   __or__   __pos__   __pow__   __radd__
__radd__   __rand__   __rdiv__   __rdivmod__   __rfloordiv__   __rlshift__
__rmod__   __rmul__   __ror__   __rpow__   __rrshift__   __rshift__
__rsub__   __rtruediv__   __rxor__   __sub__   __truediv__   __xor__

As usual, these functions are applied independently at each pixel. Vigranumpy overloads the numpy-versions of these functions in order to make their behavior more suitable for image analysis. In particular, we changed two aspects:

  • The memory layout of the input arrays is preserved in the result arrays. In contrast, plain numpy.ufuncs always create C-order arrays, even if the inputs have a different order (e.g. as Fortran-order).
  • The value types of result arrays (i.e. their ‘dtype’) are determined in a way that is more suitable for image processing than the original numpy conversion rules.

Array dtype conversion (aka coercion) is implemented by the function vigra.ufunc.Function.common_type according to the following coercion rules:

Function.common_type(in_type, out_type)

Find the appropriate pair (in_dtype, out_dtype) according to vigranumpy typecasting rules. in_dtype is the type into which the arguments will be casted before performing the operation (to prevent possible overflow), out_type is the type the output array will have (unless an explicit out-argument is provided).

The ideas behind the vigranumpy typcasting rules are (i) to represent data with at most 32 bit, when possible, (ii) to reduce the number of types that occur as results of mixed expressions, and (iii) to minimize the chance of bad surprises. Default output types are thus determined according to the following rules:

  1. The output type does not depend on the order of the arguments:

    a + b results in the same type as b + a
  2. With exception of logical functions and abs(), the output type does not depend on the function to be executed. The output type of logical functions is bool. The output type of abs() follows general rules unless the input is complex, in which case the output type is the corresponding float type:

    a + b results in the same type as a / b
    a == b => bool
    abs(complex128) => float64
  3. If the inputs have the same type, the type is preserved:

    uint8 + uint8 => uint8
  4. If (and only if) one of the inputs has at least 64 bits, the output will also have at least 64 bits:

    int64 + uint32 => int64
    int64 + 1.0    => float64
  5. If an array is combined with a scalar of the same kind (integer, float, or complex), the array type is preserved. If an integer array with at most 32 bits is combined with a float scalar, the result is float32 (and rule 4 kicks in if the array has 64 bits):

    uint8   + 1   => uint8
    uint8   + 1.0 => float32
    float32 + 1.0 => float32
    float64 + 1.0 => float64
  6. Integer expressions with mixed types always produce signed results. If the arguments have at most 32 bits, the result will be int32, otherwise it will be int64 (cf. rule 4):

    int8  + uint8  => int32
    int32 + uint8  => int32
    int32 + uint32 => int32
    int32 + int64  => int64
    int64 + uint64 => int64
  7. In all other cases, the output type is equal to the highest input type:

    int32   + float32    => float32
    float32 + complex128 => complex128
  8. All defaults can be overridden by providing an explicit output array:

    ufunc.add(uint8, uint8, uint16) => uint16

    In order to prevent overflow, necessary upcasting is performed before the function is executed.

Color and Intensity Manipulation

The module vigra.colors provides functions to adjust image brightness and contrast, and to transform between different color spaces. See Color Conversions in the C++ documentation for more information.

vigra.colors.brightness()
brightness( (object)image, (float)factor [, (object)range=(0.0, 255.0) [, (object)out=None]]) -> object :

Adjust the brightness of a 2D scalar or multiband image. The function applies the formula:

out = image + 0.25 * log(factor) * (range[1] - range[0])

to each element of the array. ‘factor’ and ‘range[1] - range[0]’ must be positive. Elements outside the given range are clipped at the range borders. If ‘range’ is None or “” or “auto”, the range is set to the actual range of ‘image’:

range = image.min(), image.max()
brightness( (object)volume, (float)factor [, (object)range=(0.0, 255.0) [, (object)out=None]]) -> object :
Likewise for a 3D scalar or multiband volume.
vigra.colors.contrast()
contrast( (object)image, (float)factor [, (object)range=(0.0, 255.0) [, (object)out=None]]) -> object :

Adjust the contrast of an image or volume. The function applies the formula:

out = factor * image + (1.0 - factor) * (range[1] - range[0]) / 2.0

to each element of the array. ‘factor’ and ‘range[1] - range[0]’ must be positive. Elements outside the given range are clipped at the range borders. If ‘range’ is None or “” or “auto”, the range is set to the actual range of ‘image’:

range = image.min(), image.max()
contrast( (object)volume, (float)factor [, (object)range=(0.0, 255.0) [, (object)out=None]]) -> object :
Likewise for a 3D scalar or multiband volume.
vigra.colors.gammaCorrection()
gammaCorrection( (object)image, (float)gamma [, (object)range=(0.0, 255.0) [, (object)out=None]]) -> object :

Adjust gamma correction to an image or volume. The function applies the formula:

diff = range[1] - range[0]
out = pow((image - range[0]) / diff, 1.0 / gamma) * diff + range[0]

to each element of the array. ‘gamma’ and ‘range[1] - range[0]’ must be positive. Elements outside the given range are clipped at the range borders. If ‘range’ is None or “” or “auto”, the range is set to the actual range of ‘image’:

range = image.min(), image.max()
gammaCorrection( (object)volume, (float)gamma [, (object)range=(0.0, 255.0) [, (object)out=None]]) -> object :
Likewise for a 3D scalar or multiband volume.
vigra.colors.linearRangeMapping()
linearRangeMapping( (object)image [, (object)oldRange=’auto’ [, (object)newRange=(0.0, 255.0) [, (object)out=None]]]) -> object :

Convert the intensity range of a 2D scalar or multiband image. The function applies a linear transformation to the intensities such that the value oldRange[0] is mapped onto newRange[0], and oldRange[1] is mapped onto newRange[1]. That is, the algorithm applies the formula:

oldDiff = oldRange[1] - oldRange[0]
newDiff = newRange[1] - newRange[0]
out = (image - oldRange[0]) / oldDiff * newDiff + newRange[0]

to each element of the array. ‘oldDiff’ and ‘newDiff’ must be positive. If ‘oldRange’ is None or “” or “auto” (the default), the range is set to the actual range of ‘image’:

range = image.min(), image.max()

If ‘newRange’ is None or “” or “auto”, it is set to (0, 255.0). If ‘out’ is explicitly passed, it must be a uin8 image.

linearRangeMapping( (object)image [, (object)oldRange=’auto’ [, (object)newRange=(0.0, 255.0) [, (object)out=None]]]) -> object :
Likewise, but ‘out’ is a float32 image.
linearRangeMapping( (object)volume [, (object)oldRange=’auto’ [, (object)newRange=(0.0, 255.0) [, (object)out=None]]]) -> object :
Likewise for a 3D scalar or multiband volume, when ‘out’ is a unit8 volume.
linearRangeMapping( (object)volume [, (object)oldRange=’auto’ [, (object)newRange=(0.0, 255.0) [, (object)out=None]]]) -> object :
Likewise, but ‘out’ is a float32 volume.
vigra.colors.transform_Lab2RGB()
transform_Lab2RGB( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using Lab2RGBFunctor.

For details see Lab2RGBFunctor in the C++ documentation.

vigra.colors.transform_Lab2RGBPrime()
transform_Lab2RGBPrime( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using Lab2RGBPrimeFunctor.

For details see Lab2RGBPrimeFunctor in the C++ documentation.

vigra.colors.transform_Lab2XYZ()
transform_Lab2XYZ( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using Lab2XYZFunctor.

For details see Lab2XYZFunctor in the C++ documentation.

vigra.colors.transform_Luv2RGB()
transform_Luv2RGB( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using Luv2RGBFunctor.

For details see Luv2RGBFunctor in the C++ documentation.

vigra.colors.transform_Luv2RGBPrime()
transform_Luv2RGBPrime( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using Luv2RGBPrimeFunctor.

For details see Luv2RGBPrimeFunctor in the C++ documentation.

vigra.colors.transform_Luv2XYZ()
transform_Luv2XYZ( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using Luv2XYZFunctor.

For details see Luv2XYZFunctor in the C++ documentation.

vigra.colors.transform_RGB2Lab()
transform_RGB2Lab( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using RGB2LabFunctor.

For details see RGB2LabFunctor in the C++ documentation.

vigra.colors.transform_RGB2Luv()
transform_RGB2Luv( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using RGB2LuvFunctor.

For details see RGB2LuvFunctor in the C++ documentation.

vigra.colors.transform_RGB2RGBPrime()
transform_RGB2RGBPrime( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using RGB2RGBPrimeFunctor.

For details see RGB2RGBPrimeFunctor in the C++ documentation.

vigra.colors.transform_RGB2XYZ()
transform_RGB2XYZ( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using RGB2XYZFunctor.

For details see RGB2XYZFunctor in the C++ documentation.

vigra.colors.transform_RGB2sRGB()
transform_RGB2sRGB( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using RGB2sRGBFunctor.

For details see RGB2sRGBFunctor in the C++ documentation.

vigra.colors.transform_RGBPrime2Lab()
transform_RGBPrime2Lab( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using RGBPrime2LabFunctor.

For details see RGBPrime2LabFunctor in the C++ documentation.

vigra.colors.transform_RGBPrime2Luv()
transform_RGBPrime2Luv( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using RGBPrime2LuvFunctor.

For details see RGBPrime2LuvFunctor in the C++ documentation.

vigra.colors.transform_RGBPrime2RGB()
transform_RGBPrime2RGB( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using RGBPrime2RGBFunctor.

For details see RGBPrime2RGBFunctor in the C++ documentation.

vigra.colors.transform_RGBPrime2XYZ()
transform_RGBPrime2XYZ( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using RGBPrime2XYZFunctor.

For details see RGBPrime2XYZFunctor in the C++ documentation.

vigra.colors.transform_RGBPrime2YPrimeCbCr()
transform_RGBPrime2YPrimeCbCr( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using RGBPrime2YPrimeCbCrFunctor.

For details see RGBPrime2YPrimeCbCrFunctor in the C++ documentation.

vigra.colors.transform_RGBPrime2YPrimeIQ()
transform_RGBPrime2YPrimeIQ( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using RGBPrime2YPrimeIQFunctor.

For details see RGBPrime2YPrimeIQFunctor in the C++ documentation.

vigra.colors.transform_RGBPrime2YPrimePbPr()
transform_RGBPrime2YPrimePbPr( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using RGBPrime2YPrimePbPrFunctor.

For details see RGBPrime2YPrimePbPrFunctor in the C++ documentation.

vigra.colors.transform_RGBPrime2YPrimeUV()
transform_RGBPrime2YPrimeUV( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using RGBPrime2YPrimeUVFunctor.

For details see RGBPrime2YPrimeUVFunctor in the C++ documentation.

vigra.colors.transform_XYZ2Lab()
transform_XYZ2Lab( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using XYZ2LabFunctor.

For details see XYZ2LabFunctor in the C++ documentation.

vigra.colors.transform_XYZ2Luv()
transform_XYZ2Luv( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using XYZ2LuvFunctor.

For details see XYZ2LuvFunctor in the C++ documentation.

vigra.colors.transform_XYZ2RGB()
transform_XYZ2RGB( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using XYZ2RGBFunctor.

For details see XYZ2RGBFunctor in the C++ documentation.

vigra.colors.transform_XYZ2RGBPrime()
transform_XYZ2RGBPrime( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using XYZ2RGBPrimeFunctor.

For details see XYZ2RGBPrimeFunctor in the C++ documentation.

vigra.colors.transform_YPrimeCbCr2RGBPrime()
transform_YPrimeCbCr2RGBPrime( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using YPrimeCbCr2RGBPrimeFunctor.

For details see YPrimeCbCr2RGBPrimeFunctor in the C++ documentation.

vigra.colors.transform_YPrimeIQ2RGBPrime()
transform_YPrimeIQ2RGBPrime( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using YPrimeIQ2RGBPrimeFunctor.

For details see YPrimeIQ2RGBPrimeFunctor in the C++ documentation.

vigra.colors.transform_YPrimePbPr2RGBPrime()
transform_YPrimePbPr2RGBPrime( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using YPrimePbPr2RGBPrimeFunctor.

For details see YPrimePbPr2RGBPrimeFunctor in the C++ documentation.

vigra.colors.transform_YPrimeUV2RGBPrime()
transform_YPrimeUV2RGBPrime( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using YPrimeUV2RGBPrimeFunctor.

For details see YPrimeUV2RGBPrimeFunctor in the C++ documentation.

vigra.colors.transform_sRGB2RGB()
transform_sRGB2RGB( (object)image [, (object)out=None]) -> object :

Convert the colors of the given ‘image’ using sRGB2RGBFunctor.

For details see sRGB2RGBFunctor in the C++ documentation.

Filters

The module vigra.filters provides operators that consider a window around each pixel, compute one or several numbers from the values in the window, and store the results in the corresponding pixel of the output image. This includes convolution, non-linear diffusion, morphological operators, feature detectors (such as the structure tensor) etc.

class vigra.filters.Kernel1D

Generic 1 dimensional convolution kernel.

This kernel may be used for convolution of 1 dimensional signals or for separable convolution of multidimensional signals. The kernel’s size is given by its left() and right() methods. The desired border treatment mode is returned by getBorderTreatment(). The different init functions create a kernel with the specified properties. For more details, see Kernel1D in the C++ documentation.

__init__( (object)arg1) -> None :

Standard constructor:

Kernel1D()

Creates an identity kernel.

__init__( (object)arg1, (Kernel1D)kernel) -> None :

Copy constructor:

Kernel1D(other_kernel)
borderTreatment()
borderTreatment( (Kernel1D)arg1) -> BorderTreatmentMode :
Return current border treatment mode.
initAveraging()
initAveraging( (Kernel1D)arg1, (int)radius [, (float)norm=1.0]) -> None :

Init kernel as an averaging filter with given radius (i.e. window size 2*radius+1). ‘norm’ denotes the sum of all bins of the kernel.

Kernel construction and initialization can be performed in one step by calling the factory function ‘averagingKernel()’.

initBinomial()
initBinomial( (Kernel1D)arg1, (int)radius [, (float)norm=1.0]) -> None :

Init kernel as a binomial filter with given radius (i.e. window size 2*radius+1). ‘norm’ denotes the sum of all bins of the kernel.

Kernel construction and initialization can be performed in one step by calling the factory function ‘binomialKernel()’.

initBurtFilter()
initBurtFilter( (Kernel1D)arg1 [, (float)a=0.04785]) -> None :

Init kernel as a 5-tap smoothing filter of the form:

[ a, 0.25, 0.5 - 2*a, 0.25, a]

Kernel construction and initialization can be performed in one step by calling the factory function ‘burtFilterKernel()’.

initDiscreteGaussian()
initDiscreteGaussian( (Kernel1D)arg1, (float)scale [, (float)norm=1.0]) -> None :

Init kernel as Lindeberg’s discrete analog of the Gaussian function. The radius of the kernel is always 3*std_dev. ‘norm’ denotes the desired sum of all bins of the kernel.

Kernel construction and initialization can be performed in one step by calling the factory function ‘discreteGaussianKernel()’.

initExplicitly()
initExplicitly( (Kernel1D)arg1, (int)left, (int)right, (object)contents) -> None :

Init the kernel with explicit values from ‘contents’, which must be a 1D numpy.ndarray. ‘left’ and ‘right’ are the boundaries of the kernel (inclusive). If ‘contents’ contains the wrong number of values, a run-time error results. It is, however, possible to give just one initializer. This creates an averaging filter with the given constant. The norm is set to the sum of the initializer values.

Kernel construction and initialization can be performed in one step by calling the factory function ‘explicitlyKernel()’.

initGaussian()
initGaussian( (Kernel1D)arg1, (float)scale [, (float)norm=1.0]) -> None :

Init kernel as a sampled Gaussian function. The radius of the kernel is always 3*std_dev. ‘norm’ denotes the desired sum of all bins of the kernel (i.e. the kernel is corrected for the normalization error introduced by windowing the Gaussian to a finite interval). However, if norm is 0.0, the kernel is normalized to 1 by the analytic expression for the Gaussian, and no correction for the windowing error is performed.

Kernel construction and initialization can be performed in one step by calling the factory function ‘gaussianKernel()’.

initGaussianDerivative()
initGaussianDerivative( (Kernel1D)arg1, (float)scale, (int)order [, (float)norm=1.0]) -> None :

Init kernel as a Gaussian derivative of order ‘order’. The radius of the kernel is always 3*std_dev + 0.5*order. ‘norm’ denotes the norm of the kernel. Thus, the kernel will be corrected for the error introduced by windowing the Gaussian to a finite interval. However, if norm is 0.0, the kernel is normalized to 1 by the analytic expression for the Gaussian derivative, and no correction for the windowing error is performed.

Kernel construction and initialization can be performed in one step by calling the factory function ‘gaussianDerivativeKernel()’.

initOptimalFirstDerivative5()

initOptimalFirstDerivative5( (Kernel1D)arg1) -> None

initOptimalFirstDerivativeSmoothing3()

initOptimalFirstDerivativeSmoothing3( (Kernel1D)arg1) -> None

initOptimalFirstDerivativeSmoothing5()

initOptimalFirstDerivativeSmoothing5( (Kernel1D)arg1) -> None

initOptimalSecondDerivative5()

initOptimalSecondDerivative5( (Kernel1D)arg1) -> None

initOptimalSecondDerivativeSmoothing3()

initOptimalSecondDerivativeSmoothing3( (Kernel1D)arg1) -> None

initOptimalSecondDerivativeSmoothing5()

initOptimalSecondDerivativeSmoothing5( (Kernel1D)arg1) -> None

initOptimalSmoothing3()

initOptimalSmoothing3( (Kernel1D)arg1) -> None

initOptimalSmoothing5()

initOptimalSmoothing5( (Kernel1D)arg1) -> None

initSecondDifference3()
initSecondDifference3( (Kernel1D)arg1) -> None :

Init kernel as a 3-tap second difference filter of the form:

[ 1, -2, 1]

Kernel construction and initialization can be performed in one step by calling the factory function ‘secondDifference3Kernel()’.

initSymmetricDifference()
initSymmetricDifference( (Kernel1D)arg1 [, (float)norm=1.0]) -> None :

Init kernel as a symmetric difference filter of the form:

[ 0.5 * norm, 0.0 * norm, -0.5 * norm]

Kernel construction and initialization can be performed in one step by calling the factory function ‘symmetricDifferenceKernel()’.

left()
left( (Kernel1D)arg1) -> int :
Left border of kernel (inclusive).
norm()
norm( (Kernel1D)arg1) -> float :
Return the norm of kernel.
normalize()
normalize( (Kernel1D)arg1 [, (float)norm=1.0 [, (int)derivativeOrder=0 [, (float)offset=0.0]]]) -> None :
Set a new norm and normalize kernel, use the normalization formula for the given derivativeOrder.
right()
right( (Kernel1D)arg1) -> int :
Right border of kernel (inclusive).
setBorderTreatment()
setBorderTreatment( (Kernel1D)arg1, (BorderTreatmentMode)borderTreatment) -> None :
Set border treatment mode.
size()
size( (Kernel1D)arg1) -> int :
Number of kernel elements (right() - left() + 1).
class vigra.filters.Kernel2D

Generic 2 dimensional convolution kernel.

This kernel may be used for convolution of 2 dimensional signals. The desired border treatment mode is returned by borderTreatment().(Note that the 2D convolution functions don’t currently support all modes.) The different init functions create a kernel with the specified properties. For more details, see Kernel2D in the C++ documentation.

__init__( (object)arg1) -> None :

Standard constructor:

Kernel2D()

Creates an identity kernel.

__init__( (object)arg1, (Kernel2D)kernel) -> None :

Copy constructor:

Kernel2D(other_kernel)
borderTreatment()
borderTreatment( (Kernel2D)arg1) -> BorderTreatmentMode :
Return current border treatment mode.
height()
height( (Kernel2D)arg1) -> int :
Vertical kernel size (lowerRight()[1] - upperLeft()[1] + 1).
initDisk()
initDisk( (Kernel2D)arg1, (int)radius) -> None :

Init the 2D kernel as a circular averaging filter. The norm will be calculated as 1 / (number of non-zero kernel values).

Precondition:

radius > 0

Kernel construction and initialization can be performed in one step by calling the factory function ‘diskKernel2D()’.

initExplicitly()
initExplicitly( (Kernel2D)arg1, (object)upperLeft, (object)lowerRight, (object)contents) -> None :

Init the kernel with explicit values from ‘contents’, which must be a 2D numpy.ndarray. ‘upperLeft’ and ‘lowerRight’ are the boundaries of the kernel (inclusive), and must be 2D tuples. If ‘contents’ contains the wrong number of values, a run-time error results. It is, however, possible to give just one initializer. This creates an averaging filter with the given constant. The norm is set to the sum of the initializer values.

Kernel construction and initialization can be performed in one step by calling the factory function ‘explicitlyKernel2D()’.

initGaussian()
initGaussian( (Kernel2D)arg1, (float)scale [, (float)norm=1.0]) -> None :

Init kernel as a sampled 2D Gaussian function. The radius of the kernel is always 3*std_dev. ‘norm’ denotes the desired sum of all bins of the kernel (i.e. the kernel is corrected for the normalization error introduced by windowing the Gaussian to a finite interval). However, if norm is 0.0, the kernel is normalized to 1 by the analytic expression for the Gaussian, and no correction for the windowing error is performed.

Kernel construction and initialization can be performed in one step by calling the factory function ‘gaussianKernel2D()’.

initSeparable()
initSeparable( (Kernel2D)arg1, (Kernel1D)kernelX, (Kernel1D)kernelY) -> None :

Init the 2D kernel as the cartesian product of two 1D kernels of type Kernel1D. The norm becomes the product of the two original norms.

Kernel construction and initialization can be performed in one step by calling the factory function ‘separableKernel2D()’.

lowerRight()
lowerRight( (Kernel2D)arg1) -> object :
Lower right border of kernel (inclusive).
norm()
norm( (Kernel2D)arg1) -> float :
Return the norm of the kernel.
normalize()
normalize( (Kernel2D)arg1 [, (float)norm=1.0]) -> None :
Set the kernel’s norm and renormalize the values.
setBorderTreatment()
setBorderTreatment( (Kernel2D)arg1, (BorderTreatmentMode)borderTreatment) -> None :
Set border treatment mode.
upperLeft()
upperLeft( (Kernel2D)arg1) -> object :
Upper left border of kernel (inclusive).
width()
width( (Kernel2D)arg1) -> int :
Horizontal kernel size (lowerRight()[0] - upperLeft()[0] + 1).
vigra.filters.boundaryTensor2D()
boundaryTensor2D( (object)image, (float)scale [, (object)out=None]) -> object :
Calculate the boundary tensor for a scalar valued 2D image.For details see boundaryTensor in the vigra C++ documentation.
vigra.filters.convolve()
convolve( (object)image, (Kernel1D)kernel [, (object)out=None]) -> object :

Convolve an image with the given ‘kernel’ (or kernels). If the input has multiple channels, the filter is applied to each channel independently. The function can be used in 3 different ways:

  • When ‘kernel’ is a single object of type Kernel1D, this kernel is applied along all spatial dimensions of the data (separable filtering).
  • When ‘kernel’ is a tuple of Kernel1D objects, one different kernel is used for each spatial dimension (separable filtering). The number of kernels must equal the number of dimensions).
  • When ‘kernel’ is an instance of Kernel2D, a 2-dimensional convolution is performed (non-separable filtering). This is only applicable to 2D images.

For details see separableConvolveMultiArray and convolveImage in the vigra C++ documentation.

convolve( (object)volume, (Kernel1D)kernel [, (object)out=None]) -> object :
Convolve a volume with the same 1D kernel along all dimensions.
convolve( (object)image, (tuple)kernels [, (object)out=None]) -> object :
Convolve an image with a different 1D kernel along each dimensions.
convolve( (object)volume, (tuple)kernels [, (object)out=None]) -> object :
Convolve a volume with a different 1D kernel along each dimensions.
convolve( (object)image, (Kernel2D)kernel [, (object)out=None]) -> object :
Convolve an image with a 2D kernel.
vigra.filters.convolveOneDimension()
convolveOneDimension( (object)image, (int)dim, (Kernel1D)kernel [, (object)out=None]) -> object :

Convolution along a single dimension of a 2D scalar or multiband image. ‘kernel’ must be an instance of Kernel1D.

For details see convolveMultiArrayOneDimension in the vigra C++ documentation.

convolveOneDimension( (object)volume, (int)dim, (Kernel1D)kernel [, (object)out=None]) -> object :
Likewise for a 3D scalar or multiband volume.
vigra.filters.discClosing()
discClosing( (object)image, (int)radius [, (object)out=None]) -> object :

Apply a closing filter with disc of given radius to image.

This is an abbreviation for applying a dilation and an erosion filter in sequence. This function also works for multiband images, it is then executed on every band.

See discRankOrderFilter in the C++ documentation for more information.

vigra.filters.discDilation()
discDilation( (object)image, (int)radius [, (object)out=None]) -> object :

Apply dilation (maximum) filter with disc of given radius to image.

This is an abbreviation for the rank order filter with rank = 1.0. This function also works for multiband images, it is then executed on every band.

See discDilation in the C++ documentation for more information.

vigra.filters.discErosion()
discErosion( (object)image, (int)radius [, (object)out=None]) -> object :

Apply erosion (minimum) filter with disc of given radius to image.

This is an abbreviation for the rank order filter with rank = 0.0. This function also works for multiband images, it is then executed on every band.

See discErosion in the C++ documentation for more information.

vigra.filters.discMedian()
discMedian( (object)image, (int)radius [, (object)out=None]) -> object :

Apply median filter with disc of given radius to image.

This is an abbreviation for the rank order filter with rank = 0.5. This function also works for multiband images, it is then executed on every band.

See discMedian in the C++ documentation for more information.

vigra.filters.discOpening()
discOpening( (object)image, (int)radius [, (object)out=None]) -> object :

Apply a opening filter with disc of given radius to image.

This is an abbreviation for applying an erosion and a dilation filter in sequence. This function also works for multiband images, it is then executed on every band.

See discRankOrderFilter in the C++ documentation for more information.

vigra.filters.discRankOrderFilter()
discRankOrderFilter( (object)image, (int)radius, (float)rank [, (object)out=None]) -> object :

Apply rank order filter with disc structuring function to a float image.

The pixel values of the source image must be in the range 0...255. Radius must be >= 0. Rank must be in the range 0.0 <= rank <= 1.0. The filter acts as a minimum filter if rank = 0.0, as a median if rank = 0.5, and as a maximum filter if rank = 1.0. This function also works for multiband images, it is then executed on every band.

For details see discRankOrderFilter in the C++ documentation.

discRankOrderFilter( (object)image, (int)radius, (float)rank [, (object)out=None]) -> object :
Likewise for a uint8 image.
vigra.filters.discRankOrderFilterWithMask()
discRankOrderFilterWithMask( (object)image, (object)mask, (int)radius, (float)rank [, (object)out=None]) -> object :

Apply rank order filter with disc structuring function to a float image using a mask.

The pixel values of the source image must be in the range 0...255. Radius must be >= 0.Rank must be in the range 0.0 <= rank <= 1.0. The filter acts as a minimum filter if rank = 0.0,as a median if rank = 0.5, and as a maximum filter if rank = 1.0.

The mask is only applied to the input image, i.e. the function generates an output wherever the current disc contains at least one pixel with non-zero mask value. Source pixels with mask value zero are ignored during the calculation of the rank order.

This function also works for multiband images, it is then executed on every band. If the mask has only one band, it is used for every image band. If the mask has the same number of bands, as the image the bands are used for the corresponding image bands.

For details see discRankOrderFilterWithMask in the C++ documentation.

discRankOrderFilterWithMask( (object)image, (object)mask, (int)radius, (float)rank [, (object)out=None]) -> object :
Likewise for a uint8 image.
vigra.filters.distanceTransform2D()
distanceTransform2D( (object)image [, (float)background=0 [, (int)norm=2 [, (object)out=None]]]) -> object :

Compute the distance transform of a 2D scalar float image. For all background pixels, calculate the distance to the nearest object or contour. The label of the pixels to be considered background in the source image is passed in the parameter ‘background’. Source pixels with other labels will be considered objects. In the destination image, all pixels corresponding to background will hold their distance value, all pixels corresponding to objects will be assigned 0.

The ‘norm’ parameter gives the distance norm to use (0: infinity norm, 1: L1 norm, 2: Euclidean norm).

For details see distanceTransform in the vigra C++ documentation.

distanceTransform2D( (object)image [, (int)background=0 [, (int)norm=2 [, (object)out=None]]]) -> object :
Likewise for a 2D uint8 input array.
vigra.filters.distanceTransform3D()
distanceTransform3D( (object)array, (float)background [, (object)out=None]) -> object :

Compute the Euclidean distance transform of a 3D scalar float volume. For all background voxels, calculate the distance to the nearest object or contour.The label of the voxels to be considered background in the source volume is passed in the parameter ‘background’. Source voxels with other labels will be considered objects. In the destination volume, all voxels corresponding to background will be assigned their distance value, all voxels corresponding to objects will be assigned 0.

For more details see separableMultiDistance in the vigra C++ documentation.

vigra.filters.gaussianGradient()
gaussianGradient( (object)image, (float)sigma [, (object)out=None]) -> object :

Calculate the gradient vector by means of a 1st derivative of Gaussian filter at the given scale for a 2D scalar image.

For details see gaussianGradientMultiArray in the vigra C++ documentation.

gaussianGradient( (object)volume, (float)sigma [, (object)out=None]) -> object :
Likewise for a 3D scalar volume.
vigra.filters.gaussianGradientMagnitude()
gaussianGradientMagnitude( (object)image, (float)sigma [, (bool)accumulate=True [, (object)out=None]]) -> object :

Calculate the gradient magnitude by means of a 1st derivative of Gaussian filter at the given scale for a 2D scalar or multiband image. If ‘accumulate’ is True (the default), the gradients are accumulated (in the L2-norm sense) over all channels of a multi-channel array. Otherwise, a separate gradient magnitude is computed for each channel.

For details see gaussianGradientMultiArray in the vigra C++ documentation.

gaussianGradientMagnitude( (object)volume, (float)sigma [, (bool)accumulate=True [, (object)out=None]]) -> object :
Likewise for a 3D scalar or multiband volume.
vigra.filters.gaussianSharpening2D()
gaussianSharpening2D( (object)image [, (float)sharpeningFactor=1.0 [, (float)scale=1.0 [, (object)out=None]]]) -> object :

Perform sharpening function with gaussian filter.

For details see gaussianSharpening in the vigra C++ documentation.

vigra.filters.gaussianSmoothing()
gaussianSmoothing( (object)image, (float)sigma [, (object)out=None]) -> object :

Perform Gaussian smoothing of a 2D or 3D scalar or multiband image.

Each channel of the array is smoothed independently. If ‘sigma’ is a single value, an isotropic Gaussian filter at this scale is applied (i.e. each dimension is smoothed in the same way). If ‘sigma’ is a tuple of values, the amount of smoothing will be different for each spatial dimension. The length of the tuple must be equal to the number of spatial dimensions.

For details see gaussianSmoothing in the vigra C++ documentation.

gaussianSmoothing( (object)image, (tuple)sigmas [, (object)out=None]) -> object :
Smooth image with an anisotropic Gaussian.
gaussianSmoothing( (object)volume, (float)sigma [, (object)out=None]) -> object :
Smooth volume with an isotropic Gaussian.
gaussianSmoothing( (object)volume, (tuple)sigmas [, (object)out=None]) -> object :
Smooth volume with an anisotropic Gaussian.
vigra.filters.hessianOfGaussian()

hessianOfGaussian( (object)volume, (float)sigma [, (object)out=None]) -> object

vigra.filters.hessianOfGaussian2D()
hessianOfGaussian2D( (object)image, (float)sigma [, (object)out=None]) -> object :

Calculate the Hessian matrix by means of a derivative of Gaussian filters at the given scale for a 2D scalar image.

For details see hessianOfGaussianMultiArray in the vigra C++ documentation.

vigra.filters.hessianOfGaussian3D()
hessianOfGaussian3D( (object)volume, (float)sigma [, (object)out=None]) -> object :

Calculate the Hessian matrix by means of a derivative of Gaussian filters at the given scale for a 2D or 3D scalar image.

For details see hessianOfGaussianMultiArray in the vigra C++ documentation.

vigra.filters.hessianOfGaussianEigenvalues(image, scale, out=None)

Compute the eigenvalues of the Hessian of Gaussian at the given scale for a scalar image or volume.

Calls hessianOfGaussian() and tensorEigenvalues().

vigra.filters.hourGlassFilter2D()
hourGlassFilter2D( (object)image, (float)sigma, (float)rho [, (object)out=None]) -> object :

Anisotropic tensor smoothing with the hourglass filter.

For details see hourGlassFilter in the vigra C++ documentation.

vigra.filters.laplacianOfGaussian()
laplacianOfGaussian( (object)image [, (float)scale=1.0 [, (object)out=None]]) -> object :

Filter scalar image with the Laplacian of Gaussian operator at the given scale.

For details see laplacianOfGaussianMultiArray in the vigra C++ documentation.

laplacianOfGaussian( (object)volume [, (float)scale=1.0 [, (object)out=None]]) -> object :
Likewise for a scalar volume.
vigra.filters.multiBinaryClosing()
multiBinaryClosing( (object)volume, (float)radius [, (object)out=None]) -> object :

Binary closing on a 3D scalar or multiband uint8 array.

This function applies a flat circular opening operator (sequential dilation and erosion) with a given radius. The operation is isotropic. The input is a uint8 or boolean multi-dimensional array where non-zero pixels represent foreground and zero pixels represent background. This function also works for multiband arrays, it is then executed on every band.

For details see vigra C++ documentation (multiBinaryDilation and multiBinaryErosion).

multiBinaryClosing( (object)volume, (float)radius [, (object)out=None]) -> object :
Likewise for a bool array.
vigra.filters.multiBinaryDilation()
multiBinaryDilation( (object)volume, (float)radius [, (object)out=None]) -> object :

Binary dilation on a 3D scalar or multiband uint8 array.

This function applies a flat circular dilation operator with a given radius. The operation is isotropic. The input is a uint8 or boolean multi-dimensional array where non-zero pixels represent foreground and zero pixels represent background. This function also works for multiband arrays, it is then executed on every band.

For details see multiBinaryDilation in the C++ documentation.

multiBinaryDilation( (object)volume, (float)radius [, (object)out=None]) -> object :
Likewise for bool arrays.
vigra.filters.multiBinaryErosion()
multiBinaryErosion( (object)volume, (float)radius [, (object)out=None]) -> object :

Binary erosion on a 3D scalar or multiband uint8 array.

This function applies a flat circular erosion operator with a given radius. The operation is isotropic. The input is a uint8 or boolean multi-dimensional array where non-zero pixels represent foreground and zero pixels represent background. This function also works for multiband arrays, it is then executed on every band.

For details see multiBinaryErosion in the C++ documentation.

multiBinaryErosion( (object)volume, (float)radius [, (object)out=None]) -> object :
Likewise for a bool array.
vigra.filters.multiBinaryOpening()
multiBinaryOpening( (object)volume, (float)radius [, (object)out=None]) -> object :

Binary opening on a 3D scalar or multiband uint8 array.

This function applies a flat circular opening operator (sequential erosion and dilation) with a given radius. The operation is isotropic. The input is a uint8 or boolean multi-dimensional array where non-zero pixels represent foreground and zero pixels represent background. This function also works for multiband arrays, it is then executed on every band.

For details see vigra C++ documentation (multiBinaryDilation and multiBinaryErosion).

multiBinaryOpening( (object)volume, (float)radius [, (object)out=None]) -> object :
Likewise for a bool array.
vigra.filters.multiGrayscaleClosing()
multiGrayscaleClosing( (object)volume, (float)sigma [, (object)out=None]) -> object :

Parabolic grayscale closing on multi-dimensional arrays.

This function applies a parabolic closing (sequential dilation and erosion) operator with a given spread ‘sigma’ on a grayscale array. The operation is isotropic. The input is a grayscale multi-dimensional array. This function also works for multiband arrays, it is then executed on every band.

For details see multiGrayscaleDilation and multiGrayscaleErosion in the C++ documentation.

multiGrayscaleClosing( (object)volume, (float)sigma [, (object)out=None]) -> object :
Likewise for a 3D float array.
multiGrayscaleClosing( (object)image, (float)sigma [, (object)out=None]) -> object :
Likewise for a 2D uint8 array.

multiGrayscaleClosing( (object)image, (float)sigma [, (object)out=None]) -> object

vigra.filters.multiGrayscaleDilation()
multiGrayscaleDilation( (object)volume, (float)sigma [, (object)out=None]) -> object :

Parabolic grayscale dilation on multi-dimensional arrays.

This function applies a parabolic dilation operator with a given spread ‘sigma’ on a grayscale array. The operation is isotropic. The input is a grayscale multi-dimensional array. This function also works for multiband arrays, it is then executed on every band.

For details see multiGrayscaleDilation in the C++ documentation.

multiGrayscaleDilation( (object)volume, (float)sigma [, (object)out=None]) -> object :
Likewise for a 3D float array.
multiGrayscaleDilation( (object)image, (float)sigma [, (object)out=None]) -> object :
Likewise for a 2D uint8 array.

multiGrayscaleDilation( (object)image, (float)sigma [, (object)out=None]) -> object

vigra.filters.multiGrayscaleErosion()
multiGrayscaleErosion( (object)volume, (float)sigma [, (object)out=None]) -> object :

Parabolic grayscale erosion on a 3D scalar or multiband uint8 array.

This function applies a parabolic erosion operator with a given spread ‘sigma’ on a grayscale array. The operation is isotropic. The input is a grayscale multi-dimensional array. This function also works for multiband arrays, it is then executed on every band.

For details see multiGrayscaleErosion in the C++ documentation.

multiGrayscaleErosion( (object)volume, (float)sigma [, (object)out=None]) -> object :
Likewise for a 3D float array.
multiGrayscaleErosion( (object)image, (float)sigma [, (object)out=None]) -> object :
Likewise for a 2D uint8 array.
multiGrayscaleErosion( (object)image, (float)sigma [, (object)out=None]) -> object :
Likewise for a 2D float array.
vigra.filters.multiGrayscaleOpening()
multiGrayscaleOpening( (object)volume, (float)sigma [, (object)out=None]) -> object :

Parabolic grayscale opening on multi-dimensional arrays.

This function applies a parabolic opening (sequential erosion and dilation) operator with a given spread ‘sigma’ on a grayscale array. The operation is isotropic. The input is a grayscale multi-dimensional array. This function also works for multiband arrays, it is then executed on every band.

For details see multiGrayscaleDilation and multiGrayscaleErosion in the C++ documentation.

multiGrayscaleOpening( (object)volume, (float)sigma [, (object)out=None]) -> object :
Likewise for a 3D float array.
multiGrayscaleOpening( (object)image, (float)sigma [, (object)out=None]) -> object :
Likewise for a 2D uint8 array.

multiGrayscaleOpening( (object)image, (float)sigma [, (object)out=None]) -> object

vigra.filters.nonlinearDiffusion()
nonlinearDiffusion( (object)image, (float)edgeThreshold, (float)scale [, (object)out=None]) -> object :

Perform edge-preserving smoothing at the given scale.

For details see nonlinearDiffusion in the vigra C++ documentation.

vigra.filters.normalizedConvolveImage()
normalizedConvolveImage( (object)image, (object)mask, (Kernel2D)kernel [, (object)out=None]) -> object :

Perform normalized convolution of an image. If the image has multiple channels, every channel is convolved independently. The ‘mask’ tells the algorithm whether input pixels are valid (non-zero mask value) or not. Invalid pixels are ignored in the convolution. The mask must have one channel (which is then used for all channels input channels) or as many channels as the input image.

For details, see normalizedConvolveImage in the C++ documentation.

vigra.filters.radialSymmetryTransform2D()
radialSymmetryTransform2D( (object)image, (float)scale [, (object)out=None]) -> object :

Find centers of radial symmetry in an 2D image.

This algorithm implements the Fast Radial Symmetry Transform according to [G. Loy, A. Zelinsky: “A Fast Radial Symmetry Transform for Detecting Points of Interest”, in: A. Heyden et al. (Eds.): Proc. of 7th European Conf. on Computer Vision, Part 1, pp. 358-368, Springer LNCS 2350, 2002]

For details see radialSymmetryTransform in the vigra C++ documentation.

vigra.filters.recursiveFilter2D()
recursiveFilter2D( (object)image, (float)b [, (BorderTreatmentMode)borderTreament=vigra.filters.BorderTreatmentMode.BORDER_TREATMENT_REFLECT [, (object)out=None]]) -> object :

Perform 2D convolution with a first-order recursive filter with parameter ‘b’ and given ‘borderTreatment’. ‘b’ must be between -1 and 1.

For details see recursiveFilterX and recursiveFilterY (which this function calls in succession) in the vigra C++ documentation.

recursiveFilter2D( (object)image, (float)b1, (float)b2 [, (object)out=None]) -> object :

Perform 2D convolution with a second-order recursive filter with parameters ‘b1’ and ‘b2’. Border treatment is always BORDER_TREATMENT_REFLECT.

For details see recursiveFilterX and recursiveFilterY (which this function calls in succession) in the vigra C++ documentation.

vigra.filters.recursiveGaussianSmoothing2D()
recursiveGaussianSmoothing2D( (object)image, (tuple)sigma [, (object)out=None]) -> object :

Compute a fast approximate Gaussian smoothing of a 2D scalar or multiband image.

This function uses the third-order recursive filter approximation to the Gaussian filter proposed by Young and van Vliet. Each channel of the array is smoothed independently. If ‘sigma’ is a single value, an isotropic Gaussian filter at this scale is applied (i.e. each dimension is smoothed in the same way). If ‘sigma’ is a tuple of values, the amount of smoothing will be different for each spatial dimension. The length of the tuple must be equal to the number of spatial dimensions.

For details see recursiveGaussianFilterLine in the vigra C++ documentation.

recursiveGaussianSmoothing2D( (object)image, (float)sigma [, (object)out=None]) -> object :
Compute isotropic fast approximate Gaussian smoothing.
vigra.filters.recursiveGradient2D()
recursiveGradient2D( (object)arg1, (float)image, (BorderTreatmentMode)scale [, (object)out=None]) -> object :

Compute the gradient of a scalar image using a recursive (exponential) filter at the given ‘scale’. The output image (if given) must have two channels.

For details see recursiveSmoothLine and recursiveFirstDerivativeLine (which this function calls internally) in the vigra C++ documentation.

vigra.filters.recursiveLaplacian2D()
recursiveLaplacian2D( (object)image, (float)scale [, (object)out=None]) -> object :

Compute the gradient of a 2D scalar or multiband image using a recursive (exponential) filter at the given ‘scale’. The output image (if given) must have as many channels as the input.

For details see recursiveSmoothLine and recursiveSecondDerivativeLine (which this function calls internally) in the vigra C++ documentation.

vigra.filters.recursiveSmooth2D()
recursiveSmooth2D( (object)image, (float)scale [, (BorderTreatmentMode)borderTreament=vigra.filters.BorderTreatmentMode.BORDER_TREATMENT_REFLECT [, (object)out=None]]) -> object :

Calls recursiveFilter2D() with b = exp(-1/scale), which corresponds to smoothing with an exponential filter exp(-abs(x)/scale).

For details see recursiveSmoothLine in the vigra C++ documentation.

vigra.filters.rieszTransformOfLOG2D()
rieszTransformOfLOG2D( (object)image, (float)scale, (int)xorder, (int)yorder [, (object)out=None]) -> object :

Calculate Riesz transforms of the Laplacian of Gaussian.

For details see rieszTransformOfLOG in the vigra C++ documentation.

vigra.filters.simpleSharpening2D()
simpleSharpening2D( (object)image [, (float)sharpeningFactor=1.0 [, (object)out=None]]) -> object :

Perform simple sharpening function.

For details see simpleSharpening in the vigra C++ documentation.

vigra.filters.structureTensor()
structureTensor( (object)image, (float)innerScale, (float)outerScale [, (object)out=None]) -> object :

Calculate the structure tensor of an image by means of Gaussian (derivative) filters at the given scales. If the input has multiple channels, the structure tensors of each channel are added to get the result.

For details see structureTensorMultiArray in the vigra C++ documentation.

structureTensor( (object)volume, (float)innerScale, (float)outerScale [, (object)out=None]) -> object :
Likewise for a 3D scalar or multiband volume.
vigra.filters.structureTensorEigenvalues(image, innerScale, outerScale, out=None)

Compute the eigenvalues of the structure tensor at the given scales for a scalar or multi-channel image or volume.

Calls structureTensor() and tensorEigenvalues().

vigra.filters.symmetricGradient()
symmetricGradient( (object)arg1, (float)image [, (object)out=None]) -> object :
Calculate gradient of a scalar 2D image using symmetric difference filters. For details see symmetricGradientMultiArray in the vigra C++ documentation.
symmetricGradient( (object)arg1, (float)volume [, (object)out=None]) -> object :
Likewise for a 3D scalar volume.
vigra.filters.tensorDeterminant()
tensorDeterminant( (object)image [, (object)out=None]) -> object :

Calculate the determinant of a 2x2 tensor image.

For details see tensorDeterminantMultiArray in the vigra C++ documentation.

tensorDeterminant( (object)volume [, (object)out=None]) -> object :
Likewise for a 3x3 tensor volume.
vigra.filters.tensorEigenRepresentation2D()
tensorEigenRepresentation2D( (object)image [, (object)out=None]) -> object :

Calculate eigen representation of a symmetric 2x2 tensor.

For details see tensorEigenRepresentation in the vigra C++ documentation.

vigra.filters.tensorEigenvalues()
tensorEigenvalues( (object)image [, (object)out=None]) -> object :

Calculate the eigenvalues in each pixel/voxel of a 2x2 tensor image.

For details see tensorEigenvaluesMultiArray in the vigra C++ documentation.

tensorEigenvalues( (object)volume [, (object)out=None]) -> object :
Likewise for a 3x3 tensor volume.
vigra.filters.tensorTrace()
tensorTrace( (object)image [, (object)out=None]) -> object :

Calculate the trace of a 2x2 tensor image.

For details see tensorTraceMultiArray in the vigra C++ documentation.

tensorTrace( (object)volume [, (object)out=None]) -> object :
Likewise for a 3x3 tensor volume.
vigra.filters.vectorToTensor()
vectorToTensor( (object)image [, (object)out=None]) -> object :

Turn a 2D vector valued image (e.g. the gradient image) into a tensor image by computing the outer product in every pixel.

For details see vectorToTensorMultiArray in the vigra C++ documentation.

vectorToTensor( (object)volume [, (object)out=None]) -> object :
Likewise for a 3D vector-valued volume.

Sampling

The module vigra.sampling contains methods to change the number and/or location of the image sampling points, such as resizing, rotation, and interpolation.

vigra.sampling.resampleImage()
resampleImage( (object)image, (float)factor [, (object)out=None]) -> object :

Resample an image by the given ‘factor’

The ‘out’ parameter must have, if given, the according dimensions. This function also works for multiband images, it is then executed on every band.

For more details, see resampleImage in the vigra C++ documentation.

vigra.sampling.resamplingGaussian()
resamplingGaussian( (object)image [, (float)sigmaX=1.0 [, (int)derivativeOrderX=0 [, (float)samplingRatioX=2.0 [, (float)offsetX=0.0 [, (float)sigmaY=1.0 [, (int)derivativeOrderY=0 [, (float)samplingRatioY=2.0 [, (float)offsetY=0.0 [, (object)out=None]]]]]]]]]) -> object :

Resample image using a gaussian filter:

resamplingGaussian(image,
                   sigmaX=1.0, derivativeOrderX=0, samplingRatioX=2.0, offsetX=0.0,
                   sigmaY=1.0, derivativeOrderY=0, samplingRatioY=2.0, offsetY=0.0,
                   out=None)

This function utilizes resamplingConvolveImage with a Gaussianfilter (see the vigra C++ documentation for details).

vigra.sampling.resize()
resize( (object)image [, (object)shape=None [, (int)order=3 [, (object)out=None]]]) -> object :

Resize image or volume using B-spline interpolation.

The spline order is given in the parameter ‘order’. The desired shape of the output array is taken either from ‘shape’ or ‘out’. If both are given, they must agree. This function also works for multi-channel data, it is then executed on every channel independently.

For more details, see resizeImageSplineInterpolation and resizeMultiArraySplineInterpolation in the vigra C++ documentation.

resize( (object)image [, (object)shape=None [, (int)order=3 [, (object)out=None]]]) -> object

vigra.sampling.resizeImageCatmullRomInterpolation()
resizeImageCatmullRomInterpolation( (object)image [, (object)shape=None [, (object)out=None]]) -> object :

Resize image using the Catmull/Rom interpolation function.

The desired shape of the output image is taken either from ‘shape’ or ‘out’. If both are given, they must agree. This function also works for multiband images, it is then executed on every band.

For more details, see resizeImageCatmullRomInterpolation in the vigra C++ documentation.

vigra.sampling.resizeImageCoscotInterpolation()
resizeImageCoscotInterpolation( (object)image [, (object)shape=None [, (object)out=None]]) -> object :

Resize image using the Coscot interpolation function.

The desired shape of the output image is taken either from ‘shape’ or ‘out’. If both are given, they must agree. This function also works for multiband images, it is then executed on every band.

For more details, see resizeImageCoscotInterpolation in the vigra C++ documentation.

vigra.sampling.resizeImageLinearInterpolation()
resizeImageLinearInterpolation( (object)image [, (object)shape=None [, (object)out=None]]) -> object :

Resize image using linear interpolation. The function uses the standard separable bilinear interpolation algorithm to obtain a good compromise between quality and speed.

The desired shape of the output image is taken either from ‘shape’ or ‘out’. If both are given, they must agree. This function also works for multiband images, it is then executed on every band.

For more details, see resizeImageLinearInterpolation in the vigra C++ documentation.

vigra.sampling.resizeImageNoInterpolation()
resizeImageNoInterpolation( (object)image [, (object)shape=None [, (object)out=None]]) -> object :

Resize image by repeating the nearest pixel values.

The desired shape of the output image is taken either from ‘shape’ or ‘out’. If both are given, they must agree. This function also works for multiband images, it is then executed on every band.

For more details, see resizeImageNoInterpolation in the vigra C++ documentation.

vigra.sampling.resizeImageSplineInterpolation()
resizeImageSplineInterpolation( (object)image [, (object)shape=None [, (int)order=3 [, (object)out=None]]]) -> object :

Resize image using B-spline interpolation.

The spline order is given in the parameter ‘order’. The desired shape of the output image is taken either from ‘shape’ or ‘out’. If both are given, they must agree. This function also works for multiband images, it is then executed on every band.

For more details, see resizeImageSplineInterpolation in the vigra C++ documentation.

vigra.sampling.resizeVolumeSplineInterpolation()
resizeVolumeSplineInterpolation( (object)image [, (object)shape=None [, (int)order=3 [, (object)out=None]]]) -> object :

Resize volume using B-spline interpolation.

The spline order is given in the parameter ‘order’. The dimensions of the output volume is taken either from ‘shape’ or ‘out’. If both are given, they must agree. This function also works for multiband volumes, it is then executed on every band.

For more details, see resizeMultiArraySplineInterpolation in the vigra C++ documentation.

vigra.sampling.rotateImageDegree()
rotateImageDegree( (object)image, (float)degree [, (RotationDirection)direction=vigra.sampling.RotationDirection.CLOCKWISE [, (int)splineOrder=0 [, (object)out=None]]]) -> object :

Rotate an image by an arbitrary angle using splines for interpolation around its center.

The angle may be given in degree (parameter degree). The parameter ‘splineOrder’ indicates the order of the splines used for interpolation. If the ‘out’ parameter is given, the image is cropped for it’s dimensions. If the ‘out’ parameter is not given, an output image with the same dimensions as the input image is created.

For more details, see GeometricTransformations.rotationMatrix2DDegrees in the vigra C++ documentation.

vigra.sampling.rotateImageRadiant()
rotateImageRadiant( (object)image, (float)radiant [, (RotationDirection)direction=vigra.sampling.RotationDirection.CLOCKWISE [, (int)splineOrder=0 [, (object)out=None]]]) -> object :

Rotate an image by an arbitrary angle around its center using splines for interpolation.

The angle may be given in radiant (parameter radiant). The parameter ‘splineOrder’ indicates the order of the splines used for interpolation. If the ‘out’ parameter is given, the image is cropped for it’s dimensions. If the ‘out’ parameter is not given, an output image with the same dimensions as the input image is created.

For more details, see GeometricTransformations.rotationMatrix2DRadians in the vigra C++ documentation.

vigra.sampling.rotateImageSimple()
rotateImageSimple( (object)image [, (RotationDirection)orientation=vigra.sampling.RotationDirection.CLOCKWISE [, (object)out=None]]) -> object :

Rotate an image by a multiple of 90 degrees.

The ‘orientation’ parameter (which must be one of CLOCKWISE, COUNTER_CLOCKWISE and UPSIDE_DOWN indicates the rotation direction. The ‘out’ parameter must, if given, have the according dimensions. This function also works for multiband images, it is then executed on every band.

For more details, see rotateImage in the vigra C++ documentation.


Spline image views implement an interpolated view for an image which can be accessed at real-valued coordinates (in contrast to the plain image, which can only be accessed at integer coordinates). Module vigra.sampling defines:

SplineImageView0
SplineImageView1
SplineImageView2
SplineImageView3
SplineImageView4
SplineImageView5

The number denotes the spline interpolation order of the respective classes. Below, we describe SplineImageView3 in detail, but the other classes work analogously. See SplineImageView in the C++ documentation for more detailed information.

class vigra.sampling.SplineImageView3
__init__( (object)arg1, (object)arg2) -> object :

Construct a SplineImageView for the given image:

SplineImageView(image, skipPrefilter = False)

Currently, ‘image’ can have dtype numpy.uint8, numpy.int32, and numpy.float32. If ‘skipPrefilter’ is True, image values are directly used as spline coefficients, so that the view performs approximation rather than interploation.

__init__( (object)arg1, (object)arg2) -> object

__init__( (object)arg1, (object)arg2) -> object

__init__( (object)arg1, (object)arg2, (bool)arg3) -> object

__init__( (object)arg1, (object)arg2, (bool)arg3) -> object

__init__( (object)arg1, (object)arg2, (bool)arg3) -> object

coefficientImage()

coefficientImage( (SplineImageView3)arg1) -> object

dx()
dx( (SplineImageView3)arg1, (float)x, (float)y) -> float :

Return first derivative in x direction at a real-valued coordinate.

SplineImageView.dx(x, y) -> value

dx3()
dx3( (SplineImageView3)arg1, (float)x, (float)y) -> float :

Return third derivative in x direction at a real-valued coordinate.

SplineImageView.dx3(x, y) -> value

dx3Image()
dx3Image( (SplineImageView3)arg1 [, (float)xfactor=2.0 [, (float)yfactor=2.0]]) -> object :

Like dx3(), but returns an entire image with the given sampling factors. For example,

SplineImageView.dx3Image(2.0, 2.0) -> image

creates an derivative image with two-fold oversampling in both directions.

dxImage()
dxImage( (SplineImageView3)arg1 [, (float)xfactor=2.0 [, (float)yfactor=2.0]]) -> object :

Like dx(), but returns an entire image with the given sampling factors. For example,

SplineImageView.dxImage(2.0, 2.0) -> image

creates an derivative image with two-fold oversampling in both directions.

dxx()
dxx( (SplineImageView3)arg1, (float)x, (float)y) -> float :

Return second derivative in x direction at a real-valued coordinate.

SplineImageView.dxx(x, y) -> value

dxxImage()
dxxImage( (SplineImageView3)arg1 [, (float)xfactor=2.0 [, (float)yfactor=2.0]]) -> object :

Like dxx(), but returns an entire image with the given sampling factors. For example,

SplineImageView.dxxImage(2.0, 2.0) -> image

creates an derivative image with two-fold oversampling in both directions.

dxxy()
dxxy( (SplineImageView3)arg1, (float)x, (float)y) -> float :

Return mixed third derivative at a real-valued coordinate.

SplineImageView.dxxy(x, y) -> value

dxxyImage()
dxxyImage( (SplineImageView3)arg1 [, (float)xfactor=2.0 [, (float)yfactor=2.0]]) -> object :

Like dxxy(), but returns an entire image with the given sampling factors. For example,

SplineImageView.dxxyImage(2.0, 2.0) -> image

creates an derivative image with two-fold oversampling in both directions.

dxy()
dxy( (SplineImageView3)arg1, (float)x, (float)y) -> float :

Return mixed second derivative at a real-valued coordinate.

SplineImageView.dxy(x, y) -> value

dxyImage()
dxyImage( (SplineImageView3)arg1 [, (float)xfactor=2.0 [, (float)yfactor=2.0]]) -> object :

Like dxy(), but returns an entire image with the given sampling factors. For example,

SplineImageView.dxyImage(2.0, 2.0) -> image

creates an derivative image with two-fold oversampling in both directions.

dxyy()
dxyy( (SplineImageView3)arg1, (float)x, (float)y) -> float :

Return mixed third derivative at a real-valued coordinate.

SplineImageView.dxyy(x, y) -> value

dxyyImage()
dxyyImage( (SplineImageView3)arg1 [, (float)xfactor=2.0 [, (float)yfactor=2.0]]) -> object :

Like dxyy(), but returns an entire image with the given sampling factors. For example,

SplineImageView.dxyyImage(2.0, 2.0) -> image

creates an derivative image with two-fold oversampling in both directions.

dy()
dy( (SplineImageView3)arg1, (float)x, (float)y) -> float :

Return first derivative in y direction at a real-valued coordinate.

SplineImageView.dy(x, y) -> value

dy3()
dy3( (SplineImageView3)arg1, (float)x, (float)y) -> float :

Return third derivative in y direction at a real-valued coordinate.

SplineImageView.dy3(x, y) -> value

dy3Image()
dy3Image( (SplineImageView3)arg1 [, (float)xfactor=2.0 [, (float)yfactor=2.0]]) -> object :

Like dy3(), but returns an entire image with the given sampling factors. For example,

SplineImageView.dy3Image(2.0, 2.0) -> image

creates an derivative image with two-fold oversampling in both directions.

dyImage()
dyImage( (SplineImageView3)arg1 [, (float)xfactor=2.0 [, (float)yfactor=2.0]]) -> object :

Like dy(), but returns an entire image with the given sampling factors. For example,

SplineImageView.dyImage(2.0, 2.0) -> image

creates an derivative image with two-fold oversampling in both directions.

dyy()
dyy( (SplineImageView3)arg1, (float)x, (float)y) -> float :

Return second derivative in y direction at a real-valued coordinate.

SplineImageView.dyy(x, y) -> value

dyyImage()
dyyImage( (SplineImageView3)arg1 [, (float)xfactor=2.0 [, (float)yfactor=2.0]]) -> object :

Like dyy(), but returns an entire image with the given sampling factors. For example,

SplineImageView.dyyImage(2.0, 2.0) -> image

creates an derivative image with two-fold oversampling in both directions.

facetCoefficients()
facetCoefficients( (SplineImageView3)arg1, (float)arg2, (float)arg3) -> object :

SplineImageView.facetCoefficients(x, y) -> matrix

Return the facet coefficient matrix so that spline values can be computed explicitly. The matrix has size (order+1)x(order+1), where order is the order of the spline. The matrix must be multiplied from left and right with the powers of the local facet x- and y-coordinates respectively (note that local facet coordinates are in the range [0,1] for odd order splines and [-0.5, 0.5] for even order splines).

Usage for odd spline order:

s = SplineImageView3(image) c = s.coefficients(10.1, 10.7) x = matrix([1, 0.1, 0.1**2, 0.1**3]) y = matrix([1, 0.7, 0.7**2, 0.7**3]) assert abs(x * c * y.T - s[10.1, 10.7]) < smallNumber

Usage for even spline order:

s = SplineImageView2(image) c = s.coefficients(10.1, 10.7) x = matrix([1, 0.1, 0.1**2]) y = matrix([1, -0.3, (-0.3)**2]) assert abs(x * c * y.T - s[10.1, 10.7]) < smallNumber
g2()
g2( (SplineImageView3)arg1, (float)x, (float)y) -> float :

Return gradient squared magnitude at a real-valued coordinate.

SplineImageView.g2(x, y) -> value

g2Image()
g2Image( (SplineImageView3)arg1 [, (float)xfactor=2.0 [, (float)yfactor=2.0]]) -> object :

Like g2(), but returns an entire image with the given sampling factors. For example,

SplineImageView.g2Image(2.0, 2.0) -> image

creates an derivative image with two-fold oversampling in both directions.

g2x()
g2x( (SplineImageView3)arg1, (float)x, (float)y) -> float :

Return first derivative in x direction of the gradient squared magnitude at a real-valued coordinate.

SplineImageView.g2x(x, y) -> value

g2xImage()
g2xImage( (SplineImageView3)arg1 [, (float)xfactor=2.0 [, (float)yfactor=2.0]]) -> object :

Like g2x(), but returns an entire image with the given sampling factors. For example,

SplineImageView.g2xImage(2.0, 2.0) -> image

creates an derivative image with two-fold oversampling in both directions.

g2y()
g2y( (SplineImageView3)arg1, (float)x, (float)y) -> float :

Return first derivative in y direction of the gradient squared magnitude at a real-valued coordinate.

SplineImageView.g2y(x, y) -> value

g2yImage()
g2yImage( (SplineImageView3)arg1 [, (float)xfactor=2.0 [, (float)yfactor=2.0]]) -> object :

Like g2y(), but returns an entire image with the given sampling factors. For example,

SplineImageView.g2yImage(2.0, 2.0) -> image

creates an derivative image with two-fold oversampling in both directions.

height()
height( (SplineImageView3)arg1) -> int :
The height of the underlying image.
interpolatedImage()
interpolatedImage( (SplineImageView3)arg1 [, (float)xfactor=2.0 [, (float)yfactor=2.0 [, (int)xorder=0 [, (int)yorder=0]]]]) -> object :

Return an interpolated image or derivative image with the given sampling factors and derivative orders. For example, we get a two-fold oversampled image with the x-derivatives in each pixel by:

SplineImageView.interpolatedImage(2.0, 2.0, 1, 0) -> image

isInside()
isInside( (SplineImageView3)arg1, (float)arg2, (float)arg3) -> bool :

Check if a coordinate is inside the underlying image.

SplineImageView.isInside(x, y) -> bool

isValid()
isValid( (SplineImageView3)arg1, (float)arg2, (float)arg3) -> bool :

Check if a coordinate is within the valid range of the SplineImageView.

SplineImageView.isValid(x, y) -> bool

Thanks to reflective boundary conditions, the valid range is three times as big as the size of the underlying image.

shape()
shape( (SplineImageView3)arg1) -> object :
The shape of the underlying image.
size()

size( (SplineImageView3)arg1) -> object

width()
width( (SplineImageView3)arg1) -> int :
The width of the underlying image.

Fourier Transforms

The module vigra.fourier contains functions for Fourier transforms, Cosine/Sine transforms, and Fourier-domain filters.

vigra.fourier.angularGaborSigma()
angularGaborSigma( (int)arg1, (float)arg2) -> float :
Calculate sensible angular sigma for given parameters.
vigra.fourier.createGaborFilter()
createGaborFilter( (object)shape, (float)orientation, (float)centerFrequency, (float)angularSigma, (float)radialSigma [, (object)out=None]) -> object :
Create a 2-dimensional gabor filter in frequency space.
vigra.fourier.fourierTransform()
fourierTransform( (object)image [, (object)out=None]) -> object :
Perform 2-dimensional or 3-dimensional Fourier transformation of a scalar float64 array.If the input array has multiple channels, each channel is transformed separately.
fourierTransform( (object)image [, (object)out=None]) -> object :
Likewise for a 2D complex128 image.
fourierTransform( (object)volume [, (object)out=None]) -> object :
Likewise for a 3D complex128 volume.
vigra.fourier.fourierTransformInverse()
fourierTransformInverse( (object)image [, (object)out=None]) -> object :
Perform 2-dimensional inverse Fourier transformation of a complex array.If the input array has multiple channels, each channel is transformed separately.
fourierTransformInverse( (object)volume [, (object)out=None]) -> object :
Likewise for a 3D complex128 volume.
vigra.fourier.radialGaborSigma()
radialGaborSigma( (float)arg1) -> float :
Calculate sensible radial sigma for given parameters.

Image Analysis

The module vigra.analysis contains segmentation algorithms (e.g. watershed), edge and corner detection, localization of maxima and minima etc.

class vigra.analysis.Edgel

Represent an Edgel at a particular subpixel position (x, y), having given ‘strength’ and ‘orientation’.

For details, see Edgel in the vigra C++ documentation.

__init__( (object)arg1) -> None :

Standard constructor:

Edgel()
__init__( (object)arg1, (float)x, (float)y, (float)strength, (float)orientation) -> None :

Constructor:

Edgel(x, y, strength, orientation)
orientation

The edgel’s orientation.

strength

The edgel’s strength.

x

The edgel’s x position.

y

The edgel’s y position.

vigra.analysis.beautifyCrackEdgeImage()
beautifyCrackEdgeImage( (object)image, (int)edgeMarker, (int)backgroundMarker [, (object)out=None]) -> object :

Beautify crack edge image for visualization.

For details see beautifyCrackEdgeImage in the vigra C++ documentation.

vigra.analysis.cannyEdgeImage()
cannyEdgeImage( (object)image, (float)scale, (float)threshold, (int)edgeMarker [, (object)out=None]) -> object :

Detect and mark edges in an edge image using Canny’s algorithm.

For details see cannyEdgeImage in the vigra C++ documentation.

vigra.analysis.cannyEdgeImageWithThinning()
cannyEdgeImageWithThinning( (object)image, (float)scale, (float)threshold, (int)edgeMarker [, (bool)addBorder=True [, (object)out=None]]) -> object :

Detect and mark edges in an edge image using Canny’s algorithm.

For details see cannyEdgeImageWithThinning in the vigra C++ documentation.

vigra.analysis.cannyEdgelList()
cannyEdgelList( (object)gradient, (float)threshold) -> list :

Return a list of Edgel objects whose strength is at least ‘threshold’.

The function comes in two forms:

cannyEdgelList(gradient, threshold) -> list
cannyEdgelList(image, scale, threshold) -> list

The first form expects a gradient image (i.e. with two channels) to compute edgels, whereas the second form expects a scalar image and computes the gradient internally at ‘scale’.

For details see cannyEdgelList in the vigra C++ documentation.

cannyEdgelList( (object)image, (float)scale, (float)threshold) -> list :
Compute edgels of a 2D scalar image, given the filter scale.
vigra.analysis.cannyEdgelList3x3()
cannyEdgelList3x3( (object)gradient, (float)threshold) -> list :

Return a list of Edgel objects whose strength is at least ‘threshold’.

The function comes in two forms:

cannyEdgelList3x3(gradient, threshold) -> list
cannyEdgelList3x3(image, scale, threshold) -> list

The first form expects a gradient image (i.e. with two channels) to compute edgels, whereas the second form expects a scalar image and computes the gradient internally at ‘scale’. The results are slightly better than those of cannyEdgelList().

For details see cannyEdgelList3x3 in the vigra C++ documentation.

cannyEdgelList3x3( (object)image, (float)scale, (float)threshold) -> list :
Compute edgels of a 2D scalar image, given the filter scale.
vigra.analysis.closeGapsInCrackEdgeImage()
closeGapsInCrackEdgeImage( (object)image, (int)edgeMarker [, (object)out=None]) -> object :

Close one-pixel wide gaps in a cell grid edge image.

For details see closeGapsInCrackEdgeImage in the vigra C++ documentation.

vigra.analysis.cornernessBeaudet()
cornernessBeaudet( (object)image, (float)scale [, (object)out=None]) -> object :

Find corners in a scalar 2D image using the method of Beaudet at the given ‘scale’.

For details see beaudetCornerDetector in the vigra C++ documentation.

vigra.analysis.cornernessBoundaryTensor()
cornernessBoundaryTensor( (object)image, (float)scale [, (object)out=None]) -> object :

Find corners in a scalar 2D image using the boundary tensor at the given ‘scale’.

Specifically, the cornerness is defined as twice the small eigenvalue of the boundary tensor.

For details see boundaryTensor in the vigra C++ documentation.

vigra.analysis.cornernessFoerstner()
cornernessFoerstner( (object)image, (float)scale [, (object)out=None]) -> object :

Find corners in a scalar 2D image using the method of Foerstner at the given ‘scale’.

For details see foerstnerCornerDetector in the vigra C++ documentation.

vigra.analysis.cornernessHarris()
cornernessHarris( (object)image, (float)scale [, (object)out=None]) -> object :

Find corners in a scalar 2D image using the method of Harris at the given ‘scale’.

For details see cornerResponseFunction in the vigra C++ documentation.

vigra.analysis.cornernessRohr()
cornernessRohr( (object)image, (float)scale [, (object)out=None]) -> object :

Find corners in a scalar 2D image using the method of Rohr at the given ‘scale’.

For details see rohrCornerDetector in the vigra C++ documentation.

vigra.analysis.extendedLocalMaxima()
extendedLocalMaxima( (object)image [, (float)marker=1.0 [, (int)neighborhood=8 [, (object)out=None]]]) -> object :

Find local maxima and maximal plateaus in an image and mark them with the given ‘marker’. Parameter ‘neighborhood’ specifies the pixel neighborhood to be used and can be 4 or 8 (default).

For details see localMinima in the vigra C++ documentation.

vigra.analysis.extendedLocalMinima()
extendedLocalMinima( (object)image [, (float)marker=1.0 [, (int)neighborhood=8 [, (object)out=None]]]) -> object :

Find local minima and minimal plateaus in an image and mark them with the given ‘marker’. Parameter ‘neighborhood’ specifies the pixel neighborhood to be used and can be 4 or 8 (default).

For details see extendedLocalMinima in the vigra C++ documentation.

vigra.analysis.labelImage()
labelImage( (object)image [, (int)neighborhood=4 [, (object)out=None]]) -> object :

Find the connected components of a segmented image. Parameter ‘neighborhood’ specifies the pixel neighborhood to be used and can be 4 (default) or 8.

For details see labelImage in the vigra C++ documentation.

labelImage( (object)image [, (int)neighborhood=4 [, (object)out=None]]) -> object

vigra.analysis.labelImageWithBackground()
labelImageWithBackground( (object)image [, (int)neighborhood=4 [, (int)background_value=0 [, (object)out=None]]]) -> object :

Find the connected components of a segmented image, excluding the background from labeling, where the background is the set of all pixels with the given ‘background_value’. Parameter ‘neighborhood’ specifies the pixel neighborhood to be used and can be 4 (default) or 8.

For details see labelImageWithBackground in the vigra C++ documentation.

labelImageWithBackground( (object)image [, (int)neighborhood=4 [, (float)background_value=0 [, (object)out=None]]]) -> object

vigra.analysis.labelVolume()
labelVolume( (object)volume [, (int)neighborhood=6 [, (object)out=None]]) -> object :

Find the connected components of a segmented volume. Parameter ‘neighborhood’ specifies the pixel neighborhood to be used and can be 6 (default) or 26.

For details see labelVolume in the vigra C++ documentation.

labelVolume( (object)volume [, (int)neighborhood=6 [, (object)out=None]]) -> object

vigra.analysis.labelVolumeWithBackground()
labelVolumeWithBackground( (object)volume [, (int)neighborhood=6 [, (int)background_value=0 [, (object)out=None]]]) -> object :

Find the connected components of a segmented volume, excluding the background from labeling, where the background is the set of all pixels with the given ‘background_value’. Parameter ‘neighborhood’ specifies the pixel neighborhood to be used and can be 6 (default) or 26.

For details see labelVolumeWithBackground in the vigra C++ documentation.

labelVolumeWithBackground( (object)volume [, (int)neighborhood=6 [, (float)background_value=0 [, (object)out=None]]]) -> object

vigra.analysis.localMaxima()
localMaxima( (object)image [, (float)marker=1.0 [, (int)neighborhood=8 [, (object)out=None]]]) -> object :

Find local maxima in an image and mark them with the given ‘marker’. Parameter ‘neighborhood’ specifies the pixel neighborhood to be used and can be 4 or 8 (default).

For details see localMaxima in the vigra C++ documentation.

vigra.analysis.localMinima()
localMinima( (object)image [, (float)marker=1.0 [, (int)neighborhood=8 [, (object)out=None]]]) -> object :

Find local minima in an image and mark them with the given ‘marker’. Parameter ‘neighborhood’ specifies the pixel neighborhood to be used and can be 4 or 8 (default).

For details see localMinima in the vigra C++ documentation.

vigra.analysis.regionImageToCrackEdgeImage()
regionImageToCrackEdgeImage( (object)image [, (int)edgeLabel=0 [, (object)out=None]]) -> object :

Transform a labeled uint32 image into a crack edge image.

For details see regionImageToCrackEdgeImage in the vigra C++ documentation.

regionImageToCrackEdgeImage( (object)image [, (long)edgeLabel=0 [, (object)out=None]]) -> object :
Likewise for a uint64 image.
vigra.analysis.regionImageToEdgeImage()
regionImageToEdgeImage( (object)image [, (int)edgeLabel=0 [, (object)out=None]]) -> object :

Transform a labeled uint32 image into an edge image.

For details see regionImageToEdgeImage in the vigra C++ documentation.

regionImageToEdgeImage( (object)image [, (long)edgeLabel=0 [, (object)out=None]]) -> object :
Likewise for a uint64 image.
vigra.analysis.removeShortEdges()
removeShortEdges( (object)image, (int)minEdgeLength, (int)nonEdgeMarker [, (object)out=None]) -> object :

Remove short edges from an edge image.

For details see removeShortEdges in the vigra C++ documentation.

vigra.analysis.shenCastanCrackEdgeImage()
shenCastanCrackEdgeImage( (object)image, (float)scale, (float)threshold, (int)edgeMarker [, (object)out=None]) -> object :

Detect and mark edges in a crack edge image using the Shen/Castan zero-crossing detector.

For details see differenceOfExponentialCrackEdgeImage in the vigra C++ documentation.

vigra.analysis.shenCastanEdgeImage()
shenCastanEdgeImage( (object)image, (float)scale, (float)threshold, (int)edgeMarker [, (object)out=None]) -> object :

Detect and mark edges in an edge image using the Shen/Castan zero-crossing detector.

For details see differenceOfExponentialEdgeImage in the vigra C++ documentation.

vigra.analysis.watersheds()
watersheds( (object)image [, (int)neighborhood=4 [, (object)seeds=None [, (str)method=’RegionGrowing’ [, (SRGType)terminate=vigra.analysis.SRGType.CompleteGrow [, (int)max_cost=0.0 [, (object)out=None]]]]]]) -> tuple :

Compute the watersheds of a 2D image.

watersheds(image, neighborhood=4, seeds = None, methods = ‘RegionGrowing’,
terminate=CompleteGrow, threshold=0, out = None) -> (labelimage, max_ragion_label)

Parameters:

image:
the image or volume containing the boundary indicator values (high values = high edgeness, dtype=numpy.uint8 or numpy.float32).
neighborhood:

the pixel neighborhood to be used. Feasible values depend on the dimension and method:

2-dimensional data:
4 (default) or 8.
3-dimensional data:
6 (default) or 26
seeds:
a label image specifying region seeds, only supported by method ‘RegionGrowing’ (with dtype=numpy.uint32).
method:

the algorithm to be used for watershed computation. Possible values:

‘RegionGrowing’:
(default) use seededRegionGrowing or seededRegionGrowing3D respectively
‘UnionFind:
use watersheds or watersheds3D respectively
terminate:

when to stop growing. Possible values:

CompleteGrow:
(default) grow until all pixels are assigned to a region
KeepCountours:
keep a 1-pixel wide contour between all regions, only supported by method ‘RegionGrowing’
StopAtThreshold:
stop when the boundary indicator values exceed the threshold given by parameter ‘max_cost’, only supported by method ‘RegionGrowing’
KeepCountours | StopAtThreshold:
keep 1-pixel wide contour and stop at given ‘max_cost’, only supported by method ‘RegionGrowing’
max_cost:
terminate growing when boundary indicator exceeds this value (ignored when ‘terminate’ is not StopAtThreshold or method is not ‘RegionGrowing’)
out:
the label image (with dtype=numpy.uint32) to be filled by the algorithm. It will be allocated by the watershed function if not provided)

The function returns a Python tuple (labelImage, maxRegionLabel)

watersheds( (object)image [, (int)neighborhood=4 [, (object)seeds=None [, (str)method=’RegionGrowing’ [, (SRGType)terminate=vigra.analysis.SRGType.CompleteGrow [, (float)max_cost=0.0 [, (object)out=None]]]]]]) -> tuple

watersheds( (object)volume [, (int)neighborhood=6 [, (object)seeds=None [, (str)method=’RegionGrowing’ [, (SRGType)terminate=vigra.analysis.SRGType.CompleteGrow [, (int)max_cost=0.0 [, (object)out=None]]]]]]) -> tuple :
Likewise, compute watersheds of a volume.

watersheds( (object)volume [, (int)neighborhood=6 [, (object)seeds=None [, (str)method=’RegionGrowing’ [, (SRGType)terminate=vigra.analysis.SRGType.CompleteGrow [, (float)max_cost=0.0 [, (object)out=None]]]]]]) -> tuple

vigra.analysis.watershedsUnionFind(image, neighborhood=None, out=None)

Compute watersheds of an image using the union find algorithm. If ‘neighborhood’ is ‘None’, it defaults to 8-neighborhood for 2D inputs and 6-neighborhood for 3D inputs.

Calls watersheds() with parameters:

watersheds(image, neighborhood=neighborhood, method='UnionFind', out=out)

Geometry

The module vigra.geometry contains geometric primitives (such as polygons) and related algorithms.

vigra.geometry.convexHull()
convexHull( (object)points) -> object :

Compute the convex hull of a point set.

For details see convexHull in the vigra C++ documentation.

convexHull( (object)points) -> object

convexHull( (object)points) -> object

Machine Learning

The module vigra.learning will eventually provide a wide range of machine learning tools. Right now, it only contains an implementation of the random forest classifier.

class vigra.learning.RandomForest
__init__( (object)arg1 [, (int)treeCount=255 [, (int)mtry=-1 [, (int)min_split_node_size=1 [, (int)training_set_size=0 [, (float)training_set_proportions=1.0 [, (bool)sample_with_replacement=True [, (bool)sample_classes_individually=False [, (bool)prepare_online_learning=False]]]]]]]]) -> object :

Constructor:

RandomForest(treeCount = 255, mtry=RF_SQRT, min_split_node_size=1,
             training_set_size=0, training_set_proportions=1.0,
             sample_with_replacement=True, sample_classes_individually=False,
             prepare_online_learning=False)

‘treeCount’ controls the number of trees that are created.

See RandomForest and RandomForestOptions in the C++ documentation for the meaning of the other parameters.

featureCount()
featureCount( (RandomForest)arg1) -> int :
Returns the number of features the RandomForest works with.
labelCount()
labelCount( (RandomForest)arg1) -> int :
Returns the number of labels, the RandomForest knows.
learnRF()
learnRF( (RandomForest)arg1, (object)trainData, (object)trainLabels) -> float :

Trains a random Forest using ‘trainData’ and ‘trainLabels’.

and returns the OOB. See the vigra documentation for the meaning af the rest of the paremeters.

learnRFWithFeatureSelection()
learnRFWithFeatureSelection( (RandomForest)arg1, (object)trainData, (object)trainLabels) -> tuple :

Train a random Forest using ‘trainData’ and ‘trainLabels’.

and returns the OOB and the Variable importanceSee the vigra documentation for the meaning af the rest of the paremeters.

onlineLearn()
onlineLearn( (RandomForest)arg1, (object)arg2, (object)trainData, (int)trainLabels, (bool)startIndex) -> None :

Learn online.

Works only if forest has been created with prepare_online_learning=true. Needs the old training data and the new appened, starting at startIndex.

predictLabels()
predictLabels( (RandomForest)arg1, (object)testData [, (object)out=None]) -> object :

Predict labels on ‘testData’.

The output is an array containing a labels for every test samples.

predictProbabilities()
predictProbabilities( (RandomForest)arg1, (object)testData [, (object)out=None]) -> object :

Predict probabilities for different classes on ‘testData’.

The output is an array containing a probability for every test sample and class.

predictProbabilities( (RandomForest)arg1, (RF_OnlinePredictionSet)testData [, (object)out=None]) -> object :
The output is an array containing a probability for every test sample and class.
reLearnTree()
reLearnTree( (RandomForest)arg1, (object)trainData, (object)trainLabels, (int)treeId) -> None :

Re-learn one tree of the forest using ‘trainData’ and ‘trainLabels’.

and returns the OOB. This might be helpful in an online learning setup to improve the classifier.

treeCount()
treeCount( (RandomForest)arg1) -> int :
Returns the ‘treeCount’, that was set when constructing the RandomForest.

For more information, refer to RandomForest in the C++ documentation.

class vigra.learning.RandomForestOld
__init__( (object)arg1, (object)trainData, (object)trainLabels [, (int)treeCount=255 [, (int)mtry=0 [, (int)min_split_node_size=1 [, (int)training_set_size=0 [, (float)training_set_proportions=1.0 [, (bool)sample_with_replacement=True [, (bool)sample_classes_individually=False]]]]]]]) -> object :

Constructor:

RandomForestOld(trainData, trainLabels,
                treeCount = 255, mtry=0, min_split_node_size=1,
                training_set_size=0, training_set_proportions=1.0,
                sample_with_replacement=True, sample_classes_individually=False,)

Construct and train a RandomForest using ‘trainData’ and ‘trainLabels’. ‘treeCount’ controls the number of trees that are created.

See RandomForest and RandomForestOptions in the C++ documentation for the meaning of the other parameters.

featureCount()
featureCount( (RandomForestOld)arg1) -> int :
Returns the number of features the RandomForest works with.
labelCount()
labelCount( (RandomForestOld)arg1) -> int :
Returns the number of labels, the RanfomForest knows.
predictLabels()
predictLabels( (RandomForestOld)arg1, (object)testData [, (object)out=None]) -> object :
Predict labels on ‘testData’.The output is an array containing a labels for every test samples.
predictProbabilities()
predictProbabilities( (RandomForestOld)arg1, (object)testData [, (object)out=None]) -> object :
Predict probabilities for different classes on ‘testData’.The output is an array containing a probability for every test sample and class.
treeCount()
treeCount( (RandomForestOld)arg1) -> int :
Returns the ‘treeCount’, that was set when constructing the RandomForest.

Noise Estimation and Normalization

The module vigra.noise provides noise estimation and normalization according to a method proposed by Foerstner.

vigra.noise.linearNoiseNormalization()
linearNoiseNormalization( (object)image, (float)a0, (float)a1 [, (object)out=None]) -> object :

Noise normalization by means of an estimated linear noise model.

For details see linearNoiseNormalization in the vigra C++ documentation.

vigra.noise.linearNoiseNormalizationEstimated()

linearNoiseNormalizationEstimated( (object)image [, (bool)useGradient=True [, (int)windowRadius=6 [, (int)clusterCount=10 [, (float)averagingQuantile=0.8 [, (float)noiseEstimationQuantile=1.5 [, (float)noiseVarianceInitialGuess=10.0 [, (object)out=None]]]]]]]) -> object

vigra.noise.noiseVarianceClustering()
noiseVarianceClustering( (object)image [, (bool)useGradient=True [, (int)windowRadius=6 [, (int)clusterCount=10 [, (float)averagingQuantile=0.8 [, (float)noiseEstimationQuantile=1.5 [, (float)noiseVarianceInitialGuess=10.0 [, (object)out=None]]]]]]]) -> object :

Determine the noise variance as a function of the image intensity and cluster the results. This operator first calls noiseVarianceEstimation() to obtain a sequence of intensity/variance pairs, which are then clustered using the median cut algorithm. Then the cluster centers (i.e. average variance vs. average intensity) are determined and returned in the result sequence.

Since the length of the resulting array is not known beforhand, it cannot be written into an preallocated array (the “out” argument in most other vigra python functions) . For details see the vigra documentation noiseVarianceClustering.

vigra.noise.noiseVarianceEstimation()
noiseVarianceEstimation( (object)image [, (bool)useGradient=True [, (int)windowRadius=6 [, (int)clusterCount=10 [, (float)averagingQuantile=0.8 [, (float)noiseEstimationQuantile=1.5 [, (float)noiseVarianceInitialGuess=10.0 [, (object)out=None]]]]]]]) -> object :

Determine the noise variance as a function of the image intensity.

Returns an array with the means in the first column and the variances in the second column. Since the length of the resulting array is not known beforhand, it can not be written into an preallocated array (the “out” argument in most other vigra python functions.

For details see the vigra documentation noiseVarianceEstimation.

vigra.noise.nonparametricNoiseNormalization()
nonparametricNoiseNormalization( (object)image [, (bool)useGradient=True [, (int)windowRadius=6 [, (int)clusterCount=10 [, (float)averagingQuantile=0.8 [, (float)noiseEstimationQuantile=1.5 [, (float)noiseVarianceInitialGuess=10.0 [, (object)out=None]]]]]]]) -> object :

Noise normalization by means of an estimated non-parametric noise model.

For details see nonparametricNoiseNormalization in the vigra C++ documentation.

vigra.noise.quadraticNoiseNormalization()
quadraticNoiseNormalization( (object)image, (float)a0, (float)a1, (float)a2 [, (object)out=None]) -> object :

Noise normalization by means of an estimated quadratic noise model.

For details see quadraticNoiseNormalization in the vigra C++ documentation.

vigra.noise.quadraticNoiseNormalizationEstimated()

quadraticNoiseNormalizationEstimated( (object)image [, (bool)useGradient=True [, (int)windowRadius=6 [, (int)clusterCount=10 [, (float)averagingQuantile=0.8 [, (float)noiseEstimationQuantile=1.5 [, (float)noiseVarianceInitialGuess=10.0 [, (object)out=None]]]]]]]) -> object