I'd suggest another way:
<pre>
Mat bound (img.rows, img.cols, CV_8UC1, Scalar(0));
rectangle(bound, Rect(0, 0, img.cols, img.rows), Scalar::all(255));
</pre>