| #include "samples/risp4ml/common/utils.h" |
| #include "samples/risp4ml/isp_stages/blc.h" |
| #include "samples/risp4ml/isp_stages/demosaic.h" |
| #include "samples/risp4ml/isp_stages/dg.h" |
| #include "samples/risp4ml/isp_stages/downscale.h" |
| #include "samples/risp4ml/isp_stages/gamma.h" |
| #include "samples/risp4ml/isp_stages/wbg.h" |
| #include "samples/risp4ml/pipeline/pipeline.h" |
| |
| void isp_pipeline(ImageU8 *input, ImageU8 *output) { |
| Image *img_bayer = |
| image_new(input->num_channels, input->height, input->width); |
| // shift the 8bits wide input to 16bits (the processing pipeline bitwidth) |
| const uint32_t input_dimensions = |
| input->num_channels * input->height * input->width; |
| for (uint32_t i = 0; i < input_dimensions; ++i) { |
| img_bayer->data[i] = input->data[i] << kRawPipelineFraction; // 8 |
| } |
| |
| // black level offset (in-place) |
| blc_process(img_bayer); |
| |
| // digital gain (in-place) |
| dg_process(img_bayer); |
| |
| // white balance gain (in-place) |
| wbg_process(img_bayer); |
| |
| // demosaic |
| Image *img_color = |
| image_new(output->num_channels, input->height, input->width); |
| demosaic_process(img_bayer, img_color); |
| image_delete(img_bayer); |
| |
| // gamma correction (in-place) |
| gamma_process(img_color); |
| |
| // downscaler |
| set_downscale_factor(img_color, output); |
| downscale_process(img_color, output); |
| image_delete(img_color); |
| } |