MCPcopy Create free account
hub / github.com/creatale/node-dv / compare

Method compare

deps/opencv/modules/core/src/arithm.cpp:2461–2576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2459}
2460
2461void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
2462{
2463 CV_Assert( op == CMP_LT || op == CMP_LE || op == CMP_EQ ||
2464 op == CMP_NE || op == CMP_GE || op == CMP_GT );
2465
2466 int kind1 = _src1.kind(), kind2 = _src2.kind();
2467 Mat src1 = _src1.getMat(), src2 = _src2.getMat();
2468
2469 if( kind1 == kind2 && src1.dims <= 2 && src2.dims <= 2 && src1.size() == src2.size() && src1.type() == src2.type() )
2470 {
2471 int cn = src1.channels();
2472 _dst.create(src1.size(), CV_8UC(cn));
2473 Mat dst = _dst.getMat();
2474 Size sz = getContinuousSize(src1, src2, dst, src1.channels());
2475 getCmpFunc(src1.depth())(src1.data, src1.step, src2.data, src2.step, dst.data, dst.step, sz, &op);
2476 return;
2477 }
2478
2479 bool haveScalar = false;
2480
2481 if( (kind1 == _InputArray::MATX) + (kind2 == _InputArray::MATX) == 1 ||
2482 src1.size != src2.size || src1.type() != src2.type() )
2483 {
2484 if( checkScalar(src1, src2.type(), kind1, kind2) )
2485 {
2486 // src1 is a scalar; swap it with src2
2487 swap(src1, src2);
2488 op = op == CMP_LT ? CMP_GT : op == CMP_LE ? CMP_GE :
2489 op == CMP_GE ? CMP_LE : op == CMP_GT ? CMP_LT : op;
2490 }
2491 else if( !checkScalar(src2, src1.type(), kind2, kind1) )
2492 CV_Error( CV_StsUnmatchedSizes,
2493 "The operation is neither 'array op array' (where arrays have the same size and the same type), "
2494 "nor 'array op scalar', nor 'scalar op array'" );
2495 haveScalar = true;
2496 }
2497
2498
2499 int cn = src1.channels(), depth1 = src1.depth(), depth2 = src2.depth();
2500
2501 _dst.create(src1.dims, src1.size, CV_8UC(cn));
2502 src1 = src1.reshape(1); src2 = src2.reshape(1);
2503 Mat dst = _dst.getMat().reshape(1);
2504
2505 size_t esz = src1.elemSize();
2506 size_t blocksize0 = (size_t)(BLOCK_SIZE + esz-1)/esz;
2507 BinaryFunc func = getCmpFunc(depth1);
2508
2509 if( !haveScalar )
2510 {
2511 const Mat* arrays[] = { &src1, &src2, &dst, 0 };
2512 uchar* ptrs[3];
2513
2514 NAryMatIterator it(arrays, ptrs);
2515 size_t total = it.size;
2516
2517 for( size_t i = 0; i < it.nplanes; i++, ++it )
2518 func( ptrs[0], 0, ptrs[1], 0, ptrs[2], 0, Size((int)total, 1), &op );

Callers 2

hasMethod · 0.45
getStringMethod · 0.45

Calls 15

getContinuousSizeFunction · 0.85
getCmpFuncFunction · 0.85
checkScalarFunction · 0.85
SizeFunction · 0.85
convertAndUnrollScalarFunction · 0.85
getMinValFunction · 0.85
getMaxValFunction · 0.85
cvRoundFunction · 0.85
cvCeilFunction · 0.85
cvFloorFunction · 0.85
MatClass · 0.85
kindMethod · 0.80

Tested by

no test coverage detected