Skip to content

Instantly share code, notes, and snippets.

@jiemojiemo
jiemojiemo / patches.py
Created April 20, 2018 03:08 — forked from dwf/patches.py
Some patch extraction code I'm using to process images.
import os
import numpy as np
import scipy.ndimage as ndimage
import matplotlib
import matplotlib.pyplot as plt
def frac_eq_to(image, value=0):
return (image == value).sum() / float(np.prod(image.shape))
def extract_patches(image, patchshape, overlap_allowed=0.5, cropvalue=None,