from matplotlib import pyplot as plt
from skimage import data
from skimage.feature import blob_dog
from skimage.color import rgb2gray
image = data.imread('Img.png')
blobs_dog = blob_dog(image, max_sigma=30, threshold=.1)
blobs = [blobs_dog]
colors = ['red']
titles = ['Difference of Gaussian']
sequence = zip(blobs, colors, titles)
for blobs, color, title in sequence:
fig, ax = plt.subplots(1, 1)
ax.set_title(title)
ax.imshow(image, interpolation='nearest')
for blob in blobs:
y, x, r = blob
c = plt.Circle((x, y), r, color=color, linewidth=1, fill=False)
ax.add_patch(c)
plt.show()
现在我的问题是:我使用了一个灰度图像(我没有用rgb2gray函数修改它),但是当我运行代码时,作为输出,我有一个“彩色”的图像(几乎所有的青色都带有一些红色和黄色的斑点)。
如果我使用RGB图像,然后将其转换为灰度,我不会有问题。为什么会这样?在