Add old get_ft_prnu.py

This commit is contained in:
Benjamin Loison 2024-05-14 01:19:57 +02:00
parent 810bde8e35
commit b7c494579c
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -0,0 +1,27 @@
#!/usr/bin/python3
import cv2
import numpy as np
# now we will be loading the image and converting it to grayscale
image = cv2.imread(r'-002.ppm')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Compute the discrete Fourier Transform of the image
fourier = cv2.dft(np.float32(gray), flags=cv2.DFT_COMPLEX_OUTPUT)
# Shift the zero-frequency component to the center of the spectrum
fourier_shift = np.fft.fftshift(fourier)
# calculate the magnitude of the Fourier Transform
magnitude = 20*np.log(cv2.magnitude(fourier_shift[:,:,0],fourier_shift[:,:,1]))
# Scale the magnitude for display
magnitude = cv2.normalize(magnitude, None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8UC1)
# Display the magnitude of the Fourier Transform
cv2.imshow('Fourier Transform', magnitude)
cv2.waitKey(0)
cv2.destroyAllWindows()