Hi,
You didn't post the output of these calls, so it's hard to know what went wrong with this exact image.
But, png images usually come with 3 channels (or 4, since they can also have an alpha channel). You can load them as grayscale via:
original_mask = cv2.imread(imgfile, cv2.IMREAD_GRAYSCALE)
If you want a binary mask (assumes original_mask has values in [0, 255]):
thresh, binary_mask = cv2.threshold(original_mask, 127, 255, cv2.THRESH_BINARY)
All very cumbersome. An alternative is to use scikit-image:
import numpy as np
import skimage.io as skio
binary_mask = skio.imread(imgfile, dtype=np.uint8)
You can also store them as dtype=np.bool, in which case all "pixel values" are True/False.
A sidenote is that cv2.resize does not change the number of channels. If you're image has size (n, n, 3) and you resize by specifying (k, k), then the resulting image will be (k, k, 3), not (k, k, 1).
Cheers,
Michael