Image broke after togray

do you realize that your file has an alpha channel?

please consult docs for imread.

you need to ask for IMREAD_UNCHANGED.

further, cvtColor can’t convert to “grayscale with alpha”. that format isn’t defined.