import matplotlib.pyplot as plt import numpy as np from skimage import (filters, io, color, exposure, feature, segmentation, morphology, img_as_float)
(Based on StackOverflow http://stackoverflow.com/questions/28281742/fitting-a-circle-to-a-binary-image)
Consider a pill from the NLM Pill Image Recognition Pilot (
../images/round_pill.jpg). Fit a circle to the pill outline and compute its area.
feature.canny--depending on your version)
NOTE: this is expensive to compute, so may take a while to execute
# Initial level set pill = color.rgb2gray(image) pill = restoration.denoise_nl_means(pill, multichannel=False) level_set = segmentation.circle_level_set(pill.shape, radius=200) ls = segmentation.morphological_chan_vese(pill, 80, init_level_set=level_set, smoothing=3) fig, ax = plt.subplots(1, 1, figsize=(8, 8)) ax.imshow(pill, cmap="gray") ax.set_axis_off() ax.contour(ls, [0.5], colors='r');
Consider the coins image from the scikit-image example dataset, shown below. Write a function to count the number of coins.
The procedure outlined here is a bit simpler than in the notebook lecture (and works just fine!)
from skimage import data fig, ax = plt.subplots() ax.imshow(data.coins(), cmap='gray');
Consider the zig-zaggy snakes on the left (
Write some code to find the begin- and end-points of each.
scipy.signal.convolve2d[find all points with only one neighbor], and
np.logical_and[which of those points lie on the snake?] to do that, but there are many other ways).
How many blue M&Ms are there in this image (
Based on StackOverflow: http://stackoverflow.com/questions/23121416/long-boundary-detection-in-a-noisy-image
Consider the fluid experiment on the right (
../images/fingers.png). Determine any kind of meaningful boundary in this noisy image.