This is my code
Float * ptr_image_r=image_data;
Float * ptr_image_g=image_data + size/3;
Float * ptr_image_b=image_data + size/3 * 2;
Float mean_b=0.485;
Float mean_g=0.456;
Float mean_r=0.406;
Float std_b=0.229;
Float std_g=0.224;
Float std_r=0.225;
Auto data1=im. Ptr(0);
STD: : cout & lt;(* data1) & lt;
for (int i=0; i{
Auto data=https://bbs.csdn.net/topics/im.ptr(I);
For (int j=0; J & lt; Im. Cols; J++)
{
* ptr_image_b + +=(static_cast & lt; Float> (* data++)/255.0 - mean_b)/std_b;
* ptr_image_g + +=(static_cast & lt; Float> (* data++)/255.0 - mean_g)/std_g;
* ptr_image_r + +=(static_cast & lt; Float> (* data++)/255.0 - mean_r)/std_r;
}
}
//transpose shape from (h, w, c) to (c, h, w)
For (int k=0; K & lt; 1; K++)
{
For (int c=0; C & lt; 3; + + c)
{
for (int i=0; i{
For (int j=0; J & lt; New_width; + + j)
{
Array. The push_back (static_cast & lt; Float> (image_data [new_width + j) (I * * 3 + c]));
}
}
}
}
//expend shape from (c, h, w) to (a, c, h, w)
Shape image_shape=Shape (1, 3, new_height, new_width);
NDArray transformed_image=NDArray (image_shape, (* model_p) global_ctx, false);
Transformed_image. SyncCopyFromCPU (array. The data (), image_shape. The Size ());
NDArray: : WaitAll ();