Files
deconv-test/scaling_converter.py

27 lines
785 B
Python
Raw Permalink Normal View History

2025-10-27 09:05:27 +02:00
"scaling the images, so that the maximums would be the same"
import numpy as np
import h5py
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--infile", type = str, help = "input file with all the calculated images")
parser.add_argument('--converted', type = str, help = 'name of the converted data file')
args = parser.parse_args()
with h5py.File(args.infile, 'r') as input_images, h5py.File(args.converted, 'w') as converter:
for name in input_images:
if isinstance(input_images[name], h5py.Group):
input_images.copy(name, converter)
def conv(name, obj):
if isinstance(obj, h5py.Dataset):
data = obj[:]
mod = data / np.max(data) * 100
obj[...] = mod
converter.visititems(conv)