* Bug #8431: eval3d() set obsolete
[scilab.git] / scilab / modules / signal_processing / help / ja_JP / transforms / dct.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 1997   - INRIA
5 * Copyright (C) 2012 - Serge Steer - INRIA
6 *
7  * Copyright (C) 2012 - 2016 - Scilab Enterprises
8  *
9  * This file is hereby licensed under the terms of the GNU GPL v2.0,
10  * pursuant to article 5.3.4 of the CeCILL v.2.1.
11  * This file was originally licensed under the terms of the CeCILL v2.1,
12  * and continues to be available under such terms.
13  * For more information, see the COPYING file which you should have received
14  * along with this program.
15 *
16 -->
17 <refentry xmlns="http://docbook.org/ns/docbook"
18           xmlns:xlink="http://www.w3.org/1999/xlink"
19           xmlns:svg="http://www.w3.org/2000/svg"
20           xmlns:mml="http://www.w3.org/1998/Math/MathML"
21           xmlns:db="http://docbook.org/ns/docbook"
22           xmlns:scilab="http://www.scilab.org" xml:lang="ja" xml:id="dct">
23     <refnamediv>
24         <refname>dct</refname>
25         <refpurpose>離散コサイン変換.</refpurpose>
26     </refnamediv>
27     <refnamediv xml:id="idct">
28         <refname>idct</refname>
29         <refpurpose>逆離散コサイン変換.</refpurpose>
30     </refnamediv>
31     <refsynopsisdiv>
32         <title>呼び出し手順</title>
33         <synopsis>X=dct(A [,sign] [,option])
34             X=dct(A,sign,selection [,option])
35             X=dct(A,sign,dims,incr [,option])
36             X=idct(A [,option])
37             X=idct(A,selection [,option])
38             X=idct(A,dims,incr [,option])
39         </synopsis>
40     </refsynopsisdiv>
41     <refsection>
42         <title>引数</title>
43         <variablelist>
44             <varlistentry>
45                 <term>A</term>
46                 <listitem>
47                     <para>実数/複素ベクトルまたは実数/複素配列
48                         (ベクトル, 行列または N-D 配列).
49                     </para>
50                 </listitem>
51             </varlistentry>
52             <varlistentry>
53                 <term>X</term>
54                 <listitem>
55                     <literal>A</literal>と同じ大きさの
56                     実数または複素配列.
57                 </listitem>
58             </varlistentry>
59             <varlistentry>
60                 <term>sign</term>
61                 <listitem>
62                     整数.値は <literal>1</literal>または
63                     <literal>-1</literal>となります.
64                     順方向または逆変換を選択します.
65                     デフォルト値は<literal>-1</literal>
66                     (順方向変換)です.
67                 </listitem>
68             </varlistentry>
69             <varlistentry>
70                 <term>selection</term>
71                 <listitem>
72                     <literal>A</literal>の各配列次元への添字を有する
73                     ベクトル. 詳細は説明を参照ください.
74                 </listitem>
75             </varlistentry>
76             <varlistentry>
77                 <term>dims</term>
78                 <listitem>
79                     整数値を有する正の数値ベクトル, または正の整数のベクトル.
80                     詳細は説明を参照ください.
81                     <para>
82                         各要素は
83                         <literal>A</literal>の要素の総数の約数となります.
84                     </para>
85                     <para>
86                         各要素の積は<literal>A</literal>の要素の総数よりも
87                         小さな値とする必要があります.
88                     </para>
89                 </listitem>
90             </varlistentry>
91             <varlistentry>
92                 <term>incr</term>
93                 <listitem>
94                     整数値を有する正の数値ベクトル, または正の整数のベクトル.
95                     詳細は説明を参照ください.
96                     <para>
97                         <literal>incr</literal> は,
98                         <literal>dims</literal>の要素数と同じにする
99                         必要があります.
100                     </para>
101                     <para>
102                         各要素は,<literal>A</literal>の要素の総数の約数とする
103                         必要があります.
104                     </para>
105                     <para>
106                         <literal>incr</literal> の要素は,
107                         厳密に昇順とする必要があります.
108                     </para>
109                 </listitem>
110             </varlistentry>
111             <varlistentry>
112                 <term>option</term>
113                 <listitem>
114                     文字列. 値は,順方向変換の場合,
115                     <literal>"dct1"</literal>, <literal>"dct2"</literal>,
116                     <literal>"dct4"</literal> または <literal>"dct"</literal>,
117                     逆変換の場合は <literal>"dct1"</literal>,
118                     <literal>"dct3"</literal>, <literal>"dct4"</literal>または
119                     <literal>"idct"</literal> です.
120                     デフォルト値は,順方向変換の場合に<literal>"dct"</literal>,
121                     逆変換の場合に<literal>"idct"</literal>です.
122                     詳細は説明を参照ください.
123                 </listitem>
124             </varlistentry>
125         </variablelist>
126     </refsection>
127     <refsection>
128         <title>説明</title>
129         <refsection>
130             <title>変換の説明</title>
131             <para>
132                 この関数は,
133                 パラメータ値<literal>option</literal>で指定したシフト量を用いて
134                 順方向または逆方向の1次元またはN次元離散コサイン変換を
135                 行います.
136                 長さ<latex scilab:localized="true">$n$</latex>の1次元配列<latex scilab:localized="true">$A$</latex>の場合:
137             </para>
138             <itemizedlist>
139                 <listitem>
140                     <para>
141                         <literal>"dct1"</literal>の場合, この関数は
142                         正規化しないDCT-I変換を計算します:
143                     </para>
144                     <para>
145                         <latex>
146                             $X(k) = A(1) + (-1)^{k-1}A(n) + 2\sum_{i=2}^{n-1} {A(i)
147                             \cos\frac{\pi (i -1)(k-1)}{n-1}}, k=1\ldots n$
148                         </latex>
149                     </para>
150                 </listitem>
151                 <listitem>
152                     <para>
153                         <literal>"dct2"</literal>の場合,この関数は
154                         正規化しないDCT-II変換を計算します:
155                     </para>
156                     <para>
157                         <latex>
158                             $X(k) = 2 \sum_{i=1}^{n} {A(i) \cos\frac{\pi (i
159                             -1/2)(k-1)}{n}}, k=1\ldots n$
160                         </latex>
161                     </para>
162                 </listitem>
163                 <listitem>
164                     <para>
165                         <literal>"dct3"</literal>の場合,この関数は
166                         正規化しないDCT-III変換を計算します:
167                     </para>
168                     <para>
169                         <latex>
170                             $X(k) = A(1) + 2 \sum_{i=2}^{n} {A(i) \cos\frac{\pi (i
171                             -1)(k-1/2)}{n}}, k=1\ldots n$
172                         </latex>
173                     </para>
174                 </listitem>
175                 <listitem>
176                     <para>
177                         <literal>"dct4"</literal>の場合,この関数は
178                         正規化しないDCT-IV変換を計算します:
179                     </para>
180                     <para>
181                         <latex>
182                             $X(k) = 2 \sum_{i=1}^{n} {A(i) \cos\frac{\pi (i
183                             -1/2)(k-1/2)}{n}}, k=1\ldots n$
184                         </latex>
185                     </para>
186                 </listitem>
187                 <listitem>
188                     <para>
189                         <literal>"dct"</literal>の場合,この関数は
190                         正規化されたDCT-II変換を計算します:
191                     </para>
192                     <para>
193                         <latex>
194                             $X(k) = \omega(k)
195                             \sum_{i=1}^n {A(i) \cos\frac{\pi (i
196                             -1/2)(k-1)}{n}}, k=1\ldots n \quad\text{with }
197                             \omega(1)=\frac{1}{\sqrt{n}} \quad\text{and }
198                             \omega(k)=\sqrt{\frac{2}{n}} , k>1$
199                         </latex>
200                     </para>
201                 </listitem>
202                 <listitem>
203                     <para>
204                         <literal>"idct"</literal>の場合,この関数は
205                         正規化されたDCT-III変換を計算します:
206                     </para>
207                     <para>
208                         <latex>
209                             $X(i) = \sum_{k=1}^n {\omega(k) A(k) \cos\frac{\pi (i
210                             -1/2)(k-1)}{n}}, k=1\ldots n \quad\text{with }
211                             \omega(1)=\frac{1}{\sqrt{n}} \quad\text{and }
212                             \omega(k)=\sqrt{\frac{2}{n}} , k>1$
213                         </latex>
214                     </para>
215                 </listitem>
216             </itemizedlist>
217             <para>
218                 多次元のDCT変換は,一般に,
219                 配列の各次元方向の1次元変換の分離可能な積です.
220                 正規化しない変換の場合,
221                 順方向の後に逆方向多次元変換を行うと,
222                 元の配列が各次元の大きさの積で拡大されたものと
223                 なります.
224             </para>
225             <para>
226                 次元が       <latex>$n_1, n_2, \ldots, n_p$</latex>の
227                 配列<literal>A</literal>の正規化された多次元DCT変換
228                 は以下のように計算されます
229             </para>
230             <para>
231                 <latex>
232                     $\begin{array} \\X(k_1, \dots, k_p) =
233                     \omega_1(k_1) \ldots \omega_p(k_p)
234                     \sum_{i_1=1}^{n_1} \ldots \sum_{i_p=1}^{n_p}
235                     {A(i_1,\ldots ,i_p) \cos\frac{\pi (2 i_1
236                     -1)(k_1-1)}{2 n} \ldots \cos\frac{\pi (2 i_p
237                     -1)(k_p-1)}{2 n}}, k_j=1\ldots n_j\\
238                     \text{with}\\
239                     \omega_j(1)=\frac{1}{\sqrt{n_j}}\\
240                     \omega_j(k)=\sqrt{\frac{2}{n_j}} , k>1
241                     \end{array}$
242                 </latex>
243             </para>
244             <para>
245                 次元が<latex>$n_1, n_2, \ldots, n_p$</latex>の
246                 配列<literal>A</literal>の正規化された多次元DCT逆変換
247                 は以下のように計算されます
248             </para>
249             <para>
250                 <latex>
251                     $\begin{array} \\X(i_1, \dots, i_p) = \sum_{k_1=1}^{n_1}
252                     \ldots \sum_{k_p=1}^{n_p} {\omega_1(i_1) \ldots \omega_p(i_p)
253                     A(k_1,\ldots ,k_p) \cos\frac{\pi (2 k_1 -1)(i_1-1)}{2 n}
254                     \ldots \cos\frac{\pi (2 k_p -1)(i_p-1)}{2 n}}, i_j=1\ldots
255                     n_j\\
256                     \text{with}\\
257                     \omega_j(1)=\frac{1}{\sqrt{n_j}}\\
258                     \omega_j(k)=\sqrt{\frac{2}{n_j}} , k>1 \end{array}$
259                 </latex>
260             </para>
261         </refsection>
262         <refsection>
263             <title>構文の説明</title>
264             <variablelist>
265                 <varlistentry>
266                     <term>短縮構文</term>
267                     <listitem>
268                         <variablelist>
269                             <varlistentry>
270                                 <term>順方向</term>
271                                 <listitem>
272                                     <para>
273                                         <literal>X=dct(A,-1 [,option])</literal> または
274                                         <literal>X=dct(A [,option])</literal> により,
275                                         オプション値を指定した順方向変換が得られます.
276                                         デフォルトは,正規化された
277                                         DCT-II順方向変換です.
278                                     </para>
279                                     <para>
280                                         <literal>A</literal>がベクトルの場合
281                                         (1より大きい次元が1つだけの場合),
282                                         1次元の変換が行われ,
283                                         その他の場合にはn次元変換が行われます.
284                                     </para>
285                                     <para>
286                                         (引数<literal>-1</literal>は"inverse"ではなく,
287                                         指数の符号を意味します).
288                                     </para>
289                                 </listitem>
290                             </varlistentry>
291                             <varlistentry>
292                                 <term>逆方向</term>
293                                 <listitem>
294                                     <para>
295                                         <literal>X=dct(A,1 [,option])</literal>または
296                                         <literal>X=idct(A [,option])</literal>は
297                                         逆変換を行います.
298                                     </para>
299                                     <para>
300                                         <literal>A</literal>がベクトルの場合
301                                         (1より大きい次元が1つだけの場合),
302                                         1次元の変換が行われ,
303                                         その他の場合にはn次元変換が行われます.
304                                     </para>
305                                 </listitem>
306                             </varlistentry>
307                         </variablelist>
308                     </listitem>
309                 </varlistentry>
310                 <varlistentry>
311                     <term>指定した次元方向のDCTの長い構文</term>
312                     <listitem>
313                         <itemizedlist>
314                             <listitem>
315                                 <para>
316                                     <literal>X=dct(A,sign,selection [,option])</literal>
317                                     により,
318                                     選択した次元方向の<literal>A</literal>の"スライス"の
319                                     順方向または逆方向dctを
320                                     効率的に計算することができます.
321                                 </para>
322                                 <para>
323                                     例えば, <literal>A</literal> が3次元配列の場合,
324                                     <literal>X=dct(A,-1,2)</literal> は以下と等価になります:
325                                 </para>
326                                 <programlisting role=""><![CDATA[
327             for i1=1:size(A,1),
328               for i3=1:size(A,3),
329                 X(i1,:,i3)=dct(A(i1,:,i3),-1);
330               end
331             end
332             ]]></programlisting>
333                                 <para>
334                                     そして <literal>X=dct(A,-1,[1 3])</literal> は
335                                     以下と等価になります:
336                                 </para>
337                                 <programlisting role=""><![CDATA[
338             for i2=1:size(A,2),
339               X(:,i2,:)=dct(A(:,i2,:),-1);
340             end
341             ]]></programlisting>
342                             </listitem>
343                             <listitem>
344                                 <para>
345                                     <literal>X=dct(A,sign,dims,incr)</literal> は
346                                     古い構文であり,この方法でも
347                                     指定した次元方向の<literal>A</literal>のスライスの
348                                     順方向または逆方向のdctを行うことができます.
349                                 </para>
350                                 <para>
351                                     例えば,<literal>A</literal>が
352                                     <literal>n1*n2*n3</literal> 個の要素を有する配列の場合,
353                                     <literal>X=dct(A,-1,n1,1)</literal> は
354                                     <literal>X=dct(matrix(A,[n1,n2,n3]),-1,1)</literal>
355                                     と等価で,
356                                     <literal>X=dct(A,-1,[n1 n3],[1 n1*n2])</literal>
357                                     は
358                                     <literal>X=dct(matrix(A,[n1,n2,n3]),-1,[1,3])</literal>
359                                     と等価です.
360                                 </para>
361                             </listitem>
362                         </itemizedlist>
363                     </listitem>
364                 </varlistentry>
365             </variablelist>
366         </refsection>
367         <refsection>
368             <title>dctを最適化</title>
369             <para>
370                 注意:
371                 この関数は直近のパラメータをメモリに保持し,2回目に再利用します.
372                 これにより(同じパラメータで)連続的にコールした場合の
373                 計算時間が著しく改善されます.
374             </para>
375             <para>
376                 <link linkend="get_fftw_wisdom">get_fftw_wisdom</link>, <link
377           linkend="set_fftw_wisdom">set_fftw_wisdom</link> 関数により
378                 dctを更に最適化することができます.
379             </para>
380         </refsection>
381     </refsection>
382     <refsection>
383         <title>アルゴリズム</title>
384         <para>
385             この関数は,<ulink url="http://www.fftw.org/">fftw3</ulink>ライブラリを
386             使用します.
387         </para>
388     </refsection>
389     <refsection>
390         <title>例</title>
391         <para>1次元dct</para>
392         <programlisting role="example"><![CDATA[
393   // 信号の周波数要素
394   //----------------------------------
395   // 50および70Hzの信号を含む1000hzで標本化された信号を構築
396   sample_rate=1000;
397   t = 0:1/sample_rate:0.6;
398   N=size(t,'*'); //number of samples
399   s=sin(2*%pi*50*t)+sin(2*%pi*70*t+%pi/4)+grand(1,N,'nor',0,1);
400   d=dct(s);
401   // 低エネルギー部分を0にする
402   d(abs(d)<1)=0;
403   size(find(y1<>0),'*') //only 30 non zero coefficients out of 600
404   clf;plot(s,'b'),plot(dct(d,1),'r')
405   ]]></programlisting>
406         <para>2次元 dct</para>
407         <programlisting role="example"><![CDATA[
408   function z = __milk_drop(x,y)
409       sq = x.^2+y.^2;
410       z = exp( exp(-sq).*(exp(cos(sq).^20)+8*sin(sq).^20+2*sin(2*(sq)).^8) );
411   endfunction
412   x = -2:0.1:2;
413   [X,Y] = ndgrid(x,x);
414   A = __milk_drop(X,Y);
415   d = dct(A);
416   d(abs(d)<1)=0;
417   size(find(d<>0),'*')
418   A1 = dct(d,1);
419   clf
420   gcf().color_map = graycolormap(128);
421   subplot(121), grayplot(x,x,A)
422   subplot(122), grayplot(x,x,A1)
423   ]]></programlisting>
424     </refsection>
425     <refsection role="see also">
426         <title>参照</title>
427         <simplelist type="inline">
428             <member>
429                 <link linkend="fft">fft</link>
430             </member>
431             <member>
432                 <link linkend="dst">dst</link>
433             </member>
434             <member>
435                 <link linkend="fftw_flags">fftw_flags</link>
436             </member>
437             <member>
438                 <link linkend="get_fftw_wisdom">get_fftw_wisdom</link>
439             </member>
440             <member>
441                 <link linkend="set_fftw_wisdom">set_fftw_wisdom</link>
442             </member>
443             <member>
444                 <link linkend="fftw_forget_wisdom">fftw_forget_wisdom</link>
445             </member>
446         </simplelist>
447     </refsection>
448     <refsection>
449         <title>参考文献</title>
450         <para>
451             Matteo Frigo and Steven G. Johnson, "FFTW Documentation" <ulink
452     url="http://www.fftw.org/#documentation">http://www.fftw.org/#documentation</ulink>
453         </para>
454     </refsection>
455 </refentry>