布拉德利自适应阈值 - 迷茫(问题) [英] Bradley Adaptive Thresholding -- Confused (questions)

查看:264
本文介绍了布拉德利自适应阈值 - 迷茫(问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题,可能是愚蠢的,对自适应阈值由布拉德利的实施。我读过一篇关于它的 HTTP: //people.scs.carleton.ca:8008/~roth/iit-publications-iti/docs/gerh-50002.pdf 和我有点糊涂了。主要是对本声明:

I have some questions, probably stupid, about the implementation of the adaptive thresholding by Bradley. I have read paper about it http://people.scs.carleton.ca:8008/~roth/iit-publications-iti/docs/gerh-50002.pdf and I am a bit confused. Mainly about this statement:

if ((in[i,j]*count) ≤ (sum*(100−t)/100)) then

让我们假设,我们有这个输入:

Let's assume that we have this input:

            width, i
            [0] [1] [2]
           +---+---+---+
height [0] | 1 | 2 | 2 |
j          +---+---+---+
       [1] | 3 | 4 | 3 |
           +---+---+---+
       [2] | 5 | 3 | 2 |
           +---+---+---+

和我们说:

s = 2
s/2 = 1
t = 15
i = 1
j = 1 (we are at the center pixel)

因此​​,这意味着我们有一个3×3的窗口,对不对?然后:

So that means we have a window 3x3, right? Then:

x1 = 0, x2 = 2, y1 = 0, y2 = 2

什么是的计数的呢?如果它是在窗口的像素的数,它为什么2 * 2 = 4,而不是3 * 3 = 9根据算法?另外,为什么在像素的原始值乘以计数?

What is count then? If it is number of pixels in the window, why it is 2*2=4, instead of 3*3=9 according to the algorithm? Further, why is the original value of the pixel multiplied by the count?

,全文说,值与周围像素的平均值,它为什么不

The paper says that the value is compared to the average value of surrounding pixels, why it isn't

in[i,j] <= (sum/count) * ((100 - t) / 100)

呢?

能否有人请给我讲解一下?这可能是非常愚蠢的问题,但我不明白。

Can somebody please explain this to me? It is probably very stupid question but I can't figure it out.

推荐答案

在我们开始之前,让我们present写在他们的论文算法的伪code:

Before we start, let's present the pseudocode of the algorithm written in their paper:

procedure AdaptiveThreshold(in,out,w,h)
1: for i = 0 to w do
2:     sum ← 0
3:     for j = 0 to h do
4:         sum ← sum+in[i, j]
5:         if i = 0 then
6:             intImg[i, j] ← sum
7:         else
8:             intImg[i, j] ← intImg[i−1, j] +sum
9:         end if
10:     end for
11: end for
12: for i = 0 to w do
13:     for j = 0 to h do
14:         x1 ← i−s/2 {border checking is not shown}
15:         x2 ← i+s/2
16:         y1 ← j −s/2
17:         y2 ← j +s/2
18:         count ← (x2−x1)×(y2−y1)
19:         sum ← intImg[x2,y2]−intImg[x2,y1−1]−intImg[x1−1,y2] +intImg[x1−1,y1−1]
20:          if (in[i, j]×count) ≤ (sum×(100−t)/100) then
21:              out[i, j] ← 0
22:          else
23:              out[i, j] ← 255
24:          end if
25:     end for
26: end for

intImg 积分图像将输入图像的阈值,假设灰度的

intImg is the integral image of the input image to threshold, assuming grayscale.

我实现了这个算法的成功,让我们来谈谈你的疑惑。

I've implemented this algorithm with success, so let's talk about your doubts.

什么是计数呢?如果是象素的窗口数,为什么它是2 * 2 = 4,而不是3 * 3 = 9根据算法

What is count then? If it is number of pixels in the window, why it is 2*2=4, instead of 3*3=9 according to the algorithm?

有一个在他们不谈论论文的基本假设。值取值 需要为奇数,且窗口应该是:

There is an underlying assumption in the paper that they don't talk about. The value of s needs to be odd, and the windowing should be:

x1 = i - floor(s/2)
x2 = i + floor(s/2)
y1 = j - floor(s/2)
y2 = j + floor(s/2)

计数肯定是在窗口的像素的总数,但你还需要确保你不要去出界。你有什么应该肯定是一个3×3窗等 S = 3 ,而不是2。现在,如果 S = 3 ,但如果我们要选择 I = 0,J = 0 ,我们将有 X 值是。我们不能让这一点,所以有效像素这3×3窗口集中在 I = 0,J = 0 4,所以在总数数= 4 。对于windows是图像的范围内,那么计数将是9。

count is certainly the total number of pixels in the window, but you also need to make sure that you don't go out of bounds. What you have there should certainly be a 3 x 3 window and so s = 3, not 2. Now, if s = 3, but if we were to choose i = 0, j = 0, we will have x and y values that are negative. We can't have this and so the total number of valid pixels within this 3 x 3 window centred at i = 0, j = 0 is 4, and so count = 4. For windows that are within the bounds of the image, then count would be 9.

另外,为什么在像素的原始值乘以计数?文章说的值与周围像素的平均值,为什么它不是

Further, why is the original value of the pixel multiplied by the count? The paper says that the value is compared to the average value of surrounding pixels, why it isn't:

   in[i,j] <= (sum/count) * ((100 - t) / 100)

     

呢?

then?

您正在寻找的条件是在算法的第20行:

The condition you're looking at is at line 20 of the algorithm:

20: (in[i, j]×count) ≤ (sum×(100−t)/100)

在为什么我们一起来看看的原因[I,J] *计数是因为我们假定的[I,J] 平均的SxS 窗口内的强度。因此,如果我们检查了的SxS 窗口,并添加了所有的强度,这是等于的[I,J]×计数。该算法是相当巧妙。基本上,我们(在[I,J]×计数 )比较的SxS 窗口中,如果假设平均强度这是不到 T%实际平均此的SxS 窗内(总和×((100-T)/ 100)),然后将输出设置为黑色。如果它较大,比输出被设定为白色。但是,你已经雄辩地指出,它应该是这样:

The reason why we take a look at in[i,j]*count is because we assume that in[i,j] is the average intensity within the s x s window. Therefore, if we examined a s x s window and added up all of the intensities, this is equal to in[i,j] x count. The algorithm is quite ingenious. Basically, we compare the assumed average intensity (in[i,j] x count) within the s x s window and if this is less than t% of the actual average within this s x s window (sum x ((100-t)/100)), then the output is set to black. If it is larger, than the output is set to white. However, you have eloquently stated that it should be this instead:

in[i,j] <= (sum/count) * ((100 - t) / 100)

这是基本相同的线20条,但您可以通过除以等式两边计数,所以它仍然是相同的前pression。我会说,这明确规定我上面所讲的。通过计数乘法肯定是混乱的,所以你写了什么更有意义。

This is essentially the same as line 20, but you divided both sides of the equation by count, so it's still the same expression. I would say that this explicitly states what I talked about above. The multiplication by count is certainly confusing, and so what you have written makes more sense.

所以,你只是看到它以不同的方式,这是完全正常!因此,要回答你的问题,你有什么说当然是正确的,相当于前pression看出,在实际的算法。

Therefore, you're just seeing it a different way, and that's totally fine! So to answer your question, what you have stated is certainly correct and is equivalent to the expression seen in the actual algorithm.

希望这有助于!

这篇关于布拉德利自适应阈值 - 迷茫(问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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