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 CenterFile Exchange에서 Scopes and Data Logging에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by