【问题标题】:Histogram equalization with SimpleITK使用 SimpleITK 进行直方图均衡
【发布时间】:2020-01-29 14:31:05
【问题描述】:

在这个SO answer 上建议我这个代码:

import SimpleITK as sitk
import numpy as np

# Create a noise Gaussian blob test image
img = sitk.GaussianSource(sitk.sitkFloat32, size=[240,240,48], mean=[120,120,24])
img = img + sitk.AdditiveGaussianNoise(img,10)

# Create a ramp image of the same size
h = np.arange(0.0, 255,1.0666666666, dtype='f4')
h2 = np.reshape(np.repeat(h, 240*48), (48,240,240))
himg = sitk.GetImageFromArray(h2)
print(himg.GetSize())

# Match the histogram of the Gaussian image with the ramp
result=sitk.HistogramMatching(img, himg)

# Display the 3d image
import itkwidgets
itkwidgets.view(result)

为什么我需要两张图像来做直方图均衡化?

因为我想做直方图均衡,这就是直方图匹配。在此article 中解释不同之处。

【问题讨论】:

标签: python itk simpleitk


【解决方案1】:

通过直方图匹配实现直方图均衡化是一种变通方法。

'himg' 是一个渐变图像,因此强度从 0 到 255。它的所有强度均等表示,因此它的直方图是平坦的。

因此,我们将您图片的直方图与平面直方图进行匹配。最终结果是直方图均衡化。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-15
    • 1970-01-01
    • 1970-01-01
    • 2017-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-21
    相关资源
    最近更新 更多