Most likely since cv2.resize uses some interpolation method (default is linear interpolation if I’m not mistaken) other than “nearest neighbors”.
Try to pass cv2.INTER_NEAREST as the method to this function.