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月18日
    34
  • 游戏建模经验分享:模型学习方法

    游戏建模经验分享:模型学习方法最近通过很多师弟的交流,我发现游戏建模初学者大多存在三个大问题,一是工具的使用不够熟练,甚至有些功能还不知道,二是对布线的规范没有太大的要求和了解,三是对游戏制作流程不清晰和板绘下的功力不够,对贴图制作用工少,甚至有些人还处于一直做白膜的阶段,那么对大多说想要要学游戏建模的学习者想要学什么:低模,高模制作,贴图材质,动作特效。毕竟很多人学的并没有那么快,建模实质就是孰能生巧,做的东西…

    2022年5月19日
    35
  • strictmode android,Android StrictMode使用「建议收藏」

    strictmode android,Android StrictMode使用「建议收藏」StrictMode是Android提供的一个开发工具,用于检测一些异常的操作,以便开发者进行修复。StrictMode可以监控以下问题,不应该在应用主线程中完成的工作,包括磁盘读写、网络访问等。内存泄露,包括Activity泄露、SQLite泄露、未正确释放的对象等。使能StrictMode通常在Application和Activity的开始处(如onCreate)添加代码使能StrictMod…

    2022年5月2日
    99
  • http://extasp.net/ 浴火重生

    http://extasp.net/ 浴火重生

    2021年8月1日
    55
  • jax-ws 生成soap_使用JAX-WS创建SOAP Web服务

    jax-ws 生成soap_使用JAX-WS创建SOAP Web服务本文中显示的Web服务已在此处实时部署。有多种创建Web服务的方法。在本文中,我们将使用JAX-WS创建基于SOAP的Web服务,该服务是XMLWebServices的JavaAPI,并将其部署在Tomcat下。要记住的重要一点是,可以使用JAX-WS构建SOAP和REST样式的Web服务。有一个常见的误解,即JAX-WS用于创建基于SOAP的Web服务,而JAX-R…

    2022年7月15日
    13
  • idea202112激活码永久【永久激活】

    (idea202112激活码永久)JetBrains旗下有多款编译器工具(如:IntelliJ、WebStorm、PyCharm等)在各编程领域几乎都占据了垄断地位。建立在开源IntelliJ平台之上,过去15年以来,JetBrains一直在不断发展和完善这个平台。这个平台可以针对您的开发工作流进行微调并且能够提供…

    2022年3月21日
    96

发表回复

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

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