Skip to content

Instantly share code, notes, and snippets.

View tayden's full-sized avatar

Taylor Denouden tayden

View GitHub Profile
@tayden
tayden / skimage-exposure-match-histograms-with-masked-array.py
Last active June 19, 2024 16:25
Scikit-Image histogram matching doesn't work on numpy masked arrays. This gist is a workaround for this issue. It shows how to do histogram matching when you have an image and need to exclude certain values from being considered as part of the image histogram.
from skimage import io, exposure
import numpy as np
# Histogram matching with masked image
def match_histograms(image, reference, image_mask, fill_value=0):
masked_image = np.ma.array(image, mask=image_mask)
matched = np.ma.array(np.empty(image.shape, dtype=image.dtype),
mask=image_mask, fill_value=fill_value)
for channel in range(masked_image.shape[-1]):
@tayden
tayden / index.html
Created September 13, 2015 01:56
Top 250 IMDB Movies Treemap
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
margin: auto;
position: relative;
width: 960px;
}