diff --git a/src/methods/template/reconstruct.py b/src/methods/template/reconstruct.py index a97bd3f6e3c68df763b36c46b2727461af078bd2..7861be22030f5c44f160449144080c09c3a9a33d 100755 --- a/src/methods/template/reconstruct.py +++ b/src/methods/template/reconstruct.py @@ -7,6 +7,7 @@ Students can call their functions (declared in others files of src/methods/your_ import numpy as np from src.forward_model import CFA +from src.methods.template.somefunc import spectral_difference, normalization, quad_bayer_to_bayer_pattern, quad_bayer_to_bayer_image, bilinear_interpolation def run_reconstruction(y: np.ndarray, cfa: str) -> np.ndarray: @@ -20,11 +21,26 @@ def run_reconstruction(y: np.ndarray, cfa: str) -> np.ndarray: np.ndarray: Demosaicked image. """ # Performing the reconstruction. - # TODO + input_shape = (y.shape[0], y.shape[1], 3) op = CFA(cfa, input_shape) - return np.zeros(op.input_shape) + if op.cfa != 'bayer' and op.cfa != 'quad_bayer': + raise ValueError("CFA must be bayer or quad_bayer") + + if op.cfa == 'quad_bayer': + quad_bayer_to_bayer_pattern(op) + quad_bayer_to_bayer_image(y) + + # Apply adjoint operation on raw aquisition + z = op.adjoint(y) + + # Demosaicing process + res_bi = bilinear_interpolation(op, z) + res_sd = spectral_difference(op, z, res_bi) + res = normalization(res_sd) # min-max normalization + + return res ####