ImageStackMixin

class Stoner.Image.stack.ImageStackMixin(*args, **kargs)[source]

Bases: object

Implement an interface for a baseFolder to store images in a 3D numpy array for faster access.

Attributes Summary

imarray

Produce the 3D stack of images - as [image,x,y].

max_size

Get the biggest image dimensions in the stack.

shape

Return the stack shape - after re-ordering the indices.

Methods Summary

asfloat([normalise, clip, clip_negative])

Convert stack to floating point type.

convert(dtype[, force_copy, uniform, normalise])

Convert an image to the requested data-type.

correct_drifts(refindex[, threshold, ...])

Align images to correct for image drift.

crop_stack(box)

Crop the imagestack to a box.

dtype_limits([clip_negative])

Return intensity limits, i.e. (min, max) tuple, of imarray dtype.

show()

Pass through to Stoner.Image.ImageFolder.view().

Attributes Documentation

imarray

Produce the 3D stack of images - as [image,x,y].

max_size

Get the biggest image dimensions in the stack.

shape

Return the stack shape - after re-ordering the indices.

Methods Documentation

asfloat(normalise=True, clip=False, clip_negative=False, **kargs)[source]

Convert stack to floating point type.

Keyword Arguments:
  • normalise (bool) – normalise the image to the max value of current int type

  • clip (bool) – clip resulting range to values between -1 and 1

  • clip_negative (bool) – clip range further to 0,1

Notes

Analogous behaviour to ImageFile.asfloat()

If currently an int type and normalise then floats will be normalised to the maximum allowed value of the int type. If currently a float type then no change occurs. If clip_negative then clip values outside the range 0,1

convert(dtype, force_copy=False, uniform=False, normalise=True)[source]

Convert an image to the requested data-type.

Warnings are issued in case of precision loss, or when negative values are clipped during conversion to unsigned integer types (sign loss).

Floating point values are expected to be normalized and will be clipped to the range [0.0, 1.0] or [-1.0, 1.0] when converting to unsigned or signed integers respectively.

Numbers are not shifted to the negative side when converting from unsigned to signed integer types. Negative values will be clipped when converting to unsigned integers.

Parameters:
  • image (ndarray) – Input image.

  • dtype (dtype) – Target data-type.

  • force_copy (bool) – Force a copy of the data, irrespective of its current dtype.

  • uniform (bool) – Uniformly quantize the floating point range to the integer range. By default (uniform=False) floating point values are scaled and rounded to the nearest integers, which minimizes back and forth conversion errors.

  • normalise (bool) – When converting from int types to float normalise the resulting array by the maximum allowed value of the int type.

References

  1. DirectX data conversion rules. http://msdn.microsoft.com/en-us/library/windows/desktop/dd607323%28v=vs.85%29.aspx

2, Data Conversions.

In “OpenGL ES 2.0 Specification v2.0.25”, pp 7-8. Khronos Group, 2010.

3, Proper treatment of pixels as integers. A.W. Path.

In “Graphics Gems I”, pp 249-256. Morgan Kaufmann, 1990.

4, Dirty Pixels. J. Blinn.

In “Jim Blinn’s corner: Dirty Pixels”, pp 47-57. Morgan Kaufmann, 1998.

correct_drifts(refindex, threshold=0.005, upsample_factor=50, box=None)[source]

Align images to correct for image drift.

Pass through to ImageArray.corret_drift.

Arg:
refindex: int or str

index or name of the reference image to use for zero drift

Keyword Arguments:
  • threshold (float) – see ImageArray.correct_drift

  • upsample_factor (int) – see ImageArray.correct_drift

  • box – see ImageArray.correct_drift

crop_stack(box)[source]

Crop the imagestack to a box.

Parameters:

box (array or list of type int) – [xmin,xmax,ymin,ymax]

Returns:

(ImageStack) – cropped images

dtype_limits(clip_negative=True)[source]

Return intensity limits, i.e. (min, max) tuple, of imarray dtype.

Keyword Arguments:

clip_negative (bool) – If True, clip the negative range (i.e. return 0 for min intensity) even if the image dtype allows negative values.

Returns:

(imin,imax) (tuple) – Lower and upper intensity limits.

show()[source]

Pass through to Stoner.Image.ImageFolder.view().