################# ############# ################## ################ ################### ################## ######## ####### ################### ###### ################ ###### ###### ############### ################# ####### ################ ####### ################# ####### ###### ############### ###### ############### ###### ################ ###### ######## ####### ################### ######## ####### ######################## ###### ######## ####### ###################### ###### ######## ####### ##########################Produce la salida adelgazada:
# ########## ####### ## # #### # # # ## # # # # # # # # # ############ # # # # # # # # # # # # # # ## # ############ ### ### </pre>
Algoritmo
Suponga que los píxeles negros son uno y los píxeles blancos cero, y que la imagen de entrada es una matriz rectangular N por M de unos y ceros. El algoritmo opera en todos los píxeles negros P1 que pueden tener ocho vecinos. Los vecinos están, en orden, dispuestos como:
P9 | P2 | P3 |
P8 | P1 | P4 |
P7 | P6 | P5 |
Define $A(P1)$ = the number of transitions from white to black, (0 -> 1) in the sequence P2,P3,P4,P5,P6,P7,P8,P9,P2. (Note the extra P2 at the end - it is circular). Define $B(P1)$ = the number of black pixel neighbours of P1. ( = sum(P2 .. P9) )
Tarea: Escriba una rutina para realizar el adelgazamiento de Zhang-Suen en una matriz de imágenes de unos y ceros.
thinImage
debe ser una función
testString: 'assert.equal(typeof thinImage, "function", "thinImage
must be a function");'
- text: thinImage
debe devolver una matriz
testString: 'assert(Array.isArray(result), "thinImage
must return an array");'
- text: thinImage
debe devolver una serie de cadenas
testString: 'assert.equal(typeof result[0], "string", "thinImage
must return an array of strings");'
- text: thinImage
debe devolver una serie de cadenas
testString: 'assert.deepEqual(result, expected, "thinImage
must return an array of strings");'
```