|
|
|
@ -2012,8 +2012,6 @@ void cv::morphologyEx( InputArray _src, OutputArray _dst, int op, |
|
|
|
|
CV_IPP_RUN_FAST(ipp_morphologyEx(op, src, dst, kernel, anchor, iterations, borderType, borderValue)); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
Mat k1, k2, e1, e2; //only for hit and miss op
|
|
|
|
|
|
|
|
|
|
switch( op ) |
|
|
|
|
{ |
|
|
|
|
case MORPH_ERODE: |
|
|
|
@ -2051,21 +2049,29 @@ void cv::morphologyEx( InputArray _src, OutputArray _dst, int op, |
|
|
|
|
break; |
|
|
|
|
case MORPH_HITMISS: |
|
|
|
|
CV_Assert(src.type() == CV_8UC1); |
|
|
|
|
if(countNonZero(kernel) <=0) |
|
|
|
|
{ |
|
|
|
|
src.copyTo(dst); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
Mat k1, k2, e1, e2; |
|
|
|
|
k1 = (kernel == 1); |
|
|
|
|
k2 = (kernel == -1); |
|
|
|
|
|
|
|
|
|
if (countNonZero(k1) <= 0) |
|
|
|
|
e1 = src; |
|
|
|
|
else |
|
|
|
|
erode(src, e1, k1, anchor, iterations, borderType, borderValue); |
|
|
|
|
if (countNonZero(k2) <= 0) |
|
|
|
|
e2 = src; |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
Mat src_complement; |
|
|
|
|
bitwise_not(src, src_complement); |
|
|
|
|
if (countNonZero(k2) <= 0) |
|
|
|
|
e2 = src_complement; |
|
|
|
|
else |
|
|
|
|
erode(src_complement, e2, k2, anchor, iterations, borderType, borderValue); |
|
|
|
|
} |
|
|
|
|
dst = e1 & e2; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
CV_Error( CV_StsBadArg, "unknown morphological operation" ); |
|
|
|
|