Input/Output helper functions¶
Overview¶
The io module provides the following input/output helper functions:
io.imread()
: load an image (.png, .tiff,.dicom, etc.) and return its data as a NumPy array
io.imwrite()
: save an array to an image fileio.load_items()
: load plot items from HDF5io.save_items()
: save plot items to HDF5
Reference¶
- plotpy.io.imread(fname: str, ext: str | None = None, to_grayscale: bool = False) ndarray [source]¶
Read an image from a file as a NumPy array
- Parameters:
fname – image filename
ext – image file extension (if None, extension is guessed from filename)
to_grayscale – convert RGB images to grayscale
- plotpy.io.imwrite(fname: str, arr: ndarray, ext: str | None = None, dtype: dtype | None = None, max_range: bool | None = None, **kwargs) None [source]¶
Write a NumPy array to an image file
- Parameters:
fname – image filename
arr – NumPy array
ext – image file extension (if None, extension is guessed from filename)
dtype – data type (if None, data type is guessed from array)
max_range – scale data to fit dtype dynamic range
kwargs – additional keyword arguments passed to the image writer
Warning
If max_range is True, array data is modified in place
- plotpy.io.load_items(reader: guidata.io.HDF5Reader | guidata.io.INIReader | guidata.io.JSONReader) list[Any] [source]¶
Load items from HDF5, INI or JSON file
- Parameters:
reader – HDF5, INI or JSON reader
- Returns:
list of plot item instances
- plotpy.io.save_items(writer: guidata.io.HDF5Writer | guidata.io.INIWriter | guidata.io.JSONWriter, items: list[Any]) None [source]¶
Save items to HDF5, INI or JSON file
- Parameters:
writer – HDF5, INI or JSON writer
items – list of serializable plot items