-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFostroSmoothingFilter.cpp
More file actions
48 lines (41 loc) · 1.11 KB
/
FostroSmoothingFilter.cpp
File metadata and controls
48 lines (41 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "FostroSmoothingFilter.h"
FostroSmoothingFilter::FostroSmoothingFilter(int width, int height) : FostroFilter(width, height) {
}
FostroSmoothingFilter::~FostroSmoothingFilter() {
}
FostroImage* FostroSmoothingFilter::applyFilter(FostroImage* image, int c) {
FostroPixel* pixel;
FostroImage* newImage = new FostroImage(*image, "tmpSmooth.png");
for (unsigned long x = 0; x < image->getHeight(); x++) {
for (unsigned long y = 0; y < image->getWidth(); y++) {
unsigned long val = 0;
for (int i = 0; i < mask->getHeight(); i++) {
for (int j = 0; j < mask->getWidth(); j++) {
val += mask->getImageValAtMaskLoc(i,j,(int)x,(int)y,image,c);
}
}
pixel = newImage->getPixel(x,y);
switch (c) {
case RED:
pixel->setRedVal(val);
break;
case GREEN:
pixel->setGreenVal(val);
break;
case BLUE:
pixel->setBlueVal(val);
break;
case ALPHA:
pixel->setAlphaVal(val);
break;
case GRAY:
pixel->setRedVal(val);
pixel->setGreenVal(val);
pixel->setBlueVal(val);
pixel->calcGrayscaleIntensity();
break;
}
}
}
return newImage;
};