1 <?xml version="1.0" encoding="UTF-8"?>
2 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en_US" xml:id="conv2">
4 <refname>conv2</refname>
5 <refpurpose>discrete 2-D convolution. </refpurpose>
10 C = conv2(A,B [,shape])
11 C = conv2(hrow,hcol,B [,shape])
15 <title>Parameters</title>
21 a real or complex vector.
29 a real or complex vector.
37 a real or complex 2-D array.
45 a real or complex 2-D array.
53 an optional character string with possible values:
57 <literal>"full"</literal>, <literal>conv2</literal>
58 computes the full two-dimensional convolution. It is the
62 <literal>"same"</literal>, <literal>conv2</literal>
63 computes the central part of the convolution of the same
64 size as <literal>A</literal>.
67 <literal>"valid"</literal>, <literal>conv2</literal>
68 computes the convolution parts without the zero-padding of <literal>A</literal>.
77 a real or complex 2-D array.
84 <title>Description</title>
86 <literal>conv2</literal> uses a straightforward formal
87 implementation of the two-dimensional convolution equation in
91 <literal>C=conv2(A,B [,shape])</literal> computes the
92 two-dimensional convolution of the arrays <literal>A</literal>
93 and <literal>B</literal>:
95 <itemizedlist><listitem>
96 With <literal>shape=="full"</literal> the
97 dimensions of the result<literal>C</literal> are given by
98 <literal>size(A)+size(B)+1</literal>. The indices of the
99 center element of <literal>B</literal> are defined as
100 <literal>floor((size(B)+1)/2)</literal>.
103 With <literal>shape=="same"</literal> the dimensions
104 of the result<literal>C</literal> are given by
105 <literal>size(A)</literal>. The indices of the center element of
106 <literal>B</literal> are defined as
107 <literal>floor((size(B)+1)/2)</literal>.
110 With <literal>shape=="valid"</literal> the dimensions
111 of the result <literal>C</literal> are given by
112 <literal>size(A)-size(B)+1)</literal> if
113 <literal>and(size(A)-size(B))>=0</literal> else
114 <literal>C</literal> is empty . The indices of the center
115 element of <literal>B</literal> are defined as <literal>[1
122 The separable form <literal>C=conv2(hrow,hcol,B [,shape])</literal>is equivalent to <literal>C=conv2(hrow(:)*hcol(:).',B [,shape])</literal>
126 Note that <link linkend="convol2d">convol2d</link> can be more efficient for large arrays.
130 <title>Examples</title>
131 <programlisting role="example"><![CDATA[
132 s = [1 2 1; 0 0 0; -1 -2 -1];//Sobel horizontal edge kernel
133 A = zeros(10,10);A(3:7,3:7) = 1;
137 u=[1;0;-1];v=[1 2 1];// u*v=s
141 <refsection role="see also">
142 <title>See also</title>
143 <simplelist type="inline">
145 <link linkend="convol2d">convol2d</link>
148 <link linkend="conv">conv</link>
153 <title>History</title>
156 <revnumber>5.4.0</revnumber>
157 <revremark>Function conv2 introduced.</revremark>