IO
eva.vision.utils.io.image
Image I/O related functions.
read_image
Reads and loads the image from a file path as a RGB.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
The path of the image file. |
required |
Returns:
Type | Description |
---|---|
NDArray[uint8]
|
The RGB image as a numpy array (HxWxC). |
Raises:
Type | Description |
---|---|
FileExistsError
|
If the path does not exist or it is unreachable. |
IOError
|
If the image could not be loaded. |
Source code in src/eva/vision/utils/io/image.py
read_image_as_tensor
Reads and loads the image from a file path as a RGB torch tensor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
The path of the image file. |
required |
Returns:
Type | Description |
---|---|
Image
|
The RGB image as a torch tensor (CxHxW). |
Raises:
Type | Description |
---|---|
FileExistsError
|
If the path does not exist or it is unreachable. |
IOError
|
If the image could not be loaded. |
Source code in src/eva/vision/utils/io/image.py
read_image_as_array
Reads and loads an image file as a numpy array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
The path to the image file. |
required |
flags |
int
|
Specifies the way in which the image should be read. |
IMREAD_UNCHANGED
|
Returns:
Type | Description |
---|---|
NDArray[uint8]
|
The image as a numpy array. |
Raises:
Type | Description |
---|---|
FileExistsError
|
If the path does not exist or it is unreachable. |
IOError
|
If the image could not be loaded. |
Source code in src/eva/vision/utils/io/image.py
eva.vision.utils.io.nifti
NIfTI I/O related functions.
read_nifti
Reads and loads a NIfTI image from a file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
The path to the NIfTI file. |
required |
slice_index |
int | None
|
Whether to read only a slice from the file. |
None
|
use_storage_dtype |
bool
|
Whether to cast the raw image array to the inferred type. |
True
|
Returns:
Type | Description |
---|---|
NDArray[Any]
|
The image as a numpy array (height, width, channels). |
Raises:
Type | Description |
---|---|
FileExistsError
|
If the path does not exist or it is unreachable. |
ValueError
|
If the input channel is invalid for the image. |
Source code in src/eva/vision/utils/io/nifti.py
save_array_as_nifti
Saved a numpy array as a NIfTI image file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array |
ArrayLike
|
The image array to save. |
required |
filename |
str
|
The name to save the image like. |
required |
dtype |
DTypeLike | None
|
The data type to save the image. |
int64
|
Source code in src/eva/vision/utils/io/nifti.py
fetch_nifti_shape
Fetches the NIfTI image shape from a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
The path to the NIfTI file. |
required |
Returns:
Type | Description |
---|---|
Tuple[int]
|
The image shape. |
Raises:
Type | Description |
---|---|
FileExistsError
|
If the path does not exist or it is unreachable. |
ValueError
|
If the input channel is invalid for the image. |