<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Le 17/08/2012 20:29, <a class="moz-txt-link-abbreviated" href="mailto:tvitklg@rambler.ru">tvitklg@rambler.ru</a>
a écrit :<br>
</div>
<blockquote
cite="mid:1345228164.512773.31919.54484@saddam3.rambler.ru"
type="cite">
<p>Hello. Whether there is a function Discrete cosine transform
(DCT)? </p>
<p> </p>
<p><a class="moz-txt-link-abbreviated" href="mailto:tvitklg@rambler.ru">tvitklg@rambler.ru</a></p>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.scilab.org">Users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
Please find below the dct and idct scilab code:<br>
<br>
function y = dct (x,flag)<br>
//Ref: A. K. Jain, "Fundamentals of Digital Image Processing", pp.
150-153.<br>
[mx,nx]=size(x);<br>
if argn(2)==1 then flag=-1,end<br>
if size(x,1)==1 then <br>
//transform x as a column vector<br>
x=matrix(x,-1,1);<br>
n=mx*nx;<br>
nc=1;<br>
else<br>
n=mx;<br>
nc=nx<br>
end<br>
if n==1 then y=matrix(y,mx,nx),return,end<br>
if flag==-1 then<br>
w=[sqrt(0.25/n);sqrt(0.5/n)*exp((-%i*%pi/2/n)*(1:n-1)')]*ones(1,nc);<br>
if isreal(x)&modulo(n,2)==0 then<br>
y=2*real(w.*fft([x(1:2:n,:); x(n:-2:2,:)],flag,1));<br>
else<br>
y=fft([x;x($:-1:1,:)],flag,1);<br>
y=w.*y(1:n,:);<br>
if isreal(x) then y=real(y); end<br>
end<br>
else //inverse transform<br>
if isreal(x)&modulo(n,2)==0 then<br>
w =
[sqrt(n/4);sqrt(n/2)*exp((%i*%pi/2/n)*(1:n-1)')]*ones(1,nc);<br>
y=fft(w.*x,flag,1);<br>
y([1:2:n,n:-2:1],:)=2*real(y);<br>
else<br>
w =
[sqrt(4*n);sqrt(2*n)*exp((%i*%pi/2/n)*(1:n-1)')]*ones(1,nc);<br>
y=[x.*w;zeros(1,nc);-%i*w(2:$,:).*x($:-1:2,:)];<br>
y=fft([x.*w;zeros(1,nc);-%i*w(2:$,:).*x($:-1:2,:)],flag,1);<br>
y=y(1:n,:);<br>
if isreal(x) then y=real(y); end<br>
end<br>
end<br>
y=matrix(y,mx,nx);<br>
endfunction<br>
function y=idct(x)<br>
y=dct(x,1)<br>
endfunction<br>
<br>
<br>
Serge Steer<br>
INRIA<br>
</body>
</html>