Count the spots!

For Brayden Bagla

with help from PyImageSearch


My young cousin was playing with fusible plastic beads. He had a pegboard of a dinosaur and I asked him a simple question:

"How many beads do you need for this one?"

He responded, "I don't know! Could you write a program to count the spots?"

Finding the right tools

No programmer works alone. Every single person depends on things other people have built.

This is true everywhere! In most paintings, someone besides the artist made the paint and the canvas. We all rely on each other's work to make cool things :)

Here, I'm using the language Python and a few extra packages to handle images. I also looked at a tutorial to help me solve this puzzle.

In [1]:
## First, let's make sure it's Python 3
import sys
3.6.4 (default, Jan  6 2018, 11:51:15) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]
In [2]:
## Import the necessary packages
%matplotlib inline
import matplotlib.pyplot as plt
from imutils import contours
from skimage import measure
import numpy as np
import argparse
import imutils
import cv2

Looking at the image

Let's load up the image, and see what we can do with it.

In [3]:
## Loading the image
args = {}
args["image"] = "./IMG_0747.JPG"
image = cv2.imread(args["image"])
## Plotting the image
<matplotlib.image.AxesImage at 0x11c449860>