Debian Codegraph @

src/filter/sobel/sobel.cpp

raw symbols SCIP
1 /* sobel.cpp
2 * Copyright (C) 2005 Jean-Sebastien Senecal ([email protected])
3 * This file is a Frei0r plugin.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include "frei0r.hpp"cxx . . $ `<file>/include/frei0r.hpp`/
21 #include "frei0r/math.h"cxx . . $ `<file>/include/frei0r/math.h`/
22 #include <stdlib.h>
23
24 class sobelcxx . . $ sobel# : public frei0rcxx . . $ frei0r/::filtercxx . . $ frei0r/filter#
25 {
26 public:
27 sobelcxx . . $ sobel#sobel(b4d55b1286ff73e8).(unsigned int width, unsigned int height)
28 {
29 this->widthcxx . . $ frei0r/fx#width. = width;
30 this->heightcxx . . $ frei0r/fx#height. = height;
31 }
32
33 virtual void updatecxx . . $ sobel#update(da7b4a17ceb4e697).(double time,
34 uint32_t* out,
35 const uint32_t* in)
36 {
37 if (widthcxx . . $ frei0r/fx#width. == 0 || heightcxx . . $ frei0r/fx#height. == 0) return;
38
39 stdcxx . . $ std/::copycxx . . $ std/copy(88304b602929f6f4).(in, in + widthcxx . . $ frei0r/fx#width.*heightcxx . . $ frei0r/fx#height., out);
40 for (unsigned int y=1; y<heightcxx . . $ frei0r/fx#height.-1; ++y)
41 {
42 for (unsigned int x=1; x<widthcxx . . $ frei0r/fx#width.-1; ++x)
43 {
44 // XXX faut eviter le * width en y allant par rangee
45 unsigned char *p1 = (unsigned char *)&in[(y-1)*widthcxx . . $ frei0r/fx#width.+(x-1)];
46 unsigned char *p2 = (unsigned char *)&in[(y-1)*widthcxx . . $ frei0r/fx#width.+x];
47 unsigned char *p3 = (unsigned char *)&in[(y-1)*widthcxx . . $ frei0r/fx#width.+(x+1)];
48 unsigned char *p4 = (unsigned char *)&in[y*widthcxx . . $ frei0r/fx#width.+(x-1)];
49 unsigned char *p6 = (unsigned char *)&in[y*widthcxx . . $ frei0r/fx#width.+(x+1)];
50 unsigned char *p7 = (unsigned char *)&in[(y+1)*widthcxx . . $ frei0r/fx#width.+(x-1)];
51 unsigned char *p8 = (unsigned char *)&in[(y+1)*widthcxx . . $ frei0r/fx#width.+x];
52 unsigned char *p9 = (unsigned char *)&in[(y+1)*widthcxx . . $ frei0r/fx#width.+(x+1)];
53
54 unsigned char *g = (unsigned char *)&out[y*widthcxx . . $ frei0r/fx#width.+x];
55
56 for (int i=0; i<3; ++i)
57 g[i] = CLAMP0255cxx . . $ CLAMP0255(bc0fba5608a0bfe7).(
58 abscxx . . $ abs(7864480464b09eea).(p1[i] + p2[i]*2 + p3[i] - p7[i] - p8[i]*2 - p9[i]) +
59 abscxx . . $ abs(7864480464b09eea).(p3[i] + p6[i]*2 + p9[i] - p1[i] - p4[i]*2 - p7[i]) );
60
61 g[3] = ((unsigned char*)&in[y*widthcxx . . $ frei0r/fx#width.+x])[3]; // copy alpha
62 }
63 }
64 }
65 };
66
67
68 frei0rcxx . . $ frei0r/::constructcxx . . $ frei0r/construct#<sobelcxx . . $ sobel#> plugincxx . . $ plugin.("Sobel"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
69 "Sobel filter"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
70 "Jean-Sebastien Senecal (Drone)"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
71 0,2,
72 F0R_COLOR_MODEL_RGBA8888cxx . . $ `include/frei0r.h:308:9`!);
73