Problem to Threshold a Matrix
Mostrar comentarios más antiguos

I need to threshold the surrounding pixels of the given matrix with respect to the centre pixel of the given matrix. If the surrounding values are greater than or equal to the center of the pixel they are given a 1 otherwise they are given a 0. Then I need to store all the values in the shown order to result in a vector which contains the binary value.
2 comentarios
James Tursa
el 12 de Abr. de 2017
Have you tried coding this? What problems are you having? Not working, or too slow, or ???
CharlesB
el 12 de Abr. de 2017
Respuesta aceptada
Más respuestas (1)
James Tursa
el 12 de Abr. de 2017
Editada: James Tursa
el 12 de Abr. de 2017
Using your small example:
>> x = 2;
>> y = 2;
>> matrix = [ 85 99 21; 54 54 86; 57 12 13]
matrix =
85 99 21
54 54 86
57 12 13
>> t = matrix >= matrix(y,x)
t =
1 1 0
1 1 1
1 0 0
>> b = [t(y,x-1) t(y+1,x-1:x+1) t(y,x+1) t(y-1,x+1:-1:x-1)]
b =
1 1 0 0 1 0 1 1
>> d = sum(b.*2.^(7:-1:0))
d =
203
1 comentario
CharlesB
el 13 de Abr. de 2017
Categorías
Más información sobre Graph and Network Algorithms en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
