How to find non zeros in multiple matrices ?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
fish minox
el 3 de Ag. de 2017
Respondida: fish minox
el 3 de Ag. de 2017
Hi,
I have an issue with my program :
Basically I have a stack of 20 images (555*555 pixels each) and I want to record the coordinates of a bright object on each image. For that, I use the function imbinarize that returns a 555*555 matrix of 0 (backgroud) and 1 (bright object). I have now a Bin=555*555*20 matrix with all the 0 and 1 of my 20 images.
My problem is that when I use the find fuction : [a,b]=find(Bin(:,:,1:20)==1); it works for the variable a that gives me all the y (horizontal) coordinates that have 1 for value but the value b only works for the first image (for the other images b is superior to 555 which is normally the maximal coordinate !).
Can you please help me with that ?
Thanks a lot
0 comentarios
Respuesta aceptada
Jakub
el 3 de Ag. de 2017
Variable b holds linear indices corresponding to second and third dimension. That's why it exceeds the size of array. A possible solution is to use linear indexing from start followed by ind2sub:
k = find(Bin(:,:,1:20)==1);
[a,b,nimage] = ind2sub(size(Bin),k);
0 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Geometric Transformation and Image Registration en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!