Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
source ~/.bashrc
git clone https://github.com/mpicbg-csbd/stardist
my_venvs_create stardist_env
my_venvs_activate stardist_env
pip install tifffile==2019.7.2 # as newer versions somehow wont install on noto
pip install stardist
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