I'm less familiar with how slicing or this type of array access works. If it's like Matlab, then the alternative in C++ is to just make your own for loops that iterate over and copy elements.
img = gray
Implement a suitable grayscale algorithm by using the formula in https://en.wikipedia.org/wiki/Grayscale (converting color to grayscale section)
I'm sure there's also an image processing library that could do this as well, but I don't know of one off the top of my head, try a search.
I don't know what the rest of the stuff is. My advice is to not try to translate the whole thing at once. Just getting an image to load and printing out the RGB value of the first pixel will be enough of a challenge at first. Start small.