post_global_result=cv2.bitwise_and(image, image, mask=post_global_mask)
image : 환자 얼굴 이미지
post_global_mask : HSV, YCbCr, Gray 기반 추출 마스크를 모두 합친 mask
-> 환자 이미지에서 모든 색공간 기반 추출 마스크를 적용하는 bitwise_and 연산을 하려고 했는데, 다음과 같은 에러가 발생
error: (-215:Assertion failed) (mtype == CV_8U || mtype == CV_8S) && _mask.sameSize(*psrc1) in function 'cv::binary_op'
* 구글링 결과, 에러가 발생하는 다음 3가지 이유가 있었음.
1. 이미지 크기가 다름
-> image.shape 그리고 post_global_mask.shape 둘 다 같았음
2. 데이터 타입이 다름
-> image.dtype 그리고 post_global_mask.dtype 모두 uint8로 같았음
3. 마스크가 gray scale이 아님
-> image.shape = (_, _, 3)
-> post_global_mask.shape = (_, _, 3)
-> post_global_mask는 3채널 즉, gray scale이 아니였음
▶ 파일에서 mask를 불러올 때(cv2.imread), gray scale로 불러왔더니(cv2.IMREAD_GRAYSCALE) bistwise_and 연산이 잘 되었다!