[TASK] Still not done.
This commit is contained in:
parent
7f186fa4e9
commit
b1e5a69464
|
@ -80,7 +80,7 @@ class HoughMachine {
|
|||
std::cout << "n_ang: " << this->n_ang << ", d_ang: " << this->d_ang << std::endl;
|
||||
std::cout << "n_rad: " << this->n_rad << ", d_rad: " << this->d_rad << ", r_max: " << r_max << std::endl;
|
||||
this->fillHoughAccumulator();
|
||||
this->debugShow();
|
||||
//this->debugShow();
|
||||
};
|
||||
|
||||
void fillHoughAccumulator() {
|
||||
|
@ -113,7 +113,6 @@ class HoughMachine {
|
|||
};
|
||||
|
||||
void drawLines(int n) {
|
||||
n += 1;
|
||||
// for each value: if == 0 ignore
|
||||
// else check if bigger than all neighbours
|
||||
// if so, put it in the list
|
||||
|
@ -121,7 +120,7 @@ class HoughMachine {
|
|||
int line = 0;
|
||||
for(int i=0; i<=this->n_ang*this->n_rad; i++) {
|
||||
int value = this->hough_arr[i];
|
||||
if(value == 0) continue; // Ignore zeros
|
||||
if(value <= 5) continue; // Ignore small values
|
||||
// TODO: Check neighbours and compare!
|
||||
// Store value if bigger than neighbours
|
||||
int a = i / this->n_ang;
|
||||
|
@ -135,7 +134,29 @@ class HoughMachine {
|
|||
}
|
||||
// Now sort it
|
||||
qsort((void*) lines, line, sizeof(struct hparam), HoughMachine::comp);
|
||||
for(int i=0; i<10; i++) std::cout << "Top " << i << ": " << lines[i].value << std::endl;
|
||||
// Draw them
|
||||
double pi_half = M_PI / 2.0;
|
||||
for(int i=0; i<n; i++) {
|
||||
double theta = lines[i].theta;
|
||||
int r = lines[i].r;
|
||||
int quadrant = floor(theta / pi_half);
|
||||
theta = theta - quadrant * pi_half;
|
||||
std::cout << "Top " << i << ": " << lines[i].value << ", r: " << r << ", theta: " << theta << " quadrand: " << quadrant;
|
||||
int x_inter = r / cos(theta);
|
||||
int y_inter = r / cos(pi_half - theta);
|
||||
//if(quadrant % 2 == 1) x_inter *= -1;
|
||||
//if(quadrant > 2) y_inter *= -1;
|
||||
//double x_factor = (this->x_center + x_inter) / x_inter;
|
||||
//double y_factor = (this->y_center + y_inter) / y_inter;
|
||||
//x_inter *= x_factor;
|
||||
//y_inter *= y_factor;
|
||||
int x1 = 0; int x2 = 0; int y1 = 0; int y2 = 0;
|
||||
std::cout << " x: " << x_inter << ", y: " << y_inter << std::endl;
|
||||
x1 = 0; y1 = y_inter;
|
||||
x2 = x_inter; y2 = 0;
|
||||
this->otherBresenham(x1, y1, x2, y2);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
@ -152,11 +173,11 @@ class HoughMachine {
|
|||
void setPixelDebug(int x, int y, int color=0) {
|
||||
int our_color = QColor::fromRgb(0, 255, 0).rgb();
|
||||
if(color == 0) color = our_color;
|
||||
std::cout << " --> SET (" << x << ", " << y << ")" << std::endl;
|
||||
//std::cout << " --> SET (" << x << ", " << y << ")" << std::endl;
|
||||
this->working_copy->getImage()->setPixel(x, y, color);
|
||||
};
|
||||
|
||||
void otherBresenham(int x, int x2, int y, int y2) {
|
||||
void otherBresenham(int x, int y, int x2, int y2) {
|
||||
int width = x2 - x;
|
||||
int height = y2 - y;
|
||||
int dx1 = 0, dy1 = 0, dx2 = 0, dy2 = 0;
|
||||
|
|
|
@ -790,8 +790,9 @@ void ImageViewer::runHoughTransformation(void) {
|
|||
HoughMachine* hm = new HoughMachine(original, working_copy);
|
||||
hm->reset();
|
||||
hm->setMatchingThreshold(threshold);
|
||||
hm->run(256, 256);
|
||||
hm->drawLines(10);
|
||||
//hm->run(256, 256);
|
||||
hm->run(300, 300);
|
||||
hm->drawLines(40);
|
||||
delete hm;
|
||||
updateImageDisplay();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue