Equivalent of zero padding in frequency space
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
I was wondering if instead of zero padding an image in space domain and then taking its FT, I could take the FT first and the do something to simulate the 0 padding? This is for template matching function that I'm writing. I need zero padding because I perform convolution by taking FT of both the template and data image and then find the product of the transforms, so the 2 transforms need to match in size. I don't use conv2 function because I perform template matching with approximately 100 different scales of the template image and conv2 takes too long. I would really appreciate any suggestions. Thank you very much!
채택된 답변
Star Strider
2020년 6월 14일
Since zero-padding in the space domain increases the frequency resolution in the frequency domain, the equivalent in the frequency domain seems to me to create a frequency vector of the appropriate increased length (using linspace with the same frequency limits as the original frequency-domain result to create the appropriate vectors in each dimension) and then interpolate to it, creating a frequency-comain result with increased frequency resolution. That is how I would do it with a one-dimensional signal (such as in signal processing), so a similar approach should work with a two-dimensional signal. Note that you would have to do this on the complex result if you wanted to invert it later.
I have never actually done this on a two-dimensional signal, so experiment with it to see how well it works.
댓글 수: 10
KT
2020년 6월 15일
Thank you very much for your answer Star Strider! I did 2D interpolation using interp2 where:
Xq = linspace(1, size(bigger, 1), size(bigger, 1) + 100);
Yq = linspace(1, size(bigger, 2), size(bigger, 2) + 100);
result = interp2d(bigger, Yq, Xq(:));
bigger is an FFT of my original image. When I take the ifft2 of the result and conver it to an image, that image is a scaled version of the original image. Instead of scaling I would just like to zero-pad the original image. Should I be using interp2 differently? Thank you again very much for your suggestions! I'm new to image processing so I'm not interile sure how to properly work with an FFT of an image.
My pleasure!
Rescaling in the frequency domain will not result in zero-padding the original space (or time) domain signal. It simply interpolates it to the new spatial dimensions. If you want to zero-pad the original image, do just that.
I suppose it could be possible to downsample the upsampled frequency-domain signal, then invert it and insert it into an existing zeros matrix, however that seems to me to be more trouble than it’s worth.
KT
2020년 6월 15일
Thank you Star Strider! I apologize, I didn't explain my code well in the previous post. I already perfom image scaling in frequency domain. After I scale the image through its FT, I want to also zero pad the image through its FT. I tried interpolating the FT as shown in the code in my previous post, but that just scaled the image. The reason I do not want to zero pad in space domain is because that would cause my code to run slower. Thank you again very much! I appreciate your help!
I’m lost.
It’s certainly possible to zero-pad in the frequency domain as well, if you want to. See: 2-D Inverse Transform of Matrix . This would likely have the effect of interplating the inverted matrix. It would not zero-pad it.
KT
2020년 6월 15일
What I would like it to do is something like:
Approach 1
imagePadded = padarray(image, [100 50], 0, 'post');
imageFFT = fft2(imagePadded);
Approach 2
imageFFT = fft2(image);
imagePadded = some_function(imageFFT)
Result
imageFFT (approach 1) = imagePadded (approach 2)
I'm sorry for the confusion. Thank you for your help!
Go for it!
Experiment until you get the result you want.
KT
2020년 6월 15일
Do you have any ideas for what that some_function could be? I tried using interp2 but it did not work. I read that 0 padding in space domain is equivalent to sinc interpolation in frequency domain, but interp2 does not have an option for sinc interpolation? Thank you again so much!
You would have to write ‘some_function’ yourself, depending on the result you want.
The sinc function is just the Fourier transform of an even square pulse. I am not certain how it could be used to interpolate anything.
Inverting the matrix would not automatically include zero-padding. You would have to do that yourself, inserting the inverted matrix into a zeros matrix, as I mentioned previously.
KT
2020년 6월 15일
Great, thank you very much for all of your help! I'll test that out.
As always, my pleasure!
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
