0

I couldnot translate this into Python/OpenCV. Can s.o. please help…

cvClose(mask, mask, se21);  
cvOpen(mask, mask, se11);  
fabian
  • 5,433
  • 10
  • 61
  • 92

1 Answers1

1

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 :

  1. http://homepages.inf.ed.ac.uk/rbf/HIPR2/open.htm
  2. http://homepages.inf.ed.ac.uk/rbf/HIPR2/close.htm

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

Abid Rahman K
  • 51,886
  • 31
  • 146
  • 157
  • Oh I just use 'import cv' – installed python and opencv via macports. How Do I get the cv2-interface? – fabian Dec 11 '12 at 07:38
  • 1
    Even if you are using `cv` interface, still you use the function,`cv.MorphologyEx`, check same links I provided. To know more about cv2 interface, check following links – Abid Rahman K Dec 11 '12 at 13:10
  • Install cv2 in windows 7 : http://stackoverflow.com/q/4709301/1134940 ... (I don't know about Mac, may be google it) – Abid Rahman K Dec 11 '12 at 13:12