assuming, Activerows, Activecols
actually mean, what they say,
try to stick with conventional x:cols, y:rows
indexing
Mat image(Activerows, Activecols, CV_8UC3); // Mat is 'row major'
for (int x = 0; x<Activecols; x++)
for (y = 0; y<Activerows; y++)
{
// get a *reference* to the pixel,
// make sure to get the type right, CV_8UC3 <--> Vec3b
Vec3b &pixel_val = image.at<Vec3b>(y,x);//toutes les composantes YCrCb
pixel_val[0] = matrice[y][x];//Y
pixel_val[1] = ????;//Cr
pixel_val[2] = ????;//Cb
// no need to 'set' anything, it's a reference
}
for further reference, please read tutorials