Unexpected values for color at specific pixel

Hi,
You wrote CV_8UC4 it means four channels B,G,R,X x can bewhat you want.

cv::Scalar(0, 255, 0))

It’s only three channel and Ve3b too so it’s wrong
Use CV_8UC3 :

 cv::Mat greenMat(cv::Size(300, 300), CV_8UC3);