Image Dimensions
- tomni.img_dim.img_dim(arr, showChannels=False)[source]
Get the dimensions and optionally the number of color channels of a numpy array representing an image.
- Parameters
arr (numpy.ndarray) – The image represented as a numpy array.
showChannels (bool, optional) – Whether to include the number of color channels in the output. True to show channels, False to hide them. Defaults to False.
- Returns
- A tuple containing the dimensions of the image (width, height) or (width, height, channels)
depending on the value of showChannels.
- Return type
tuple
Example:
import numpy as np image = np.zeros((100, 200, 3), dtype=np.uint8) dimensions = img_dim(image) print(dimensions) # Output: (200, 100) dimensions_with_channels = img_dim(image, showChannels=True) print(dimensions_with_channels) # Output: (200, 100, 3)