How to find non zeros in multiple matrices ?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Jakub
il 3 Ago 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 Commenti
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Geometric Transformation and Image Registration in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!