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

Method reduce

deps/opencv/modules/core/src/matrix.cpp:2239–2381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2237#define reduceMinC64f reduceC_<double,double,OpMin<double> >
2238
2239void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype)
2240{
2241 Mat src = _src.getMat();
2242 CV_Assert( src.dims <= 2 );
2243 int op0 = op;
2244 int stype = src.type(), sdepth = src.depth(), cn = src.channels();
2245 if( dtype < 0 )
2246 dtype = _dst.fixedType() ? _dst.type() : stype;
2247 int ddepth = CV_MAT_DEPTH(dtype);
2248
2249 _dst.create(dim == 0 ? 1 : src.rows, dim == 0 ? src.cols : 1,
2250 CV_MAKETYPE(dtype >= 0 ? dtype : stype, cn));
2251 Mat dst = _dst.getMat(), temp = dst;
2252
2253 CV_Assert( op == CV_REDUCE_SUM || op == CV_REDUCE_MAX ||
2254 op == CV_REDUCE_MIN || op == CV_REDUCE_AVG );
2255 CV_Assert( src.channels() == dst.channels() );
2256
2257 if( op == CV_REDUCE_AVG )
2258 {
2259 op = CV_REDUCE_SUM;
2260 if( sdepth < CV_32S && ddepth < CV_32S )
2261 {
2262 temp.create(dst.rows, dst.cols, CV_32SC(cn));
2263 ddepth = CV_32S;
2264 }
2265 }
2266
2267 ReduceFunc func = 0;
2268 if( dim == 0 )
2269 {
2270 if( op == CV_REDUCE_SUM )
2271 {
2272 if(sdepth == CV_8U && ddepth == CV_32S)
2273 func = GET_OPTIMIZED(reduceSumR8u32s);
2274 else if(sdepth == CV_8U && ddepth == CV_32F)
2275 func = reduceSumR8u32f;
2276 else if(sdepth == CV_8U && ddepth == CV_64F)
2277 func = reduceSumR8u64f;
2278 else if(sdepth == CV_16U && ddepth == CV_32F)
2279 func = reduceSumR16u32f;
2280 else if(sdepth == CV_16U && ddepth == CV_64F)
2281 func = reduceSumR16u64f;
2282 else if(sdepth == CV_16S && ddepth == CV_32F)
2283 func = reduceSumR16s32f;
2284 else if(sdepth == CV_16S && ddepth == CV_64F)
2285 func = reduceSumR16s64f;
2286 else if(sdepth == CV_32F && ddepth == CV_32F)
2287 func = GET_OPTIMIZED(reduceSumR32f32f);
2288 else if(sdepth == CV_32F && ddepth == CV_64F)
2289 func = reduceSumR32f64f;
2290 else if(sdepth == CV_64F && ddepth == CV_64F)
2291 func = reduceSumR64f64f;
2292 }
2293 else if(op == CV_REDUCE_MAX)
2294 {
2295 if(sdepth == CV_8U && ddepth == CV_8U)
2296 func = GET_OPTIMIZED(reduceMaxR8u);

Callers

nothing calls this directly

Calls 7

fixedTypeMethod · 0.80
getMatMethod · 0.45
typeMethod · 0.45
depthMethod · 0.45
channelsMethod · 0.45
createMethod · 0.45
convertToMethod · 0.45

Tested by

no test coverage detected