[TASK] I don't know right now, but i need something like this. :|

This commit is contained in:
Jan Philipp Timme 2016-01-08 01:57:16 +01:00
parent 07c350fe8e
commit 0468c47858
1 changed files with 47 additions and 1 deletions

View File

@ -26,6 +26,7 @@ class HoughMachine {
int* hough_arr; int* hough_arr;
int matching_threshold; int matching_threshold;
int bresenham_orientation_sector;
public: public:
HoughMachine(LazyImage* original, LazyImage* working_copy) { HoughMachine(LazyImage* original, LazyImage* working_copy) {
@ -50,6 +51,7 @@ class HoughMachine {
this->hough_arr = NULL; this->hough_arr = NULL;
} }
this->matching_threshold = 0; this->matching_threshold = 0;
this->bresenham_orientation_sector = 0;
}; };
void setMatchingThreshold(int matching_threshold) { void setMatchingThreshold(int matching_threshold) {
@ -113,8 +115,14 @@ class HoughMachine {
}; };
void drawLineBresenham(int start_x, int start_y, int end_x, int end_y) { void drawLineBresenham(int start_x, int start_y, int end_x, int end_y) {
this->bresenham_orientation_sector = this->getOrientationSector(end_x - start_x, end_y - start_y);
// Now adapt input
// Output will be adapted in setPixel()
};
void bresenham(int start_x, int start_y, int end_x, int end_y) {
int x, y; int x, y;
int delta_x, delta_y; int delta_x, delta_y;
int d; int d;
@ -137,8 +145,46 @@ class HoughMachine {
} }
}; };
int getOrientationSector(double dx, double dy) {
// Matrix multiplication with rotation matrix pi/8
//
// cos(pi/8) -sin(pi/8)
// sin(pi/8) cos(pi/8)
// TODO: Move these somewhere else!
double octangle = M_PI/8;
double cosoct = cos(octangle);
double sinoct = sin(octangle);
double neg_sinoct = -sinoct;
// Do matrix multiplication
double new_dx = dx * cosoct + dy * neg_sinoct;
double new_dy = dx * sinoct + dy * cosoct;
if(new_dy < 0) {
new_dx = -new_dx;
new_dy = -new_dy;
}
int orientation_sector;
if(new_dx >= 0 && new_dx >= new_dy) orientation_sector = 0;
if(new_dx >= 0 && new_dx < new_dy) orientation_sector = 1;
if(new_dx < 0 && -new_dx < new_dy) orientation_sector = 2;
if(new_dx < 0 && -new_dy >= new_dy) orientation_sector = 3;
return orientation_sector;
};
void setPixel(int x, int y) { void setPixel(int x, int y) {
int color = QColor::fromRgb(0, 255, 0).rgb(); int color = QColor::fromRgb(0, 255, 0).rgb();
switch(this->bresenham_orientation_sector) {
case 0:
break;
case 1:
//TODO
break;
case 2:
break;
case 3:
break;
}
this->working_copy->getImage()->setPixel(x, y, color); this->working_copy->getImage()->setPixel(x, y, color);
}; };