-
Notifications
You must be signed in to change notification settings - Fork 11
Image
icbicket edited this page May 30, 2017
·
5 revisions
An image is a 2D dataset (two spatial dimensions), assumed to by a grayscale image. Colourmaps may be applied when plotting.
Image(Img, calibration=0)
Required:
- Img: a 2D numpy array
Optional:
- calibration: calibration of the spatial dimensions (in meter/pixel). Used for plotting the image with a scalebar. Default is 0; a calibration value of 0 means no calibration is set and no scalebar can be displayed.
A function to pad the sides of the image with NaN, for certain image processing functions.
PadImg(pad)
Required
- pad: the number of pixels to pad around each edge, (2x2 numpy array or 2x2 tuple) in the format: ((axis0_before, axis0_after), (axis1_before, axis1_after))
A function to save the image to a png file with pixel values from 0 to 255 (grayscale). Can also handle colourmaps (eg matplotlib colourmaps) applied to grayscale images through indexing the images. Can handle alpha values in the applied colourmap.
Required:
- filename: the filename to which the image should be saved. Can include the filepath to a folder
- clim: the colour limits of the image to be written; this argument allows changing of the contrast limits of the image before saving, otherwise the user can input the Imglim attribute of the Image object.
Optional:
- cmap: the colourmap to be applied, should be a matplotlib colormap object. Default is None, in which case the image will be saved in grayscale.
Import Image class, set scalebar to 10nm per pixel, initialize Image class.
import Image
scale = 1e-8
Im = Image.Image(data, calibration=scale)