utils/io_utils.py
def convert_sat_np_for_vis(
    img_path: str,
    target_size: Union[None, Tuple[int]] = None,
) -> np.array:
    """Convert np.array to open-cv format.
    Args:
        img_path (str): np.array to be converted
        target_size (Tuple[int], optional): Size of returned image.
                                            Defaults to [256, 256].
    Returns:
        [np.array]: Converted np.array
    """
    img = np.load(img_path)
    img = img.astype(np.float32)
    if target_size is not None:
        img = cv2.resize(img, target_size)

    for channel in [0, 1, 2, 3]:
        img[:, :, channel] = (
            img[:, :, channel] - channels_stats["means"][channels[channel]]
        ) / channels_stats["stds"][channels[channel]]

    img = img[:, :, [3, 2, 1]]

    img = np.clip(img, -2, 2)
    img = (img + 2) * 255 / 4
    img = img.astype(np.uint8)
    return img
Convert np.array to open-cv format.
    Args:
        img_path (str): np.array to be converted
        target_size (Tuple[int], optional): Size of returned image.
                                            Defaults to [256, 256].
    Returns:
        [np.array]: Converted np.array
    
Convert np.array to open-cv format.
Convert np . array to open - cv format .
def convert_sat_np_for_vis(
    img_path: str,
    target_size: Union[None, Tuple[int]] = None,
) -> np.array:
    img = np.load(img_path)
    img = img.astype(np.float32)
    if target_size is not None:
        img = cv2.resize(img, target_size)
    for channel in [0, 1, 2, 3]:
        img[:, :, channel] = (
            img[:, :, channel] - channels_stats["means"][channels[channel]]
        ) / channels_stats["stds"][channels[channel]]
    img = img[:, :, [3, 2, 1]]
    img = np.clip(img, -2, 2)
    img = (img + 2) * 255 / 4
    img = img.astype(np.uint8)
    return img
def convert_sat_np_for_vis ( img_path : str , target_size : Union [ None , Tuple [ int ] ] = None , ) -> np . array : img = np . load ( img_path ) img = img . astype ( np . float32 ) if target_size is not None : img = cv2 . resize ( img , target_size ) for channel in [ 0 , 1 , 2 , 3 ] : img [ : , : , channel ] = ( img [ : , : , channel ] - channels_stats [ "means" ] [ channels [ channel ] ] ) / channels_stats [ "stds" ] [ channels [ channel ] ] img = img [ : , : , [ 3 , 2 , 1 ] ] img = np . clip ( img , - 2 , 2 ) img = ( img + 2 ) * 255 / 4 img = img . astype ( np . uint8 ) return img
Convert np.array to open-cv format.
Convert np . array to open - cv format .
"""Convert np.array to open-cv format.
    Args:
        img_path (str): np.array to be converted
        target_size (Tuple[int], optional): Size of returned image.
                                            Defaults to [256, 256].
    Returns:
        [np.array]: Converted np.array
    """
None
[np.array]
img_path
str
np.array to be converted
np . array to be converted
target_size
Union[None, Tuple[int]]
Size of returned image.
Size of returned image .