How to do a Fourier analysis with a mask?
27 次查看(过去 30 天)
显示 更早的评论
I want to exclude the transparent parts of PNG pictures in Fourier analysis.
I just don't know how to use the alpha mask given by imread to do Fourier analysis analysis through fft2 (which needs the input images being rectangular) appropriately when the transparent part is not rectangle.
Do you know how to exclude transparent parts which are not rectangles of PNG picture?
Thank you very much!
5 个评论
Walter Roberson
2023-9-9
You should read the terms and conditions for using the MATLAB Answers facility. You had to click to signify acceptance of the terms in order to post your question.
回答(2 个)
Walter Roberson
2022-9-7
Use
[A,MAP,ALPHA] = imread(...)
syntax. You can then threshold based on alpha to determine whether to include a pixel or not.
However... your fft2 depends upon the image being rectangular. It is not going to be easy to ignore the pixels outside the mask when you use fft2 for phase analysis.
Also, we do not recommend naming a variable image due to the conflict with the important MATLAB function named image
3 个评论
Walter Roberson
2022-9-8
Taking the fourier transform of an interval of a continuous function is equivalent to taking the fourier transform of a rectangular pulse multiplied by the function. The fourier transform of a product of functions is the convolution of the fourier transform of the two functions.
So in theory if you could define the opaque area as a disk instead of by mask you could take the 2D fft of the full image, and the 2D fft of the disk, and convolve them. You would probably have to be careful with the fft shift for the convolvution.
Walter Roberson
2022-9-13
I looked at the code. The option for separating the image into foreground and background and matching the two separately, only applies to Luminance and Histogram matching, and does not apply to spectral matching (fft)
Bruno Luong
2022-9-14
编辑:Bruno Luong
2022-9-14
Discrete Fourier transform always has unwanted artefact on finite region, due to boundary wrapping jumps, even for rectangular region.
The way people overcome is to multiply the data by window functions https://en.wikipedia.org/wiki/Window_function to smooth out the boundary, then take the FFT to get a less affectef spectrum.
You could do the same with you disk-region image by (1) multiplying the image with a tensorial of two window functions then (2) taking the FFT on the bounding box rectangle to find the spectrum.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!