About changes in "cpp" file. I think, that author had in mind that: if w...

"Cpp" changes. I think, that author have in mind this: if we have 4 arguments and 4th arg. is G (G,-from gray scale), - then, read the image in Mat I, with appropriate mode (gray scale).
Otherwise, do the same, but with color mode.
+ made few changes in tutorial. I think, that now, it's will be more understandable.