coastalimagelib/corefunctions.py
def matchHist(ref, image):
    """

    Trying Chris Sherwood's method if using an RBG image
    Note: usually working with BW for Argus stuff so far

    Matches the histogram of an input image to a reference
    image saved in self in order to better blend seams
    of multiple cameras.

    Arguments:
        ref (ndarray): reference image
        image (ndarray): image to match histogram

    Returns:
        matched (ndarray): modified image with matching histogram

    """

    if (len(image.shape) > 2) & (image.shape[2] > 1):
        # Convert to hsv space
        im_hsv = cv.cvtColor(image, cv.COLOR_RGB2HSV)
        ref_hsv = cv.cvtColor(ref, cv.COLOR_RGB2HSV)

        # Match histogram to reference hist on only v channel
        matched_v = match_histograms(
            im_hsv[:, :, 2], ref_hsv[:, :, 2], multichannel=False
        )

        # Paste matched values channel into HSV version of source image
        # Then, convert back to RGB
        matched_hsv = im_hsv.copy()
        matched_hsv[:, :, 2] = matched_v
        matched = cv.cvtColor(matched_hsv, cv.COLOR_HSV2RGB)
    else:
        if (len(ref.shape) > 2) & (ref.shape[2] > 1):
            ref = cv.cvtColor(image, cv.COLOR_BGR2GRAY)

        matched = match_histograms(image, ref, multichannel=False)
    return matched


    Trying Chris Sherwood's method if using an RBG image
    Note: usually working with BW for Argus stuff so far

    Matches the histogram of an input image to a reference
    image saved in self in order to better blend seams
    of multiple cameras.

    Arguments:
        ref (ndarray): reference image
        image (ndarray): image to match histogram

    Returns:
        matched (ndarray): modified image with matching histogram

    
Trying Chris Sherwood's method if using an RBG image
Note: usually working with BW for Argus stuff so far

Matches the histogram of an input image to a reference
image saved in self in order to better blend seams
of multiple cameras.
Trying Chris Sherwood ' s method if using an RBG image Note : usually working with BW for Argus stuff so far Matches the histogram of an input image to a reference image saved in self in order to better blend seams of multiple cameras .
def matchHist(ref, image):
    if (len(image.shape) > 2) & (image.shape[2] > 1):
        im_hsv = cv.cvtColor(image, cv.COLOR_RGB2HSV)
        ref_hsv = cv.cvtColor(ref, cv.COLOR_RGB2HSV)
        matched_v = match_histograms(
            im_hsv[:, :, 2], ref_hsv[:, :, 2], multichannel=False
        )
        matched_hsv = im_hsv.copy()
        matched_hsv[:, :, 2] = matched_v
        matched = cv.cvtColor(matched_hsv, cv.COLOR_HSV2RGB)
    else:
        if (len(ref.shape) > 2) & (ref.shape[2] > 1):
            ref = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
        matched = match_histograms(image, ref, multichannel=False)
    return matched
def matchHist ( ref , image ) : if ( len ( image . shape ) > 2 ) & ( image . shape [ 2 ] > 1 ) : im_hsv = cv . cvtColor ( image , cv . COLOR_RGB2HSV ) ref_hsv = cv . cvtColor ( ref , cv . COLOR_RGB2HSV ) matched_v = match_histograms ( im_hsv [ : , : , 2 ] , ref_hsv [ : , : , 2 ] , multichannel = False ) matched_hsv = im_hsv . copy ( ) matched_hsv [ : , : , 2 ] = matched_v matched = cv . cvtColor ( matched_hsv , cv . COLOR_HSV2RGB ) else : if ( len ( ref . shape ) > 2 ) & ( ref . shape [ 2 ] > 1 ) : ref = cv . cvtColor ( image , cv . COLOR_BGR2GRAY ) matched = match_histograms ( image , ref , multichannel = False ) return matched
Trying Chris Sherwood's method if using an RBG image
Note: usually working with BW for Argus stuff so far
Trying Chris Sherwood ' s method if using an RBG image Note : usually working with BW for Argus stuff so far
"""

    Trying Chris Sherwood's method if using an RBG image
    Note: usually working with BW for Argus stuff so far

    Matches the histogram of an input image to a reference
    image saved in self in order to better blend seams
    of multiple cameras.

    Arguments:
        ref (ndarray): reference image
        image (ndarray): image to match histogram

    Returns:
        matched (ndarray): modified image with matching histogram

    """ # Convert to hsv space # Match histogram to reference hist on only v channel # Paste matched values channel into HSV version of source image # Then, convert back to RGB
matched (ndarray): modified image with matching histogram
matched ( ndarray ) : modified image with matching histogram
ref
None
image
image to match histogram
image to match histogram