StackOverflow Problems
Real-world problems to test your skills on!
Parameters of a pill
(Based on StackOverflow http://stackoverflow.com/questions/28281742/fitting-a-circle-to-a-binary-image)
Hints:
Equalize (
exposure.equalize_*
)Detect edges (
filter.canny
orfeature.canny
--depending on your version)Fit the
CircleModel
usingmeasure.ransac
.
Alternative: morphological snakes
NOTE: this is expensive to compute, so may take a while to execute
Counting coins
Based on StackOverflow http://stackoverflow.com/questions/28242274/count-number-of-objects-using-watershed-algorithm-scikit-image
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!)
Hint:
Equalize
Threshold (
filters.threshold_otsu
)Remove objects touching boundary (
segmentation.clear_border
)Apply morphological closing (
morphology.closing
)Remove small objects (
measure.regionprops
)Visualize (potentially using
color.label2rgb
)
Snakes
Based on https://stackoverflow.com/q/8686926/214686
Consider the zig-zaggy snakes on the left (../images/snakes.png
).
Write some code to find the begin- and end-points of each.
Hints:
Threshold the image to turn it into "black and white"
Not all lines are a single pixel thick. Use skeletonization to thin them out (
morphology.skeletonize
)Locate all snake endpoints (I used a combination of
scipy.signal.convolve2d
[find all points with only one neighbor], andnp.logical_and
[which of those points lie on the snake?] to do that, but there are many other ways).
M&Ms
How many blue M&Ms are there in this image (../images/mm.jpg
)?
Steps:
Denoise the image (using, e.g.,
restoration.denoise_nl_means
)Calculate how far each pixel is away from pure blue
Segment this distance map to give a "pill mask"
Fill in any holes in that mask, using
scipy.ndimage.binary_fill_holes
Use watershed segmentation to split apart any M&Ms that were joined, as described in http://scikit-image.org/docs/dev/auto_examples/segmentation/plot_watershed.html
Alternative approach:
Viscous fingers
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.
Hints:
Convert to grayscale
Try edge detection (
feature.canny
)If edge detection fails, denoising is needed (try
restoration.denoise_tv_bregman
)Try edge detection (
feature.canny
)