This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from mpl_draggable_line import DraggableVLine | |
def compare_images(img1, img2, ax=None): | |
img1 = np.asanyarray(img1) | |
img2 = np.asanyarray(img2) | |
if not np.all(img1.shape == img2.shape): | |
raise ValueError("Image shapes must match!") | |
if ax is None: | |
ax = plt.gca() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%matplotlib widget | |
from functools import lru_cache | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from mpl_interactions import ipyplot as iplt | |
from scipy import ndimage as ndi | |
from skimage.data import binary_blobs | |
from skimage.feature import peak_local_max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jlab-env-basic() | |
{ | |
conda create -n $1 -c conda-forge python mamba -y | |
conda activate $1 | |
mamba install -c conda-forge jupyterlab nodejs -y | |
} | |
jlab-env-full() | |
{ | |
conda create -n $1 -c conda-forge python=3.8 mamba -y | |
conda activate $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class panhandler: | |
""" | |
enable click to pan image. | |
button determines which button will be used (default right click) | |
Left: 1 | |
Middle: 2 | |
Right: 3 | |
""" | |
def __init__(self, fig, button=3): | |
self.fig = fig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
def zoom_factory(ax,base_scale = 1.1): | |
""" | |
parameters | |
---------- | |
ax : matplotlib axes object | |
axis on which to implement scroll to zoom | |
base_scale : float | |
how much zoom on each tick of scroll wheel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib.widgets import LassoSelector | |
from matplotlib.path import Path | |
class image_lasso_selector: | |
def __init__(self, img, mask_alpha=.75, figsize=(10,10)): | |
""" | |
img must have shape (X, Y, 3) | |
""" |