def to_ndarray(t_img: Image, dtype=None) -> np.ndarray:
    """
    Convert a towhee.types.Image into ndarray.

    The mode is same as `towhee_img`, use `towhee_img.mode` to get the information.

    Args:
        t_img (`towhee.types.Image`):
            A towhee image.
        dtype:
            The type of the narray.

    Returns:
        (`np.ndarray`)
            The ndarray of the image, the mode is same as the `towhee_img`.
    """
    shape = t_img.shape
    dtype = np.uint8 if not dtype else dtype

    arr = np.ndarray(shape, dtype, t_img)

    return arr
Convert a towhee.types.Image into ndarray.

The mode is same as `towhee_img`, use `towhee_img.mode` to get the information.

Args:
t_img (`towhee.types.Image`):
A towhee image.
dtype:
The type of the narray.

Returns:
(`np.ndarray`)
The ndarray of the image, the mode is same as the `towhee_img`.
towhee/utils/ndarray_utils.py