Convert a 3D image array into a cell array
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I know this will be basic for an experienced Matlab user but what I'm trying to do is convert an image stack, say a [mxnXp] matrix where p is the indexing dimension into a [px1] cell array.
My motivation for doing this originally was because I wanted to check to see which 'frames' of my image array were blank, i.e. equal to zeros(m,n).
I tried to use something like the following:
indices = find(arrayfun(@(IDX) ~isequal(IDX), isequal(imstack, zeros(size(imstack,1),size(imstack,2)))));
however this didn't work since imstack is a 3D matrix (at least this is why I suspect it didn't work)
To remedy I thought to convert imstack to a px1 cell array, with the view to using a 'cellfun' version of the above. And this is where I got stuck converting imstack to a cell array.
Any suggestions would be appreciated.
Thank you.
n
0 Commenti
Risposta accettata
Più risposte (1)
Matt J
il 29 Set 2012
Modificato: Matt J
il 29 Set 2012
A more efficient approach than the for-loop would be
blank=~any(reshape(M,[],p),1);
Also, to put the slices of an array into cells, you can use this FEX file
In your case, this would look like
Mcell=mat2tiles(M,[inf,inf,1]);
Mcell=Mcell(:); %make px1
0 Commenti
Vedere anche
Categorie
Scopri di più su Cell Arrays 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!