Skip to content
Snippets Groups Projects
Commit 8d24c311 authored by Nathan Lioret's avatar Nathan Lioret
Browse files

final commit

parent 31795a89
No related branches found
No related tags found
1 merge request!26Image Analysis project - Nathan Lioret
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
......@@ -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:
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment