当前位置: 首页>>代码示例>>C++>>正文


C++ Func::chunk方法代码示例

本文整理汇总了C++中Func::chunk方法的典型用法代码示例。如果您正苦于以下问题:C++ Func::chunk方法的具体用法?C++ Func::chunk怎么用?C++ Func::chunk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Func的用法示例。


在下文中一共展示了Func::chunk方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: process

Func process(Func raw, Type result_type,
             UniformImage matrix_3200, UniformImage matrix_7000, Uniform<float> color_temp, 
             Uniform<float> gamma, Uniform<float> contrast) {

    Func processed("processed");
    Var xi, yi;

    Func denoised = hot_pixel_suppression(raw);
    Func deinterleaved = deinterleave(denoised);
    Func demosaiced = demosaic(deinterleaved);
    Func corrected = color_correct(demosaiced, matrix_3200, matrix_7000, color_temp);
    Func curved = apply_curve(corrected, result_type, gamma, contrast);

    // Schedule
    Var co, ci;
    //#define USE_CI_HACK
    #ifndef USE_CI_HACK
    ci = c;
    #endif
    processed(tx, ty, c) = curved(tx, ty, ci);
    #ifdef USE_CI_HACK
    processed.split(c, co, ci, 3); // bound color loop to 0-3
    #else
    processed.bound(c, 0, 3); // bound color loop 0-3, properly
    #endif
    if (schedule == 0) {
        // Compute in chunks over tiles, vectorized by 8
        denoised.chunk(tx).vectorize(x, 8);
        deinterleaved.chunk(tx).vectorize(x, 8);
        corrected.chunk(tx).vectorize(x, 4);
        processed.tile(tx, ty, xi, yi, 32, 32).reorder(xi, yi, ci, tx, ty);
        processed.parallel(ty);
    } else if (schedule == 1) {
        // Same as above, but don't vectorize (sse is bad at interleaved 16-bit ops)
        denoised.chunk(tx);
        deinterleaved.chunk(tx);
        corrected.chunk(tx);
        processed.tile(tx, ty, xi, yi, 128, 128).reorder(xi, yi, ci, tx, ty);
        processed.parallel(ty);
    } else {
        denoised.root();
        deinterleaved.root();
        corrected.root();
        processed.root();
    }

    return processed;
}
开发者ID:iitaku,项目名称:Halide,代码行数:48,代码来源:camera_pipe.cpp

示例2: demosaic


//.........这里部分代码省略.........
    b_gr(x, y) = correction + (b_b(x, y) + b_b(x, y-1))/2;

    correction = g_gb(x, y) - (g_r(x, y) + g_r(x, y+1))/2;
    r_gb(x, y) = correction + (r_r(x, y) + r_r(x, y+1))/2;

    correction = g_gb(x, y) - (g_b(x, y) + g_b(x+1, y))/2;
    b_gb(x, y) = correction + (b_b(x, y) + b_b(x+1, y))/2;

    // Now interpolate diagonally to get red at blue and blue at
    // red. Hold onto your hats; this gets really fancy. We do the
    // same thing as for interpolating green where we try both
    // directions (in this case the positive and negative diagonals),
    // and use the one with the lowest absolute difference. But we
    // also use the same trick as interpolating red and blue at green
    // sites - we correct our interpolations using the second
    // derivative of green at the same sites.

    correction = g_b(x, y)  - (g_r(x, y) + g_r(x-1, y+1))/2;
    Expr rp_b  = correction + (r_r(x, y) + r_r(x-1, y+1))/2;
    Expr rpd_b = abs(r_r(x, y) - r_r(x-1, y+1));

    correction = g_b(x, y)  - (g_r(x-1, y) + g_r(x, y+1))/2;
    Expr rn_b  = correction + (r_r(x-1, y) + r_r(x, y+1))/2;
    Expr rnd_b = abs(r_r(x-1, y) - r_r(x, y+1));

    r_b(x, y)  = select(rpd_b < rnd_b, rp_b, rn_b);


    // Same thing for blue at red
    correction = g_r(x, y)  - (g_b(x, y) + g_b(x+1, y-1))/2;
    Expr bp_r  = correction + (b_b(x, y) + b_b(x+1, y-1))/2;
    Expr bpd_r = abs(b_b(x, y) - b_b(x+1, y-1));

    correction = g_r(x, y)  - (g_b(x+1, y) + g_b(x, y-1))/2;
    Expr bn_r  = correction + (b_b(x+1, y) + b_b(x, y-1))/2;
    Expr bnd_r = abs(b_b(x+1, y) - b_b(x, y-1));

    b_r(x, y)  =  select(bpd_r < bnd_r, bp_r, bn_r);    

    // Interleave the resulting channels
    Func r = interleave_y(interleave_x(r_gr, r_r),
                          interleave_x(r_b, r_gb));
    Func g = interleave_y(interleave_x(g_gr, g_r),
                          interleave_x(g_b, g_gb));
    Func b = interleave_y(interleave_x(b_gr, b_r),
                          interleave_x(b_b, b_gb));


    Func output;
    output(x, y, c) = select(c == 0, r(x, y), 
                             select(c == 1, g(x, y), b(x, y)));


    /* THE SCHEDULE */    
    if (schedule == 0) {
        // optimized for ARM
        // Compute these in chunks over tiles, vectorized by 8
        g_r.chunk(tx).vectorize(x, 8);
        g_b.chunk(tx).vectorize(x, 8);
        r_gr.chunk(tx).vectorize(x, 8);
        b_gr.chunk(tx).vectorize(x, 8);
        r_gb.chunk(tx).vectorize(x, 8);
        b_gb.chunk(tx).vectorize(x, 8);
        r_b.chunk(tx).vectorize(x, 8);
        b_r.chunk(tx).vectorize(x, 8);
        // These interleave in y, so unrolling them in y helps
        r.chunk(tx).vectorize(x, 8).unroll(y, 2);
        g.chunk(tx).vectorize(x, 8).unroll(y, 2);
        b.chunk(tx).vectorize(x, 8).unroll(y, 2);
    } else if (schedule == 1) {
        // optimized for X86
        // Don't vectorize, because sse is bad at 16-bit interleaving
        g_r.chunk(tx);
        g_b.chunk(tx);
        r_gr.chunk(tx);
        b_gr.chunk(tx);
        r_gb.chunk(tx);
        b_gb.chunk(tx);
        r_b.chunk(tx);
        b_r.chunk(tx);
        // These interleave in x and y, so unrolling them helps
        r.chunk(tx).unroll(x, 2).unroll(y, 2);
        g.chunk(tx).unroll(x, 2).unroll(y, 2);
        b.chunk(tx).unroll(x, 2).unroll(y, 2);
    } else {
        // Basic naive schedule
        g_r.root();
        g_b.root();
        r_gr.root();
        b_gr.root();
        r_gb.root();
        b_gb.root();
        r_b.root();
        b_r.root();
        r.root();
        g.root();
        b.root();
    }
    return output;
}
开发者ID:iitaku,项目名称:Halide,代码行数:101,代码来源:camera_pipe.cpp


注:本文中的Func::chunk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。