Skip to content

Instantly share code, notes, and snippets.

@Feyn-Man
Feyn-Man / _dice.py
Last active December 14, 2020 14:55 — forked from brunodoamaral/_dice.py
Dice coefficient between two boolean NumPy arrays or array-like data. This is commonly used as a set similarity measurement (though note it is not a true metric; it does not satisfy the triangle inequality). The dimensionality of the input is completely arbitrary, but `im1.shape` and `im2.shape` much be equal. This Gist is licensed under the mod…
def dice(im1, im2):
"""
Computes the Dice coefficient, a measure of set similarity.
Parameters
----------
im1 : array-like, bool
Any array of arbitrary size. If not boolean, will be converted.
im2 : array-like, bool
Any other array of identical size. If not boolean, will be converted.
Returns
@Feyn-Man
Feyn-Man / load_inbreast_roi.py
Last active July 19, 2022 12:49 — forked from jendelel/load_inbreast_roi.py
Load INBREAST ROIs
from skimage.draw import polygon
import numpy as np
import plistlib
def load_inbreast_mask(mask_path, imshape=(4084, 3328)):
"""
This function loads a osirix xml region as a binary numpy array for INBREAST
dataset
@mask_path : Path to the xml file