diff --git a/datasets/raise/fft/get_ft_prnu.py b/datasets/raise/fft/get_ft_prnu.py new file mode 100644 index 0000000..cb157a1 --- /dev/null +++ b/datasets/raise/fft/get_ft_prnu.py @@ -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() +