Skip to content

Instantly share code, notes, and snippets.

import numpy as np
from colorsys import rgb_to_hls, hls_to_rgb
def _rgb2hls(im):
return np.stack(np.vectorize(rgb_to_hls)(*im.transpose(2,0,1)/256), axis=-1)
def _hls2rgb(im):
return (255*np.stack(np.vectorize(hls_to_rgb)(*im.transpose(2,0,1)), axis=-1)).astype(np.uint8)
def invert(img):
import numpy as np
from csbdeep.utils import normalize
def norm_minmse(gt, x, normalize_gt=True):
"""
normalizes and affinely scales an image pair such that the MSE is minimized
Parameters
----------
gt: ndarray