forked from bobobo1618/halideraw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
34 lines (28 loc) · 1.08 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <libraw/libraw.h>
#include <iostream>
#include <Halide.h>
#include <HalideRuntime.h>
#include "KHC_YHC_demosaic_halide.h"
#include "halide_image_io.h"
using namespace Halide;
int main(int argc, char const *argv[])
{
LibRaw rawProcessor;
rawProcessor.open_file(argv[argc-1]);
rawProcessor.unpack();
buffer_t input_buf = {0};
input_buf.host = (uint8_t *)rawProcessor.imgdata.rawdata.raw_image;
input_buf.stride[0] = 1;
input_buf.stride[1] = rawProcessor.imgdata.sizes.width;
input_buf.extent[0] = rawProcessor.imgdata.sizes.width;
input_buf.extent[1] = rawProcessor.imgdata.sizes.height;
input_buf.elem_size = sizeof(*rawProcessor.imgdata.rawdata.raw_image);
Image<uint16_t> in_image = Image<uint16_t>(&input_buf, "image");
ImageParam param = ImageParam(UInt(16), 2);
Func output = make_demosaic_func(param, UInt(8));
param.set(in_image);
Image<uint8_t> output_image = output.realize(in_image.width(), in_image.height(), 3);
output_image.copy_to_host();
Tools::save_image(output_image, "test.png");
return 0;
}