Zadanie 8
This commit is contained in:
parent
094dcbc4a3
commit
90fb90b2a8
105
08/do_sprawdzenia/cpp/edge_gradient.cpp
Normal file
105
08/do_sprawdzenia/cpp/edge_gradient.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
#include "edge_gradient.h"
|
||||
|
||||
EdgeGradient::EdgeGradient(PNM* img, ImageViewer* iv) :
|
||||
Convolution(img, iv)
|
||||
{
|
||||
}
|
||||
|
||||
EdgeGradient::EdgeGradient(PNM* img) :
|
||||
Convolution(img)
|
||||
{
|
||||
}
|
||||
|
||||
PNM* EdgeGradient::verticalDetection()
|
||||
{
|
||||
return convolute(g_y, RepeatEdge);
|
||||
}
|
||||
|
||||
PNM* EdgeGradient::horizontalDetection()
|
||||
{
|
||||
return convolute(g_x, RepeatEdge);
|
||||
}
|
||||
|
||||
|
||||
int EdgeGradient::calcValue(int i, int j, Channel channel, PNM* img_x, PNM* img_y)
|
||||
{
|
||||
int value_x, value_y;
|
||||
double power_x, power_y;
|
||||
int value_xy;
|
||||
int result;
|
||||
|
||||
QRgb pixel_x = img_x->pixel(i, j);
|
||||
QRgb pixel_y = img_y->pixel(i, j);
|
||||
|
||||
switch(channel)
|
||||
{
|
||||
|
||||
case RChannel:
|
||||
value_x = qRed(pixel_x);
|
||||
value_y = qRed(pixel_y);
|
||||
break;
|
||||
case GChannel:
|
||||
value_x = qGreen(pixel_x);
|
||||
value_y = qGreen(pixel_y);
|
||||
break;
|
||||
case BChannel:
|
||||
value_x = qBlue(pixel_x);
|
||||
value_y = qBlue(pixel_y);
|
||||
break;
|
||||
case LChannel:
|
||||
value_x = qGray(pixel_x);
|
||||
value_y = qGray(pixel_y);
|
||||
break;
|
||||
}
|
||||
|
||||
power_x = pow(value_x, 2);
|
||||
power_y = pow(value_y, 2);
|
||||
|
||||
value_xy = (int) sqrt(power_x + power_y);
|
||||
|
||||
result = std::max(0, std::min(255, value_xy));
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
PNM* EdgeGradient::transform()
|
||||
{
|
||||
PNM* newImage = new PNM(image->width(), image->height(), image->format());
|
||||
|
||||
int width = image->width();
|
||||
int height = image->height();
|
||||
|
||||
// Gradient image by x
|
||||
PNM* img_x = horizontalDetection();
|
||||
|
||||
// Gradient image by y
|
||||
PNM* img_y = verticalDetection();
|
||||
|
||||
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
if (image->format() == QImage::Format_Indexed8)
|
||||
{
|
||||
// Calculate gray pixel value
|
||||
int l = calcValue(i, j, LChannel, img_x, img_y);
|
||||
newImage->setPixel(i, j, l);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Calculate RGB values for pixel
|
||||
int r = calcValue(i, j, RChannel, img_x, img_y);
|
||||
int g = calcValue(i, j, GChannel, img_x, img_y);
|
||||
int b = calcValue(i, j, BChannel, img_x, img_y);
|
||||
|
||||
QColor color = QColor(r, g, b);
|
||||
newImage->setPixel(i, j, color.rgb());
|
||||
}
|
||||
}
|
||||
}
|
||||
return newImage;
|
||||
}
|
||||
|
24
08/do_sprawdzenia/cpp/edge_gradient.h
Normal file
24
08/do_sprawdzenia/cpp/edge_gradient.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef EDGE_GRADIENT_H
|
||||
#define EDGE_GRADIENT_H
|
||||
|
||||
#include "convolution.h"
|
||||
|
||||
class EdgeGradient : public Convolution
|
||||
{
|
||||
public:
|
||||
EdgeGradient(PNM*);
|
||||
EdgeGradient(PNM*, ImageViewer*);
|
||||
|
||||
virtual PNM* transform();
|
||||
|
||||
PNM* verticalDetection();
|
||||
PNM* horizontalDetection();
|
||||
int calcValue(int i, int j, Channel channel, PNM* img_x, PNM* img_y);
|
||||
|
||||
protected:
|
||||
virtual void prepareMatrices() = 0;
|
||||
math::matrix<float> g_x,
|
||||
g_y;
|
||||
};
|
||||
|
||||
#endif // EDGE_GRADIENT_H
|
33
08/do_sprawdzenia/cpp/edge_laplacian.cpp
Normal file
33
08/do_sprawdzenia/cpp/edge_laplacian.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include "edge_laplacian.h"
|
||||
|
||||
EdgeLaplacian::EdgeLaplacian(PNM* img) :
|
||||
Convolution(img)
|
||||
{
|
||||
}
|
||||
|
||||
EdgeLaplacian::EdgeLaplacian(PNM* img, ImageViewer* iv) :
|
||||
Convolution(img, iv)
|
||||
{
|
||||
}
|
||||
|
||||
math::matrix<float> EdgeLaplacian::getMask(int, Mode)
|
||||
{
|
||||
int size = getParameter("size").toInt();
|
||||
math::matrix<float> mask(size, size);
|
||||
|
||||
int center = size / 2;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
for (int j = 0; j < size; j++)
|
||||
{
|
||||
mask(i, j) = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate center element of mask
|
||||
mask(center, center) = pow(size, 2) - 1;
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
55
08/do_sprawdzenia/cpp/edge_laplacian_of_gauss.cpp
Normal file
55
08/do_sprawdzenia/cpp/edge_laplacian_of_gauss.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include "edge_laplacian_of_gauss.h"
|
||||
|
||||
#include "blur_gaussian.h"
|
||||
|
||||
EdgeLaplaceOfGauss::EdgeLaplaceOfGauss(PNM* img) :
|
||||
Convolution(img)
|
||||
{
|
||||
}
|
||||
|
||||
EdgeLaplaceOfGauss::EdgeLaplaceOfGauss(PNM* img, ImageViewer* iv) :
|
||||
Convolution(img, iv)
|
||||
{
|
||||
}
|
||||
|
||||
math::matrix<float> EdgeLaplaceOfGauss::getMask()
|
||||
{
|
||||
size = getParameter("size").toInt();
|
||||
double sigma = getParameter("sigma").toDouble();
|
||||
|
||||
math::matrix<float> mask(size, size);
|
||||
|
||||
int center = -size / 2;
|
||||
|
||||
|
||||
for (int x = 0, k = center; x < size; x++, k++)
|
||||
{
|
||||
for (int y = 0, l = center; y < size; y++, l++)
|
||||
{
|
||||
mask(x, y) = getLoG(k, l, sigma);
|
||||
}
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
float EdgeLaplaceOfGauss::getLoG(int x, int y, float s)
|
||||
{
|
||||
int px = pow(x, 2);
|
||||
int py = pow(y, 2);
|
||||
|
||||
float ps = pow(s, 2);
|
||||
int numerator = px + py - 2;
|
||||
|
||||
int gauss = BlurGaussian::getGauss(x, y, ps);
|
||||
|
||||
int result = (numerator / ps) * gauss;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int EdgeLaplaceOfGauss::getSize()
|
||||
{
|
||||
return size;
|
||||
}
|
21
08/do_sprawdzenia/cpp/edge_laplacian_of_gauss.h
Normal file
21
08/do_sprawdzenia/cpp/edge_laplacian_of_gauss.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef EDGE_LAPLACE_GAUSS_H
|
||||
#define EDGE_LAPLACE_GAUSS_H
|
||||
|
||||
#include "convolution.h"
|
||||
|
||||
class EdgeLaplaceOfGauss : public Convolution
|
||||
{
|
||||
public:
|
||||
EdgeLaplaceOfGauss(PNM*);
|
||||
EdgeLaplaceOfGauss(PNM*, ImageViewer*);
|
||||
|
||||
virtual math::matrix<float> getMask();
|
||||
|
||||
static float getLoG(int, int, float);
|
||||
int getSize();
|
||||
|
||||
private:
|
||||
int size;
|
||||
};
|
||||
|
||||
#endif // EDGE_LAPLACE_GAUSS_H
|
19
08/do_sprawdzenia/cpp/edge_prewitt.cpp
Normal file
19
08/do_sprawdzenia/cpp/edge_prewitt.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "edge_prewitt.h"
|
||||
|
||||
EdgePrewitt::EdgePrewitt(PNM*img) :
|
||||
EdgeGradient(img)
|
||||
{
|
||||
prepareMatrices();
|
||||
}
|
||||
|
||||
EdgePrewitt::EdgePrewitt(PNM*img, ImageViewer* iv) :
|
||||
EdgeGradient(img, iv)
|
||||
{
|
||||
prepareMatrices();
|
||||
}
|
||||
|
||||
void EdgePrewitt::prepareMatrices()
|
||||
{
|
||||
g_x = math::matrix<float>(3, 3, {-1, 0, 1, -1, 0, 1, -1, 0, 1});
|
||||
g_y = math::matrix<float>(3, 3, {-1, -1, -1, 0, 0, 0, 1, 1, 1});
|
||||
}
|
19
08/do_sprawdzenia/cpp/edge_roberts.cpp
Normal file
19
08/do_sprawdzenia/cpp/edge_roberts.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "edge_roberts.h"
|
||||
|
||||
EdgeRoberts::EdgeRoberts(PNM* img) :
|
||||
EdgeGradient(img)
|
||||
{
|
||||
prepareMatrices();
|
||||
}
|
||||
|
||||
EdgeRoberts::EdgeRoberts(PNM* img, ImageViewer* iv) :
|
||||
EdgeGradient(img, iv)
|
||||
{
|
||||
prepareMatrices();
|
||||
}
|
||||
|
||||
void EdgeRoberts::prepareMatrices()
|
||||
{
|
||||
g_x = math::matrix<float>(2, 2, {1, 0, 0, -1});
|
||||
g_y = math::matrix<float>(2, 2, {0, 1, -1, 0});
|
||||
}
|
37
08/do_sprawdzenia/cpp/edge_sobel.cpp
Normal file
37
08/do_sprawdzenia/cpp/edge_sobel.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include "edge_sobel.h"
|
||||
|
||||
EdgeSobel::EdgeSobel(PNM* img, ImageViewer* iv) :
|
||||
EdgeGradient(img, iv)
|
||||
{
|
||||
prepareMatrices();
|
||||
}
|
||||
|
||||
EdgeSobel::EdgeSobel(PNM* img) :
|
||||
EdgeGradient(img)
|
||||
{
|
||||
prepareMatrices();
|
||||
}
|
||||
|
||||
void EdgeSobel::prepareMatrices()
|
||||
{
|
||||
g_x = math::matrix<float>(3, 3, {-1, 0, 1, -2, 0, 2, -1, 0, 1});
|
||||
g_y = math::matrix<float>(3, 3, {-1, -2, -1, 0, 0, 0, 1, 2, 1});
|
||||
}
|
||||
|
||||
math::matrix<float>* EdgeSobel::rawHorizontalDetection()
|
||||
{
|
||||
math::matrix<float>* x_gradient = new math::matrix<float>(this->image->width(), this->image->height());
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
|
||||
return x_gradient;
|
||||
}
|
||||
|
||||
math::matrix<float>* EdgeSobel::rawVerticalDetection()
|
||||
{
|
||||
math::matrix<float>* y_gradient = new math::matrix<float>(this->image->width(), this->image->height());
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
|
||||
return y_gradient;
|
||||
}
|
59
08/do_sprawdzenia/cpp/edge_zero.cpp
Normal file
59
08/do_sprawdzenia/cpp/edge_zero.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
#include "edge_zero.h"
|
||||
|
||||
#include "edge_laplacian_of_gauss.h"
|
||||
|
||||
EdgeZeroCrossing::EdgeZeroCrossing(PNM* img) :
|
||||
Convolution(img)
|
||||
{
|
||||
}
|
||||
|
||||
EdgeZeroCrossing::EdgeZeroCrossing(PNM* img, ImageViewer* iv) :
|
||||
Convolution(img, iv)
|
||||
{
|
||||
}
|
||||
|
||||
PNM* EdgeZeroCrossing::transform()
|
||||
{
|
||||
int size = getParameter("size").toInt();
|
||||
double sigma = getParameter("sigma").toDouble();
|
||||
int t = getParameter("threshold").toInt();
|
||||
|
||||
int width = image->width();
|
||||
int height = image->height();
|
||||
|
||||
int t_width;
|
||||
int t_height;
|
||||
|
||||
PNM* newImage = new PNM(width, height, QImage::Format_Grayscale8);
|
||||
|
||||
EdgeLaplaceOfGauss *laplace_gauss = new EdgeLaplaceOfGauss(image);
|
||||
|
||||
laplace_gauss->setParameter("size", size);
|
||||
laplace_gauss->setParameter("sigma", sigma);
|
||||
|
||||
PNM* transformed_image = laplace_gauss->transform();
|
||||
|
||||
t_width = transformed_image->width();
|
||||
t_height = transformed_image->height();
|
||||
|
||||
for (int i = 0; i < t_width; i++)
|
||||
{
|
||||
for (int j = 0; j < t_height; j++)
|
||||
{
|
||||
math::matrix<float> window = laplace_gauss->getWindow(i, j, size, LChannel, RepeatEdge);
|
||||
|
||||
if (window.min() < (128 - t) && window.max() > (128 + t))
|
||||
{
|
||||
QRgb pixel = transformed_image->pixel(i, j);
|
||||
newImage->setPixel(i, j, QColor(pixel).rgb());
|
||||
}
|
||||
else
|
||||
{
|
||||
newImage->setPixel(i, j, QColor(0,0,0).rgb());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newImage;
|
||||
}
|
||||
|
BIN
08/do_sprawdzenia/cpp/image_laplacian.png
Normal file
BIN
08/do_sprawdzenia/cpp/image_laplacian.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 510 KiB |
BIN
08/do_sprawdzenia/cpp/image_prewitt.png
Normal file
BIN
08/do_sprawdzenia/cpp/image_prewitt.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 576 KiB |
BIN
08/do_sprawdzenia/cpp/image_roberts.png
Normal file
BIN
08/do_sprawdzenia/cpp/image_roberts.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 494 KiB |
BIN
08/do_sprawdzenia/cpp/image_sobel.png
Normal file
BIN
08/do_sprawdzenia/cpp/image_sobel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 615 KiB |
BIN
08/do_sprawdzenia/cpp/image_zero_cross.png
Normal file
BIN
08/do_sprawdzenia/cpp/image_zero_cross.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 77 KiB |
@ -20,12 +20,86 @@ PNM* EdgeGradient::horizontalDetection()
|
||||
return convolute(g_x, RepeatEdge);
|
||||
}
|
||||
|
||||
|
||||
int EdgeGradient::calcValue(int i, int j, Channel channel, PNM* img_x, PNM* img_y)
|
||||
{
|
||||
int value_x, value_y;
|
||||
double power_x, power_y;
|
||||
int value_xy;
|
||||
int result;
|
||||
|
||||
QRgb pixel_x = img_x->pixel(i, j);
|
||||
QRgb pixel_y = img_y->pixel(i, j);
|
||||
|
||||
switch(channel)
|
||||
{
|
||||
|
||||
case RChannel:
|
||||
value_x = qRed(pixel_x);
|
||||
value_y = qRed(pixel_y);
|
||||
break;
|
||||
case GChannel:
|
||||
value_x = qGreen(pixel_x);
|
||||
value_y = qGreen(pixel_y);
|
||||
break;
|
||||
case BChannel:
|
||||
value_x = qBlue(pixel_x);
|
||||
value_y = qBlue(pixel_y);
|
||||
break;
|
||||
case LChannel:
|
||||
value_x = qGray(pixel_x);
|
||||
value_y = qGray(pixel_y);
|
||||
break;
|
||||
}
|
||||
|
||||
power_x = pow(value_x, 2);
|
||||
power_y = pow(value_y, 2);
|
||||
|
||||
value_xy = (int) sqrt(power_x + power_y);
|
||||
|
||||
result = std::max(0, std::min(255, value_xy));
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
PNM* EdgeGradient::transform()
|
||||
{
|
||||
PNM* newImage = new PNM(image->width(), image->height(), image->format());
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
int width = image->width();
|
||||
int height = image->height();
|
||||
|
||||
// Gradient image by x
|
||||
PNM* img_x = horizontalDetection();
|
||||
|
||||
// Gradient image by y
|
||||
PNM* img_y = verticalDetection();
|
||||
|
||||
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
if (image->format() == QImage::Format_Indexed8)
|
||||
{
|
||||
// Calculate gray pixel value
|
||||
int l = calcValue(i, j, LChannel, img_x, img_y);
|
||||
newImage->setPixel(i, j, l);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Calculate RGB values for pixel
|
||||
int r = calcValue(i, j, RChannel, img_x, img_y);
|
||||
int g = calcValue(i, j, GChannel, img_x, img_y);
|
||||
int b = calcValue(i, j, BChannel, img_x, img_y);
|
||||
|
||||
QColor color = QColor(r, g, b);
|
||||
newImage->setPixel(i, j, color.rgb());
|
||||
}
|
||||
}
|
||||
}
|
||||
return newImage;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ public:
|
||||
|
||||
PNM* verticalDetection();
|
||||
PNM* horizontalDetection();
|
||||
int calcValue(int i, int j, Channel channel, PNM* img_x, PNM* img_y);
|
||||
|
||||
protected:
|
||||
virtual void prepareMatrices() = 0;
|
||||
|
@ -15,7 +15,18 @@ math::matrix<float> EdgeLaplacian::getMask(int, Mode)
|
||||
int size = getParameter("size").toInt();
|
||||
math::matrix<float> mask(size, size);
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
int center = size / 2;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
for (int j = 0; j < size; j++)
|
||||
{
|
||||
mask(i, j) = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate center element of mask
|
||||
mask(center, center) = pow(size, 2) - 1;
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
@ -12,25 +12,43 @@ EdgeLaplaceOfGauss::EdgeLaplaceOfGauss(PNM* img, ImageViewer* iv) :
|
||||
{
|
||||
}
|
||||
|
||||
math::matrix<float> EdgeLaplaceOfGauss::getMask(int, Mode)
|
||||
math::matrix<float> EdgeLaplaceOfGauss::getMask()
|
||||
{
|
||||
size = getParameter("size").toInt();
|
||||
double sigma = getParameter("sigma").toDouble();
|
||||
|
||||
math::matrix<float> mask(size, size);
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
int center = -size / 2;
|
||||
|
||||
|
||||
for (int x = 0, k = center; x < size; x++, k++)
|
||||
{
|
||||
for (int y = 0, l = center; y < size; y++, l++)
|
||||
{
|
||||
mask(x, y) = getLoG(k, l, sigma);
|
||||
}
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
float EdgeLaplaceOfGauss::getLoG(int x, int y, float s)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
int px = pow(x, 2);
|
||||
int py = pow(y, 2);
|
||||
|
||||
return 0;
|
||||
float ps = pow(s, 2);
|
||||
int numerator = px + py - 2;
|
||||
|
||||
int gauss = BlurGaussian::getGauss(x, y, ps);
|
||||
|
||||
int result = (numerator / ps) * gauss;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int EdgeLaplaceOfGauss::getSize()
|
||||
{
|
||||
return size;
|
||||
|
@ -9,7 +9,7 @@ public:
|
||||
EdgeLaplaceOfGauss(PNM*);
|
||||
EdgeLaplaceOfGauss(PNM*, ImageViewer*);
|
||||
|
||||
virtual math::matrix<float> getMask(int, Mode);
|
||||
virtual math::matrix<float> getMask();
|
||||
|
||||
static float getLoG(int, int, float);
|
||||
int getSize();
|
||||
|
@ -14,6 +14,6 @@ EdgePrewitt::EdgePrewitt(PNM*img, ImageViewer* iv) :
|
||||
|
||||
void EdgePrewitt::prepareMatrices()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
g_x = math::matrix<float>(3, 3, {-1, 0, 1, -1, 0, 1, -1, 0, 1});
|
||||
g_y = math::matrix<float>(3, 3, {-1, -1, -1, 0, 0, 0, 1, 1, 1});
|
||||
}
|
||||
|
||||
|
@ -14,5 +14,6 @@ EdgeRoberts::EdgeRoberts(PNM* img, ImageViewer* iv) :
|
||||
|
||||
void EdgeRoberts::prepareMatrices()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
g_x = math::matrix<float>(2, 2, {1, 0, 0, -1});
|
||||
g_y = math::matrix<float>(2, 2, {0, 1, -1, 0});
|
||||
}
|
||||
|
@ -14,7 +14,8 @@ EdgeSobel::EdgeSobel(PNM* img) :
|
||||
|
||||
void EdgeSobel::prepareMatrices()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
g_x = math::matrix<float>(3, 3, {-1, 0, 1, -2, 0, 2, -1, 0, 1});
|
||||
g_y = math::matrix<float>(3, 3, {-1, -2, -1, 0, 0, 0, 1, 2, 1});
|
||||
}
|
||||
|
||||
math::matrix<float>* EdgeSobel::rawHorizontalDetection()
|
||||
|
@ -14,16 +14,45 @@ EdgeZeroCrossing::EdgeZeroCrossing(PNM* img, ImageViewer* iv) :
|
||||
|
||||
PNM* EdgeZeroCrossing::transform()
|
||||
{
|
||||
int width = image->width(),
|
||||
height = image->height();
|
||||
|
||||
int size = getParameter("size").toInt();
|
||||
double sigma = getParameter("sigma").toDouble();
|
||||
int t = getParameter("threshold").toInt();
|
||||
|
||||
int width = image->width();
|
||||
int height = image->height();
|
||||
|
||||
int t_width;
|
||||
int t_height;
|
||||
|
||||
PNM* newImage = new PNM(width, height, QImage::Format_Grayscale8);
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
EdgeLaplaceOfGauss *laplace_gauss = new EdgeLaplaceOfGauss(image);
|
||||
|
||||
laplace_gauss->setParameter("size", size);
|
||||
laplace_gauss->setParameter("sigma", sigma);
|
||||
|
||||
PNM* transformed_image = laplace_gauss->transform();
|
||||
|
||||
t_width = transformed_image->width();
|
||||
t_height = transformed_image->height();
|
||||
|
||||
for (int i = 0; i < t_width; i++)
|
||||
{
|
||||
for (int j = 0; j < t_height; j++)
|
||||
{
|
||||
math::matrix<float> window = laplace_gauss->getWindow(i, j, size, LChannel, RepeatEdge);
|
||||
|
||||
if (window.min() < (128 - t) && window.max() > (128 + t))
|
||||
{
|
||||
QRgb pixel = transformed_image->pixel(i, j);
|
||||
newImage->setPixel(i, j, QColor(pixel).rgb());
|
||||
}
|
||||
else
|
||||
{
|
||||
newImage->setPixel(i, j, QColor(0,0,0).rgb());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newImage;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user