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

Method inRange

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

Source from the content-addressed store, hash-verified

2696}
2697
2698void cv::inRange(InputArray _src, InputArray _lowerb,
2699 InputArray _upperb, OutputArray _dst)
2700{
2701 int skind = _src.kind(), lkind = _lowerb.kind(), ukind = _upperb.kind();
2702 Mat src = _src.getMat(), lb = _lowerb.getMat(), ub = _upperb.getMat();
2703
2704 bool lbScalar = false, ubScalar = false;
2705
2706 if( (lkind == _InputArray::MATX && skind != _InputArray::MATX) ||
2707 src.size != lb.size || src.type() != lb.type() )
2708 {
2709 if( !checkScalar(lb, src.type(), lkind, skind) )
2710 CV_Error( CV_StsUnmatchedSizes,
2711 "The lower bounary is neither an array of the same size and same type as src, nor a scalar");
2712 lbScalar = true;
2713 }
2714
2715 if( (ukind == _InputArray::MATX && skind != _InputArray::MATX) ||
2716 src.size != ub.size || src.type() != ub.type() )
2717 {
2718 if( !checkScalar(ub, src.type(), ukind, skind) )
2719 CV_Error( CV_StsUnmatchedSizes,
2720 "The upper bounary is neither an array of the same size and same type as src, nor a scalar");
2721 ubScalar = true;
2722 }
2723
2724 CV_Assert( ((int)lbScalar ^ (int)ubScalar) == 0 );
2725
2726 int cn = src.channels(), depth = src.depth();
2727
2728 size_t esz = src.elemSize();
2729 size_t blocksize0 = (size_t)(BLOCK_SIZE + esz-1)/esz;
2730
2731 _dst.create(src.dims, src.size, CV_8U);
2732 Mat dst = _dst.getMat();
2733 InRangeFunc func = getInRangeFunc(depth);
2734
2735 const Mat* arrays_sc[] = { &src, &dst, 0 };
2736 const Mat* arrays_nosc[] = { &src, &dst, &lb, &ub, 0 };
2737 uchar* ptrs[4];
2738
2739 NAryMatIterator it(lbScalar && ubScalar ? arrays_sc : arrays_nosc, ptrs);
2740 size_t total = it.size, blocksize = std::min(total, blocksize0);
2741
2742 AutoBuffer<uchar> _buf(blocksize*(((int)lbScalar + (int)ubScalar)*esz + cn) + 2*cn*sizeof(int) + 128);
2743 uchar *buf = _buf, *mbuf = buf, *lbuf = 0, *ubuf = 0;
2744 buf = alignPtr(buf + blocksize*cn, 16);
2745
2746 if( lbScalar && ubScalar )
2747 {
2748 lbuf = buf;
2749 ubuf = buf = alignPtr(buf + blocksize*esz, 16);
2750
2751 CV_Assert( lb.type() == ub.type() );
2752 int scdepth = lb.depth();
2753
2754 if( scdepth != depth && depth < CV_32S )
2755 {

Callers 1

image.test.jsFile · 0.80

Calls 15

checkScalarFunction · 0.85
getInRangeFuncFunction · 0.85
alignPtrFunction · 0.85
SizeFunction · 0.85
cvRoundFunction · 0.85
getMinValFunction · 0.85
getMaxValFunction · 0.85
MatClass · 0.85
convertAndUnrollScalarFunction · 0.85
inRangeReduceFunction · 0.85
kindMethod · 0.80
minFunction · 0.70

Tested by

no test coverage detected