matlab code not working for 64x64 dct block

8 ビュー (過去 30 日間)
pragyan bisoyi
pragyan bisoyi 2015 年 6 月 12 日
コメント済み: Walter Roberson 2015 年 6 月 17 日
I have implemented 2d dct code which is working for (4x4 ,8x8,16x16)block but its not working for 64x64 block ,in matlab its showing busy for more than 1 hour,what changes i should do to get the desired result.
for N = [8];
C = zeros(N,N);
for m = 0:1:N-1
for n = 0:1:N-1
if n == 0
k = sqrt(1/N);
else
k = sqrt(2/N);
end
C(m+1,n+1) = k*cos( ((2*m+1)*n*pi) / (2*N));
end
end
% Get Basis Functions
figure;
colormap('gray');
for m = 0:1:N-1
for n = 0:1:N-1
subplot(N,N,m*N+n+1);
Y = [zeros(m,N);
zeros(1,n) 1 zeros(1,N-n-1);
zeros(N-m-1,N)];
X = C*Y*C';
imagesc(X);
axis square;
axis off;
end
end
end
Please help i m trying a lot.
  2 件のコメント
Image Analyst
Image Analyst 2015 年 6 月 15 日
What's the point of this for loop:
for N = [8];
.....
end
You don't need a for loop to execute just one time with N=8. Just set N=8, and don't have a for loop.
Joseph Cheng
Joseph Cheng 2015 年 6 月 16 日
What i take out of the for N= [8] is that this person was looking to perform this section of code on for N=[2 4 8 16 ... 64]

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

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 6 月 15 日
The code finishes in a small number of seconds when I try it.
  5 件のコメント
Joseph Cheng
Joseph Cheng 2015 年 6 月 15 日
編集済み: Joseph Cheng 2015 年 6 月 15 日
Walter the code above works fine but the problem is going up and up for N=64 such that the block of data is 64x64. the code above is the 8x8 case (line 1)
Walter Roberson
Walter Roberson 2015 年 6 月 17 日
Ah yes, it does take a long time to build the 4096 individual plots.
The C matrix generation could obviously be optimized some, but that probably does not matter compared to the plot time.
[mg, ng] = ngrid(0:1:N-1);
k = sqrt(2/N);
C = k .* cos( ((2*mg+1) .* ng .* pi) ./ (2*N));
C(:,1) = C(:,1) ./ sqrt(2);
That is, build it all using the larger k, and then correct the first column which is now sqrt(2) too large. k*cos( ((2*m+1)*n*pi) / (2*N));

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

カテゴリ

Help Center および File ExchangeScopes and Data Logging についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by