Skip to content

Commit a0686a6

Browse files
author
Kirill Kornyakov
committed
Minor code cleanings
1 parent 569aa2f commit a0686a6

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

include/skeleton_filter.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ void GuoHallThinning(const cv::Mat& src, cv::Mat& dst);
2525
void GuoHallThinning_optimized(const cv::Mat& src, cv::Mat& dst);
2626
void ImageResize_optimized(const cv::Mat &src, cv::Mat &dst, const cv::Size sz);
2727
void ConvertColor_BGR2GRAY_BT709_fpt(const cv::Mat& src, cv::Mat& dst);
28-
void ConvertColor_BGR2GRAY_BT709_simd(const cv::Mat& src, cv::Mat& dst);
28+
void ConvertColor_BGR2GRAY_BT709_simd(const cv::Mat& src, cv::Mat& dst);

perf/perf_skeleton.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,13 @@ PERF_TEST_P(Size_Only, ConvertColor_simd, testing::Values(MAT_SIZES))
151151
cv::Mat diff1; cv::threshold(diff, diff1, 1, 0, cv::THRESH_TOZERO);
152152
ASSERT_EQ(0, cv::countNonZero(diff1));
153153

154-
// even if it is 1-off error there should be no mo than 20% of such pixels
154+
// Even if it is 1-off error there should be no more than 20% of such pixels
155155
ASSERT_LT(cv::countNonZero(diff), sz.width*sz.height*20/100);
156156

157157
SANITY_CHECK(dst);
158158
}
159159

160-
161-
// accuracy test by the way...
160+
// Accuracy test by the way...
162161
TEST(CompleteColorSpace, ConvertColor_fpt)
163162
{
164163
Size sz(4096, 4096);
@@ -190,4 +189,4 @@ TEST(CompleteColorSpace, ConvertColor_fpt)
190189
EXPECT_EQ(0, cv::countNonZero(diff1));
191190
ASSERT_LT(cv::countNonZero(diff), 7565);
192191
// ASSERT_EQ(0, cv::countNonZero(diff));
193-
}
192+
}

src/convertcolor.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
#include <string>
99
#include <sstream>
1010

11+
// Function for debug prints
1112
template <typename T>
12-
std::string __m128i_toString(const __m128i var) // function for debug prints
13+
std::string __m128i_toString(const __m128i var)
1314
{
1415
std::stringstream sstr;
1516
const T* values = (const T*) &var;
@@ -98,7 +99,7 @@ void ConvertColor_BGR2GRAY_BT709_simd(const cv::Mat& src, cv::Mat& dst)
9899
int x = 0;
99100

100101
#ifdef HAVE_SSE
101-
// here is 16 times unrolled loop for vector processing
102+
// Here is 16 times unrolled loop for vector processing
102103
for (; x <= sz.width - 16; x += 16)
103104
{
104105
__m128i chunk0 = _mm_loadu_si128((const __m128i*)(psrc + x*3 + 16*0));
@@ -107,20 +108,21 @@ void ConvertColor_BGR2GRAY_BT709_simd(const cv::Mat& src, cv::Mat& dst)
107108

108109
__m128i red = _mm_or_si128(_mm_or_si128(_mm_shuffle_epi8(chunk0, ssse3_red_indices_0),
109110
_mm_shuffle_epi8(chunk1, ssse3_red_indices_1)),
110-
_mm_shuffle_epi8(chunk2, ssse3_red_indices_2));
111+
_mm_shuffle_epi8(chunk2, ssse3_red_indices_2));
111112

112113
/* ??? */
113114

114115
_mm_storeu_si128((__m128i*)(pdst + x), red);
115116
}
116117
#endif
117118

118-
// process leftover pixels
119+
// Process leftover pixels
119120
for (; x < sz.width; x++)
120121
{
121122
/* ??? */
122123
}
123124
}
124125

125-
ConvertColor_BGR2GRAY_BT709_fpt(src, dst); // !remove this!
126+
// ! Remove this before writing your optimizations !
127+
ConvertColor_BGR2GRAY_BT709_fpt(src, dst);
126128
}

0 commit comments

Comments
 (0)