Problem of large adjacency matrix

3 views (last 30 days)
Mourchid
Mourchid on 11 Oct 2015
Edited: Mourchid on 11 Oct 2015
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.

Answers (2)

John D'Errico
John D'Errico on 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.

Walter Roberson
Walter Roberson on 11 Oct 2015
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 Comment
Mourchid
Mourchid on 11 Oct 2015
Edited: Mourchid on 11 Oct 2015
Thank you Wlater Roberson for your respense, can you please give me the matlab code to doing it. for example i have the matlab code:
I=imread(Myimage); what i will do after ?

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!