Problem of large adjacency matrix
이전 댓글 표시
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.
답변 (2개)
John D'Errico
2015년 10월 11일
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
2015년 10월 11일
0 개 추천
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
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!