zadanie-5

This commit is contained in:
Patrycjusz Mania 2021-05-15 10:56:30 +02:00
parent 468677b949
commit c6daa832b7
2 changed files with 10 additions and 8 deletions

View File

@ -25,7 +25,7 @@ math::matrix<float> Convolution::getMask(int size, Mode mode = Normalize)
for (int i=0; i<size; ++i) { for (int i=0; i<size; ++i) {
for (int j=0; j<size; ++j) { for (int j=0; j<size; ++j) {
if (i / 2 == size / 2) if (i / 2 == size / 2 && j / 2 == size / 2)
mask[i][j] = 1; mask[i][j] = 1;
else else
mask[i][j] = 0; mask[i][j] = 0;

View File

@ -21,23 +21,25 @@ PNM* EdgeZeroCrossing::transform()
double sigma = getParameter("sigma").toDouble(); double sigma = getParameter("sigma").toDouble();
int t = getParameter("threshold").toInt(); int t = getParameter("threshold").toInt();
PNM* newImage = new PNM(width, height, QImage::Format_Grayscale8); PNM* newImage = new PNM(width, height, image->format());
EdgeLaplaceOfGauss log(newImage); EdgeLaplaceOfGauss log(newImage);
log.setParameter("size", getParameter("size"));
log.setParameter("sigma", getParameter("sigma"));
Transformation laplasjan(log.transform());
int v0 = 128; int v0 = 128;
int half = size/2;
for (int x=0;x<width;++x) { for (int x=0;x<width;++x) {
for (int y=0;y<height;++y) { for (int y=0;y<height;++y) {
float lapsjan = EdgeLaplaceOfGauss::getLoG(x,y, sigma) * v0; math::matrix<float> mask = laplasjan.getWindow(x, y, size, LChannel, RepeatEdge);
math::matrix<float> mask = log.getMask(size, sigma, RepeatEdge);
float max = mask.max(); float max = mask.max();
float min = mask.min(); float min = mask.min();
int gray = (min < (v0 - t) && max > (v0 + t)) ? mask(half, half) : 0;
if (min < v0 - t && max > v0 + t) newImage->setPixel(x,y, QColor(gray, gray, gray).rgb());
newImage->setPixel(x,y, QColor(255, 255, 255).rgb());
else
newImage->setPixel(x,y, QColor(0, 0, 0).rgb());
} }
} }