hyperspy.io_plugins.image module
- hyperspy.io_plugins.image.file_reader(filename, **kwds)
Read data from any format supported by imageio (PIL/pillow). For a list of formats see https://imageio.readthedocs.io/en/stable/formats.html
- Parameters:
filename ({str, pathlib.Path, bytes, file}) – The resource to load the image from, e.g. a filename, pathlib.Path, http address or file object, see the docs for more info. The file format is defined by the file extension that is any one supported by imageio.
format (str, optional) – The format to use to read the file. By default imageio selects the appropriate for you based on the filename and its contents.
**kwds (keyword arguments) – Allows to pass keyword arguments supported by the individual file readers as documented at https://imageio.readthedocs.io/en/stable/formats.html
- hyperspy.io_plugins.image.file_writer(filename, signal, scalebar=False, scalebar_kwds=None, output_size=None, imshow_kwds=None, **kwds)
Writes data to any format supported by pillow. When
output_size
orscalebar
orimshow_kwds
is used,imshow()
is used to generate a figure.- Parameters:
filename ({str, pathlib.Path, bytes, file}) – The resource to write the image to, e.g. a filename, pathlib.Path or file object, see the docs for more info. The file format is defined by the file extension that is any one supported by imageio.
signal (a Signal instance) –
scalebar (bool, optional) – Export the image with a scalebar. Default is False.
scalebar_kwds (dict, optional) – Dictionary of keyword arguments for the scalebar. Useful to set formattiong, location, etc. of the scalebar. See the documentation of the ‘matplotlib-scalebar’ library for more information.
output_size ({tuple of length 2, int, None}, optional) –
The output size of the image in pixels (width, height):
if int, defines the width of the image, the height is determined from the aspec ratio of the image
if tuple of length 2, defines the width and height of the image. Padding with white pixels is used to maintain the aspect ratio of the image.
if None, the size of the data is used.
For output size larger than the data size, “nearest” interpolation is used by default and this behaviour can be changed through the imshow_kwds dictionary. Default is None.
imshow_kwds (dict, optional) – Keyword arguments dictionary for
imshow()
.**kwds (keyword arguments, optional) – Allows to pass keyword arguments supported by the individual file writers as documented at https://imageio.readthedocs.io/en/stable/formats.html when exporting an image without scalebar. When exporting with a scalebar, the keyword arguments are passed to the pil_kwargs dictionary of
savefig()