[TASK] Parametrize threshold for pixel matchin in hough machine.
This commit is contained in:
parent
c3d7dfb593
commit
229aaf8d5d
|
@ -24,6 +24,8 @@ class HoughMachine {
|
|||
int n_rad;
|
||||
double d_rad;
|
||||
int* hough_arr;
|
||||
|
||||
int matching_threshold;
|
||||
|
||||
public:
|
||||
HoughMachine(LazyImage* original, LazyImage* working_copy) {
|
||||
|
@ -47,6 +49,13 @@ class HoughMachine {
|
|||
free(this->hough_arr);
|
||||
this->hough_arr = NULL;
|
||||
}
|
||||
this->matching_threshold = 0;
|
||||
};
|
||||
|
||||
void setMatchingThreshold(int matching_threshold) {
|
||||
// If negative, pixels greater than the absolute value match.
|
||||
// If positive, pixels less than the absolute value match.
|
||||
this->matching_threshold = matching_threshold;
|
||||
};
|
||||
|
||||
void run(int a_steps, int r_steps) {
|
||||
|
@ -73,8 +82,12 @@ class HoughMachine {
|
|||
QColor pixel = QColor::fromRgb(this->original->getPixel(u, v, LazyImage::DEFAULT));
|
||||
int h, s, l;
|
||||
pixel.getHsl(&h, &s, &l);
|
||||
if(l < 15) { // TODO: parameterize this
|
||||
this->doPixel(u, v);
|
||||
if(this->matching_threshold > 0) {
|
||||
int threshold = this->matching_threshold;
|
||||
if(l < threshold) this->doPixel(u, v);
|
||||
} else {
|
||||
int threshold = -this->matching_threshold;
|
||||
if(l > threshold) this->doPixel(u, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +105,11 @@ class HoughMachine {
|
|||
}
|
||||
};
|
||||
|
||||
void drawLines(int n) {
|
||||
// TODO: Sort stuff in hough_arr by value, get the n top values and draw them using bresenham.
|
||||
|
||||
};
|
||||
|
||||
void debugShow() {
|
||||
std::cout << "Dimensions: " << this->n_ang << " x " << this->n_rad << " | " << std::endl;
|
||||
|
||||
|
|
|
@ -774,7 +774,11 @@ void ImageViewer::runHoughTransformation(void) {
|
|||
logFile << "Let's run a hough transformation!" << std::endl;
|
||||
renewLogging();
|
||||
HoughMachine* hm = new HoughMachine(original, working_copy);
|
||||
hm->setMatchingThreshold(15);
|
||||
hm->run(256, 256);
|
||||
|
||||
hm->drawLines(10);
|
||||
|
||||
delete hm;
|
||||
updateImageDisplay();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue