Image utilities
Kano provides some image-related functions:
show_image
: show image from a file path or a numpy array.download_image
: download an image from the internet.get_randow_image
: download an image with desired size.rotate_image
: rotate an image around its center.concatenate_images
: concatenate a 2-dimensional list of images.
kano.image.show_image(image, figsize=(10, 10))
Show image from a numpy array or a file path. Which can be used when run .py or .ipynb files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
Union[ndarray, str]
|
a numpy array or a file path |
required |
figsize |
Tuple[int, int]
|
(width, height) for image to show |
(10, 10)
|
Source code in kano\image\utils.py
kano.image.download_image(url, save_path=None)
Download image from given url
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
url of the image |
required |
save_path |
str
|
path to save image |
None
|
Returns:
Name | Type | Description |
---|---|---|
image |
Union[ndarray, NoneType]
|
return numpy array of the image if it's downloaded successfullly. Otherwise return None |
Source code in kano\image\utils.py
kano.image.get_random_image(width=400, height=300, save_path=None)
Download a random image with desired size.
kano.image.rotate_image(image, degree, expand=False)
Rotate the given image with given degree
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
ndarray
|
numpy array of the image |
required |
degree |
float
|
total degrees to rotate |
required |
expand |
bool
|
Pad rotated image with black color if True, otherwise return the cropped rotated image |
False
|
Returns:
Name | Type | Description |
---|---|---|
rotated_image |
ndarray
|
numpy array of the rotated image |
Source code in kano\image\process.py
kano.image.concatenate_images(image_list, padding_size=0)
Concatenate images based on its appearance order in the given 2D list Each image will be padded to the max height, max width in the given list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_list |
list(list(np.ndarray
|
2D (or 1D) list of images |
required |
padding_size |
int
|
padding distance between each image |
0
|
Returns:
Name | Type | Description |
---|---|---|
concatenated_image |
ndarray
|
the concatenated image from 2D list |