Stoner.Image.ImageFile

class Stoner.Image.ImageFile(*args)[source]

An Image file type that is analagous to Stoner.Data.

This contains metadata and an image attribute which is an Stoner.Image.ImageArray type which subclasses numpy ndarray and adds lots of extra image specific processing functions.

image

A numpy.ndarray subclass that stores the actual image data.

Type

Stoner.Image.ImageArray

metadata

A dictionary of metadata items associated with this image.

Type

Stoner.core.regexpDict

filename

The name of the file from which this image was laoded.

Type

str

title

The title of the image (defaults to the filename).

Type

str

mask

A special object that allows manipulation of the image’s mask - thius allows the user to selectively disable regions of the image from rpocessing functions.

Type

Stoner.Image.attrs.MaskProxy

draw

A sepcial object that allows the user to manipulate the image data by making use of skimage.draw functions as well as some additional drawing functions.

Type

Stoner.Image.attrs.DrawProxy

clone

Return a duplicate copy of the current image - this allows subsequent methods to modify the cloned version rather than the original version.

Type

Stoner.ImageFile

centre

The coordinates of the centre of the image.

Type

tuple of (int,int)

aspect

The aspect ratio (width/height) of the image.

Type

float

max_box

The extent of the iamge size in a form suitable for use in defining a box.

Type

tuple (0,x-size,0-y-size)

flip_h

Clone the current image and then flip it horizontally (left-right).

Type

ImageFile

flip_v

Clone the current image and then flip it vertically (top-bottom).

Type

ImageFile

CW

Clone the current image and then rotate it 90 degrees clockwise.

Type

ImageFile

CCW

Clone the current image and then rotate it 90 degrees counter-clockwise.

Type

ImageFile

T

Transpose the current image

Type

ImageFile

shape

Return the current shape of the image (rows, columns)

Type

tuple (int,int)

dtype

The current dtype of the elements of the image data.

Type

numpy.dtype

The ImageFile owned attribute is image. All other calls including metadata are passed through to ImageArray (so no need to inherit from metadataObject).

Almost all calls to ImageFile are passed through to the underlying ImageArray logic and ImageArray can be used as a standalone class. However because ImageArray subclasses an ndarray it is not possible to enter it in place. All attributes return an array instance which needs to be reassigned. ImageFile owns image and so can change in place. The penalty is that numpy ufuncs don’t return ImageFile type

so can do:

imfile.asfloat() #imagefile.image is updated to float type however need to do:
imfile.image = np.abs(imfile.image)

whereas for imarray need to do:

imarray = imagearray.asfloat()

but:

np.abs(imarray) #returns ImageArray type

Methods

Stoner__Image__imagefuncs__adjust_contrast([...])

Rescale the intensity of the image.

Stoner__Image__imagefuncs__align(ref[, method])

Use one of a variety of algroithms to align two images.

Stoner__Image__imagefuncs__asarray()

Provide a consistent way to get at the underlying array data in both ImageArray and ImageFile objects.

Stoner__Image__imagefuncs__asfloat([...])

Return the image converted to floating point type.

Stoner__Image__imagefuncs__asint([dtype])

Convert the image to unsigned integer format.

Stoner__Image__imagefuncs__clip_intensity([...])

Clip intensity outside the range -1,1 or 0,1.

Stoner__Image__imagefuncs__clip_neg()

Clip negative pixels to 0.

Stoner__Image__imagefuncs__convert(dtype[, ...])

Convert an image to the requested data-type.

Stoner__Image__imagefuncs__correct_drift(...)

Align images to correct for image drift.

Stoner__Image__imagefuncs__crop(*args, **kargs)

Crop the image according to a box.

Stoner__Image__imagefuncs__denoise([weight])

Rename the skimage restore function.

Stoner__Image__imagefuncs__do_nothing()

Nulop function for testing the integration into ImageArray.

Stoner__Image__imagefuncs__dtype_limits([...])

Return intensity limits, i.e. (min, max) tuple, of the image's dtype.

Stoner__Image__imagefuncs__fft([shift, ...])

Perform a 2d fft of the image and shift the result to get zero frequency in the centre.

Stoner__Image__imagefuncs__filter_image([sigma])

Alias for skimage.filters.gaussian.

Stoner__Image__imagefuncs__gridimage([...])

Use scipy.interpolate.griddata() to shift the image to a regular grid of co-ordinates.

Stoner__Image__imagefuncs__hist(*args, **kargs)

Pass through to matplotlib.pyplot.hist() function.

Stoner__Image__imagefuncs__imshow(**kwargs)

Quickly plot of image.

Stoner__Image__imagefuncs__level_image([...])

Subtract a polynomial background from image.

Stoner__Image__imagefuncs__normalise([...])

Norm alise the data to a fixed scale.

Stoner__Image__imagefuncs__plot_histogram([bins])

Plot the histogram and cumulative distribution for the image.

Stoner__Image__imagefuncs__profile_line([...])

Wrap sckit-image method of the same name to get a line_profile.

Stoner__Image__imagefuncs__quantize(output)

Quantise the image data into fixed levels given by a mapping.

Stoner__Image__imagefuncs__radial_coordinates([...])

Rerurn a map of the radial co-ordinates of an image from a given centre, with adjustments for pixel size.

Stoner__Image__imagefuncs__radial_profile([...])

Extract a radial profile line from an image.

Stoner__Image__imagefuncs__remove_outliers([...])

Find values of the data that are beyond a percentile of the overall distribution and replace them.

Stoner__Image__imagefuncs__rotate(angle[, ...])

Rotate image by a certain angle around its center.

Stoner__Image__imagefuncs__save([filename])

Save the image into the file 'filename'.

Stoner__Image__imagefuncs__save_npy(filename)

Save the ImageArray as a numpy array.

Stoner__Image__imagefuncs__save_png(filename)

Save the ImageArray with metadata in a png file.

Stoner__Image__imagefuncs__save_tiff(filename)

Save the ImageArray as a tiff image with metadata.

Stoner__Image__imagefuncs__sgolay2d([...])

Implements a 2D Savitsky Golay Filter for a 2D array (e.g.

Stoner__Image__imagefuncs__span()

Return the minimum and maximum values in the image.

Stoner__Image__imagefuncs__subtract_image(...)

Subtract a background image from the ImageArray.

Stoner__Image__imagefuncs__threshold_minmax([...])

Return a boolean array which is thresholded between threshmin and threshmax.

Stoner__Image__imagefuncs__translate(translation)

Translate the image.

Stoner__Image__imagefuncs__translate_limits(...)

Find the limits of an image after a translation.

Stoner__Image__util__im_scale(n, m, ...[, copy])

Scaleunsigned/positive integers from n to m bits.

Stoner__Image__util__prec_loss(dtypeobj)

Warn over precision loss when converting image.

Stoner__Image__util__sign_loss(dtypeobj)

Warn over loss of sign information when converting image.

Stoner__compat__get_filedialog(**opts)

Wrap around Tk file dialog to mange creating file dialogs in a cross platform way.

Stoner__plot__utils__auto_fit_fontsize(...)

Resale the font size of a matplotlib text object to fit within a box.

Stoner__tools__decorators__changes_size()

Mark a function as one that changes the size of the ImageArray.

Stoner__tools__decorators__keep_return_type()

Mark a function as one that Should not be converted from an array to an ImageFile.

Stoner__tools__decorators__make_Data(**kargs)

Return an instance of Stoner.Data passig through constructor arguments.

Stoner__tools__null__null(**kargs)

A null function to be documented.

Stoner__tools__tests__isTuple(*args[, strict])

Determine if obj is a tuple of a certain signature.

Stoner__tools__tests__isiterable()

Chack to see if a value is iterable.

__init__(*args, **kargs)

Mostly a pass through to ImageArray constructor.

adjust_contrast([lims, percent])

Rescale the intensity of the image.

align(ref[, method])

Use one of a variety of algroithms to align two images.

all([axis, out, keepdims])

Returns True if all elements evaluate to True.

anom([axis, dtype])

Compute the anomalies (deviations from the arithmetic mean) along the given axis.

any([axis, out, keepdims])

Returns True if any of the elements of a evaluate to True.

argmax([axis, fill_value, out])

Returns array of indices of the maximum values along the given axis.

argmin([axis, fill_value, out])

Return array of indices to the minimum values along the given axis.

argpartition(*args, **kwargs)

argsort([axis, kind, order, endwith, fill_value])

Return an ndarray of indices that sort the array along the specified axis.

asarray()

Provide a consistent way to get at the underlying array data in both ImageArray and ImageFile objects.

asfloat([normalise, clip, clip_negative])

Return the image converted to floating point type.

asint([dtype])

Convert the image to unsigned integer format.

astype(dtype[, order, casting, subok, copy])

Copy of the array, cast to a specified type.

auto_fit_fontsize(width, height[, ...])

Resale the font size of a matplotlib text object to fit within a box.

byteswap([inplace])

Swap the bytes of the array elements

changes_size()

Mark a function as one that changes the size of the ImageArray.

choose(choices[, out, mode])

Use an index array to construct a new array from a set of choices.

clear()

clip([min, max, out])

Return an array whose values are limited to [min, max].

clip_intensity([clip_negative, limits])

Clip intensity outside the range -1,1 or 0,1.

clip_neg()

Clip negative pixels to 0.

compress(condition[, axis, out])

Return a where condition is True.

compressed()

Return all the non-masked data as a 1-D array.

conj()

Complex-conjugate all elements.

conjugate()

Return the complex conjugate, element-wise.

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

Convert an image to the requested data-type.

copy([order])

Return a copy of the array.

correct_drift(ref, **kargs)

Align images to correct for image drift.

count([axis, keepdims])

Count the non-masked elements of the array along the given axis.

crop(*args, **kargs)

Crop the image according to a box.

cumprod([axis, dtype, out])

Return the cumulative product of the array elements over the given axis.

cumsum([axis, dtype, out])

Return the cumulative sum of the array elements over the given axis.

denoise([weight])

Rename the skimage restore function.

diagonal([offset, axis1, axis2])

Return specified diagonals.

do_nothing()

Nulop function for testing the integration into ImageArray.

dot(b[, out])

Masked dot product of two arrays.

dtype_limits([clip_negative])

Return intensity limits, i.e. (min, max) tuple, of the image's dtype.

dump(file)

Dump a pickle of the array to the specified file.

dumps()

Returns the pickle of the array as a string.

fft([shift, phase, remove_dc, gaussian, window])

Perform a 2d fft of the image and shift the result to get zero frequency in the centre.

fill(value)

Fill the array with a scalar value.

filled([fill_value])

Return a copy of self, with masked values filled with a given value.

filter_image([sigma])

Alias for skimage.filters.gaussian.

flatten([order])

Return a copy of the array collapsed into one dimension.

gaussian_filter(sigma[, order, output, ...])

Multidimensional Gaussian filter.

get(k[,d])

get_filedialog(**opts)

Wrap around Tk file dialog to mange creating file dialogs in a cross platform way.

get_filename(mode)

Force the user to choose a new filename using a system dialog box.

get_fill_value()

The filling value of the masked array is a scalar.

get_imag()

The imaginary part of the masked array.

get_real()

The real part of the masked array.

getfield(dtype[, offset])

Returns a field of the given array as a certain type.

griddata(values, xi[, method, fill_value, ...])

Interpolate unstructured D-D data.

gridimage([points, xi, method, fill_value, ...])

Use scipy.interpolate.griddata() to shift the image to a regular grid of co-ordinates.

harden_mask()

Force the mask to hard.

hist(*args, **kargs)

Pass through to matplotlib.pyplot.hist() function.

ids()

Return the addresses of the data and mask areas.

im_scale(n, m, dtypeobj_in, dtypeobj[, copy])

Scaleunsigned/positive integers from n to m bits.

imshow(**kwargs)

Quickly plot of image.

isTuple(*args[, strict])

Determine if obj is a tuple of a certain signature.

iscontiguous()

Return a boolean indicating whether the data is contiguous.

isiterable()

Chack to see if a value is iterable.

item(*args)

Copy an element of an array to a standard Python scalar and return it.

items()

Make sure we implement an items that doesn't just iterate over self.

itemset(*args)

Insert scalar into an array (scalar is cast to array's dtype, if possible)

keep_return_type()

Mark a function as one that Should not be converted from an array to an ImageFile.

keys()

Return the keys of the metadata dictionary.

level_image([poly_vert, poly_horiz, box, ...])

Subtract a polynomial background from image.

load(*args, **kargs)

Create a ImageFile from file abnd guessing a better subclass if necessary.

make_Data(**kargs)

Return an instance of Stoner.Data passig through constructor arguments.

max([axis, out, fill_value, keepdims])

Return the maximum along a given axis.

mean([axis, dtype, out, keepdims])

Returns the average of the array elements along given axis.

min([axis, out, fill_value, keepdims])

Return the minimum along a given axis.

mini([axis])

Return the array minimum along the specified axis.

newbyteorder([new_order])

Return the array with the same data viewed with a different byte order.

nonzero()

Return the indices of unmasked elements that are not zero.

normalise([scale, sample, limits, scale_masked])

Norm alise the data to a fixed scale.

null(**kargs)

A null function to be documented.

partition(*args, **kwargs)

plot_histogram([bins])

Plot the histogram and cumulative distribution for the image.

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

prec_loss(dtypeobj)

Warn over precision loss when converting image.

prod([axis, dtype, out, keepdims])

Return the product of the array elements over the given axis.

product([axis, dtype, out, keepdims])

Return the product of the array elements over the given axis.

profile_line([src, dst, linewidth, order, ...])

Wrap sckit-image method of the same name to get a line_profile.

ptp([axis, out, fill_value, keepdims])

Return (maximum - minimum) along the given dimension (i.e.

put(indices, values[, mode])

Set storage-indexed locations to corresponding values.

quantize(output[, levels])

Quantise the image data into fixed levels given by a mapping.

radial_coordinates([centre, pixel_size, angle])

Rerurn a map of the radial co-ordinates of an image from a given centre, with adjustments for pixel size.

radial_profile([angle, r, centre, pixel_size])

Extract a radial profile line from an image.

ravel([order])

Returns a 1D version of self, as a view.

remove_outliers([percentiles, replace])

Find values of the data that are beyond a percentile of the overall distribution and replace them.

repeat(repeats[, axis])

Repeat elements of an array.

reshape(*s, **kwargs)

Give a new shape to the array without changing its data.

resize(newshape[, refcheck, order])

rotate(angle[, resize, center, order, mode, ...])

Rotate image by a certain angle around its center.

round([decimals, out])

Return each element rounded to the given number of decimals.

save([filename])

Save the image into the file 'filename'.

save_npy(filename)

Save the ImageArray as a numpy array.

save_png(filename)

Save the ImageArray with metadata in a png file.

save_tiff(filename[, forcetype])

Save the ImageArray as a tiff image with metadata.

scipy__interpolate__ndgriddata__griddata(...)

Interpolate unstructured D-D data.

scipy__ndimage__filters__gaussian_filter(sigma)

Multidimensional Gaussian filter.

searchsorted(v[, side, sorter])

Find indices where elements of v should be inserted in a to maintain order.

set_fill_value([value])

setdefault(k[,d])

setfield(val, dtype[, offset])

Put a value into a specified place in a field defined by a data-type.

setflags([write, align, uic])

Set array flags WRITEABLE, ALIGNED, (WRITEBACKIFCOPY and UPDATEIFCOPY), respectively.

sgolay2d([points, poly, derivative])

Implements a 2D Savitsky Golay Filter for a 2D array (e.g.

shrink_mask()

Reduce a mask to nomask when possible.

sign_loss(dtypeobj)

Warn over loss of sign information when converting image.

soften_mask()

Force the mask to soft.

sort([axis, kind, order, endwith, fill_value])

Sort the array, in-place

span()

Return the minimum and maximum values in the image.

squeeze([axis])

Remove axes of length one from a.

std([axis, dtype, out, ddof, keepdims])

Returns the standard deviation of the array elements along given axis.

subtract_image(background[, contrast, clip, ...])

Subtract a background image from the ImageArray.

sum([axis, dtype, out, keepdims])

Return the sum of the array elements over the given axis.

swapaxes(axis1, axis2)

Return a view of the array with axis1 and axis2 interchanged.

take(indices[, axis, out, mode])

threshold_minmax([threshmin, threshmax])

Return a boolean array which is thresholded between threshmin and threshmax.

tobytes([fill_value, order])

Return the array data as a string containing the raw bytes in the array.

tofile(fid[, sep, format])

Save a masked array to a file in binary format.

toflex()

Transforms a masked array into a flexible-type array.

tolist([fill_value])

Return the data portion of the masked array as a hierarchical Python list.

torecords()

Transforms a masked array into a flexible-type array.

tostring([fill_value, order])

A compatibility alias for tobytes, with exactly the same behavior.

trace([offset, axis1, axis2, dtype, out])

Return the sum along diagonals of the array.

translate(translation[, add_metadata, ...])

Translate the image.

translate_limits(translation[, reverse])

Find the limits of an image after a translation.

transpose(*axes)

Returns a view of the array with axes transposed.

unshare_mask()

Copy the mask and set the sharedmask flag to False.

update([E, ]**F)

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values()

Return the values of the metadata dictionary.

var([axis, dtype, out, ddof, keepdims])

Compute the variance along the specified axis.

view([dtype, type, fill_value])

Return a view of the MaskedArray data.

Attributes

CCW

Clone the image and then rotate the imaage 90 degrees counter clockwise.

CW

Clone the image and then rotate the imaage 90 degrees clockwise.

LineSelect

Stoner__Image__widgets__LineSelect

Stoner__core__base__metadataObject

T

aspect

Return the aspect ratio (width/height) of the image.

base

Pass thrpough for base

baseclass

Class of the underlying data (read-only).

centre

Return the coordinates of the centre of the image.

clone

Make a copy of this ImageFile.

ctypes

Pass thrpough for ctypes

data

].

debug

Pass thrpough for debug

draw

Access the DrawProxy opbject for accessing the skimage draw sub module.

dtype

filename

Pass thrpough for filename

fill_value

The filling value of the masked array is a scalar.

flags

Pass thrpough for flags

flat

Return the numpy.ndarray.flat rather than a MaskedIterator.

flip_h

Clone the image and then mirror the image horizontally.

flip_v

Clone the image and then mirror the image vertically.

fmts

Pass thrpough for fmts

hardmask

Hardness of the mask

imag

The imaginary part of the masked array.

image

Access the image data.

itemsize

Pass thrpough for itemsize

mask

Get the mask of the underlying IamgeArray.

max_box

Return the maximum coordinate extent (xmin,xmax,ymin,ymax).

metadata

Read the metadata dictionary.

metadataObject

mime_type

nbytes

Pass thrpough for nbytes

ndim

Pass thrpough for ndim

priority

real

The real part of the masked array.

recordmask

Get or set the mask of the array if it has no named fields.

shape

sharedmask

Share status of the mask (read-only).

size

Pass thrpough for size

strides

Pass thrpough for strides

title

Get a title for this image.