I need clarification on reshape and conv2 comparison

2 ビュー (過去 30 日間)
mathango
mathango 2016 年 5 月 6 日
コメント済み: mathango 2016 年 5 月 6 日
In convmtx2 documentation I found the following description :
T = convmtx2(H,m,n) returns the convolution matrix T for the matrix H. If X is an m-by-n matrix, then T = convmtx2(H,m,n) returns the convolution matrix T for the matrix H. If X is an m-by-n matrix, then reshape(T*X(:),size(H)+[m n]-1) is the same as conv2(X,H).
T = convmtx2(H,[m n]) returns the convolution matrix, where the dimensions m and n are a two-element vector. is the same as conv2(X,H).
T = convmtx2(H,[m n]) returns the convolution matrix, where the dimensions m and n are a two-element vector.
I am trying an alternative for C=conv2(A,B,'same') by using reshape command. Below is my attempt that does not work,
A = rand(n,n);
B = rand(3,3);
C=reshape(T*A(:),size(B)+[n n]-1);
I know that reshape command set up is incorrect. How to fix this?

採用された回答

Image Analyst
Image Analyst 2016 年 5 月 6 日
That is not correct. Be aware that convolution "flips" the kernel, so unless your kernel is symmetric, which it won't be if you're getting it from rand(), then the answers won't be the same.
  1 件のコメント
mathango
mathango 2016 年 5 月 6 日
Thanks for the tip. I was not aware of that.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by