我想在 OpenCV Python 中加载并显示 .tif 图像。我使用 cv2.imread('1_00001.tif') 加载图像,然后使用 plt.imshow(img) 显示它,但显示的图像是全黑的,而不是原来的图像。
我可以使用 PIL 的 Image.open() 和 matplotlib 的 mpimg.imread() 正确加载和显示图像,所以我认为这是 cv2 特定的问题。但是,我还使用相同的 cv2.imread() 函数成功显示了 .jpg 和 .tiff 图像,因此该 .tif 图像也可能存在问题。
import cv2
import matplotlib.pyplot as plt
img = cv2.imread('1_00001.tif')
plt.imshow(img)
Run Code Online (Sandbox Code Playgroud)
我期望得到一个内部有一些模糊线条的圆圈图像,但实际输出只是一个黑色图像。
我正在尝试在视网膜图像中追踪血管。目前我正在使用 cv2 的阈值函数来使血管与周围视网膜的对比度更高:
from matplotlib import pyplot as plt
import cv2
img = cv2.imread('misc images/eye.jpeg',0)
img = cv2.medianBlur(img,5)
ret,th1 = cv2.threshold(img,127,255,cv2.THRESH_BINARY)
th2 = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_MEAN_C,\
cv2.THRESH_BINARY,11,2)
th3 = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,\
cv2.THRESH_BINARY,11,2)
titles = ['Original Image', 'Global Thresholding (v = 127)',
'Adaptive Mean Thresholding', 'Adaptive Gaussian Thresholding']
images = [img, th1, th2, th3]
for i in range(4):
plt.subplot(2,2,i+1),plt.imshow(images[i],'gray')
plt.title(titles[i])
plt.xticks([]),plt.yticks([])
plt.show()
Run Code Online (Sandbox Code Playgroud)
所有 3 种方法仍然存在来自视网膜其余部分的大量背景噪声。如何提高船舶追踪的准确性?