taichi.tools.image
¶
Module Contents¶
Functions¶
|
Takes a NumPy array or Taichi field of any type. |
|
Try to display image in interactive shell. |
|
Resize an image to a specific size. |
|
Save a field to a a specific file. |
|
Load image from a specific file. |
|
Show image in a Taichi GUI. |
- taichi.tools.image.cook_image_to_bytes(img)¶
Takes a NumPy array or Taichi field of any type. Returns a NumPy array of uint8. This is used by ti.imwrite and ti.imdisplay.
- taichi.tools.image.imdisplay(img)¶
Try to display image in interactive shell.
- Parameters
img (Union[ti.field, np.ndarray]) – A field of of array with shape (width, height) or (height, width, 3) or (height, width, 4).
- taichi.tools.image.imresize(img, w, h=None)¶
Resize an image to a specific size.
- Parameters
img (Union[ti.field, np.ndarray]) – A field of of array with shape (width, height, …)
w (int) – The output width after resize.
h (int, optional) – The output height after resize, will be the same as width if not set. Default to None.
- Returns
An output image after resize input.
- Return type
np.ndarray
- taichi.tools.image.imwrite(img, filename)¶
Save a field to a a specific file.
- Parameters
img (Union[ti.field, np.ndarray]) – A field of shape (height, width) or (height, width, 3) or (height, width, 4), if dtype is float-type (ti.f16, ti.f32, np.float32 etc), the value of each pixel should be float between [0.0, 1.0]. Otherwise ti.imwrite will first clip them into [0.0, 1.0] if dtype is int-type (ti.u8, ti.u16, np.uint8 etc), , the value of each pixel can be any valid integer in its own bounds. These integers in this field will be scaled to [0, 255] by being divided over the upper bound of its basic type accordingly.
filename (str) – The filename to save to.
- taichi.tools.image.imread(filename, channels=0)¶
Load image from a specific file.
- Parameters
filename (str) – An image filename to load from.
channels (int, optinal) – The channels hint of input image, Default to 0.
- Returns
An output image loaded from given filename.
- Return type
np.ndarray
- taichi.tools.image.imshow(img, window_name='imshow')¶
Show image in a Taichi GUI.
- Parameters
img (Union[ti.field, np.ndarray]) – A field of of array with shape (width, height) or (height, width, 3) or (height, width, 4).
window_name (str, optional) – The title of GUI window. Default to imshow.