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)
for?
Sorry if it's a dumb question and the answers will be appreciated.
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 logical indexing.
In this approach you create a logical matrix, the same size as image_map
and then you can access all the extrines in image_map
for which the locial matrix has the value true
.