blob: a9863470b84590d971181089b9aca51be52448d7 (
plain)
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
|
// Copyright 2006 Google Inc.
// All Rights Reserved.
// Author: <renn@google.com> (Marius Renn)
// Local includes
#include "edgedetector.h"
using namespace helium;
// We try to do as much initializing in the base constructor as possible, to
// avoid redundancy in the subclasses
EdgeDetector::EdgeDetector(unsigned mask_size)
: kernel_size_(mask_size),
kernel_half_((mask_size - 1) / 2) {
}
void EdgeDetector::ApplyKernel(const int8* mask,
const Color* image_ptr,
int image_width,
int& red,
int& green,
int& blue) {
unsigned i = 0;
for(unsigned y = 0; y < kernel_size_; y++) {
for(unsigned x = 0; x < kernel_size_; x++) {
red += Red(*image_ptr) * mask[i];
green += Green(*image_ptr) * mask[i];
blue += Blue(*(image_ptr++)) * mask[i++];
}
image_ptr += (image_width - kernel_size_);
}
}
|