35 std::vector<std::vector<cv::Point>>& blobList)
39 int width = binaryImage.cols;
40 int heigth = binaryImage.rows;
44 binaryImage.convertTo(outputImage, CV_16UC1);
47 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)
79 BlobLabeler::markBlob(cv::Mat& image,
82 std::vector<cv::Point>& pointList)
85 int x = currentPixel.x;
86 int y = currentPixel.y;
87 int width = image.cols;
88 int heigth = image.rows;
89 image.at<uint16_t>(currentPixel) = color;
91 for (
int j = y - 1; j <= y + 1; j++)
93 for (
int i = x - 1; i <= x + 1; i++)
97 bool validPoint = i >= 0 && j >= 0 && i <= width && j <= heigth;
102 uint16_t* neighborValue = &image.at<uint16_t>(neighbor);
103 bool isWhite = *neighborValue == 65535;
107 image.at<uint16_t>(neighbor) = color;
109 pointList.push_back(neighbor);
110 markBlob(image, neighbor, color, pointList);