#33: Add datasets/raise/extract_noise.py
This commit is contained in:
parent
4dd52aae90
commit
faed1e33e8
23
datasets/raise/extract_noise.py
Executable file
23
datasets/raise/extract_noise.py
Executable file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
from skimage.restoration import denoise_tv_chambolle
|
||||
from skimage import img_as_float
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
import os
|
||||
from tqdm import tqdm
|
||||
import gzip
|
||||
|
||||
imagesFolderPath = 'tif'
|
||||
npArrayFolderPath = 'np'
|
||||
|
||||
for imageFileName in tqdm(os.listdir(imagesFolderPath)):
|
||||
npArrayFilePath = f'{npArrayFolderPath}/{imageFileName}.npy.gz'
|
||||
if os.path.isfile(npArrayFilePath):
|
||||
continue
|
||||
imageFilePath = f'{imagesFolderPath}/{imageFileName}'
|
||||
imagePil = Image.open(imageFilePath)
|
||||
imageNpArray = img_as_float(np.array(imagePil))
|
||||
imageNoiseNpArray = imageNpArray - denoise_tv_chambolle(imageNpArray, weight=0.2, channel_axis=-1)
|
||||
with gzip.open(npArrayFilePath, 'wb') as f:
|
||||
np.save(f, imageNoiseNpArray)
|
Loading…
Reference in New Issue
Block a user