~ubuntu-branches/ubuntu/trusty/etl/trusty-proposed

« back to all changes in this revision

Viewing changes to ETL/_gaussian.h

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2013-05-13 19:36:15 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20130513193615-8z59omgg2twsvu2i
Tags: 0.04.16-1
* New upstream release [May 2013].
* Standards to 3.9.4.
* xz compression for source and binary packages.
* Minor debian/watch update.
* Updated my email address; bumped copyright years.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
 
43
43
template<typename T> void
44
44
gaussian_blur_5x5_(T pen,int w, int h,
45
 
typename T::pointer SC0,
46
 
typename T::pointer SC1,
47
 
typename T::pointer SC2,
48
 
typename T::pointer SC3)
 
45
typename T::accumulator_pointer SC0,
 
46
typename T::accumulator_pointer SC1,
 
47
typename T::accumulator_pointer SC2,
 
48
typename T::accumulator_pointer SC3)
49
49
{
50
50
        int x,y;
51
 
        typename T::value_type Tmp1,Tmp2,SR0,SR1,SR2,SR3;
 
51
        typename T::accumulator_type Tmp1,Tmp2,SR0,SR1,SR2,SR3;
52
52
 
53
53
        //typename T::iterator_x iter;
54
54
 
55
55
        // Setup the row buffers
56
 
        for(x=0;x<w;x++)SC0[x+2]=pen.x()[x]*24;
57
 
        memset(SC1,0,(w+2)*sizeof(typename T::value_type));
58
 
        memset(SC2,0,(w+2)*sizeof(typename T::value_type));
59
 
        memset(SC3,0,(w+2)*sizeof(typename T::value_type));
 
56
        for(x=0;x<w;x++)SC0[x+2]=(typename T::accumulator_type)(pen.x()[x])*24;
 
57
        memset(SC1,0,(w+2)*sizeof(typename T::accumulator_type));
 
58
        memset(SC2,0,(w+2)*sizeof(typename T::accumulator_type));
 
59
        memset(SC3,0,(w+2)*sizeof(typename T::accumulator_type));
60
60
 
61
61
        for(y=0;y<h+2;y++,pen.inc_y())
62
62
        {
63
63
                int yadj;
64
64
                if(y>=h)
65
 
                        {yadj=(h-y)-1; SR0=pen.y()[yadj]*1.35;}
 
65
                        {yadj=(h-y)-1; SR0=(typename T::accumulator_type)(pen.y()[yadj])*1.35;}
66
66
                else
67
 
                        {yadj=0; SR0=pen.get_value()*1.35; }
 
67
                        {yadj=0; SR0=(typename T::accumulator_type)(pen.get_value())*1.35; }
68
68
 
69
 
                SR1=SR2=SR3=typename T::value_type();
 
69
                SR1=SR2=SR3=typename T::accumulator_type();
70
70
                for(x=0;x<w+2;x++,pen.inc_x())
71
71
                {
72
72
                        if(x>=w)
73
 
                                Tmp1=pen[yadj][(w-x)-1];
 
73
                                Tmp1=(typename T::accumulator_type)(pen[yadj][(w-x)-1]);
74
74
                        else
75
 
                                Tmp1=*pen[yadj];
 
75
                                Tmp1=(typename T::accumulator_type)(*pen[yadj]);
76
76
 
77
77
                        Tmp2=SR0+Tmp1;
78
78
                        SR0=Tmp1;
91
91
                        Tmp2=SC2[x]+Tmp1;
92
92
                        SC2[x]=Tmp1;
93
93
                        if(y>1&&x>1)
94
 
                                pen[-2][-2]=(SC3[x]+Tmp2)/256;
 
94
                                pen[-2][-2]=(typename T::value_type)((SC3[x]+Tmp2)/256);
95
95
                        SC3[x]=Tmp2;
96
96
                }
97
97
                pen.dec_x(x);
102
102
template<typename T> void
103
103
gaussian_blur_5x5(T pen, int w, int h)
104
104
{
105
 
        typename T::pointer SC0=new typename T::value_type[w+2];
106
 
        typename T::pointer SC1=new typename T::value_type[w+2];
107
 
        typename T::pointer SC2=new typename T::value_type[w+2];
108
 
        typename T::pointer SC3=new typename T::value_type[w+2];
 
105
        typename T::accumulator_pointer SC0=new typename T::accumulator_type[w+2];
 
106
        typename T::accumulator_pointer SC1=new typename T::accumulator_type[w+2];
 
107
        typename T::accumulator_pointer SC2=new typename T::accumulator_type[w+2];
 
108
        typename T::accumulator_pointer SC3=new typename T::accumulator_type[w+2];
109
109
 
110
110
        gaussian_blur_5x5_(pen,w,h,SC0,SC1,SC2,SC3);
111
111
 
120
120
{
121
121
        typename T::difference_type size(end-begin);
122
122
 
123
 
        typename T::pointer SC0=new typename T::value_type[size.x+2];
124
 
        typename T::pointer SC1=new typename T::value_type[size.x+2];
125
 
        typename T::pointer SC2=new typename T::value_type[size.x+2];
126
 
        typename T::pointer SC3=new typename T::value_type[size.x+2];
 
123
        typename T::accumulator_pointer SC0=new typename T::accumulator_type[size.x+2];
 
124
        typename T::accumulator_pointer SC1=new typename T::accumulator_type[size.x+2];
 
125
        typename T::accumulator_pointer SC2=new typename T::accumulator_type[size.x+2];
 
126
        typename T::accumulator_pointer SC3=new typename T::accumulator_type[size.x+2];
127
127
 
128
128
        gaussian_blur_5x5_(begin,size.x,size.y,SC0,SC1,SC2,SC3);
129
129
 
137
137
gaussian_blur_3x3(T pen,int w, int h)
138
138
{
139
139
        int x,y;
140
 
        typename T::value_type Tmp1,Tmp2,SR0,SR1;
 
140
        typename T::accumulator_type Tmp1,Tmp2,SR0,SR1;
141
141
 
142
142
//      typename T::iterator_x iter;
143
143
 
144
 
        typename T::pointer SC0=new typename T::value_type[w+1];
145
 
        typename T::pointer SC1=new typename T::value_type[w+1];
 
144
        typename T::accumulator_pointer SC0=new typename T::accumulator_type[w+1];
 
145
        typename T::accumulator_pointer SC1=new typename T::accumulator_type[w+1];
146
146
 
147
147
        // Setup the row buffers
148
 
        for(x=0;x<w;x++)SC0[x+1]=pen.x()[x]*4;
149
 
        memset(SC1,0,(w+1)*sizeof(typename T::value_type));
 
148
        for(x=0;x<w;x++)SC0[x+1]=(typename T::accumulator_type)(pen.x()[x])*4;
 
149
        memset(SC1,0,(w+1)*sizeof(typename T::accumulator_type));
150
150
 
151
151
        for(y=0;y<h+1;y++,pen.inc_y())
152
152
        {
153
153
                int yadj;
154
154
                if(y>=h)
155
 
                        {yadj=-1; SR1=SR0=pen.y()[yadj];}
 
155
                        {yadj=-1; SR1=SR0=(typename T::accumulator_type)(pen.y()[yadj]);}
156
156
                else
157
 
                        {yadj=0; SR1=SR0=pen.get_value(); }
 
157
                        {yadj=0; SR1=SR0=(typename T::accumulator_type)(pen.get_value()); }
158
158
 
159
159
                for(x=0;x<w+1;x++,pen.inc_x())
160
160
                {
161
161
                        if(x>=w)
162
 
                                Tmp1=pen[yadj][(w-x)-2];
 
162
                                Tmp1=(typename T::accumulator_type)(pen[yadj][(w-x)-2]);
163
163
                        else
164
 
                                Tmp1=*pen[yadj];
 
164
                                Tmp1=(typename T::accumulator_type)(*pen[yadj]);
165
165
 
166
166
                        Tmp2=SR0+Tmp1;
167
167
                        SR0=Tmp1;
171
171
                        Tmp2=SC0[x]+Tmp1;
172
172
                        SC0[x]=Tmp1;
173
173
                        if(y&&x)
174
 
                                pen[-1][-1]=(SC1[x]+Tmp2)/16;
 
174
                                pen[-1][-1]=(typename T::value_type)((SC1[x]+Tmp2)/16);
175
175
                        SC1[x]=Tmp2;
176
176
                }
177
177
                pen.dec_x(x);
242
242
template<typename T> void
243
243
gaussian_blur(T pen, int w, int h, int blur_x, int blur_y)
244
244
{
245
 
        typename T::pointer SC0=new typename T::value_type[w+2];
246
 
        typename T::pointer SC1=new typename T::value_type[w+2];
247
 
        typename T::pointer SC2=new typename T::value_type[w+2];
248
 
        typename T::pointer SC3=new typename T::value_type[w+2];
 
245
        typename T::accumulator_pointer SC0=new typename T::accumulator_type[w+2];
 
246
        typename T::accumulator_pointer SC1=new typename T::accumulator_type[w+2];
 
247
        typename T::accumulator_pointer SC2=new typename T::accumulator_type[w+2];
 
248
        typename T::accumulator_pointer SC3=new typename T::accumulator_type[w+2];
249
249
 
250
250
        blur_x--;
251
251
        blur_y--;