image_modifier.select_channel
Module Contents
Functions
|
Modifies an RGB image by either isolating or removing a specified color channel. |
- image_modifier.select_channel.select_channel(image, channel, without=False)[source]
Modifies an RGB image by either isolating or removing a specified color channel.
Parameters: image (numpy.ndarray): The input image as a 3-dimensional RGB array. channel (str): The color channel to interact with. Valid options are ‘r’, ‘g’, or ‘b’ for red, green, or blue, respectively. without (bool, optional): If True, removes the specified channel from the image. Defaults to False.
Returns: numpy.ndarray: The modified image with either the specified channel isolated or removed.
Raises: ValueError: If an invalid channel is specified or the input image does not have 3 channels. TypeError: If the input image is not a NumPy array.
Example usage: modified_image_with_channel = select_channel(original_image, ‘g’, without=False) # Isolate green channel modified_image_without_channel = select_channel(original_image, ‘r’, without=True) # Remove red channel