为什么要在2D频域中的两条线上删除一条线给我重复的工件?

发布于 2025-02-07 17:58:01 字数 1270 浏览 2 评论 0原文

我试图理解为什么如果我设置为频域下半部分的两行上的0+0J,当我重建空间图像时,我会在原始图像上进行移动的副本:

这是一个示例

import cv2 as cv
import math
import numpy as np
import matplotlib.pyplot as plt

imgpath =  "MRI_blackandwhite.png"
img = cv.imread(imgpath, cv.IMREAD_GRAYSCALE)
norm_image = cv.normalize(img, None, alpha=0, beta=1, norm_type=cv.NORM_MINMAX, dtype=cv.CV_32F)
amp = (np.fft.fftshift(np.fft.fft2(norm_image)))
amp[367//2:-1:2] = amp[367//2:-1:2]* (0+0j)
amp_log =  np.abs(amp)
norm_amp = cv.normalize(amp_log, None, alpha=0, beta=1, norm_type=cv.NORM_MINMAX, dtype=cv.CV_32F)
restoredAMP = np.abs(np.fft.ifft2(np.fft.ifftshift(amp)))

plt.subplot(131), plt.imshow(norm_image, "gray", vmin=0, vmax=1), plt.title('Image')
plt.xticks([]), plt.yticks([])
plt.subplot(132), plt.imshow(norm_amp, "gray", vmin=0, vmax=1), plt.title('Amplitude')
plt.xticks([]), plt.yticks([])
plt.subplot(133), plt.imshow(restoredAMP, "gray", vmin=0, vmax=1), plt.title('Restored ')
plt.xticks([]), plt.yticks([])
plt.show()

和图像:

I'm trying to understand why if I set to 0+0j one line over two on the bottom half of the frequency domain gives me a shifted copy on the original image when I reconstruct the spacial image:

enter image description here

here is the example

import cv2 as cv
import math
import numpy as np
import matplotlib.pyplot as plt

imgpath =  "MRI_blackandwhite.png"
img = cv.imread(imgpath, cv.IMREAD_GRAYSCALE)
norm_image = cv.normalize(img, None, alpha=0, beta=1, norm_type=cv.NORM_MINMAX, dtype=cv.CV_32F)
amp = (np.fft.fftshift(np.fft.fft2(norm_image)))
amp[367//2:-1:2] = amp[367//2:-1:2]* (0+0j)
amp_log =  np.abs(amp)
norm_amp = cv.normalize(amp_log, None, alpha=0, beta=1, norm_type=cv.NORM_MINMAX, dtype=cv.CV_32F)
restoredAMP = np.abs(np.fft.ifft2(np.fft.ifftshift(amp)))

plt.subplot(131), plt.imshow(norm_image, "gray", vmin=0, vmax=1), plt.title('Image')
plt.xticks([]), plt.yticks([])
plt.subplot(132), plt.imshow(norm_amp, "gray", vmin=0, vmax=1), plt.title('Amplitude')
plt.xticks([]), plt.yticks([])
plt.subplot(133), plt.imshow(restoredAMP, "gray", vmin=0, vmax=1), plt.title('Restored ')
plt.xticks([]), plt.yticks([])
plt.show()

and the image:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如果没有你 2025-02-14 17:58:01

理解这一点的最简单方法是,您将K空间的一半乘以Delta梳子过滤器。在这里,K空间中的一些伪代码

delta_comb = np.ones(shape)
delta_comb[shape//2:-1:2] = 0
k_space_ = k_space * delta_comb
ifft(k_space_) = ifft(k_space) convolved with ifft(delta_comb)

# and
ifft(delta_comb) = delta_comb_with_1_over_spacing 

乘法等于图像空间中的FFT(Delta Comb)卷积。 Delta梳子的FFT是另一个三角洲梳子,带有间距FOV/K间距。在您的情况下,k间距= 2,因此增量梳子的FFT是带有FOV/2间距的Delta梳子。
如果您使用三角洲梳子将图像卷积,则将获得以每个三角洲为中心的图像的副本。

您只采用一半的k空间,这一事实只是与图像的相对振幅及其“ N/2 Ghost”弄乱了,但是如果您有amp [0: - - - 1:2] = amp [0:-1:2]*(0+0J)而不是其中。

但为什么?您可能会问,这是什么直觉。好吧,通过归零k空间的线,您将迫使许多波的系数为零。由于K空间中任何给定点的系数由双重空间中的组件(图像空间)中的组件定义,因此组件为0的唯一途径是如果此总和完美地取消了。
因为频率彼此独立,所以系数取消的唯一方法是,如果正和负波完全取消每个频率,则意味着它们必须完全不相同。为此,您需要将它们转移。
因此,实际上是零是零的,导致对相对波的信息不被取消或被取消。您不能仅仅考虑一下振幅。

The easiest way to understand this is that you are multiplying half of your k-space by a delta comb filter. Here some pseudo-code

delta_comb = np.ones(shape)
delta_comb[shape//2:-1:2] = 0
k_space_ = k_space * delta_comb
ifft(k_space_) = ifft(k_space) convolved with ifft(delta_comb)

# and
ifft(delta_comb) = delta_comb_with_1_over_spacing 

Multiplication in k-space is equivalent to convolution by the FFT(delta comb) in image space. The FFT of a delta comb is another delta comb, with spacing FOV/k-spacing. In your case k-spacing=2, so the FFT of the delta comb is a delta comb with FOV/2 spacing.
If you convolve your image with a delta comb, you get copies of your image centered at each individual delta.

The fact that you are taking only half of your k-space just messes up with the relative amplitudes of the image and its "N/2 ghost", but it would work just the same if you had amp[0:-1:2] = amp[0:-1:2]* (0+0j) in there instead.

But why? What is the intuition behind this, you may ask. Well, by zeroing out lines of k-space you are forcing the coefficients of a number of waves to necessary be zero. Since the coefficient of any given point in k-space is defined by a sum over components in the dual space (image space), the only way for a component to be 0 is if this sum perfectly cancels out.
Because frequencies are independent from each other, the only way for coefficients to cancel out is if the positive and negative wave perfectly cancel each out, which means they have to be perfectly out of phase. For that you need them to be shifted.
So it's really about the phase being zero that causes the information from the opposing wave to not be cancelled or be cancelled out. You cannot reason about it thinking of amplitudes alone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文