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
John D'Errico 2015 年 10 月 11 日

0 投票

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 件のコメント

Mourchid
Mourchid 2015 年 10 月 11 日
So? there is a solution for that ??

サインインしてコメントする。

Walter Roberson
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 件のコメント

Mourchid
Mourchid 2015 年 10 月 11 日
編集済み: Mourchid 2015 年 10 月 11 日
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 ?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

質問済み:

2015 年 10 月 11 日

編集済み:

2015 年 10 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by