Skip to content

Instantly share code, notes, and snippets.

@spotter
spotter / rand_index_adjusted.py
Created March 2, 2011 14:06
Compute the adjusted rand_index
def rand_stat_adjusted(C, P):
"""Return Rand statistic.
C and P are two iterables.
"""
sz = len(C)
M = a = b = c= d = 0
for i in range(sz-1):
for j in range(i+1,sz):
M += 1
if C[i] == C[j]:
@spotter
spotter / dab_colormap.py
Created May 2, 2011 09:00
How to make and use a DAB colormap.
#! /bin/usr/env python
# -*- coding: utf-8 -*-
"""Building DAB colormap."""
__author__ = "Xavier Moles Lopez <x.moleslo@gmail.com>"
__date__ = "01/05/11"
from pylab import *
from matplotlib.colors import LinearSegmentedColormap
@spotter
spotter / noise.py
Created November 7, 2012 15:19
Implementation of the noise function
def noise(image):
""" Compute the noise feature.
Parameters
----------
image: ndarray
Image array (uint8 array).
Returns
-------