matlab code not working for 64x64 dct block
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Image Analyst
il 15 Giu 2015
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
il 16 Giu 2015
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]
Risposte (1)
Walter Roberson
il 15 Giu 2015
The code finishes in a small number of seconds when I try it.
5 Commenti
Joseph Cheng
il 15 Giu 2015
Modificato: Joseph Cheng
il 15 Giu 2015
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
il 17 Giu 2015
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));
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!