| 1216 | } |
| 1217 | |
| 1218 | static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst, |
| 1219 | const Mat& _kernel, Point anchor, int iterations, |
| 1220 | int borderType, const Scalar &borderValue) |
| 1221 | { |
| 1222 | Mat src = _src.getMat(), kernel = _kernel; |
| 1223 | if( !( src.depth() == CV_8U || src.depth() == CV_32F ) || ( iterations > 1 ) || |
| 1224 | !( borderType == cv::BORDER_REPLICATE || (borderType == cv::BORDER_CONSTANT && borderValue == morphologyDefaultBorderValue()) ) |
| 1225 | || !( op == MORPH_DILATE || op == MORPH_ERODE) ) |
| 1226 | return false; |
| 1227 | if( borderType == cv::BORDER_CONSTANT && kernel.data ) |
| 1228 | { |
| 1229 | int x, y; |
| 1230 | for( y = 0; y < kernel.rows; y++ ) |
| 1231 | { |
| 1232 | if( kernel.at<uchar>(y, anchor.x) != 0 ) |
| 1233 | continue; |
| 1234 | for( x = 0; x < kernel.cols; x++ ) |
| 1235 | { |
| 1236 | if( kernel.at<uchar>(y,x) != 0 ) |
| 1237 | return false; |
| 1238 | } |
| 1239 | } |
| 1240 | for( x = 0; x < kernel.cols; x++ ) |
| 1241 | { |
| 1242 | if( kernel.at<uchar>(anchor.y, x) != 0 ) |
| 1243 | continue; |
| 1244 | for( y = 0; y < kernel.rows; y++ ) |
| 1245 | { |
| 1246 | if( kernel.at<uchar>(y,x) != 0 ) |
| 1247 | return false; |
| 1248 | } |
| 1249 | } |
| 1250 | |
| 1251 | } |
| 1252 | Size ksize = kernel.data ? kernel.size() : Size(3,3); |
| 1253 | |
| 1254 | _dst.create( src.size(), src.type() ); |
| 1255 | Mat dst = _dst.getMat(); |
| 1256 | |
| 1257 | if( iterations == 0 || kernel.rows*kernel.cols == 1 ) |
| 1258 | { |
| 1259 | src.copyTo(dst); |
| 1260 | return true; |
| 1261 | } |
| 1262 | |
| 1263 | bool rectKernel = false; |
| 1264 | if( !kernel.data ) |
| 1265 | { |
| 1266 | ksize = Size(1+iterations*2,1+iterations*2); |
| 1267 | anchor = Point(iterations, iterations); |
| 1268 | rectKernel = true; |
| 1269 | iterations = 1; |
| 1270 | } |
| 1271 | else if( iterations >= 1 && countNonZero(kernel) == kernel.rows*kernel.cols ) |
| 1272 | { |
| 1273 | ksize = Size(ksize.width + (iterations-1)*(ksize.width-1), |
| 1274 | ksize.height + (iterations-1)*(ksize.height-1)), |
| 1275 | anchor = Point(anchor.x*iterations, anchor.y*iterations); |
no test coverage detected