from math import sqrt
from skimage import data
from skimage.feature import blob_dog, blob_log, blob_doh
from skimage.color import rgb2gray
from skimage import io

import matplotlib.pyplot as plt


image = io.imread("star.jpg")
image_gray = rgb2gray(image)

blobs_log = blob_log(image_gray, max_sigma=30, num_sigma=10, threshold=.1)

# Compute radii in the 3rd column.
blobs_log[:, 2] = blobs_log[:, 2] * sqrt(2)

blobs_dog = blob_dog(image_gray, max_sigma=30, threshold=.1)
blobs_dog[:, 2] = blobs_dog[:, 2] * sqrt(2)

blobs_doh = blob_doh(image_gray, max_sigma=30, threshold=.01)

blobs_list = [blobs_log, blobs_dog, blobs_doh]
colors = ['yellow', 'lime', 'red']
titles = ['Laplacian of Gaussian', 'Difference of Gaussian',
          'Determinant of Hessian']
sequence = zip(blobs_list, colors, titles)

fig, axes = plt.subplots(1, 3, figsize=(9, 3), sharex=True, sharey=True)
ax = axes.ravel()

for idx, (blobs, color, title) in enumerate(sequence):
    ax[idx].set_title(title)
    ax[idx].imshow(image)
    for blob in blobs:
        y, x, r = blob
        c = plt.Circle((x, y), r, color=color, linewidth=2, fill=False)
        ax[idx].add_patch(c)
    ax[idx].set_axis_off()

plt.tight_layout()
plt.show()
[(10, 'skimage.io.imread', 'io.imread', (['"""star.jpg"""'], {}), False, 'from skimage import io\n'), (11, 'skimage.color.rgb2gray', 'rgb2gray', (['image'], {}), False, 'from skimage.color import rgb2gray\n'), (13, 'skimage.feature.blob_log', 'blob_log', (['image_gray'], {'max_sigma': '(30)', 'num_sigma': '(10)', 'threshold': '(0.1)'}), False, 'from skimage.feature import blob_dog, blob_log, blob_doh\n'), (18, 'skimage.feature.blob_dog', 'blob_dog', (['image_gray'], {'max_sigma': '(30)', 'threshold': '(0.1)'}), False, 'from skimage.feature import blob_dog, blob_log, blob_doh\n'), (21, 'skimage.feature.blob_doh', 'blob_doh', (['image_gray'], {'max_sigma': '(30)', 'threshold': '(0.01)'}), False, 'from skimage.feature import blob_dog, blob_log, blob_doh\n'), (29, 'matplotlib.pyplot.subplots', 'plt.subplots', (['(1)', '(3)'], {'figsize': '(9, 3)', 'sharex': '(True)', 'sharey': '(True)'}), True, 'import matplotlib.pyplot as plt\n'), (41, 'matplotlib.pyplot.tight_layout', 'plt.tight_layout', ([], {}), True, 'import matplotlib.pyplot as plt\n'), (42, 'matplotlib.pyplot.show', 'plt.show', ([], {}), True, 'import matplotlib.pyplot as plt\n'), (16, 'math.sqrt', 'sqrt', (['(2)'], {}), False, 'from math import sqrt\n'), (19, 'math.sqrt', 'sqrt', (['(2)'], {}), False, 'from math import sqrt\n'), (37, 'matplotlib.pyplot.Circle', 'plt.Circle', (['(x, y)', 'r'], {'color': 'color', 'linewidth': '(2)', 'fill': '(False)'}), True, 'import matplotlib.pyplot as plt\n')]