out of memory with [c,s]=wavedec2()

i apply wavelet transform for MP4 video, already i read the video and divide it to frames and divide each frame to each color channel and each color channel to 512*512 blocks, and apply wavedec2 to each block. how solve out of memory error in [c,s]=wavedec2(img,4,db2)?? the error exactly is:
??? Error using ==> conv2
Out of memory. Type HELP MEMORY for your options.
Error in ==> dwt2 at 94
z = conv2(y,Hi_D(:)','valid');
Error in ==> wavedec2 at 66
[x,h,v,d] = dwt2(x,Lo_D,Hi_D); % decomposition
Error in ==> WaveletTransform at 21
[C,S]=wavedec2(img,nLevel,wname);
also it shouldn't have problem with AVI video. my MP4 video is short and 2 sec.

Réponses (1)

Wayne King
Wayne King le 27 Oct 2013

0 votes

Are you saying that wavedec2() throws a memory error on a single call with a 512x512?
For example, this does not cause a memory issue:
X = randn(512,512);
[C,S] = wavedec2(X,4,'db2');
Are you sure that you are not somehow aggregating data in your img variable so that it is growing in your WavletTransform script?

3 commentaires

roya
roya le 27 Oct 2013
Modifié(e) : roya le 27 Oct 2013
in fact i am using wavedec2() in nested loop which in each iteration it is applied for a block...i can show you here this part of my code:
for k=1:c
for i=1:nbw
for j=1:nbh
img=im2double(Blocks{nFrame}{k}{i}{j});
[C,S]=wavedec2(img,nLevel,wname);
CS{nFrame}{k}{i}{j}{1}=C;
CS{nFrame}{k}{i}{j}{2}=S;
A=appcoef2(C,S,wname,nLevel);
W{nFrame}{k}{i}{j}{1}=A;
for ii=1:nLevel
[H,V,D]=detcoef2('all',C,S,ii);
W{nFrame}{k}{i}{j}{(nLevel-ii+1)*3-1}=H;
W{nFrame}{k}{i}{j}{(nLevel-ii+1)*3}=V;
W{nFrame}{k}{i}{j}{(nLevel-ii+1)*3+1}=D;
end
end
end
if true
% code
end
roya
roya le 27 Oct 2013
also i use the limited number of frames for example i assign "maxnumframe=10", but it doesn't work and same error. this code is ok for AVI video but not for MP4 video...:(

Connectez-vous pour commenter.

Question posée :

le 27 Oct 2013

Commenté :

le 27 Oct 2013

Community Treasure Hunt

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

Start Hunting!

Translated by