Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Assert that your input image and mask are also numpy array, you can do this :

import numpy as np import cv2

imageAllBlurred = cv2.medianBlur(image,ksize) # with a kernel size value 'ksize' equals to 3 for example imageBlurredInMask = np.where(mask==0,imageAllBlurred,image)

Assert that your input image and mask are also numpy array, you can do this :

import numpy as np import cv2

imageAllBlurred = cv2.medianBlur(image,ksize) # with a kernel size value 'ksize' equals to 3 for example imageBlurredInMask = np.where(mask==0,imageAllBlurred,image)np.where(mask!=0,imageAllBlurred,image)

click to hide/show revision 3
No.3 Revision

Assert that your input image and mask are also numpy array, you can do this :

import numpy as np
import cv2

cv2

imageAllBlurred = cv2.medianBlur(image,ksize) # with a kernel size value 'ksize' equals to 3 for example imageBlurredInMask = np.where(mask!=0,imageAllBlurred,image)

np.where(mask!=0,imageAllBlurred,image)