99from utils .yacs import Config
1010
1111
12- output_dir = './output'
13- os .makedirs (output_dir , exist_ok = True )
12+ OUTPUT_DIR = './output'
13+ os .makedirs (OUTPUT_DIR , exist_ok = True )
1414
1515
1616def demo_test_raw ():
17- print ('Processing test raw started' )
18-
1917 cfg = Config ('configs/test.yaml' )
2018 pipeline = Pipeline (cfg )
2119
@@ -25,14 +23,12 @@ def demo_test_raw():
2523
2624 data , _ = pipeline .execute (bayer )
2725
28- output_path = op .join (output_dir , 'test.png' )
26+ output_path = op .join (OUTPUT_DIR , 'test.png' )
2927 output = cv2 .cvtColor (data ['output' ], cv2 .COLOR_RGB2BGR )
3028 cv2 .imwrite (output_path , output )
3129
3230
3331def demo_nikon_d3x ():
34- print ('\n Processing Nikon D3x raw started' )
35-
3632 cfg = Config ('configs/nikon_d3x.yaml' )
3733 pipeline = Pipeline (cfg )
3834
@@ -41,11 +37,43 @@ def demo_nikon_d3x():
4137
4238 data , _ = pipeline .execute (bayer )
4339
44- output_path = op .join (output_dir , 'color_checker.png' )
40+ output_path = op .join (OUTPUT_DIR , 'color_checker.png' )
4541 output = cv2 .cvtColor (data ['output' ], cv2 .COLOR_RGB2BGR )
4642 cv2 .imwrite (output_path , output )
4743
4844
45+ def demo_intermediate_results ():
46+ cfg = Config ('configs/nikon_d3x.yaml' )
47+
48+ # Boost parameters for exaggeration effect
49+ with cfg .unfreeze ():
50+ cfg .module_enable_status .nlm = True
51+ cfg .nlm .h = 15
52+ cfg .eeh .flat_threshold = 1
53+ cfg .eeh .flat_threshold = 2
54+ cfg .eeh .edge_gain = 1280
55+ cfg .hsc .saturation_gain = 384
56+ cfg .bcc .contrast_gain = 300
57+
58+ pipeline = Pipeline (cfg )
59+
60+ pgm_path = 'raw/color_checker.pgm'
61+ bayer = skimage .io .imread (pgm_path ).astype (np .uint16 )
62+
63+ _ , intermediates = pipeline .execute (bayer , save_intermediates = True )
64+ for module_name , result in intermediates .items ():
65+ output = pipeline .get_output (result )
66+ output_path = op .join (OUTPUT_DIR , '{}.jpg' .format (module_name ))
67+ output = cv2 .cvtColor (output , cv2 .COLOR_RGB2BGR )
68+ cv2 .imwrite (output_path , output )
69+
70+
4971if __name__ == '__main__' :
72+ print ('Processing test raw...' )
5073 demo_test_raw ()
74+
75+ print ('Processing Nikon D3x raw...' )
5176 demo_nikon_d3x ()
77+
78+ print ('Processing Nikon D3x raw with intermediate results...' )
79+ demo_intermediate_results ()
0 commit comments