Problem of large adjacency matrix
Afficher commentaires plus anciens
Hi,
I need to deal with a very large adjacency matrix in Matlab, i have a image matrix of size 321x481, and i want te generate the adjacency matrix from this image, its size is 321*481 x 321*481, but matlab give the message error Out of memory, can anybody give me a solution o that. My code is like that:
I= imread(Myimage);
A= Adjaceny_Matrix(I);
My treatement
Thank a Lot.
Réponses (2)
John D'Errico
le 11 Oct 2015
Just wanting to solve a large problem is not enough.
You lack sufficient memory. What is the size of that matrix?
321*481 * 321*481*8
ans =
1.9072e+11
So roughly 190 GIGABYTES of memory. Be careful not to make a copy of that matrix along the way too.
Computers are not infinitely large or infinitely fast.
1 commentaire
Mourchid
le 11 Oct 2015
Walter Roberson
le 11 Oct 2015
0 votes
You can use a sparse() array. Each entry is connected to 8 others if you are using standard 8-connectivity and you should be able to fit that easily.
However I recommend you reconsider whether you really need the adjacency matrix. For any one entry, the connected elements can be calculated fairly easily: for logical index K on the interior of the matrix, the logical index of the entry "above" is K-1, below is K+1, left is K-321, right is K+321, and diagonals are K-322, K+320, K-320, K+322 . With the connections easily calculated it does not seem appropriate to use a lot of memory to store them.
1 commentaire
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!