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

Function IPPMorphOp

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

Source from the content-addressed store, hash-verified

1216}
1217
1218static 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);

Callers 1

morphOpFunction · 0.85

Calls 11

SizeFunction · 0.85
MatClass · 0.85
IPPMorphReplicateFunction · 0.85
PointClass · 0.50
getMatMethod · 0.45
depthMethod · 0.45
sizeMethod · 0.45
createMethod · 0.45
typeMethod · 0.45
copyToMethod · 0.45

Tested by

no test coverage detected