بایستی از تابع randu استفاده کنید.
به صورت زیر عمل کنید.
Mat img; randu(img,Scalar::all(100),Scalar::all(200));