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

Class MorphologyRunner

deps/opencv/modules/imgproc/src/morph.cpp:1076–1140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1074{
1075
1076class MorphologyRunner : public ParallelLoopBody
1077{
1078public:
1079 MorphologyRunner(Mat _src, Mat _dst, int _nStripes, int _iterations,
1080 int _op, Mat _kernel, Point _anchor,
1081 int _rowBorderType, int _columnBorderType, const Scalar& _borderValue) :
1082 borderValue(_borderValue)
1083 {
1084 src = _src;
1085 dst = _dst;
1086
1087 nStripes = _nStripes;
1088 iterations = _iterations;
1089
1090 op = _op;
1091 kernel = _kernel;
1092 anchor = _anchor;
1093 rowBorderType = _rowBorderType;
1094 columnBorderType = _columnBorderType;
1095 }
1096
1097 void operator () ( const Range& range ) const
1098 {
1099 int row0 = min(cvRound(range.start * src.rows / nStripes), src.rows);
1100 int row1 = min(cvRound(range.end * src.rows / nStripes), src.rows);
1101
1102 /*if(0)
1103 printf("Size = (%d, %d), range[%d,%d), row0 = %d, row1 = %d\n",
1104 src.rows, src.cols, range.start, range.end, row0, row1);*/
1105
1106 Mat srcStripe = src.rowRange(row0, row1);
1107 Mat dstStripe = dst.rowRange(row0, row1);
1108
1109
1110#if defined HAVE_TEGRA_OPTIMIZATION
1111 //Iterative separable filters are converted to single iteration filters
1112 //But anyway check that we really get 1 iteration prior to processing
1113 if( countNonZero(kernel) == kernel.rows*kernel.cols && iterations == 1 &&
1114 src.depth() == CV_8U && ( op == MORPH_ERODE || op == MORPH_DILATE ) &&
1115 tegra::morphology(srcStripe, dstStripe, op, kernel, anchor,
1116 rowBorderType, columnBorderType, borderValue) )
1117 return;
1118#endif
1119
1120 Ptr<FilterEngine> f = createMorphologyFilter(op, src.type(), kernel, anchor,
1121 rowBorderType, columnBorderType, borderValue );
1122
1123 f->apply( srcStripe, dstStripe );
1124 for( int i = 1; i < iterations; i++ )
1125 f->apply( dstStripe, dstStripe );
1126 }
1127
1128private:
1129 Mat src;
1130 Mat dst;
1131 int nStripes;
1132 int iterations;
1133

Callers 1

morphOpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected