Hi All,
I am aware of the following:
  • Given two matrices A and B, the matrix is a submatrix of their convolution , and I know the definition of .
  • and A have the same size.
My question is:
If A is a matrix and B is , then what are the values of i and j such that ? That is, where does start inside the matrix ?
Many thanks

댓글 수: 4

Guillaume
Guillaume 2018년 11월 19일
Isn't the doc clear enough?
  • 'same' — Return the central part of the convolution, which is the same size as A.
Anonymous
Anonymous 2018년 11월 19일
It wasn't clear to me where the "central part" is chosen to be though. I guessed it was something like the answer that Bruno gave below. It's not the most natural looking formula in the world, so I wanted confirmation.
Richard Lockwood
Richard Lockwood 2020년 11월 5일
I believe it is the middle half, from 1/4 to 3/4 of the total interval
Image Analyst
Image Analyst 2020년 11월 6일
RIchard, no, not correct. It's not the middle 50%.
'Same' is the part of the output signal where the moving kernel's central element overlaps some part of the signal. So it includes signal where the central element of the moving kernel overlaps an element of the input signal and includes locations where the kernel "falls off" the end of the signal as long as the central element is still over the input signal.
'Full" is the entire output signal, even when the kernel is at the end and only a single element of the kernel overlaps the signal.
'Valid' is where the kernel fully overlaps the signal. So it would not include the ends of the signal where some parts of the moving kernel "fall off" the end of the input signal (they do not overlap).

댓글을 달려면 로그인하십시오.

 채택된 답변

Bruno Luong
Bruno Luong 2018년 11월 19일
편집: Bruno Luong 2021년 1월 25일

3 개 추천

For vectors A and B
C = conv(A,B,'same')
is equivalent to
Cfull = conv(A,B,'full')
C = Cfull(floor(length(B)/2) + (1:length(A)))
For 2D or ND, repeat the above indexing for each dimension d, using size(.,d) instead of length(.).

댓글 수: 5

Anonymous
Anonymous 2018년 11월 19일
Thanks Bruno, that's really helpful.
Bruno Luong
Bruno Luong 2018년 11월 19일
편집: Bruno Luong 2018년 11월 19일
Yeap you are welcome, and you'll note that the MATLAB document is poorly written in term of accuracy and clarity
conv(u,v,'same') "Central part of the convolution of the same size as u."
Anonymous
Anonymous 2018년 11월 19일
This is exactly my point, thanks for being understanding.
Bruno Luong
Bruno Luong 2021년 1월 25일
편집: Bruno Luong 2021년 1월 25일
This is ta reply to
Nunzio Russo 's deleted question
"Hello Bruno can you pls explain it again for 2dimensional arrays ? I don't get it right now. I don't know what you mean with variable d ? Perhaps you can explain it again and write it down as a formula. Thank you ! "
In 2D
C = conv2(A,B,'same')
is equivalent to
Cfull = conv2(A,B,'full')
C = Cfull(floor(size(B,1)/2) + (1:size(A,1)), ...
floor(size(B,2)/2) + (1:size(A,2)))
Fot nd case
C = convn(A,B,'same') % is eqivalent to
Cfull = convn(A,B,'full');
idx = arrayfun(@(B,A) floor(B/2)+(1:A), size(B), size(A), 'unif', 0); % NOTE: traling singleton needs to be handled
C = Cfull(idx{:})
Nunzio Russo
Nunzio Russo 2021년 1월 26일
Bruno Thank you again !
I deleted my question yesterday after coming to the same conclusion. :)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2018년 11월 19일

0 개 추천

Sounds like homework. This is very easy. Just make up arrays on paper, like cut out gridded paper or draw something. Then just physically move the paper along and look where you are. Really, it's trivial.

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

태그

질문:

2018년 11월 19일

댓글:

2021년 1월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by