I couldnot translate this into Python/OpenCV. Can s.o. please help…
cvClose(mask, mask, se21);
cvOpen(mask, mask, se11);
Hope you are using new cv2 interface of OpenCV-Python.
If my assumption is correct, this is morphological opening and closing operations.
You can use cv2.morphologyEx
function for this, with corresponding flags, like MORPH_OPEN, MORPH_CLOSE
etc.
Closing is dilation of image followed by erosion and is used to remove small black holes inside white bodies.
Opening is erosion of image followed by dilation and is used to remove small white blobs or points in an image.
More about Opening and Closing :
Alternatively you can use cv2.erode and cv2.dilate
functions for this.
You can find an example here : https://github.com/abidrahmank/OpenCV2-Python/blob/master/Official_Tutorial_Python_Codes/3_imgproc/morphology_1.py