EDA365电子论坛网

标题: matlab中的conv2卷积运算的三种形式 [打印本页]

作者: thinkfunny    时间: 2020-1-14 10:27
标题: matlab中的conv2卷积运算的三种形式
5 B+ q: C9 A( o
6 e5 c! T' P% A7 h  e: B; ^5 o& R
matlab中的conv2是用于对二维数据进行卷积运算,有三个参数可供选择,下面是help content of conv2  l0 _2 P% [4 j( T( x; p9 t
. A) `7 y4 t9 u$ O+ f
conv2 Two dimensional convolution.
# P: t4 q$ a& x* @% p  k/ W0 }4 @, w! e! S# N% H$ k
    C = conv2(A, B) performs the 2-D convolution of matrices A and B., c8 g! t! P/ u3 m  x3 `" ]
    If [ma,na] = size(A), [mb,nb] = size(B), and [mc,nc] = size(C), then1 ^; u4 I4 _5 P
    mc = max([ma+mb-1,ma,mb]) and nc = max([na+nb-1,na,nb]).& j7 S; i3 ^. T) }- n, V

# a2 T8 a$ l* Y& W& s: B    C = conv2(H1, H2, A) first convolves each column of A with the vector- \% h7 k( e# T5 }) P- A9 n
    H1 and then convolves each row of the result with the vector H2.  If
! i$ d7 x" ~, z    n1 = length(H1), n2 = length(H2), and [mc,nc] = size(C) then
* `! q3 b' p% `8 J& _) b    mc = max([ma+n1-1,ma,n1]) and nc = max([na+n2-1,na,n2]).
/ }- v8 A- j4 ^: `$ E    conv2(H1, H2, A) is equivalent to conv2(H1(:)*H2(:).', A) up to
9 s# N0 `: `9 F8 C% {: _5 T    round-off.
' Q7 l  a; |8 ^" J
( M% }! n) o. p5 m0 r9 y% D    C = conv2(..., SHAPE) returns a subsection of the 2-D
, l, q. ^# `* ^1 C3 G    convolution with size specified by SHAPE:9 R+ J5 j* K, q
      'full'  - (default) returns the full 2-D convolution,
9 `& N- W. L' e* @4 J% Y      'same'  - returns the central part of the convolution
  D3 I. G4 Z* o  ?                that is the same size as A.! R: a! c$ p& d9 {. \3 N
      'valid' - returns only those parts of the convolution$ m, l% |6 D* o8 E8 l  |- j
                that are computed without the zero-padded edges.
- i- t# h/ }, P8 A' K9 B9 V                size(C) = max([ma-max(0,mb-1),na-max(0,nb-1)],0).
, C. A: q6 M% V3 M4 G% f7 ]! G) O9 q. o* N$ I- i$ N( Y5 l$ F$ _

, {7 `5 c" R% }9 K关于full, same以及valid三种参数的区别,如下面的实例所示:- c5 e. V$ m: r, L3 O# H9 k; ~/ y
7 [. Y' Y# G& g0 O( v
full4 z5 b+ y& k  t* ^- R

2 M. o- s3 [* k% x4 D2 N7 z3 O
) q, i: ]0 I7 X. w) h  i. U$ j3 d) ^

0 }7 u( W( |' z' d# _3 [3 e5 b) o3 |same8 X' {) C0 d1 c& c

2 p! T7 M  U' P$ q& ?  `7 C ! r; N7 |0 g/ P% B, J& f
' i/ Q5 P$ ~2 n
: w0 i) L' t. Y8 ^9 {; @& I& J
valid" D" |! v- n4 X/ d5 D* e# e

8 L1 K  k: {8 g( O, N$ X$ x9 w- q1 ~/ @7 {6 j% [

1 L  J# S: g; K+ v& `/ {5 Z1 H2 ?+ {( F; Y8 i: q

作者: yin123    时间: 2020-1-14 19:49
三种形式的matlab中的conv2卷积运算




欢迎光临 EDA365电子论坛网 (https://bbs.eda365.com/) Powered by Discuz! X3.2