Circular vs. linear convolution of 2D data

조회 수: 5 (최근 30일)
William Thielicke
William Thielicke 2019년 8월 23일
댓글: William Thielicke 2019년 8월 27일
Hi, there is an example for 1D data and circular vs linear convolution here: https://de.mathworks.com/help/signal/ug/linear-and-circular-convolution.html
If I want to do this with 2D data, how do I zero-pad my data? I mean in which side of the matrix do I add zeros? Everywhere? Thank you! William

채택된 답변

Devineni Aslesha
Devineni Aslesha 2019년 8월 26일
Hi William,
In order to zero-pad a 2D data i.e. matrix, padding should be in such a way that the row length is equal to r1+r2-1 and column length is equal to c1+c2-1 where r1 and r2 are the number of rows and c1 and c2 are the number of columns of the 1st and 2nd matrices respectively.
Use the below code for reference.
rng default;
x = rand(2);
y = rand(3);
c = conv2(x,y);
xpad = [x zeros(size(x,1),size(y,2)-1); zeros(size(y,1)-1,size(x,2)+size(y,2)-1)];
ypad = [y zeros(size(y,1),size(x,2)-1); zeros(size(x,1)-1,size(y,2)+size(x,2)-1)];
c1 = ifft2(fft2(xpad).*fft2(ypad));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by