Add fft
scripts
This commit is contained in:
parent
4bab354a95
commit
810bde8e35
@ -3,8 +3,24 @@ import numpy as np
|
||||
import imageio
|
||||
from PIL import Image, ImageDraw
|
||||
import matplotlib.pyplot as plt
|
||||
import sys
|
||||
|
||||
image = imageio.imread('image.jpg', mode = 'L')
|
||||
sys.path.insert(0, '../')
|
||||
|
||||
from utils import Color, mergeSingleColorChannelImagesAccordingToBayerFilter
|
||||
|
||||
PREFIX = 'mean_rafael_230424_mean_'
|
||||
|
||||
def getImageByColor(color):
|
||||
filePath = PREFIX + f'{color}.npy'
|
||||
image = np.load(filePath)
|
||||
return image
|
||||
|
||||
singleColorChannelImages = {color: getImageByColor(color) for color in Color}
|
||||
multipleColorsImage = mergeSingleColorChannelImagesAccordingToBayerFilter(singleColorChannelImages)
|
||||
image = multipleColorsImage
|
||||
|
||||
#image = imageio.imread('image.jpg', mode = 'L')
|
||||
#plt.imshow(image, cmap = 'grey')
|
||||
#plt.show()
|
||||
|
||||
@ -17,7 +33,7 @@ fft1 = fftpack.fftshift(fftpack.fft2(imageNp))
|
||||
# create a low pass filter image
|
||||
x, y = imageNp.shape
|
||||
# size of circle
|
||||
CIRCLE_RADIUS = 50
|
||||
CIRCLE_RADIUS = 20
|
||||
eX, eY = CIRCLE_RADIUS, CIRCLE_RADIUS
|
||||
# create a box
|
||||
middleX, middleY = x / 2, y / 2
|
||||
@ -38,4 +54,6 @@ ifft2 = np.real(fftpack.ifft2(fftpack.ifftshift(filtered)))
|
||||
ifft2 = np.maximum(0, np.minimum(ifft2, 255))
|
||||
|
||||
# save the image
|
||||
imageio.imsave('fft-then-ifft.png', ifft2.astype(np.uint8))
|
||||
plt.imshow(ifft2)
|
||||
plt.show()
|
||||
#imageio.imsave('fft-then-ifft.png', ifft2.astype(np.uint8))
|
13
datasets/raise/fft/fourier_to_image.py
Normal file
13
datasets/raise/fft/fourier_to_image.py
Normal file
@ -0,0 +1,13 @@
|
||||
from PIL import Image
|
||||
import numpy as np
|
||||
|
||||
fft = np.array(Image.open('fft.png').convert('L'))# / 255
|
||||
print(fft)
|
||||
|
||||
ifft2 = np.real(fftpack.ifft2(fftpack.ifftshift(fft)))
|
||||
ifft2 = np.maximum(0, np.minimum(ifft2, 255)) * 255# / 255
|
||||
|
||||
# save the image
|
||||
plt.imshow(ifft2)
|
||||
plt.show()
|
||||
#plt.imsave('ifft2.png', ifft2)
|
15
datasets/raise/fft/image_to_fourier.py
Normal file
15
datasets/raise/fft/image_to_fourier.py
Normal file
@ -0,0 +1,15 @@
|
||||
from PIL import Image
|
||||
import numpy as np
|
||||
|
||||
image = np.array(Image.open('image_4.png').convert('L'))# / 255
|
||||
print(image)
|
||||
|
||||
# fft of image
|
||||
# fftpack.fftshift
|
||||
fft1 = (fftpack.fft2(image))
|
||||
|
||||
# save the image
|
||||
# np.log10
|
||||
plt.imshow(np.log10(abs(fft1)))
|
||||
plt.show()
|
||||
#plt.imsave('ifft1.png', fft1)
|
Loading…
x
Reference in New Issue
Block a user