36 int width = binaryImage.cols;
37 int heigth = binaryImage.rows;
41 binaryImage.convertTo(outputImage, CV_16UC1);
44 for (uint16_t& pixel : cv::Mat_<uint16_t>(outputImage))
56 for (
int y = 0; y < heigth; y++)
58 for (
int x = 0; x < width; x++)
62 bool isWhite = (outputImage.at<uint16_t>(currentPixel) == 65535);
63 std::vector<cv::Point> pointlist;
66 this->markBlob(outputImage, currentPixel, blobIndex, pointlist);
67 blobList.push_back(pointlist);
69 if (blobIndex >= 65535)
80 void BlobLabeler::markBlob(cv::Mat& image,
cv::Point currentPixel, uint16_t color, std::vector<cv::Point>& pointList)
83 int x = currentPixel.x;
84 int y = currentPixel.y;
85 int width = image.cols;
86 int heigth = image.rows;
87 image.at<uint16_t>(currentPixel) = color;
89 for (
int j = y - 1; j <= y + 1; j++)
91 for (
int i = x - 1; i <= x + 1; i++)
95 bool validPoint = i >= 0 && j >= 0 && i <= width && j <= heigth;
100 uint16_t* neighborValue = &image.at<uint16_t>(neighbor);
101 bool isWhite = *neighborValue == 65535;
105 image.at<uint16_t>(neighbor) = color;
107 pointList.push_back(neighbor);
108 markBlob(image, neighbor, color, pointList);