Adaptive Mean Thresholding X66117


Statement
 

pdf   zip

html

Input

The number of lines of the input depends on the size of the image, but it always follows the same structure: * First line is the number of rows of the input image. * Second line is the number of columns of the input image. * The following lines correspond to the input image. * Finally, the last line is the size of the window. This must be an odd value.

Output

The output is the thresholded image.

Public test cases
  • Input

    5
    5
    7 5 8 4 7 
    3 6 5 5 1 
    9 3 8 8 9 
    2 4 9 1 1 
    4 4 1 4 9
    5

    Output

    1 1 1 1 1 
    1 1 1 1 0 
    1 0 1 1 1 
    1 1 1 0 0 
    1 1 0 1 1
  • Input

    4
    6
    2 4 6 8 10 20
    2 4 6 8 10 20
    2 4 6 8 10 20
    2 4 6 8 10 20
    3

    Output

    1 1 1 1 1 1 
    1 1 1 1 0 1 
    1 1 1 1 0 1 
    1 1 1 1 1 1
  • Input

    5
    20
    212 91 23 60 94 76 10 93 28 163 186 21 133 75 84 179 208 46 106 92
    80 14 4 251 166 210 241 34 93 78 205 241 143 251 161 235 181 89 73 214
    138 113 59 154 19 175 241 128 25 218 20 31 235 74 105 78 198 236 185 41
    17 143 16 122 32 241 23 183 208 239 119 180 246 20 147 137 219 97 187 95
    68 247 129 204 45 186 35 159 255 17 175 206 14 92 122 172 70 130 120 158
    7

    Output

    1 1 0 0 1 1 0 1 0 1 1 0 1 0 1 1 1 0 1 1 
    1 0 0 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 
    1 1 0 1 0 1 1 1 0 1 0 0 1 0 1 0 1 1 1 0 
    0 1 0 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 
    1 1 1 1 0 1 0 1 1 0 1 1 0 1 1 1 0 1 1 1
  • Information
    Author
    HP CodeWars
    Language
    English
    Official solutions
    Python
    User solutions
    C++ Python