【问题标题】:the warning message of using exposure.equalize_adapthist in scikit-image在 scikit-image 中使用 exposure.equalize_adapthist 的警告信息
【发布时间】:2020-02-03 03:15:55
【问题描述】:

在执行对比度受限自适应直方图均衡时,我收到以下警告消息。如何避免它,它意味着什么?

from skimage import exposure
img_adapteq = exposure.equalize_adapthist(image_gray, clip_limit=0.03)

C:\Users\ugwz\AppData\Local\Continuum\anaconda3\lib\site-packages\skimage\util\dtype.py:135: UserWarning: Possible precision loss when converting from float64 to uint16
  .format(dtypeobj_in, dtypeobj_out))

【问题讨论】:

  • 正如它所说,当您将 CLAHE 应用于您未与我们共享的 float64 图像时,您可能会丢失一些精度。有什么好说的?不要期望将操作应用于 64 位浮点图像的结果适合 16 位图像。您不能将 1.8E308 存储在最多只能容纳 65,536 的空间中。
  • 嗨,马克,谢谢,但我怎么知道图像是否为 float64。只是一个jpg文件,我是这样读的,image = imread("C:\\test8.jpg") image_gray = rgb2gray(image)
  • 每个频道中的 JPG 通常固有地为 uint8
  • 尝试print(image_gray.dtype)print(image.dtype) 来检查所涉及的实际类型。

标签: image-processing computer-vision scikit-image


【解决方案1】:

rgb2gray 将您的图像转换为浮动图像,因为它根据this page 上的公式计算相对亮度。请注意,由于科学 Python 生态系统的约定,它还会将值重新调整为 [0, 1] 中的值,因此.astype(np.uint16) 不会做你想做的事。请改用skimage.util.img_as_{ubyte,uint},详见scikit-image documentation on data types

from skimage import color, util, exposure

image = io.imread(<your-filename>)
image_gray = color.rgb2gray(image)
image16 = util.img_as_uint(image_gray)
img_adapteq = exposure.equalize_adapthist(image_gray, clip_limit=0.03)

很遗憾,在 0.15 版中,您仍然会看到警告,但在 0.16 及更高版本中已将其删除,应该会在接下来的几天内发布。

【讨论】:

  • 感谢您提请我注意该文档。我将删除我上面的​​任何不正确并可能误导他人的cmets。
猜你喜欢
  • 2021-11-22
  • 2018-01-18
  • 2017-05-05
  • 2018-06-02
  • 2018-09-27
  • 2010-11-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多