Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
import cv2 import numpy as np
class ColorManager: """ The Color manager is responsible for applying several color management techniques to the image passed. """ def __init__(self, color_extraction_type, channel="green", kernel_size=(13, 7)): """ Initialise Color Manager. Authors(s): Nicolai van Niekerk, Stephan Nell Args: color_extraction_type (str): Indicates the type of color extraction that should be applied. channel (str): Indicates the color channel that should be extracted. Only red, green and blue (RGB) are considered valid colors to extracts. kernel_size (integer tuple): Indicates the kernel size for operation that require modification of the kernel size, like black and white-hat modifications. Returns: None
"""
def apply(self, image): """ This performs the specified processing technique. Author(s): Nicolai van Niekerk, Stephan Nell Args: image: The image to which the technique must be applied. Raises: NameError: If invalid color extraction type is provided i.e. histogram, extract, black hat or top hat (white hat). Returns: obj:'OpenCV image': The modified image
""" else: 'Try: "histrogram", "extract", "blackhat", "topHat" or "whiteHat"')
@staticmethod def histEqualisation(image): """ This function applies histogram equalisation to the image passed. Author(s): Stephan Nell Args: image (:obj:'OpenCV image'): Image to which histogram equalisation should be applied to. Returns: obj:'OpenCV image': The Histogram equalised image. """
def extractChannel(self, image, image_channel="green"): """ This function extracts a selected color channel from an image. Author(s): Stephan Nell Args: image (:obj:'OpenCV image'): Image to which image channel should be removed. str: Color that should be removed valid color red, green, blue. Raises: NameError: If invalid colour is selected i.e. not red, green, blue Returns: obj:'OpenCV image': A copy of the image passed but with a color channel removed.
"""
else:
def blackHat(self, image, rect_kernel_size=(13, 7)): """ This function applies blackhat color changes to the image passed. Author(s): Stephan Nell Args: image (:obj:'OpenCV image'): Image to which black hat color changes should be applied to rect_kernel_size (list): Represent the kernel dimension by which blackHat morphology changes should be applied to. Raises: TypeError: If the kernel size type is not a tuple. ValueError: If the kernel size tuple contains more than 2 items. Returns: obj:'OpenCV image': A modified copy of the image where blackHat morphology was applied to an image.
"""
def topHat(self, image, rect_kernel_size=(13, 7)): """ This function applies tophat color changes to the image passed. Author(s): Stephan Nell Args: image (:obj:'OpenCV image'): Image to which top hat color changes should be applied to. rect_kernel_size (list): Represents the kernel dimension by which topHat morphology changes should be applied to. Raises: TypeError: If the kernel size type is not a tuple. ValueError: If the kernel size tuple contains more than 2 items. Returns: obj:'OpenCV image': A modified copy of the image where topHat morphology was applied to an image. """ |