我有两张对比度不同的图片。我怎样才能让第二张图片有相同的对比度?有什么技术可以做到这一点吗?直方图匹配技术是否适用于这个目的?
使用SimpleITK 直方图匹配图像过滤器:
import SimpleITK as sitk
# read images
im_ref = sitk.ReadImage("/path/to/reference/image")
im_orig = sitk.ReadImage("/path/to/image/to/be/modified")
# apply histogram matching
histogram_match = sitk.HistogramMatchingImageFilter()
histogram_match.SetThresholdAtMeanIntensity(True) # useful if a lot of background pixels
im_matched = histogram_match.Execute(im_orig, im_ref)
# write output
sitk.WriteImage(im_matched, "/path/for/output/image")