-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add utility functions for image loading and display in sharpedg…
…e.py
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
def load_image(path): | ||
""" | ||
Load an image from a specific path | ||
and convert it to a numpy array. | ||
Parameters | ||
---------- | ||
path : str | ||
The file path to the image. | ||
Returns | ||
------- | ||
numpy.ndarray | ||
The image data as a numpy array | ||
with shape (height, width, channels). | ||
Raises | ||
------ | ||
FileNotFoundError | ||
If the file path does not exist. | ||
ValueError | ||
If the file is not a valid image format. | ||
Examples | ||
-------- | ||
>>> img = load_image('image.jpg') | ||
>>> print(img.shape) | ||
(1280, 800, 3) | ||
""" | ||
pass | ||
|
||
|
||
def display_image(img): | ||
""" | ||
Display the numpy array as an image. | ||
Parameters | ||
---------- | ||
img : numpy.ndarray | ||
The image data as a numpy array | ||
with shape (height, width, channels). | ||
Raises | ||
------ | ||
ValueError | ||
If the file is not a valid numpy array. | ||
Examples | ||
-------- | ||
>>> img = load_image('image.jpg') | ||
>>> display_image(img) | ||
""" | ||
pass |