У меня есть серия изображений, которые бьются по сердцу, как я могу со временем преобразовать Фурье, чтобы извлечь из него изображения D C и 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()