Python/OpenCV中的对比度拉伸 [英] Contrast stretching in Python/ OpenCV

查看:697
本文介绍了Python/OpenCV中的对比度拉伸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Google中搜索直方图均衡化Python 对比度拉伸Python ,我直接从 OpenCv 中的python文档中获得了相同的链接与均衡而非延展(IMO)有关.

Searching Google for Histogram Equalization Python or Contrast Stretching Python I am directed to the same links from python documentation in OpenCv which are actually both related to equalization and not stretching (IMO).

  1. http://docs.opencv .org/2.4/doc/tutorials/imgproc/histograms/histogram_equalization/histogram_equalization.html

http://docs.opencv.org/3.2 .0/d5/daf/tutorial_py_histogram_equalization.html

阅读文档,这似乎与措辞混淆,因为它把均衡描述为拉伸操作:

Read the documentation, it seems to be a confusion with the wording, as it describes equalization as a stretching operation:

直方图均衡化的作用是扩展此范围.

What Histogram Equalization does is to stretch out this range.

AND

因此,您需要将此直方图拉伸到两端(如下图所示,来自维基百科),这就是直方图均衡化的作用(简单来说)

So you need to stretch this histogram to either ends (as given in below image, from wikipedia) and that is what Histogram Equalization does (in simple words)

我认为这是错误的,因为在Wikipedia上,没有任何地方说直方图均衡意味着拉伸,而在阅读其他资料时,它们清楚地区分了这两种操作.

I feel that is wrong because nowhere on Wikipedia it says that histogram equalization means stretching, and reading other sources they clearly distinguish the two operations.

  1. http://homepages.inf.ed.ac.uk/rbf/HIPR2/histeq.htm
  2. http://homepages.inf.ed.ac.uk/rbf/HIPR2/stretch.htm
  1. http://homepages.inf.ed.ac.uk/rbf/HIPR2/histeq.htm
  2. http://homepages.inf.ed.ac.uk/rbf/HIPR2/stretch.htm

我的问题:

  1. OpenCV文档是否实际上实现了直方图均衡化,但解释得很糟糕?

  1. does the OpenCV documentation actually implements Histogram Equalization, while badly explaining it?

  1. 在Python中是否有任何用于对比度扩展的实现? (OpenCV等?)

推荐答案

OpenCV没有任何用于对比度拉伸的功能,并且Google会产生相同的结果,因为直方图均衡化可以水平拉伸直方图,但是只是变换函数的差异. (两种方法都可以提高图像的对比度.变换功能会将像素强度级别从给定范围转移到所需范围.)

OpenCV doesn't have any function for contrast stretching and google yields the same result because histogram equalization does stretch the histogram horizontally but its just the difference of the transformation function. (Both methods increase the contrast of the images.Transformation function transfers the pixel intensity levels from the given range to required range.)

直方图均衡化自动从给定图像的概率密度函数(PDF)导出变换函数(TF),与之相反,拉伸时您可以根据应用程序的要求指定自己的TF.

Histogram equalization derives the transformation function(TF) automatically from probability density function (PDF) of the given image where as in contrast stretching you specify your own TF based on the applications' requirement.

一个可以进行对比拉伸的简单TF是min-max对比拉伸-

One simple TF through which you can do contrast stretching is min-max contrast stretching -

((像素-最小)/(最大-最小))* 255.

((pixel – min) / (max – min))*255.

对每个像素值执行此操作.最小和最大是最小和最大强度.

You do this for each pixel value. min and max being the minimum and maximum intensities.

这篇关于Python/OpenCV中的对比度拉伸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆