From: Kirill Kornyakov Date: Mon, 24 Oct 2011 09:12:55 +0000 (+0000) Subject: Optimized versions of Erode and Dilate functions added X-Git-Tag: accepted/2.0/20130307.220821~1685 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=602ad61967aa389e83ac2531aa89e59bb61a11c5;p=profile%2Fivi%2Fopencv.git Optimized versions of Erode and Dilate functions added --- diff --git a/modules/imgproc/src/morph.cpp b/modules/imgproc/src/morph.cpp index 389a6a2..72c4bd4 100644 --- a/modules/imgproc/src/morph.cpp +++ b/modules/imgproc/src/morph.cpp @@ -584,8 +584,20 @@ struct MorphNoVec int operator()(uchar**, int, uchar*, int) const { return 0; } }; +#ifdef HAVE_TEGRA_OPTIMIZATION +typedef tegra::MorphRowIVec ErodeRowVec8u; +typedef tegra::MorphRowIVec DilateRowVec8u; + +typedef tegra::MorphColumnIVec ErodeColumnVec8u; +typedef tegra::MorphColumnIVec DilateColumnVec8u; +#else typedef MorphRowNoVec ErodeRowVec8u; typedef MorphRowNoVec DilateRowVec8u; + +typedef MorphColumnNoVec ErodeColumnVec8u; +typedef MorphColumnNoVec DilateColumnVec8u; +#endif + typedef MorphRowNoVec ErodeRowVec16u; typedef MorphRowNoVec DilateRowVec16u; typedef MorphRowNoVec ErodeRowVec16s; @@ -593,8 +605,6 @@ typedef MorphRowNoVec DilateRowVec16s; typedef MorphRowNoVec ErodeRowVec32f; typedef MorphRowNoVec DilateRowVec32f; -typedef MorphColumnNoVec ErodeColumnVec8u; -typedef MorphColumnNoVec DilateColumnVec8u; typedef MorphColumnNoVec ErodeColumnVec16u; typedef MorphColumnNoVec DilateColumnVec16u; typedef MorphColumnNoVec ErodeColumnVec16s; @@ -613,6 +623,7 @@ typedef MorphNoVec DilateVec32f; #endif + template struct MorphRowFilter : public BaseRowFilter { typedef typename Op::rtype T; @@ -834,10 +845,10 @@ cv::Ptr cv::getMorphologyRowFilter(int op, int type, int ksiz CV_Assert( op == MORPH_ERODE || op == MORPH_DILATE ); if( op == MORPH_ERODE ) { - if( depth == CV_8U ) - return Ptr(new MorphRowFilter, - ErodeRowVec8u>(ksize, anchor)); - if( depth == CV_16U ) + if( depth == CV_8U ) + return Ptr(new MorphRowFilter, + ErodeRowVec8u>(ksize, anchor)); + if( depth == CV_16U ) return Ptr(new MorphRowFilter, ErodeRowVec16u>(ksize, anchor)); if( depth == CV_16S ) @@ -849,7 +860,7 @@ cv::Ptr cv::getMorphologyRowFilter(int op, int type, int ksiz } else { - if( depth == CV_8U ) + if( depth == CV_8U ) return Ptr(new MorphRowFilter, DilateRowVec8u>(ksize, anchor)); if( depth == CV_16U ) @@ -861,8 +872,8 @@ cv::Ptr cv::getMorphologyRowFilter(int op, int type, int ksiz if( depth == CV_32F ) return Ptr(new MorphRowFilter, DilateRowVec32f>(ksize, anchor)); - } - + } + CV_Error_( CV_StsNotImplemented, ("Unsupported data type (=%d)", type)); return Ptr(0); } @@ -875,7 +886,7 @@ cv::Ptr cv::getMorphologyColumnFilter(int op, int type, in CV_Assert( op == MORPH_ERODE || op == MORPH_DILATE ); if( op == MORPH_ERODE ) { - if( depth == CV_8U ) + if( depth == CV_8U ) return Ptr(new MorphColumnFilter, ErodeColumnVec8u>(ksize, anchor)); if( depth == CV_16U ) @@ -890,7 +901,7 @@ cv::Ptr cv::getMorphologyColumnFilter(int op, int type, in } else { - if( depth == CV_8U ) + if( depth == CV_8U ) return Ptr(new MorphColumnFilter, DilateColumnVec8u>(ksize, anchor)); if( depth == CV_16U )