Skip to content

Instantly share code, notes, and snippets.

View shandilya1998's full-sized avatar

Shreyas Shandilya shandilya1998

View GitHub Profile
@dwf
dwf / patches.py
Created April 14, 2010 19:49
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,