cv::Mat convert channel to float[]

that would be: extractChannel()

however, given your C struct, it rather looks like you want “seperated colour planes” (not a single channel, but all 3 of them)

proposed solution is quite simple:;

// step 1: get seperated float planes in [0..1]
Mat floatimg;
src.convertTo(floatimg,  CV_32F, 1.0/255);
vector<Mat> planes;
split(floatimg, planes);

// step 2: assign to your C struct
t_image_rgb rgb;
rgb.b = planes[0].ptr<float>(0); // note: bgr vs rgb
rgb.g = planes[1].ptr<float>(0);
rgb.r = planes[2].ptr<float>(0);
1 Like