coastalimagelib/corefunctions.py
def cameraSeamBlend(IrIndv, numcams, nc):
    """
    This function takes rectifications from different cameras (but same grid)
    and merges them together into a single rectification.

    The function performs a weighted average where pixels closest to the seams
    are not weighted as highly as those closest to the center of the camera
    rectification.

    Notes:
        - Calculates Euclidean distance to nearest non-zero pixel value
        - edt: Euclidean Distance Transform

    Args:
        IrIndv (ndarray): A NxMxK matrix where N and M are the grid lengths
            for the rectified image and K is the number of cameras.
            Each k entry is a rectified image from a camera.

    Returns:
        M (ndarray): A NxM uint8 matrix of the greyscale merged image.
            N and M are the grid lengths for the rectified image.

    """

    totalW = np.zeros_like(IrIndv[:, :, :nc])
    M = np.zeros_like(IrIndv[:, :, :nc])

    # Iterate through each camera
    for kk in range(numcams):
        K = IrIndv[:, :, (kk * nc): (kk * nc + nc)]

        # Make binary matrix from image (1 for Nan, 0 for nonnan)
        K_nans = K[:, :, 0]
        K_nans[np.isnan(K_nans)] = np.nan

        # edt finds euclidean distance from Nan to closest real value
        # Find the nans, then invert
        W = distance_transform_edt(~np.isnan(K_nans))
        if np.isinf(np.max(W)):
            W = np.ones_like(W)
        else:
            W = W / np.max(W)

        # Apply weights to image
        K_weighted = K * W[:, :, np.newaxis]

        # Add weights and pixel itensities
        totalW = totalW + W[:, :, np.newaxis]

        K_weighted[np.isnan(K_weighted)] = 0
        M = M + K_weighted

    # Stop divide by 0 warnings
    with np.errstate(invalid="ignore"):
        M = M / totalW

    M[np.isnan(M)] = 0

    return M.astype(np.uint8)

    This function takes rectifications from different cameras (but same grid)
    and merges them together into a single rectification.

    The function performs a weighted average where pixels closest to the seams
    are not weighted as highly as those closest to the center of the camera
    rectification.

    Notes:
        - Calculates Euclidean distance to nearest non-zero pixel value
        - edt: Euclidean Distance Transform

    Args:
        IrIndv (ndarray): A NxMxK matrix where N and M are the grid lengths
            for the rectified image and K is the number of cameras.
            Each k entry is a rectified image from a camera.

    Returns:
        M (ndarray): A NxM uint8 matrix of the greyscale merged image.
            N and M are the grid lengths for the rectified image.

    
This function takes rectifications from different cameras (but same grid)
and merges them together into a single rectification.

The function performs a weighted average where pixels closest to the seams
are not weighted as highly as those closest to the center of the camera
rectification.

Calculates Euclidean distance to nearest non-zero pixel value
edt: Euclidean Distance Transform
This function takes rectifications from different cameras ( but same grid ) and merges them together into a single rectification . The function performs a weighted average where pixels closest to the seams are not weighted as highly as those closest to the center of the camera rectification . Calculates Euclidean distance to nearest non - zero pixel value edt : Euclidean Distance Transform
def cameraSeamBlend(IrIndv, numcams, nc):
    totalW = np.zeros_like(IrIndv[:, :, :nc])
    M = np.zeros_like(IrIndv[:, :, :nc])
    for kk in range(numcams):
        K = IrIndv[:, :, (kk * nc): (kk * nc + nc)]
        K_nans = K[:, :, 0]
        K_nans[np.isnan(K_nans)] = np.nan
        W = distance_transform_edt(~np.isnan(K_nans))
        if np.isinf(np.max(W)):
            W = np.ones_like(W)
        else:
            W = W / np.max(W)
        K_weighted = K * W[:, :, np.newaxis]
        totalW = totalW + W[:, :, np.newaxis]
        K_weighted[np.isnan(K_weighted)] = 0
        M = M + K_weighted
    with np.errstate(invalid="ignore"):
        M = M / totalW
    M[np.isnan(M)] = 0
    return M.astype(np.uint8)
def cameraSeamBlend ( IrIndv , numcams , nc ) : totalW = np . zeros_like ( IrIndv [ : , : , : nc ] ) M = np . zeros_like ( IrIndv [ : , : , : nc ] ) for kk in range ( numcams ) : K = IrIndv [ : , : , ( kk * nc ) : ( kk * nc + nc ) ] K_nans = K [ : , : , 0 ] K_nans [ np . isnan ( K_nans ) ] = np . nan W = distance_transform_edt ( ~ np . isnan ( K_nans ) ) if np . isinf ( np . max ( W ) ) : W = np . ones_like ( W ) else : W = W / np . max ( W ) K_weighted = K * W [ : , : , np . newaxis ] totalW = totalW + W [ : , : , np . newaxis ] K_weighted [ np . isnan ( K_weighted ) ] = 0 M = M + K_weighted with np . errstate ( invalid = "ignore" ) : M = M / totalW M [ np . isnan ( M ) ] = 0 return M . astype ( np . uint8 )
This function takes rectifications from different cameras (but same grid)
and merges them together into a single rectification.
This function takes rectifications from different cameras ( but same grid ) and merges them together into a single rectification .
"""
    This function takes rectifications from different cameras (but same grid)
    and merges them together into a single rectification.

    The function performs a weighted average where pixels closest to the seams
    are not weighted as highly as those closest to the center of the camera
    rectification.

    Notes:
        - Calculates Euclidean distance to nearest non-zero pixel value
        - edt: Euclidean Distance Transform

    Args:
        IrIndv (ndarray): A NxMxK matrix where N and M are the grid lengths
            for the rectified image and K is the number of cameras.
            Each k entry is a rectified image from a camera.

    Returns:
        M (ndarray): A NxM uint8 matrix of the greyscale merged image.
            N and M are the grid lengths for the rectified image.

    """ # Iterate through each camera # Make binary matrix from image (1 for Nan, 0 for nonnan) # edt finds euclidean distance from Nan to closest real value # Find the nans, then invert # Apply weights to image # Add weights and pixel itensities # Stop divide by 0 warnings
M (ndarray): A NxM uint8 matrix of the greyscale merged image.
N and M are the grid lengths for the rectified image.
M ( ndarray ) : A NxM uint8 matrix of the greyscale merged image . N and M are the grid lengths for the rectified image .
IrIndv
A NxMxK matrix where N and M are the grid lengths
for the rectified image and K is the number of cameras.
Each k entry is a rectified image from a camera.
A NxMxK matrix where N and M are the grid lengths for the rectified image and K is the number of cameras . Each k entry is a rectified image from a camera .
numcams
nc