Skip to content

Commit 6965db1

Browse files
authored
Update thinning.cpp
1 parent b338f6c commit 6965db1

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

modules/ximgproc/src/thinning.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,21 @@ static void thinningIteration(Mat &img, Mat &marker, const uint8_t* const lut) {
100100
marker.row(0).setTo(1);
101101
marker.row(rows - 1).setTo(1);
102102

103-
marker.forEach<uchar>([=](uchar& value, const int postion[]) {
104-
int i = postion[0];
105-
int j = postion[1];
103+
marker.forEach<uchar>([=](uchar& value, const int position[]) {
104+
int i = position[0];
105+
int j = position[1];
106106
if (i == 0 || j == 0 || i == rows - 1 || j == cols - 1) { return; }
107107

108108
auto ptr = img.ptr(i, j); // p1
109109
if (ptr[0]) {
110-
uchar p2 = ptr[-cols];
111-
uchar p3 = ptr[-cols + 1];
112-
uchar p4 = ptr[1];
113-
uchar p5 = ptr[cols + 1];
114-
uchar p6 = ptr[cols];
115-
uchar p7 = ptr[cols - 1];
116-
uchar p8 = ptr[-1];
117-
uchar p9 = ptr[-cols - 1];
110+
uchar p2 = ptr[-cols] != 0;
111+
uchar p3 = ptr[-cols + 1] != 0;
112+
uchar p4 = ptr[1] != 0;
113+
uchar p5 = ptr[cols + 1] != 0;
114+
uchar p6 = ptr[cols] != 0;
115+
uchar p7 = ptr[cols - 1] != 0;
116+
uchar p8 = ptr[-1] != 0;
117+
uchar p9 = ptr[-cols - 1] != 0;
118118

119119
int neighbors = p9 | (p2 << 1) | (p3 << 2) | (p4 << 3) | (p5 << 4) | (p6 << 5) | (p7 << 6) | (p8 << 7);
120120
value = lut[neighbors];

0 commit comments

Comments
 (0)