Zadanie 12 - fixes
This commit is contained in:
parent
d264b6070d
commit
be58a899a8
|
@ -97,7 +97,7 @@ PNM* BinarizationOtsu::transform()
|
|||
bcv[t]= W_b * W_f * pow(u_b - u_f, 2);
|
||||
}
|
||||
|
||||
int T = 0;
|
||||
T = 0;
|
||||
for (int j=0; j< 255;j++)
|
||||
{
|
||||
if (bcv[j] > bcv[T])
|
||||
|
@ -119,7 +119,6 @@ PNM* BinarizationOtsu::transform()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return newImage;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ class BinarizationOtsu : public Transformation
|
|||
public:
|
||||
BinarizationOtsu(PNM*);
|
||||
BinarizationOtsu(PNM*, ImageViewer*);
|
||||
|
||||
int T = 0;
|
||||
virtual PNM* transform();
|
||||
};
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "blur_gaussian.h"
|
||||
#include "conversion_grayscale.h"
|
||||
#include "edge_sobel.h"
|
||||
#include <iostream>
|
||||
|
||||
CornerHarris::CornerHarris(PNM* img) :
|
||||
Convolution(img)
|
||||
|
@ -24,13 +25,14 @@ PNM* CornerHarris::transform()
|
|||
int width = image->width();
|
||||
int height = image->height();
|
||||
|
||||
PNM* newImage = new PNM(width, height, QImage::Format_Mono);
|
||||
PNM* newImage = new PNM(width, height, QImage::Format_Grayscale8);
|
||||
|
||||
math::matrix<float> Ixx(width, height);
|
||||
math::matrix<float> Iyy(width, height);
|
||||
math::matrix<float> Ixy(width, height);
|
||||
math::matrix<float> corner_candidates(width, height);
|
||||
math::matrix<float> corner_nonmax_suppress(width, height);
|
||||
|
||||
this->corner_candidates = new math::matrix<float>(width, height);
|
||||
this->corner_nonmax_suppress = new math::matrix<float>(width, height);
|
||||
|
||||
ConversionGrayscale* conversion_grayscale = new ConversionGrayscale(image);
|
||||
PNM* gray_image = conversion_grayscale->transform();
|
||||
|
@ -52,8 +54,8 @@ PNM* CornerHarris::transform()
|
|||
Ixy[i][j] = (*Gx)[i][j] * (*Gy)[i][j];
|
||||
Iyy[i][j] = (*Gy)[i][j] * (*Gy)[i][j];
|
||||
|
||||
corner_candidates[i][j] = 0;
|
||||
corner_nonmax_suppress[i][j] = 0;
|
||||
(*corner_candidates)[i][j] = 0;
|
||||
(*corner_nonmax_suppress)[i][j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +94,7 @@ PNM* CornerHarris::transform()
|
|||
|
||||
if (r > threshold)
|
||||
{
|
||||
corner_candidates[i][j] = r;
|
||||
(*corner_candidates)[i][j] = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,31 +108,31 @@ PNM* CornerHarris::transform()
|
|||
{
|
||||
for (int j = 1; j <height - 1; j++)
|
||||
{
|
||||
float max = corner_candidates[i][j];
|
||||
float max = (*corner_candidates)[i][j];
|
||||
|
||||
for (int k = -1; k <= 1; k++)
|
||||
{
|
||||
for (int l = -1; l <= 1; l++)
|
||||
{
|
||||
if (max < corner_candidates[i+k][j+l])
|
||||
if (max < (*corner_candidates)[i+k][j+l])
|
||||
{
|
||||
max = corner_candidates[i+k][j+l];
|
||||
max = (*corner_candidates)[i+k][j+l];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (corner_candidates[i][j] == max)
|
||||
if ((*corner_candidates)[i][j] == max)
|
||||
{
|
||||
corner_nonmax_suppress[i][j] = corner_candidates[i][j];
|
||||
(*corner_nonmax_suppress)[i][j] = (*corner_candidates)[i][j];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (corner_candidates[i][j] > 0)
|
||||
if ((*corner_candidates)[i][j] > 0)
|
||||
{
|
||||
search = true;
|
||||
}
|
||||
|
||||
corner_nonmax_suppress[i][j] = 0;
|
||||
(*corner_nonmax_suppress)[i][j] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -142,13 +144,15 @@ PNM* CornerHarris::transform()
|
|||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
if (corner_candidates[i][j] == 0)
|
||||
if ((*corner_candidates)[i][j] == 0)
|
||||
{
|
||||
newImage->setPixel(i, j, Qt::color0);
|
||||
|
||||
newImage->setPixel(i, j, QColor(0, 0, 0).rgb());
|
||||
}
|
||||
else
|
||||
{
|
||||
newImage->setPixel(i, j, Qt::color1);
|
||||
// std::cout << "White corner" << std::endl;
|
||||
newImage->setPixel(i, j, QColor(255, 255, 255).rgb());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,8 @@ class CornerHarris : public Convolution
|
|||
public:
|
||||
CornerHarris(PNM*);
|
||||
CornerHarris(PNM*, ImageViewer*);
|
||||
|
||||
math::matrix<float>* corner_candidates;
|
||||
math::matrix<float>* corner_nonmax_suppress;
|
||||
PNM* transform();
|
||||
};
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ PNM* HoughLines::transform()
|
|||
int height = image_bin->height();
|
||||
|
||||
QPainter qPainter (newImage);
|
||||
qPainter.setPen(Qt::red);
|
||||
qPainter.setPen(Qt::yellow);
|
||||
|
||||
for (int theta = 0; theta < hough_width; theta++)
|
||||
{
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue