zadanie-5
This commit is contained in:
parent
468677b949
commit
c6daa832b7
@ -25,7 +25,7 @@ math::matrix<float> Convolution::getMask(int size, Mode mode = Normalize)
|
||||
for (int i=0; i<size; ++i) {
|
||||
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;
|
||||
else
|
||||
mask[i][j] = 0;
|
||||
|
@ -21,23 +21,25 @@ PNM* EdgeZeroCrossing::transform()
|
||||
double sigma = getParameter("sigma").toDouble();
|
||||
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);
|
||||
log.setParameter("size", getParameter("size"));
|
||||
log.setParameter("sigma", getParameter("sigma"));
|
||||
|
||||
Transformation laplasjan(log.transform());
|
||||
|
||||
int v0 = 128;
|
||||
int half = size/2;
|
||||
|
||||
for (int x=0;x<width;++x) {
|
||||
for (int y=0;y<height;++y) {
|
||||
float lapsjan = EdgeLaplaceOfGauss::getLoG(x,y, sigma) * v0;
|
||||
math::matrix<float> mask = log.getMask(size, sigma, RepeatEdge);
|
||||
math::matrix<float> mask = laplasjan.getWindow(x, y, size, LChannel, RepeatEdge);
|
||||
|
||||
float max = mask.max();
|
||||
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(255, 255, 255).rgb());
|
||||
else
|
||||
newImage->setPixel(x,y, QColor(0, 0, 0).rgb());
|
||||
newImage->setPixel(x,y, QColor(gray, gray, gray).rgb());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user