You need to apply the following transformations:
Y = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16
Cb = U = -(0.148 * R) - (0.291 * G) + (0.439 * B) + 128
Cr = V = (0.439 * R) - (0.368 * G) - (0.071 * B) + 128
//Read in an image in BGR
Mat src = imread("bgr.png");
//If (x,y) are the coordinates of the pixel that you want to transform then
uchar Y = (0.257 * src.at<Vec3b>(x, y)[2]) + (0.504 * src.at<Vec3b>(x, y)[1]) + (0.098 * src.at<Vec3b>(x, y)[0]) + 16;
uchar U = -(0.148 * src.at<Vec3b>(x, y)[2]) - (0.291 * src.at<Vec3b>(x, y)[1]) + (0.439 * src.at<Vec3b>(x, y)[0]) + 128;
uchar V = (0.439 * src.at<Vec3b>(x, y)[2]) - (0.368 * src.at<Vec3b>(x, y)[1]) - (0.071 * src.at<Vec3b>(x, y)[0]) + 128;
did you see my comment in your previous question? Moreover, how do you expect to obtain the YUV values without applying the appropriate transformation?