Matlab `imagen (imagen) = -1`? [cerrado]

I'm really new at matlab and I'm trying to understand this piece of code:

mask = false(size(image_map));
image_map(mask) = -1;

I understand that the first line is to create an array of logical zeros that is the same size as image_map, but what is this image_map(mask) para?

Sorry if it's a dumb question and the answers will be appreciated.

preguntado el 05 de mayo de 13 a las 10:05

since mask is an array of logical zeros, the next line is yields an empty matrix because the index must be a positive integer or logical in the sense of Shai's answer -

1 Respuestas

In matlab you may access entries of a matrix is several ways. One is by linear indexing:

image_map( 4 ) % access the fourth element of image_map

However, there is a more efficient way, using indexación lógica.
In this approach you create a logical matrix, el mismo tamaño as image_map and then you can access all the extrines in image_map for which the locial matrix has the value true.

contestado el 05 de mayo de 13 a las 10:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.