如何从一系列随时间移动的器官图像的 FFT 中获取 H1 和 DC 图像

How to get H1 and DC images from FFT of a series of images of organ moving over time

我有一系列令人心动的图像,如何随时间进行傅里叶变换以从中提取 DC 和 H1 图像? 到目前为止,我尝试了以下代码,但我不知道 H1 到底是什么!所以我无法提取该组件的图像! 这是我到目前为止尝试过的代码:

import numpy as np
import cv2 as cv

for sl in range(img.shape[2]):
   for fr in range(1,img.shape[3]):
    #|=======================================================|
    #|             xx Thresholding xx                        |
    #|-------------------------------------------------------|
    th_f  = cv.adaptiveThreshold(img[:,:,sl,fr  ].astype('uint8'),255,cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY,11,4)
    th_f0 = cv.adaptiveThreshold(img[:,:,sl,fr-1].astype('uint8'),255,cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY,11,4)

    #|=======================================================|
    #|   xx Fourier HPF Filter (Smoothing & Denoising) xx    |
    #|-------------------------------------------------------|
    # Fourier 2D Transform
    f = np.fft.fft2(th_f)
    f0 = np.fft.fft2(th_f0)
    #  Move the DC component of the FFT output to the center of the spectrum
    fshift = np.fft.fftshift(f)
    fshift0 = np.fft.fftshift(f0)
    # Save the original fshift
    fshift_orig = fshift.copy()
    fshift0_orig = fshift0.copy()
    # Create mask
    rows, cols = img.shape[0],img.shape[1]
    crow, ccol = int(rows/2), int(cols/2)
    # Use mask to remove low frequency components
    dist1 = 30
    #dist2 = 0
    fshift[crow-dist1:crow+dist1, ccol-dist1:ccol+dist1] = 0
    #fshift[crow-dist2:crow+dist2, ccol-dist2:ccol+dist2] = fshift_orig[crow-dist2:crow+dist2, ccol-dist2:ccol+dist2] 
    fshift0[crow-dist1:crow+dist1, ccol-dist1:ccol+dist1] = 0
    #fshift0[crow-dist2:crow+dist2, ccol-dist2:ccol+dist2] = fshift0_orig[crow-dist2:crow+dist2, ccol-dist2:ccol+dist2] 
    #-----calculate the derivative of the 2D FFT with respect to time-----------
    dfdt = fshift - fshift0 + result
    #print(np.max(result))
    # inverse Fourier transform
    img_back = np.fft.ifft2(dfdt)
    # get rid of imaginary part by abs
    Fresult = np.abs(img_back).astype('uint8')
    cv.imshow(Fresult)
    cv.waitKey(0)
    cv.destroyAllWindows()
  • 解决方案是对每个切片进行 3D 傅立叶变换,然后仅选择变换的第二个分量将其变换回空间 space,仅此而已。
  • 这样做的好处是检测是否有东西沿着第三轴(在我的例子中是时间)移动。
for sl in range(img.shape[2]):
   #-----Fourier--H1-----------------------------------------
   # ff1[:, :, 1] H1 compnent 1, if 0 then DC
   ff1 = FFT.fftn(img[:,:,sl,:])
   fh = np.absolute(FFT.ifftn(ff1[:, :, 1])) 

   #-----Fourier--H1-----------------------------------------