| 1287 | #endif |
| 1288 | |
| 1289 | static void morphOp( int op, InputArray _src, OutputArray _dst, |
| 1290 | InputArray _kernel, |
| 1291 | Point anchor, int iterations, |
| 1292 | int borderType, const Scalar& borderValue ) |
| 1293 | { |
| 1294 | Mat kernel = _kernel.getMat(); |
| 1295 | Size ksize = kernel.data ? kernel.size() : Size(3,3); |
| 1296 | anchor = normalizeAnchor(anchor, ksize); |
| 1297 | |
| 1298 | CV_Assert( anchor.inside(Rect(0, 0, ksize.width, ksize.height)) ); |
| 1299 | |
| 1300 | #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) |
| 1301 | if( IPPMorphOp(op, _src, _dst, kernel, anchor, iterations, borderType, borderValue) ) |
| 1302 | return; |
| 1303 | #endif |
| 1304 | |
| 1305 | Mat src = _src.getMat(); |
| 1306 | |
| 1307 | _dst.create( src.size(), src.type() ); |
| 1308 | Mat dst = _dst.getMat(); |
| 1309 | |
| 1310 | if( iterations == 0 || kernel.rows*kernel.cols == 1 ) |
| 1311 | { |
| 1312 | src.copyTo(dst); |
| 1313 | return; |
| 1314 | } |
| 1315 | |
| 1316 | if( !kernel.data ) |
| 1317 | { |
| 1318 | kernel = getStructuringElement(MORPH_RECT, Size(1+iterations*2,1+iterations*2)); |
| 1319 | anchor = Point(iterations, iterations); |
| 1320 | iterations = 1; |
| 1321 | } |
| 1322 | else if( iterations > 1 && countNonZero(kernel) == kernel.rows*kernel.cols ) |
| 1323 | { |
| 1324 | anchor = Point(anchor.x*iterations, anchor.y*iterations); |
| 1325 | kernel = getStructuringElement(MORPH_RECT, |
| 1326 | Size(ksize.width + (iterations-1)*(ksize.width-1), |
| 1327 | ksize.height + (iterations-1)*(ksize.height-1)), |
| 1328 | anchor); |
| 1329 | iterations = 1; |
| 1330 | } |
| 1331 | |
| 1332 | int nStripes = 1; |
| 1333 | #if defined HAVE_TEGRA_OPTIMIZATION |
| 1334 | if (src.data != dst.data && iterations == 1 && //NOTE: threads are not used for inplace processing |
| 1335 | (borderType & BORDER_ISOLATED) == 0 && //TODO: check border types |
| 1336 | src.rows >= 64 ) //NOTE: just heuristics |
| 1337 | nStripes = 4; |
| 1338 | #endif |
| 1339 | |
| 1340 | parallel_for_(Range(0, nStripes), |
| 1341 | MorphologyRunner(src, dst, nStripes, iterations, op, kernel, anchor, borderType, borderType, borderValue)); |
| 1342 | |
| 1343 | //Ptr<FilterEngine> f = createMorphologyFilter(op, src.type(), |
| 1344 | // kernel, anchor, borderType, borderType, borderValue ); |
| 1345 | |
| 1346 | //f->apply( src, dst ); |
no test coverage detected