Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 2015-08-01 06:54:59 -0600

Nbb gravatar image

draw circle function (x,y) coordinate help (Hough circle)

Hello forum,

I wrote a simple code for the standard hough circular transform. However, I am unsure why the center of the circle is shifted. Can anyone help me on this ?

int main(int argc, char** argv)
{

image = imread("lost3.png",CV_LOAD_IMAGE_GRAYSCALE);
image.copyTo(canny_output);

Canny(canny_output, canny_output, 100, 200, 3);

namedWindow("canny output", CV_WINDOW_NORMAL);
imshow("canny output", canny_output);

Mat temp        = Mat::zeros(image.size(), CV_8UC1);

for (int i = 0; i < canny_output.rows; i++)
    for (int j = 0; j < canny_output.cols; j++)
        if (canny_output.at<uchar>(i, j) != 0) {
            circle(temp, Point(i, j), 7, 20, 1, 0);
            //hough_space = hough_space + temp;
            image = image + temp;
            temp = Mat::zeros(image.size(), CV_8UC1);
        }

namedWindow("image", CV_WINDOW_NORMAL);
imshow("image", image);

waitKey(0);

}

image description

draw circle function (x,y) coordinate help (Hough circle)

Hello forum,

I wrote a simple code for the standard hough circular transform. However, I am unsure why the center of the circle is shifted. Can anyone help me on this ?

int main(int argc, char** argv)
{

image = imread("lost3.png",CV_LOAD_IMAGE_GRAYSCALE);
image.copyTo(canny_output);

Canny(canny_output, canny_output, 100, 200, 3);

namedWindow("canny output", CV_WINDOW_NORMAL);
imshow("canny output", canny_output);

Mat temp        = Mat::zeros(image.size(), CV_8UC1);

for (int i = 0; i < canny_output.rows; i++)
    for (int j = 0; j < canny_output.cols; j++)
        if (canny_output.at<uchar>(i, j) != 0) {
            circle(temp, Point(i, j), 7, 20, 1, 0);
            //hough_space = hough_space + temp;
            image = image + temp;
            temp = Mat::zeros(image.size(), CV_8UC1);
        }

namedWindow("image", CV_WINDOW_NORMAL);
imshow("image", image);

waitKey(0);

}

image description

image description

draw circle function (x,y) coordinate help (Hough circle)

Hello forum,

I wrote a simple code for the standard hough circular transform. However, I am unsure why the center of the circle is shifted. Can anyone help me on this ?

#include <opencv2\opencv.hpp>

include <opencv\cv.h>

using namespace cv; using namespace std;

int main(int argc, char** argv)
{
Mat image, canny_output;

image = imread("lost3.png",CV_LOAD_IMAGE_GRAYSCALE);
imread("lost3.png", CV_LOAD_IMAGE_GRAYSCALE);
image.copyTo(canny_output);

Canny(canny_output, canny_output, 100, 200, 3);

namedWindow("canny output", CV_WINDOW_NORMAL);
imshow("canny output", canny_output);

Mat temp        = Mat::zeros(image.size(), CV_8UC1);
 Mat hough_space = Mat::zeros(image.size(), CV_8UC1);


// Standard Hough Circle Transform ( Radius = 9 )
for (int i = 0; i < canny_output.rows; i++)
    for (int j = 0; j < canny_output.cols; j++)
         if (canny_output.at<uchar>(i, j) != 0) {
{      // Edge point

            circle(temp, Point(i, j), 7, 9, 20, 1, 0);
            //hough_space 0);   // Draw circle of radius 9 at edge point 
            //circle(temp, Point(j, i), 9, 20, 1, 0); // Using this line instead gives me the correct drawn circle
            hough_space = hough_space + temp;
            image = image + temp;
            temp = Mat::zeros(image.size(), CV_8UC1);
CV_8UC1); // Clear temp

        }

namedWindow("canny op", CV_WINDOW_NORMAL);
imshow("canny op", canny_output);

namedWindow("image", CV_WINDOW_NORMAL);
imshow("image", image);

namedWindow("hough space", CV_WINDOW_NORMAL);
imshow("hough space", hough_space);

waitKey(0);
 }

image description

image description

draw circle function (x,y) coordinate help (Hough circle)

Hello forum,

I wrote a simple code for the standard hough circular transform. However, I am unsure why the center of the circle is shifted. Can anyone help me on this ?

#include <opencv2\opencv.hpp>

include <opencv\cv.h>

<opencv2\opencv.hpp> #include <opencv\cv.h> using namespace cv; using namespace std;

std;
int main(int argc, char** argv)
{
Mat image, canny_output;
image = imread("lost3.png", CV_LOAD_IMAGE_GRAYSCALE);
image.copyTo(canny_output);
Canny(canny_output, canny_output, 100, 200, 3);
Mat temp = Mat::zeros(image.size(), CV_8UC1);
Mat hough_space = Mat::zeros(image.size(), CV_8UC1);
// Standard Hough Circle Transform ( Radius = 9 )
for (int i = 0; i < canny_output.rows; i++)
for (int j = 0; j < canny_output.cols; j++)
if (canny_output.at<uchar>(i, j) != 0) { // Edge point
circle(temp, Point(i, j), 9, 20, 1, 0); // Draw circle of radius 9 at edge point
//circle(temp, Point(j, i), 9, 20, 1, 0); // Using this line instead gives me the correct drawn circle
hough_space = hough_space + temp;
image = image + temp;
temp = Mat::zeros(image.size(), CV_8UC1); // Clear temp
}
namedWindow("canny op", CV_WINDOW_NORMAL);
imshow("canny op", canny_output);
namedWindow("image", CV_WINDOW_NORMAL);
imshow("image", image);
namedWindow("hough space", CV_WINDOW_NORMAL);
imshow("hough space", hough_space);
waitKey(0);
}

image description

image description

draw circle function (x,y) coordinate help (Hough circle)

Hello forum,

I wrote a simple code for the standard hough circular transform. However, I am unsure why the center of the circle is shifted. Can anyone help me on this ?

#include <opencv2\opencv.hpp>
#include <opencv\cv.h>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
Mat image, canny_output;

image = imread("lost3.png", CV_LOAD_IMAGE_GRAYSCALE);
image.copyTo(canny_output);

Canny(canny_output, canny_output, 100, 200, 3);

Mat temp        = Mat::zeros(image.size(), CV_8UC1);
Mat hough_space = Mat::zeros(image.size(), CV_8UC1);


// Standard Hough Circle Transform ( Radius = 9 )
for (int i = 0; i < canny_output.rows; i++)
    for (int j = 0; j < canny_output.cols; j++)

        if (canny_output.at<uchar>(i, j) != 0) {      // Edge point

            circle(temp, Point(i, j), 9, 20, 1, 0);   // Draw circle of radius 9 at edge point 
            //circle(temp, Point(j, i), 9, 20, 1, 0); // Using this line instead gives me the correct drawn circle
            hough_space = hough_space + temp;
            image = image + temp;
            temp = Mat::zeros(image.size(), CV_8UC1); // Clear temp

        }

namedWindow("canny op", CV_WINDOW_NORMAL);
imshow("canny op", canny_output);

namedWindow("image", CV_WINDOW_NORMAL);
imshow("image", image);

namedWindow("hough space", CV_WINDOW_NORMAL);
imshow("hough space", hough_space);

waitKey(0);
}

image description

image description

image description

draw circle function (x,y) coordinate help (Hough circle)

Hello forum,

I wrote a simple code for the standard hough circular transform. However, I am unsure why the center of the circle is shifted. Can anyone help me on this ?

#include <opencv2\opencv.hpp>
#include <opencv\cv.h>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
Mat image, canny_output;

image = imread("lost3.png", CV_LOAD_IMAGE_GRAYSCALE);
image.copyTo(canny_output);

Canny(canny_output, canny_output, 100, 200, 3);

Mat temp        = Mat::zeros(image.size(), CV_8UC1);
Mat hough_space = Mat::zeros(image.size(), CV_8UC1);


// Standard Hough Circle Transform ( Radius = 9 )
for (int i = 0; i < canny_output.rows; i++)
    for (int j = 0; j < canny_output.cols; j++)

        if (canny_output.at<uchar>(i, j) != 0) {      // Edge point

            circle(temp, Point(i, j), 9, 20, 1, 0);   // Draw circle of radius 9 at edge point 
            //circle(temp, Point(j, i), 9, 20, 1, 0); // Using this line instead gives me the correct drawn circle
            hough_space = hough_space + temp;
            image = image + temp;
            temp = Mat::zeros(image.size(), CV_8UC1); // Clear temp

        }

namedWindow("canny op", CV_WINDOW_NORMAL);
imshow("canny op", canny_output);

namedWindow("image", CV_WINDOW_NORMAL);
imshow("image", image);

namedWindow("hough space", CV_WINDOW_NORMAL);
imshow("hough space", hough_space);

waitKey(0);
}

image description

image description

image description