Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Morphology in opencv works on set of white pixels. So all dual operations are inverted. If you want classic hit or miss, do this:

Mat kernel; // Define your kernel
Mat negkernel;
bitwise_not(element,negkerne);
negkernel = negkernel- 254;

Mat erode;
Mat negerode;

morphologyEx(img, erode, MORPH_DILATE, kernel);
morphologyEx(negerode, negerode, MORPH_DILATE, negkernel);

Mat output;
bitwise_or(erode,negerode,output);