Skip to content

Instantly share code, notes, and snippets.

View stefanv's full-sized avatar

Stefan van der Walt stefanv

View GitHub Profile
@stefanv
stefanv / reverse_cmap.py
Created November 26, 2012 04:24
Reverse colormap
from skimage import io as sio
import skimage
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
img = skimage.img_as_float(sio.imread('im2.tif'))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stefanv
stefanv / vibrations.py
Created February 20, 2013 14:52
Mechanical vibrations simulation
# Stefan van der Walt <stefan@sun.ac.za>, 2013
# License: CC0
from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib.patches import Circle
@stefanv
stefanv / side_by_side.ipynb
Created February 22, 2013 13:05
Side-by-side dataframes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stefanv
stefanv / skimage_webcam.py
Last active May 30, 2019 23:28
Webcam video capturing with scikit-image
import numpy as np
import os
from skimage.io import ImageCollection
from skimage.io.video import CvVideo
import cv
class WebcamVideo(CvVideo):
"""
"""
==========================
Random walker segmentation
==========================
The random walker algorithm [1]_ determines the segmentation of an image from
a set of markers labeling several phases (2 or more). An anisotropic diffusion
equation is solved with tracers initiated at the markers' position. The local
diffusivity coefficient is greater if neighboring pixels have similar values,
so that diffusion is difficult across high gradients. The label of each unknown
{
"metadata": {
"name": "maximum_amplitude"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": "cat"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@magic_arguments.argument(
'filename', type=unicode,
help='file to write'
)
@cell_magic
def cat(self, line, cell):
"""Write the contents of the cell to a file.
"""
nr_pipes = line.count('>')
@stefanv
stefanv / mutual_information.py
Last active December 17, 2015 10:58
Interactive illustration of 2-D histograms
from skimage.viewer import ImageViewer
from skimage import data, img_as_float
from skimage.viewer.plugins.plotplugin import PlotPlugin
from skimage.viewer.widgets import Slider
from skimage.exposure import rescale_intensity
from skimage.transform import rotate
import numpy as np
import matplotlib.pyplot as plt