From 8d24c311cacb7bede825f3a80d74f22397d69ba4 Mon Sep 17 00:00:00 2001
From: Nathan Lioret <Nathan.Lioret@grenoble-inp.org>
Date: Wed, 31 Jan 2024 19:43:49 +0100
Subject: [PATCH] final commit

---
 src/methods/lioretn/README.txt      | 1 +
 src/methods/lioretn/demosaicking.py | 4 ++++
 src/methods/lioretn/reconstruct.py  | 2 --
 3 files changed, 5 insertions(+), 2 deletions(-)
 create mode 100644 src/methods/lioretn/README.txt

diff --git a/src/methods/lioretn/README.txt b/src/methods/lioretn/README.txt
new file mode 100644
index 0000000..adde0a7
--- /dev/null
+++ b/src/methods/lioretn/README.txt
@@ -0,0 +1 @@
+Quite simple to use : reconstruct.py file calls demosaicking.py (where is made the demosaicking) and is called by the main.ipynb
\ No newline at end of file
diff --git a/src/methods/lioretn/demosaicking.py b/src/methods/lioretn/demosaicking.py
index 7b2ed87..1b697d7 100644
--- a/src/methods/lioretn/demosaicking.py
+++ b/src/methods/lioretn/demosaicking.py
@@ -84,11 +84,13 @@ def high_quality_linear_interpolation(op : CFA, y : np.ndarray) -> np.ndarray:
                 if mask[i, j, G] == 1: # We must estimate R and B components
                     res[i, j, G] = y[i, j]
 
+                    # Estimate R (B at left and right or B at top and bottom)
                     if mask[i, max(0, j-1), R] == 1 or mask[i, min(y.shape[1]-1, j+1), R] == 1:
                         res[i, j, R] = float(convolve2d(y_pad[i_pad-2:i_pad+3, j_pad-2:j_pad+3], bayer_r_at_green_rrow_bcol, mode='valid'))
                     else:
                         res[i, j, R] = float(convolve2d(y_pad[i_pad-2:i_pad+3, j_pad-2:j_pad+3], bayer_r_at_green_brow_rcol, mode='valid'))
 
+                    # Estimate B (R at left and right or R at top and bottom)
                     if mask[i, max(0, j-1), B] == 1 or mask[i, min(y.shape[1]-1, j+1), B] == 1:
                         res[i, j, B] = float(convolve2d(y_pad[i_pad-2:i_pad+3, j_pad-2:j_pad+3], bayer_b_at_green_brow_rcol, mode='valid'))
                     else:
@@ -114,11 +116,13 @@ def high_quality_linear_interpolation(op : CFA, y : np.ndarray) -> np.ndarray:
                 if mask[i, j, G] == 1: # We must estimate R and B components
                     res[i:i+2, j:j+2, G] = y[i:i+2, j:j+2]
 
+                    # Estimate R (B at left and right or B at top and bottom)
                     if mask[i, max(0, j-1), R] == 1 or mask[i, min(y.shape[1]-1, j+1), R] == 1:
                         res[i:i+2, j:j+2, R] = float(convolve2d(y_pad[i_pad-4:i_pad+6, j_pad-4:j_pad+6], quad_r_at_green_rrow_bcol, mode='valid'))
                     else:
                         res[i:i+2, j:j+2, R] = float(convolve2d(y_pad[i_pad-4:i_pad+6, j_pad-4:j_pad+6], quad_r_at_green_brow_rcol, mode='valid'))
 
+                    # Estimate B (R at left and right or R at top and bottom)
                     if mask[i, max(0, j-1), B] == 1 or mask[i, min(y.shape[1]-1, j+1), B] == 1:
                         res[i:i+2, j:j+2, B] = float(convolve2d(y_pad[i_pad-4:i_pad+6, j_pad-4:j_pad+6], quad_b_at_green_brow_rcol, mode='valid'))
                     else:
diff --git a/src/methods/lioretn/reconstruct.py b/src/methods/lioretn/reconstruct.py
index 80f771a..5790f40 100644
--- a/src/methods/lioretn/reconstruct.py
+++ b/src/methods/lioretn/reconstruct.py
@@ -7,7 +7,6 @@ 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.lioretn.demoisaicing_fct import High_Quality_Linear_Interpolation
 from src.methods.lioretn.demosaicking import high_quality_linear_interpolation
 
 def run_reconstruction(y: np.ndarray, cfa: str) -> np.ndarray:
@@ -26,7 +25,6 @@ def run_reconstruction(y: np.ndarray, cfa: str) -> np.ndarray:
     op = CFA(cfa, input_shape)
 
     res = high_quality_linear_interpolation(op, y)
-    # res = High_Quality_Linear_Interpolation(op, y)
 
     return res
 
-- 
GitLab