MultiArray

See also

Summary
MultiArray
Functions
MultiArray[]Convert an array of Ruby objects to a multi-dimensional Sequence_ object.
MultiArray.importCreate a multi-dimensional array from raw data.
MultiArray.load_rawConstruct from file created with Sequence_.save_raw.
MultiArray.newConstruct new multi-dimensional array with elements of same type.
MultiArray.objectShortcut for MultiArray.new( OBJECT, *shape )
MultiArray.boolShortcut for MultiArray.new( BOOL, *shape )
MultiArray.ubyteShortcut for MultiArray.new( UBYTE, *shape )
MultiArray.byteShortcut for MultiArray.new( BYTE, *shape )
MultiArray.usintShortcut for MultiArray.new( USINT, *shape )
MultiArray.sintShortcut for MultiArray.new( SINT, *shape )
MultiArray.uintShortcut for MultiArray.new( UINT, *shape )
MultiArray.intShortcut for MultiArray.new( INT, *shape )
MultiArray.ulongShortcut for MultiArray.new( ULONG, *shape )
MultiArray.longShortcut for MultiArray.new( LONG, *shape )
MultiArray.dfloatShortcut for MultiArray.new( DFLOAT, *shape )
MultiArray.sfloatShortcut for MultiArray.new( SFLOAT, *shape )
MultiArray.dcomplexShortcut for MultiArray.new( DCOMPLEX, *shape )
MultiArray.scomplexShortcut for MultiArray.new( SCOMPLEX, *shape )
MultiArray.ubytergbShortcut for MultiArray.new( UBYTERGB, *shape )
MultiArray.bytergbShortcut for MultiArray.new( BYTERGB, *shape )
MultiArray.usintrgbShortcut for MultiArray.new( USINTRGB, *shape )
MultiArray.sintrgbShortcut for MultiArray.new( SINTRGB, *shape )
MultiArray.uintrgbShortcut for MultiArray.new( UINTRGB, *shape )
MultiArray.intrgbShortcut for MultiArray.new( INTRGB, *shape )
MultiArray.ulongrgbShortcut for MultiArray.new( ULONGRGB, *shape )
MultiArray.longrgbShortcut for MultiArray.new( LONGRGB, *shape )
MultiArray.dfloatrgbShortcut for MultiArray.new( DFLOATRGB, *shape )
MultiArray.sfloatrgbShortcut for MultiArray.new( SFLOATRGB, *shape )
MultiArray.laplacian_of_gaussianCompute Laplacian of gaussian filter.
MultiArray.load_ubyteLoad a 8-bit greyscale-image.
MultiArray.load_usintLoad a 16-bit greyscale-image.
MultiArray.load_ubytergbLoad a colour-image.
MultiArray.load_sfloatLoad a single-precision floating-point greyscale-image.
MultiArray.load_dfloatLoad a double-precision floating-point greyscale-image.
MultiArray.load_sfloatrgbLoad a single-precision floating-point colour-image.
MultiArray.load_dfloatrgbLoad a double-precisino floating-point colour-image.
MultiArray.loadLoad image using RMagick.
MultiArray.loadfLoad image using OpenEXR.
MultiArray.tensorComputes a tensor product for an n-dimensional result.

Functions

MultiArray[]

Convert an array of Ruby objects to a multi-dimensional Sequence_ object.  The element type of the returned sequence is choosen to fit all elements.

Parameters

argsRuby array

Returns

Object of class Sequence_

MultiArray.import

def MultiArray.import(type,
data,
*shape)

Create a multi-dimensional array from raw data.

Parameters

typeElement-type of import
dataRuby string with data
shapeDimensions of array

MultiArray.load_raw

def MultiArray.load_raw(file)

Construct from file created with Sequence_.save_raw.

See also

MultiArray.new

def MultiArray.new(element_type,
*shape)

Construct new multi-dimensional array with elements of same type.  The elements will not be initialized.  Use fill! if you need initialized elements.

Parameters

element_typeElement type
shapeDimensions of array.

MultiArray.object

def MultiArray.object(*shape)

Shortcut for MultiArray.new( OBJECT, *shape )

See also

MultiArray.bool

def MultiArray.bool(*shape)

Shortcut for MultiArray.new( BOOL, *shape )

See also

MultiArray.ubyte

def MultiArray.ubyte(*shape)

Shortcut for MultiArray.new( UBYTE, *shape )

See also

MultiArray.byte

def MultiArray.byte(*shape)

Shortcut for MultiArray.new( BYTE, *shape )

See also

MultiArray.usint

def MultiArray.usint(*shape)

Shortcut for MultiArray.new( USINT, *shape )

See also

MultiArray.sint

def MultiArray.sint(*shape)

Shortcut for MultiArray.new( SINT, *shape )

See also

MultiArray.uint

def MultiArray.uint(*shape)

Shortcut for MultiArray.new( UINT, *shape )

See also

MultiArray.int

def MultiArray.int(*shape)

Shortcut for MultiArray.new( INT, *shape )

See also

MultiArray.ulong

def MultiArray.ulong(*shape)

Shortcut for MultiArray.new( ULONG, *shape )

See also

MultiArray.long

def MultiArray.long(*shape)

Shortcut for MultiArray.new( LONG, *shape )

See also

MultiArray.dfloat

def MultiArray.dfloat(*shape)

Shortcut for MultiArray.new( DFLOAT, *shape )

See also

MultiArray.sfloat

def MultiArray.sfloat(*shape)

Shortcut for MultiArray.new( SFLOAT, *shape )

See also

MultiArray.dcomplex

def MultiArray.dcomplex(*shape)

Shortcut for MultiArray.new( DCOMPLEX, *shape )

See also

MultiArray.scomplex

def MultiArray.scomplex(*shape)

Shortcut for MultiArray.new( SCOMPLEX, *shape )

See also

MultiArray.ubytergb

def MultiArray.ubytergb(*shape)

Shortcut for MultiArray.new( UBYTERGB, *shape )

See also

MultiArray.bytergb

def MultiArray.bytergb(*shape)

Shortcut for MultiArray.new( BYTERGB, *shape )

See also

MultiArray.usintrgb

def MultiArray.usintrgb(*shape)

Shortcut for MultiArray.new( USINTRGB, *shape )

See also

MultiArray.sintrgb

def MultiArray.sintrgb(*shape)

Shortcut for MultiArray.new( SINTRGB, *shape )

See also

MultiArray.uintrgb

def MultiArray.uintrgb(*shape)

Shortcut for MultiArray.new( UINTRGB, *shape )

See also

MultiArray.intrgb

def MultiArray.intrgb(*shape)

Shortcut for MultiArray.new( INTRGB, *shape )

See also

MultiArray.ulongrgb

def MultiArray.ulongrgb(*shape)

Shortcut for MultiArray.new( ULONGRGB, *shape )

See also

MultiArray.longrgb

def MultiArray.longrgb(*shape)

Shortcut for MultiArray.new( LONGRGB, *shape )

See also

MultiArray.dfloatrgb

def MultiArray.dfloatrgb(*shape)

Shortcut for MultiArray.new( DFLOATRGB, *shape )

See also

MultiArray.sfloatrgb

def MultiArray.sfloatrgb(*shape)

Shortcut for MultiArray.new( SFLOATRGB, *shape )

See also

MultiArray.laplacian_of_gaussian

def MultiArray.laplacian_of_gaussian(sigma,
size)

Compute Laplacian of gaussian filter.  No error estimate is given.  The LoG-filter will display zero-crossings at edges.  The edges can be detected using a combination of dilation and erosion.  Alternatively one can match a set of small 3x3 patterns.  Neither technique is provided by this library at the moment.

See also

MultiArray.load_ubyte

def MultiArray.load_ubyte(file)

Load a 8-bit greyscale-image.  A colour image will be converted to greyscale.

Parameters

fileA filename or an open file.

MultiArray.load_usint

def MultiArray.load_usint(file)

Load a 16-bit greyscale-image.  A colour image will be converted to greyscale.

Parameters

fileA filename or an open file.

MultiArray.load_ubytergb

def MultiArray.load_ubytergb(file)

Load a colour-image.  A greyscale image will be represented with RGB values.

Parameters

fileA filename or an open file.

MultiArray.load_sfloat

def MultiArray.load_sfloat(file)

Load a single-precision floating-point greyscale-image.  A colour image will be converted to greyscale.

Parameters

fileA filename or an open file.

MultiArray.load_dfloat

def MultiArray.load_dfloat(file)

Load a double-precision floating-point greyscale-image.  A colour image will be converted to greyscale.

Parameters

fileA filename or an open file.

MultiArray.load_sfloatrgb

def MultiArray.load_sfloatrgb(file)

Load a single-precision floating-point colour-image.  A greyscale image will be represented with RGB values.

Parameters

fileA filename or an open file.

MultiArray.load_dfloatrgb

def MultiArray.load_dfloatrgb(file)

Load a double-precisino floating-point colour-image.  A greyscale image will be represented with RGB values.

Parameters

fileA filename or an open file.

MultiArray.load

def MultiArray.load(file)

Load image using RMagick.  It is recommended to use one of the load_* methods instead.

See also

  • <loadf>

MultiArray.loadf

def MultiArray.loadf(file)

Load image using OpenEXR.  It is recommended to use one of the load_* methods instead.

See also

  • <load>

MultiArray.tensor

def MultiArray.tensor(n)

Computes a tensor product for an n-dimensional result.  This method expects a code block as argument.  The code block is interpreted using special objects as arguments.  Therefore only certain operations are possible.  The implementation is inspired by Walter Landry’s FTensor library.  The following example shows a matrix multiplication as an example

v = MultiArray.sint( 2, 3 ).indgen!
w = MultiArray.sint( 3, 2 ).indgen!
r = MultiArray.tensor( 2 ) { |i,j,k| v[k,j] * w[i,k] }

Parameters

nthe number of indices the result will have

See also

This class provides fast (multi-dimensional) Ruby arrays where all elements are of the same type.
def MultiArray.import(type,
data,
*shape)
Create a multi-dimensional array from raw data.
def MultiArray.load_raw(file)
Construct from file created with Sequence_.save_raw.
def save_raw(file)
Write meta-information and raw data to file.
def MultiArray.new(element_type,
*shape)
Construct new multi-dimensional array with elements of same type.
def MultiArray.object(*shape)
Shortcut for MultiArray.new( OBJECT, *shape )
def MultiArray.bool(*shape)
Shortcut for MultiArray.new( BOOL, *shape )
def MultiArray.ubyte(*shape)
Shortcut for MultiArray.new( UBYTE, *shape )
def MultiArray.byte(*shape)
Shortcut for MultiArray.new( BYTE, *shape )
def MultiArray.usint(*shape)
Shortcut for MultiArray.new( USINT, *shape )
def MultiArray.sint(*shape)
Shortcut for MultiArray.new( SINT, *shape )
def MultiArray.uint(*shape)
Shortcut for MultiArray.new( UINT, *shape )
def MultiArray.int(*shape)
Shortcut for MultiArray.new( INT, *shape )
def MultiArray.ulong(*shape)
Shortcut for MultiArray.new( ULONG, *shape )
def MultiArray.long(*shape)
Shortcut for MultiArray.new( LONG, *shape )
def MultiArray.dfloat(*shape)
Shortcut for MultiArray.new( DFLOAT, *shape )
def MultiArray.sfloat(*shape)
Shortcut for MultiArray.new( SFLOAT, *shape )
def MultiArray.dcomplex(*shape)
Shortcut for MultiArray.new( DCOMPLEX, *shape )
def MultiArray.scomplex(*shape)
Shortcut for MultiArray.new( SCOMPLEX, *shape )
def MultiArray.ubytergb(*shape)
Shortcut for MultiArray.new( UBYTERGB, *shape )
def MultiArray.bytergb(*shape)
Shortcut for MultiArray.new( BYTERGB, *shape )
def MultiArray.usintrgb(*shape)
Shortcut for MultiArray.new( USINTRGB, *shape )
def MultiArray.sintrgb(*shape)
Shortcut for MultiArray.new( SINTRGB, *shape )
def MultiArray.uintrgb(*shape)
Shortcut for MultiArray.new( UINTRGB, *shape )
def MultiArray.intrgb(*shape)
Shortcut for MultiArray.new( INTRGB, *shape )
def MultiArray.ulongrgb(*shape)
Shortcut for MultiArray.new( ULONGRGB, *shape )
def MultiArray.longrgb(*shape)
Shortcut for MultiArray.new( LONGRGB, *shape )
def MultiArray.dfloatrgb(*shape)
Shortcut for MultiArray.new( DFLOATRGB, *shape )
def MultiArray.sfloatrgb(*shape)
Shortcut for MultiArray.new( SFLOATRGB, *shape )
def MultiArray.laplacian_of_gaussian(sigma,
size)
Compute Laplacian of gaussian filter.
def MultiArray.load_ubyte(file)
Load a 8-bit greyscale-image.
def MultiArray.load_usint(file)
Load a 16-bit greyscale-image.
def MultiArray.load_ubytergb(file)
Load a colour-image.
def MultiArray.load_sfloat(file)
Load a single-precision floating-point greyscale-image.
def MultiArray.load_dfloat(file)
Load a double-precision floating-point greyscale-image.
def MultiArray.load_sfloatrgb(file)
Load a single-precision floating-point colour-image.
def MultiArray.load_dfloatrgb(file)
Load a double-precisino floating-point colour-image.
def MultiArray.load(file)
Load image using RMagick.
def MultiArray.loadf(file)
Load image using OpenEXR.
def MultiArray.tensor(n)
Computes a tensor product for an n-dimensional result.
def Sequence(element_type,  
num_elements,  
stride =  element_type.size)
Create an array class.
The LoG-filter creates an image with zero-crossings at edge locations.
Close