Using halide with HDR images represented as float array
<p>that's my first post here so sorry if I do something wrong:). I will try to do my best.</p>

<p>I currently working on my HDR image processing program, and I wonna implement some basing TMO using Halide. Problem is all my images are represented as float array (with order like: b1,g1,r1,a1, b2,g2,r2,a2, ... ). Using Halide to process image require Halide::Image class. Problem is I don't know how to pass those data there. </p>

<p>Anyone can help, or have same problem and know the answer?</p>

<p>Edit: </p>

<p>Finally got it! I need to set stride on input and output buffer in generator. Thx all for help:-)</p>

<p>Edit:</p>

<p>I tried two different ways:</p>

<pre><code>int halideOperations( float data[] , int size, int width,int heighy ) 
{ 
buffer_t input_buf = { 0 }; 
input_buf.host = &amp;data[0]; 
} 
</code></pre>

<p>or: </p>

<pre><code>int halideOperations( float data[] , int size, int width,int heighy ) 
{ 
Halide::Image(Halide::Type::Float, x, y, 0, 0, data);
}
</code></pre>

<p>I was thinking about editing Halide.h file and changing uint8_t * host to float_t * host but i don't think it's good idea.</p>

<p>Edit:</p>

<p>I tried using code below with my float image (RGBA):</p>

<p>AOT function generation:</p>

<pre><code>int main(int arg, char ** argv)
{
    Halide::ImageParam img(Halide::type_of&lt;float&gt;(), 3);
    Halide::Func f;
    Halide::Var x, y, c;
    f(x, y, c) = Halide::pow(img(x,y,c), 2.f);

    std::vector&lt;Halide::Argument&gt; arguments = { img };
    f.compile_to_file("function", arguments);
    return 0;
}
</code></pre>

<p>Proper code calling:</p>

<pre><code>int halideOperations(float data[], int size, int width, int height)
{
    buffer_t  output_buf = { 0 };
    buffer_t buf = { 0 };
    buf.host = (uint8_t *)data; 
    float * output = new float[width * height * 4];
    output_buf.host = (uint8_t*)(output);
    output_buf.extent[0] = buf.extent[0] = width; 
    output_buf.extent[1] = buf.extent[1] = height; 
    output_buf.extent[2] = buf.extent[2] = 4;
    output_buf.stride[0] = buf.stride[0] = 4;
    output_buf.stride[1] = buf.stride[1] = width * 4;
    output_buf.elem_size = buf.elem_size = sizeof(float);

    function(&amp;buf, &amp;output_buf);

    delete output;
    return 1;
}
</code></pre>

<p>unfortunately I got crash with msg:</p>

<pre><code> Error: Constraint violated: f0.stride.0 (4) == 1 (1)
</code></pre>

<p>I think something is wrong with this line: output_buf.stride[0] = buf.stride[0] = 4, but I'm not sure what should I change. Any tips?</p>