From: astro mmi on 28 Apr 2010 14:11 Hi everyone, This is how I am trying to inplement the dct2 function using the equation for dct. I am not able to understand why the program runs into an infinite loop when i execute the code. Pls let me know where the error is and how I can enhance the speed of the program... Also I see that when I reduce the size of the image, it works and i am getting the dct.........which implies my for loops are running too long...........pls let me know how this efficiency can be enhanced and how my code can be made to run faster....... Thanx in advance i=imread('p_6_1.jpg'); > figure,imshow(i) > title('Original image') > > %To evaluate Discrete Cosine Transform > siz=size(i); > a=zeros(1,siz(1)); > b=zeros(1,siz(1)); > c=zeros(siz(1),siz(2)); > for x=1:siz(1) > for y=1:siz(2) > for u=1:siz(1) > for v=1:siz(2) > if(u==1) > a(u)=sqrt(1/siz(1)); > else > a(u)=sqrt(2/siz(1)); > end > b=a; > c(u,v)=a(u)*b(v)*sum(sum(i(x,y)*cos(((2*x+1)*pi*u)/(2*siz(1)))*cos(((2*y+1)*pi*v)/(2*siz(1))))); > end > end > end > end
|
Pages: 1 Prev: reg error msg Next: Fast calculation of velocity from x & y data |