algorithm - Bradley Adaptive Thresholding -- Confused (questions) -
algorithm - Bradley Adaptive Thresholding -- Confused (questions) -
i have questions, stupid, implementation of adaptive thresholding bradley. have read paper http://people.scs.carleton.ca:8008/~roth/iit-publications-iti/docs/gerh-50002.pdf , bit confused. statement:
if ((in[i,j]*count) ≤ (sum*(100−t)/100))
let's assume have input:
width, [0] [1] [2] +---+---+---+ height [0] | 1 | 2 | 2 | j +---+---+---+ [1] | 3 | 4 | 3 | +---+---+---+ [2] | 5 | 3 | 2 | +---+---+---+
and let's that:
s = 2 s/2 = 1 t = 15 = 1 j = 1 (we @ center pixel)
so means have window 3x3, right? then:
x1 = 0, x2 = 2, y1 = 0, y2 = 2
what count then? if number of pixels in window, why 2*2=4, instead of 3*3=9 according algorithm? further, why original value of pixel multiplied count?
the paper says value compared average value of surrounding pixels, why isn't
in[i,j] <= (sum/count) * ((100 - t) / 100)
then?
can please explain me? stupid question can't figure out.
before start, let's nowadays pseudocode of algorithm written in paper:
procedure adaptivethreshold(in,out,w,h) 1: = 0 w 2: sum ← 0 3: j = 0 h 4: sum ← sum+in[i, j] 5: if = 0 6: intimg[i, j] ← sum 7: else 8: intimg[i, j] ← intimg[i−1, j] +sum 9: end if 10: end 11: end 12: = 0 w 13: j = 0 h 14: x1 ← i−s/2 {border checking 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) 21: out[i, j] ← 0 22: else 23: out[i, j] ← 255 24: end if 25: end 26: end
intimg
integral image of input image threshold, assuming grayscale.
i've implemented algorithm success, let's talk doubts.
what count
then? if number of pixels in window, why 2*2=4, instead of 3*3=9 according algorithm?
there underlying assumption in paper don't talk about. value of s
needs odd, , windowing should be:
x1 = - floor(s/2) x2 = + floor(s/2) y1 = j - floor(s/2) y2 = j + floor(s/2)
count
total number of pixels in window, need create sure don't go out of bounds. have there should 3 x 3 window , s = 3
, not 2. now, if s = 3
, if take i = 0, j = 0
, have x
, y
values negative. can't have , total number of valid pixels within 3 x 3 window centred @ i = 0, j = 0
4, , count = 4
. windows within bounds of image, count
9.
further, why original value of pixel multiplied count? paper says value compared average value of surrounding pixels, why isn't:
in[i,j] <= (sum/count) * ((100 - t) / 100)
then?
the status you're looking @ at line 20 of algorithm:
20: (in[i, j]×count) ≤ (sum×(100−t)/100)
the reason why take @ in[i,j]*count
because assume in[i,j]
average intensity within s x s
window. therefore, if examined s x s
window , added of intensities, equal in[i,j] x count
. algorithm quite ingenious. basically, compare assumed average intensity (in[i,j] x count
) within s x s
window , if less t%
of actual average within s x s
window (sum x ((100-t)/100)
), output set black. if larger, output set white. however, have eloquently stated should instead:
in[i,j] <= (sum/count) * ((100 - t) / 100)
this same line 20, divided both sides of equation count
, it's still same expression. explicitly states talked above. multiplication count
confusing, , have written makes more sense.
therefore, you're seeing different way, , that's totally fine! reply question, have stated right , equivalent look seen in actual algorithm.
hope helps!
algorithm image-processing adaptive-threshold
Comments
Post a Comment