简体   繁体   English

通过 FFT2 检测“倾斜”图像

[英]Detecting a "skewed" image via FFT2

I have the following distorted image which I've computed by reshaping the image to have one more row and one less column than it's supposed to.我有以下扭曲的图像,我通过将图像重塑为比预期的多行少一列来计算它。

nr = true_nr+1
nc = true_nc-1
img = stream[:nr*nc].reshape((nr, nc, 3))

from skimage.color import rgb2gray
dark_image_grey = rgb2gray(img)

在此处输入图像描述

Here is its resulting FFT2 transform:这是其产生的 FFT2 变换:

dark_image_grey_fourier = np.fft.fftshift(np.fft.fft2(dark_image_grey)) 
plt.figure(num=None, figsize=(8, 6), dpi=80)
fft_image = np.log(abs(dark_image_grey_fourier))
plt.imshow(fft_image, cmap='gray');

在此处输入图像描述

Notice above that because of the diagonal skew of the image, the lighter regions of the fourier spectrum run at a 45 degree angle to the x/y frequency axes.请注意,由于图像的对角线倾斜,傅立叶光谱的较亮区域与 x/y 频率轴成 45 度角。

I'm trying to figure out how to estimate that this is indeed skewed, compared to the FFT2 for the undistorted image:与未失真图像的 FFT2 相比,我试图弄清楚如何估计这确实是偏斜的:

在此处输入图像描述

One thought I had was to fit a isotropic 2D Gaussian to the data, centered at the center pixel, and then examine the 2D covariance matrix to see if the off-diagonal terms are non-zero.我的一个想法是将各向同性的 2D 高斯拟合到数据中,以中心像素为中心,然后检查 2D 协方差矩阵以查看非对角项是否非零。 But I'm not sure if there is a more elegant solution that is admitted by the Fourier transform itself.但我不确定傅里叶变换本身是否承认有更优雅的解决方案。 Any suggestions?有什么建议么?

You can use 2D principal component analysis (PCA) on the 2D FFT data to figure out how much the image is skewed and in which direction.您可以对 2D FFT 数据使用 2D主成分分析(PCA) 来确定图像的倾斜程度和方向。

PCA is normally applied to a collection of points. PCA 通常应用于点的集合。 To apply it to your FFT data, consider the energy of each bit to be point density, ie, consider a bin (fx,fy) with energy E to represent E points at position (fx,fy).要将其应用于您的 FFT 数据,请将每个位的能量视为点密度,即考虑具有能量 E 的 bin (fx,fy) 来表示 position (fx,fy) 处的 E 点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM