How to get the binary value inside the binary image?
Mostrar comentarios más antiguos
How to extract the binary values inside the binary image into a set of array?
For example:
h = { 0 1 1 0 1 1 0 0 0 1 1 0 1 0 }
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 8 de Ag. de 2012
Editada: Image Analyst
el 8 de Ag. de 2012
The binary data is already in an array - a cell array, as we can tell from the braces. I'm not sure how it got into a cell array in the first place, but anyway, to get it into a regular numerical array (a double), try this:
h = { 0 1 1 0 1 1 0 0 0 1 1 0 1 0 }
h_matrix = cell2mat(h)
To extract certain elements, just index it. For example, let's say you want elements 3 through 5. Then do this
subMatrix = h_matrix(3:5)
If you have a numerical array already (unlike the cell array that you gave as an example), and you want to convert it to a logical (binary) array, you can threshold. For example to set all values above some threshold value to true (1) and lower to false (0), you can do this:
thresholdValue = 127; % Or whatever value you want.
binaryArray = yourMatrix > thresholdValue;
2 comentarios
Wei Qing
el 8 de Ag. de 2012
Image Analyst
el 8 de Ag. de 2012
This doesn't make sense. How on earth did you get numbers from nothing? Did you use a random integer generator, like randi()?
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!