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)
上一篇 2022年6月13日 上午8:16
下一篇 2022年6月13日 上午8:16


相关推荐

  • jmap使用详解_jmap作用

    jmap使用详解_jmap作用1. jmap-heappid     查看Java 堆(heap)使用情况       usingthread-localobjectallocation.       ParallelGCwith4thread(s)         //GC方式        HeapConfiguration:      //堆内存初始化配置      …

    2025年7月23日
    10
  • 实测TMG结合Bandwidth Splitter限制带宽与流量

    实测TMG结合Bandwidth Splitter限制带宽与流量

    2021年8月20日
    50
  • android+号码归属地数据库,Android手机号码归属地的查询「建议收藏」

    android+号码归属地数据库,Android手机号码归属地的查询「建议收藏」一个简单的Demo,从聚合数据申请手机号码归属地数据接口;在EditText中输入待查询号码,获取号码后在子线程中使用HttpUrlconnection获取JSON数据,之后进行解析;数据获取完成后,在主线程中更新UI,显示获取的号码归属地信息。布局文件android:layout_width=”match_parent”android:layout_height=”match_parent”an…

    2022年7月22日
    13
  • Python 遍历数组的方法

    Python 遍历数组的方法1 使用 forinpeople 李白 杜甫 我 forpeoinpeop print peo 2 使用 rangepeople 李白 杜甫 我 foriinrange 0 len people print people i

    2026年3月17日
    2
  • PyQuery笔记

    PyQuery笔记1、初始化1.1、字符串初始化frompyqueryimportPyQueryaspyhtml=”’<div>  <ul>    <liclass="item-0">firstitem</li>    <liclass="item-1"><ahref="htt

    2022年4月29日
    42
  • PINN学习记录(2)

    PINN学习记录(2)PINN 学习记录 2 PINN 基于解物理的方程的应用 所以我自己学习了一段时间 参考了网上很多的开源项目 末尾会贴出一些 自己总结了一下思路解微分方程 1 ODEf x f x f x f x f x f x f 0 1f 0 1f 0 1 网络构造这里说明一下 之后用 nn module 来解决 这只是建立一个通用网络 importtorchi nnasnnimport nn Module

    2025年6月11日
    4

发表回复

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

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