NPRC24 / OzUVGL /ips /__init__.py
Artyom
ozuvgl
1b5ee0e verified
from ips.ops import *
def process(raw_image, metadata):
out = normalize(raw_image, metadata["black_level"], metadata["white_level"])
out = demosaic(out, metadata["cfa_pattern"])
out = raw_color_denoise(out, metadata["noise_profile"][1])
out = white_balance(out, metadata)
color_matrix = [ # average color transformation matrix of Huawei Mate 40 Pro
1.06835938, -0.29882812, -0.14257812,
-0.43164062, 1.35546875, 0.05078125,
-0.1015625, 0.24414062, 0.5859375
]
out = xyz_transform(out, color_matrix)
out = xyz_to_srgb(out)
out = luminance_denoise(out, metadata["tv_weight"])
out = perform_tone_mapping(out, metadata)
out = global_mean_contrast(out, metadata["global_mc_beta"])
out = s_curve_correction(out, metadata["scc_alpha"], metadata["scc_lambda"])
out = histogram_stretching(out)
out = memory_color_enhancement(out)
out = unsharp_masking(out)
out = to_uint8(out)
out = resize(out, metadata["exp_width"], metadata["exp_height"]) # None means direct return the image, change the params to (w, h) if downsampling required.
out = fix_orientation(out, metadata["orientation"])
return out