MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

1

It's magic. R2017a gives a different result from R2016a/b with the following simple code...

Shogo Muramatsu さんによって質問されました 2017 年 4 月 10 日
最新アクティビティ Prerana Paravastu さんによって 回答されました 2017 年 11 月 20 日
R2017a gives a different result from R2016a/b with the following code:
I = magic(16); H = magic(4); imfilter(I,H,'circular')
Has the implementation of imfilter been changed?
It is a huge problem for me.

  4 件のコメント

An official response was obtained by a bug report. This is a malfunction of the imfilter function of MATLAB R2017a. They told me that this bug will be improved in the next release version (probably MATLAB R2017b).
I'm not sure if a bug being improved is a good thing or a bad thing!
This bug is a fatal problem especially for researchers and developers concerning signal processing, and should be fixed immediately.
For a double precision input image, the circular extension may fail when using an even size kernel. Please also see the answer made by myself.
Circular convolution is a special operator because
  • It is diagonalized by the discrete Fourier transform(DFT), i.e., FFT.
  • The adjoint operator is also circular convolution with flipped kernel, i.e., circular correlation.
This bug is an obstacle to using these properties on MATLAB.

サインイン to comment.

4 件の回答

回答者: Walter Roberson
2017 年 4 月 10 日
 採用された回答

Yes, the implementation did change; I do not see any release notes saying so, though.
I see in R2016b that non-separable filters have two branches: filterSingle2DWithConv() for single(), and filterPartOrWhole() for everything else. filterPartOrWhole() calls mex routines to do the work. You are using double(), so you would get the "everything else" mex routines.
I see in R2017a that non-separable filters have three branches: filterDouble2DWithConv() for double() for 2D arrays; filterDouble2DWithConv() (same routine) for double() with 3D arrays; and filterPartOrWhole() otherwise. (Notice filterSingle2DWithConv is gone and handled by filterPartOrWhole() now.) You are using double(), so you get the new filterDouble2DWithConv() routine. It calls upon conv2() to do the work.
I think you would be justified in filing a bug report on this.

  4 件のコメント

Which release do you think is the most "correct"?
R2016a/b give correct results for the above commands.
I've confirmed that the single precision routine gives the correct result by the following code:
% Input 2D array
I = magic(16);
% Filter kernel
H = magic(4);
% Circular convolution with double precision
ansimfd = imfilter(double(I),H,'conv','circular');
% Circular convolution with single precision
ansimfs = imfilter(single(I),H,'conv','circular');
% Frequency domain filtering
Iw = fft2(I,16,16);
Hw = fft2(H,16,16);
ansfft2 = circshift(ifft2(Iw.*Hw,16,16),-[2 2]);
% Evaluation of double precision filtering
norm(ansimfd-ansfft2)
% Evaluation of single precision filtering
norm(ansimfs-ansfft2)
Casting the input array to single precision would be a way to avoid the malfunction for the double precision data.

サインイン to comment.


回答者: Shogo Muramatsu 2017 年 4 月 11 日
編集済み: Shogo Muramatsu 2017 年 4 月 12 日

From line 450 to line 451 in imfilter.m, we can see the following codes:
a = padarray_algo(a, prePadSize, method, padVal, 'pre');
a = padarray_algo(a, padSize, method, padVal, 'post');
These two lines seem to periodically expand the image boundary. In this second line, it seems that the periodicity is collapsing as a result of postpadding by duplicating the result of prepadding.

  0 件のコメント

サインイン to comment.


回答者: Shogo Muramatsu 2017 年 6 月 6 日

Visit https://mathworks.com/support/bugreports/ and search #BugID: 1554862.

  0 件のコメント

サインイン to comment.


回答者: Prerana Paravastu 2017 年 11 月 20 日

Which is the recent version?

  0 件のコメント

サインイン to comment.



Translated by