-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFostroErosionFilter.cpp
More file actions
45 lines (33 loc) · 1.06 KB
/
FostroErosionFilter.cpp
File metadata and controls
45 lines (33 loc) · 1.06 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
#include "FostroErosionFilter.h"
FostroErosionFilter::FostroErosionFilter(int width, int height) : FostroFilter(width, height) {
}
FostroErosionFilter::~FostroErosionFilter() {
}
FostroImage* FostroErosionFilter::applyFilter(FostroImage* image, int c) {
FostroPixel* pixel;
float val = 0;
FostroImage* newImage = new FostroImage(*image, "tmpSobelV.png");
for (unsigned long x = 0; x < image->getHeight(); x++) {
for (unsigned long y = 0; y < image->getWidth(); y++) {
val = getVal(x, y, image);
pixel = newImage->getPixel(x,y);
pixel->setRedVal(val);
pixel->setGreenVal(val);
pixel->setBlueVal(val);
pixel->calcGrayscaleIntensity();
}
}
return newImage;
}
float FostroErosionFilter::getVal(int x, int y, FostroImage* image) {
FostroPixel* pixel;
for (int i = 0; i < mask->getHeight(); i++) {
for (int j = 0; j < mask->getWidth(); j++) {
pixel = image->getPixel(mask->calcHeightOffset(x, i), mask->calcWidthOffset(y, j));
if (pixel->getGrayscaleIntensity() < MAX_PIXEL_VAL/2) {
return 0;
}
}
}
return MAX_PIXEL_VAL;
}