Your code:
putText(imageOutput,"x:",Point(pos[0],pos[1]),1,1,Scalar(255,0,0),2);
Your question:
What does the Scalar function do?
You are creating a Scalar object, you can see the documentation here
If you want to create a BGR (full colour) image then you can initialise the Scalar with Scalar(B,G,R)
. However if you only want a greyscale image all you need to do is initialise it with your greyscale value:
Scalar(greyScaleValue);
so your code would be:
putText(imageOutput,"x:",Point(pos[0],pos[1]),1,1,Scalar(30),2);
for a greyscale value of 30.