cv2.imshow正在发生一些奇怪的事情.我正在编写一段代码并想知道为什么我的一个操作不起作用(通过观察cv2.imshow来诊断).在恼怒的情况下,我最终将相同的图像写入文件,其中看起来很好.为什么cv2.imshow显示二进制图像(下面的第一个图像),而cv2.imwrite按预期写入灰度图像(第二个图像)?我以前从未遇到过显示灰度图像的问题!
cv2.imshow('Latest', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
distTransform = cv2.distanceTransform(src=image,distanceType=cv2.DIST_L2,maskSize=5)
cv2.imwrite('distanceTransform.png', distTransform)
cv2.imshow('Latest', distTransform)
cv2.waitKey(0)
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)