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