ContrastEnhancement¶
这个应用程序是直方图均衡算法的实现。它可用于增强图像的对比度,或在不损失太多对比度的情况下降低图像的动态效果。它提供了几个选项,如无数据值、对比度限制因子、算法的本地版本以及图像亮度均衡模式。
描述¶
这个应用程序是直方图均衡算法的实现。该算法的思想是利用所有可用的动态信息。为了做到这一点,它计算图像上的直方图,然后使用整个动态:这意味着展平直方图。这为我们提供了将原始直方图转换为平面直方图的每个面元的收益。然后将该增益应用于原始图像。
该应用程序提出了几个选项,以实现更好的结果:
- 有一种选择可以限制对比度。我们选择通过修改原始直方图来限制对比度。为此,我们在给定高度裁剪直方图,并在裁剪后的种群中均匀地在垃圾桶中重新分配。然后我们添加算法的本地版本。
- 可以将该算法应用于图像的块,而不是整个图像。这取决于像素的值和它在图像中的位置。为了使结果更平滑,我们在瓷砖之间插入了增益。
参数¶
Input Image -in image
Mandatory
Input image.
Output Image -out image [dtype]
Mandatory
Output image.
Number of bins -bins int
Default value: 256
Number of bins in the histogram
Contrast Limitation -hfact float
This parameter will set the maximum height accepted in a bin on the input image histogram. The maximum height will be computed as hfact*eqHeight where eqHeight is the height of the theoretical flat histogram. The higher hfact, the higher the contrast.
When using 'luminance mode', it is recommended to limit this factor to a small value (ex: 4)
Nodata Value -nodata float
If there is a value in the image that has no visualization meaning, it can be ignored by the algorithm.
Spatial parameters for the histogram computation -spatial [local|global]
Default value: local
- Local
The histograms will be computed on each thumbnail. Each of the histogram will be equalized and the corresponding gain will be interpolated. - Global
The histogram will be computed on the whole image. The equalization will be computed on this histogram.
本地选项¶
Thumbnail height -spatial.local.h int
Default value: 256
Height of the thumbnail over which the histogram will be computed. The value is in pixels.
Thumbnail width -spatial.local.w int
Default value: 256
Width of the thumbnail over which the histogram will be computed. The value is in pixels.
Minimum and maximum settings -minmax [auto|manual]
Default value: auto
Minimum and maximum value that will bound the histogram and thus the dynamic of the resulting image. Values over those boundaries will be clipped.
- Automatic
Minimum and maximum value will be computed on the image (nodata value won't be taken into account) . Each band will have a minimum and a maximum. - Manual settings for min/max values
Minimum and maximum value will be set by the user
自动选项¶
Global -minmax.auto.global bool
Default value: false
Min/max computation will result in the same minimum and maximum for all the bands.
最小/最大值选项的手动设置¶
Minimum value -minmax.manual.min float
Maximum value -minmax.manual.max float
What to equalized -mode [each|lum]
Default value: each
- Channels
Each channel is equalized independently - Luminance
The relative luminance is computed according to the coefficients.Then the histogram is equalized and the gain is applied to each of the channels. The channel gain will depend on the weight (coef) of the channel in the luminance.
Note that default values come from color space theories on how human eyes perceive colors)
红色通道¶
Red channel -mode.lum.red.ch int
Default value: 0
Value for luminance computation for the red channel -mode.lum.red.coef float
Default value: 0.21
实例¶
从命令行执行以下操作:
# Local contrast enhancement by luminance
otbcli_ContrastEnhancement -in colours.tif -out equalizedcolors.tif float -bins 256 -spatial.local.w 500 -spatial.local.h 500 -mode lum
来自Python的评论:
# Local contrast enhancement by luminance
import otbApplication
app = otbApplication.Registry.CreateApplication("ContrastEnhancement")
app.SetParameterString("in", "colours.tif")
app.SetParameterString("out", "equalizedcolors.tif")
app.SetParameterOutputImagePixelType("out", 6)
app.SetParameterInt("bins", 256)
app.SetParameterInt("spatial.local.w", 500)
app.SetParameterInt("spatial.local.h", 500)
app.SetParameterString("mode","lum")
app.ExecuteAndWriteOutput()