-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhough.cpp
More file actions
40 lines (39 loc) · 807 Bytes
/
hough.cpp
File metadata and controls
40 lines (39 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <math.h>
#define PI 3.1415
using namespace std;
using namespace cv;
int main()
{
Mat img=imread("samps/A1.png",0);
Mat a(100,100,CV_8UC1,Scalar(0));
int ctr=0 th=255;
for (int i = 0; i < img.rows; i++)
{
for (int j = 0; j < img.cols; j++)
{
if (img.at<uchar>(i,j)==255)
{
//cout << Point {i,j} << endl;
ctr=0;
for (float th = 0; th <= 2*PI; th+=((2*PI)/100))
{
//cout << ctr <<endl;
float r=(i*sin(th)) + (j*cos(th));
//cout << Point {r/10,ctr} << endl ;
if (r>0)
{
a.at<uchar>(r/10,ctr)+=1;
}
ctr++;
}
}
}
}
namedWindow("graph",WINDOW_NORMAL);
imshow("graph",a);
waitKey(2000);
}