onnxruntime/test/shared_lib/fns_candy_style_transfer.c
static void chw_to_hwc(const float* input, size_t h, size_t w, png_bytep* output) {
  size_t stride = h * w;
  png_bytep output_data = (png_bytep)malloc(stride * 3);
  for (int c = 0; c != 3; ++c) {
    size_t t = c * stride;
    for (size_t i = 0; i != stride; ++i) {
      float f = input[t + i];
      if (f < 0.f || f > 255.0f)
        f = 0;
      output_data[i * 3 + c] = (png_byte)f;
    }
  }
  *output = output_data;
}
/**
 * convert input from CHW format to HWC format
 * \param input A single image. This float array has length of 3*h*w
 * \param h image height
 * \param w image width
 * \param output A byte array. should be freed by caller after use
 */
convert input from CHW format to HWC format
\param input A single image. This float array has length of 3*h*w
\param h image height
\param w image width
\param output A byte array. should be freed by caller after use
convert input from CHW format to HWC format \ param input A single image . This float array has length of 3 * h * w \ param h image height \ param w image width \ param output A byte array . should be freed by caller after use
static void chw_to_hwc(const float* input, size_t h, size_t w, png_bytep* output) {
  size_t stride = h * w;
  png_bytep output_data = (png_bytep)malloc(stride * 3);
  for (int c = 0; c != 3; ++c) {
    size_t t = c * stride;
    for (size_t i = 0; i != stride; ++i) {
      float f = input[t + i];
      if (f < 0.f || f > 255.0f)
        f = 0;
      output_data[i * 3 + c] = (png_byte)f;
    }
  }
  *output = output_data;
}
static void chw_to_hwc ( const float * input , size_t h , size_t w , png_bytep * output ) { size_t stride = h * w ; png_bytep output_data = ( png_bytep ) malloc ( stride * 3 ) ; for ( int c = 0 ; c != 3 ; ++ c ) { size_t t = c * stride ; for ( size_t i = 0 ; i != stride ; ++ i ) { float f = input [ t + i ] ; if ( f < 0.f || f > 255.0f ) f = 0 ; output_data [ i * 3 + c ] = ( png_byte ) f ; } } * output = output_data ; }
convert input from CHW format to HWC format
 \param input A single image.
convert input from CHW format to HWC format \ param input A single image .