Adaptive Thresholding

Adaptive Thresholdinghttp://homepages.inf.ed.ac.uk/rbf/HIPR2/adpthrsh.htmAdaptiveThresholdingCommonNames: Adaptivethresholding,DynamicthresholdingBriefDescriptionThresholdingisusedtosegmenta

大家好,又见面了,我是你们的朋友全栈君。

http://homepages.inf.ed.ac.uk/rbf/HIPR2/adpthrsh.htm

Adaptive Thresholding


Adaptive Thresholding

Common Names: Adaptive thresholding, Dynamic thresholding

Brief Description

Thresholding is used to segment an image by setting all pixels whose intensity values are above a threshold to a foreground value and all the remaining pixels to a background value.

Whereas the conventional thresholding operator uses a global threshold for all pixels, adaptive thresholding changes the threshold dynamically over the image. This more sophisticated version of thresholding can accommodate changing lighting conditions in the image, e.g. those occurring as a result of a strong illumination gradient or shadows.

Adaptive Thresholding

How It Works

Adaptive thresholding typically takes a grayscale or color image as input and, in the simplest implementation, outputs a binary image representing the segmentation. For each pixel in the image, a threshold has to be calculated. If the pixel value is below the threshold it is set to the background value, otherwise it assumes the foreground value.

There are two main approaches to finding the threshold: (i) the Adaptive ThresholdingChow and Kaneko approach and (ii) Adaptive Thresholdinglocal thresholding. The assumption behind both methods is that smaller image regions are more likely to have approximately uniform illumination, thus being more suitable for thresholding. Chow and Kaneko divide an image into an array of overlapping subimages and then find the optimum threshold for each subimage by investigating its histogram. The threshold for each single pixel is found by interpolating the results of the subimages. The drawback of this method is that it is computational expensive and, therefore, is not appropriate for real-time applications.

An alternative approach to finding the local threshold is to statistically examine the intensity values of the local neighborhood of each pixel. The statistic which is most appropriate depends largely on the input image. Simple and fast functions include the mean of the local intensity distribution,

Eqn:eqnadp1

the median value,

Eqn:eqnadp2

or the mean of the minimum and maximum values,

Eqn:eqnadp3

The size of the neighborhood has to be large enough to cover sufficient foreground and background pixels, otherwise a poor threshold is chosen. On the other hand, choosing regions which are too large can violate the assumption of approximately uniform illumination. This method is less computationally intensive than the Chow and Kaneko approach and produces good results for some applications.

Adaptive Thresholding

Guidelines for Use

Like global thresholding, adaptive thresholding is used to separate desirable foreground image objects from the background based on the difference in pixel intensities of each region. Global thresholding uses a fixed threshold for all pixels in the image and therefore works only if the intensity histogram of the input image contains neatly separated peaks corresponding to the desired subject(s) and background(s). Hence, it cannot deal with images containing, for example, a strong illumination gradient.

Local adaptive thresholding, on the other hand, selects an individual threshold for each pixel based on the range of intensity values in its local neighborhood. This allows for thresholding of an image whose global intensity histogram doesn’t contain distinctive peaks.

A task well suited to local adaptive thresholding is in segmenting text from the image

son1

Because this image contains a strong illumination gradient, global thresholding produces a very poor result, as can be seen in

son1thr1

Using the mean of a 7×7 neighborhood, adaptive thresholding yields

son1adp1

The method succeeds in the area surrounding the text because there are enough foreground and background pixels in the local neighborhood of each pixel; i.e. the mean value lies between the intensity values of foreground and background and, therefore, separates easily. On the margin, however, the mean of the local area is not suitable as a threshold, because the range of intensity values within a local neighborhood is very small and their mean is close to the value of the center pixel.

The situation can be improved if the threshold employed is not the mean, but (mean-C), where C is a constant. Using this statistic, all pixels which exist in a uniform neighborhood (e.g. along the margins) are set to background. The result for a 7×7 neighborhood and C=7 is shown in

son1adp2

and for a 75×75 neighborhood and C=10 in

son1adp3

The larger window yields the poorer result, because it is more adversely affected by the illumination gradient. Also note that the latter is more computationally intensive than thresholding using the smaller window.

The result of using the median instead of the mean can be seen in

son1adp4

(The neighborhood size for this example is 7×7 and C = 4). The result shows that, in this application, the median is a less suitable statistic than the mean.

Consider another example image containing a strong illumination gradient

wdg3

This image can not be segmented with a global threshold, as shown in

wdg3thr1

where a threshold of 80 was used. However, since the image contains a large object, it is hard to apply adaptive thresholding, as well. Using the (mean – C) as a local threshold, we obtain

wdg3adp1

with a 7×7 window and C = 4, and

wdg3adp2

with a 140×140 window and C = 8. All pixels which belong to the object but do not have any background pixels in their neighborhood are set to background. The latter image shows a much better result than that achieved with a global threshold, but it is still missing some pixels in the center of the object. In many applications, computing the mean of a neighborhood (for each pixel!) whose size is of the order 140×140 may take too much time. In this case, the more complex Chow and Kaneko approach to adaptive thresholding would be more successful.

If your image processing package does not contain an adaptive threshold operator, you can simulate the effect with the following steps:

  1. Convolve the image with a suitable statistical operator, i.e. the mean or median.
  2. Subtract the original from the convolved image.
  3. Threshold the difference image with C.
  4. Invert the thresholded image.

Interactive Experimentation

You can interactively experiment with this operator by clicking here.

Exercises

  1. In the above example using

    son1

    why does the mean produce a better result than the median? Can you think of any example where the median is more appropriate?

  2. Think of an appropriate statistic for finding dark cracks on a light object using adaptive thresholding.

  3. If you want to recover text from an image with a strong illumination gradient, how does the local thresholding method relate to the technique of removing the illumination gradient using pixel subtraction? Compare the results achieved with adaptive thresholding, pixel subtraction and pixel division.

References

E. Davies Machine Vision: Theory, Algorithms and Practicalities, Academic Press, 1990, pp 91 – 96.

R. Gonzales and R. Woods Digital Image Processing, Addison-Wesley Publishing Company, 1992, pp 443 – 452.

A. Jain Fundamentals of Digital Image Processing, Prentice-Hall, 1986, p 408.

C.K. Chow and T. Kaneko Automatic Boundary Detection of the Left Ventricle from Cineangiograms, Comp. Biomed. Res.(5), 1972, pp. 388-410.

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/130958.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 主机号「建议收藏」

    主机号「建议收藏」用于识别该网络中的主机。IP地址分为五类,A类保留给政府机构,B类分配给中等规模的公司,C类分配给任何需要的人,D类用于组播,E类用于实验,各类可容纳的地址数目不同。A、B、C三类IP地址的特征:

    2022年8月4日
  • 第一天python是干什么的–数字常量

    第一天python是干什么的–数字常量Python是干什么的?Python历史发明人:guidovanrossum1989名称:montypython马戏团发音:拍桑美国拍森英语Python能干啥?Python

    2022年7月5日
  • Java tps_Java static

    Java tps_Java static写在前面TPS即每秒查询事物,可以用于测试一个方法、工具或者系统的性能。本文采用Java并发包中的工具实现了一个工具TPS性能测试。主要是测试OKHttp库来执行Http请求的性能。测试代码用到了Java了线程池ExecuterService,CountDownLatch,CyclicBarrier,原子类,volatile关键词等。可算是对Java并发组件的组合使用。下面直接贴出源码,仅供参考

    2022年9月2日
  • 敏友的【敏捷个人】有感(5): 一位百度研发人员读后感【技术人自我管理】…

    敏友的【敏捷个人】有感(5): 一位百度研发人员读后感【技术人自我管理】…

    2021年6月20日
  • BigDecimal加减乘除运算工具类

    BigDecimal加减乘除运算工具类BigDecimal加减乘除运算工具类

    2022年6月2日
  • Java多态性:Java什么是多态?

    Java多态性:Java什么是多态?多态性是面向对象编程的又一个重要特征,它是指在父类中定义的属性和方法被子类继承之后,可以具有不同的数据类型或表现出不同的行为,这使得同一个属性或方法在父类及其各个子类中具有不同的含义。对面向对象来说,多态分为编译时多态和运行时多态。其中编译时多态是静态的,主要是指方法的重载,它是根据参数列表的不同来区分不同的方法。通过编译之后会变成两个不同的方法,在运行时谈不上多态。而运行时多态是动态的,它是通…

    2022年7月8日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号