コード例 #1
0
def undistort_image(image, look_up_table):
    """
    Function to undistort an image using a look-up table
    :param image:
    :param look_up_table:
    :return:
    """
    ################################################################################
    # Copyright (c) 2019 University of Maryland
    # Authors:
    #  Kanishka Ganguly ([email protected])
    #
    # This work is licensed under the Creative Commons
    # Attribution-NonCommercial-ShareAlike 4.0 International License.
    # To view a copy of this license, visit
    # http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to
    # Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
    #
    ################################################################################
    reshaped_lut = look_up_table[:, 1::-1].T.reshape(
        (2, image.shape[0], image.shape[1]))
    undistorted = np.rollaxis(
        np.array([
            interp2(image[:, :, channel], reshaped_lut, order=1)
            for channel in range(0, image.shape[2])
        ]), 0, 3)
    return undistorted.astype(image.dtype)
コード例 #2
0
def UndistortImage(image, LUT):
    reshaped_lut = LUT[:, 1::-1].T.reshape((2, image.shape[0], image.shape[1]))
    undistorted = np.rollaxis(
        np.array([
            interp2(image[:, :, channel], reshaped_lut, order=1)
            for channel in range(0, image.shape[2])
        ]), 0, 3)
    return undistorted.astype(image.dtype)
コード例 #3
0
    def undistort_image(image: np.array, lut: np.array) -> np.array:
        """

        Takes an distorted image and undistort it.

        Args:
            lut: np.array
                Undistortion lookup table
            image: np.array
                input color image of shape (m, n, 3)

        Returns: np.array

        """
        log.debug(f' DataPreprocessor.undistort_image() invoked..!')
        reshaped_lut = lut[:, 1::-1].T.reshape(
            (2, image.shape[0], image.shape[1]))
        undistorted = np.rollaxis(
            np.array([
                interp2(image[:, :, channel], reshaped_lut, order=1)
                for channel in range(0, image.shape[2])
            ]), 0, 3)
        log.debug(f' Exiting undistort_image()..!')
        return undistorted.astype(image.dtype)