5 m_nCannyLowThreshold = CannyLowThreshold;
6 m_nCannyHighThreshold = CannyHighThreshold;
7 m_nCirclesToExtract = CirclesToExtract;
8 m_nMinRadius = minRadius;
9 m_nMaxRadius = maxRadius;
13 void CHoughCircles::HoughSaliency(CByteImage* origin, CByteImage* saliencyImage,
int sampleWindowsize,
int width,
int height,
int windowCenterX,
int windowCenterY)
15 CVec3dArray resultListCircles(50);
16 CDynamicArrayTemplate<int> resultHits(50);
17 CVec2dArray edgePoints(10000), edgeDirections(10000);
18 CByteImage visualizationImage(sampleWindowsize, sampleWindowsize, CByteImage::eRGB24);
21 ImageProcessor::Canny(origin, edgePoints, edgeDirections, m_nCannyLowThreshold, m_nCannyHighThreshold);
24 ImageProcessor::HoughTransformCircles(edgePoints, edgeDirections, sampleWindowsize, sampleWindowsize, m_nMinRadius, m_nMaxRadius, m_nCirclesToExtract, 1, resultListCircles, resultHits, &visualizationImage);
26 Vec3d circle = resultListCircles[0];
28 for (
int i = 0; i < resultListCircles.GetSize(); i++)
30 circle = resultListCircles[i];
32 circle.x += windowCenterX - sampleWindowsize / 2;
33 circle.y += windowCenterY - sampleWindowsize / 2;
34 if (circle.x >= 0 && circle.y >= 0 && circle.x < width && circle.y < height)
36 saliencyImage->pixels[(int)circle.y * width + (
int)circle.x]++;
44 cv::Mat src(origin->height, origin->width, CV_8UC1);
45 std::vector<cv::Vec3f> resultListCircles;
48 for (
int i = 0; i < src.rows; i++)
50 for (
int j = 0; j < src.cols; j++)
52 src.at<uint8_t>(i, j) = origin->pixels[i * src.cols + j];
57 cv::HoughCircles(src, resultListCircles, cv::HOUGH_GRADIENT, 1, src.rows / 8, m_nCannyHighThreshold, 20, m_nMinRadius, m_nMaxRadius);
58 if (!resultListCircles.size())
63 for (
size_t i = 0; i < resultListCircles.size(); i++)
65 circle = resultListCircles[i];
66 circle[0] += windowCenterX - sampleWindowsize / 2;
67 circle[1] += windowCenterY - sampleWindowsize / 2;
68 if (circle[0] > 0 && circle[1] > 0 && circle[0] < width - 1 && circle[1] < height - 1)
70 for (
int j = -1; j <= 1; j++)
72 for (
int k = -1; k <= 1; k++)
74 saliencyImage->pixels[((int)circle[1] + j) * width + ((int)circle[0] + k)] = 255;