- Use proper order for the input arguments: Pass the image to be filtered as the first argument and the filter kernel as the second argument.
- Use "conv" option for filtering: By default, "imfilter()" uses correlation because the toolbox filter design functions produce correlation kernels. Use the optional parameter to use convolution as follows:
anti aliasing filter problem
조회 수: 5 (최근 30일)
이전 댓글 표시
the following is my code I'm not sure why it inverts the image upside down after doing the operation
HPsamp = HP(1:2:end, 1:2:end);
LPsamp = LP(1:2:end, 1:2:end);
HPsampfreq = (abs(fftshift(fft2(HPsamp))) / 100);
LPsampfreq = (abs(fftshift(fft2(LPsamp))) / 100);
HPsamp2 = HP(1:4:end, 1:4:end);
LPsamp2 = LP(1:4:end, 1:4:end);
HPsamp2freq = (abs(fftshift(fft2(HPsamp2))) / 100);
LPsamp2freq = (abs(fftshift(fft2(LPsamp2))) / 100);
gausshalf = fspecial('gaussian', 250, 0.05);
gaussquart = fspecial('gaussian', 125, 0.3);
HPfilthalf = imfilter(gausshalf, HPsamp);
HPfiltquart = imfilter(gaussquart, HPsamp2);
HPfilthalffreq = (abs(fftshift(fft2(HPfilthalf))) / 200);
HPfiltquartfreq = (abs(fftshift(fft2(HPfiltquart))) / 200);
댓글 수: 0
답변 (1개)
Sudarsanan A K
2023년 10월 23일
편집: Sudarsanan A K
2023년 10월 23일
Hello Rana,
I understand that you are using the "imfilter()" function for filtering your down sampled images and wanted to perform frequency domain analysis. I note that you are experiencing that the filtered images "HPfilthalf" and "HPfiltquart" are upside down after the filtering operation using the function "imfilter()".
This happens because the function "imfilter()" performs multidimensional filtering using correlation by default, which is the same way that "filter2()" performs filtering and expects the arguments as follows:
B = imfilter(A,h)
where, "A" is the multidimensional array and "h" is the multidimensional filter.
I observe that the input arguments are swapped in positions in the code that you provided. As I mentioned, since the "imfilter()" uses correlation for the filtering operation, this causes an unexpected behaviour as you observed, the upside-down nature of the filtered output.
There are two ways you can resolve this issue:
imfilter(h,A,'conv')
Note that convolution is commutative and this will produce the desired result irrespective of the order of "A" and "h".
To know more about the "imfilter()" function, you can additionally refer to the MathWorks documentation in the link:
I hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!