 Timestamp:
 Aug 29, 2008, 9:48:30 AM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

libpipi/trunk/pipi/filter/convolution.c
r2793 r2804 137 137 for(x = 0; x < w; x++) 138 138 { 139 if(FLAG_GRAY) 140 { 141 double Y = 0.; 142 int x2, y2; 143 144 for(j = 0; j < n; j++) 145 { 146 y2 = y + j  n / 2; 147 if(y2 < 0) y2 = FLAG_WRAP ? h  1  ((y2  1) % h) : 0; 148 else if(y2 >= h) y2 = FLAG_WRAP ? y2 % h : h  1; 149 150 for(i = 0; i < m; i++) 139 double R = 0., G = 0., B = 0.; 140 double Y = 0.; 141 int x2, y2, off = 4 * (y * w + x); 142 143 for(j = 0; j < n; j++) 144 { 145 y2 = y + j  n / 2; 146 if(y2 < 0) y2 = FLAG_WRAP ? h  1  ((y2  1) % h) : 0; 147 else if(y2 >= h) y2 = FLAG_WRAP ? y2 % h : h  1; 148 149 for(i = 0; i < m; i++) 150 { 151 double f = mat[j * m + i]; 152 153 x2 = x + i  m / 2; 154 if(x2 < 0) x2 = FLAG_WRAP ? w  1  ((x2  1) % w) : 0; 155 else if(x2 >= w) x2 = FLAG_WRAP ? x2 % w : w  1; 156 157 if(FLAG_GRAY) 158 Y += f * srcdata[y2 * w + x2]; 159 else 151 160 { 152 x2 = x + i  m / 2;153 if(x2 < 0) x2 = FLAG_WRAP ? w  1  ((x2  1) % w) : 0;154 else if(x2 >= w) x2 = FLAG_WRAP ? x2 % w : w  1;155 156 Y += mat[j * m + i] * srcdata[y2 * w + x2];157 }158 }159 160 dstdata[y * w + x] = Y < 0.0 ? 0.0 : Y > 1.0 ? 1.0 : Y;161 }162 else163 {164 double R = 0., G = 0., B = 0.;165 int x2, y2, off = 4 * (y * w + x);166 167 for(j = 0; j < n; j++)168 {169 y2 = y + j  n / 2;170 if(y2 < 0) y2 = FLAG_WRAP ? h  1  ((y2  1) % h) : 0;171 else if(y2 >= h) y2 = FLAG_WRAP ? y2 % h : h  1;172 173 for(i = 0; i < m; i++)174 {175 double f = mat[j * m + i];176 177 x2 = x + i  m / 2;178 if(x2 < 0) x2 = FLAG_WRAP ? w  1  ((x2  1) % w) : 0;179 else if(x2 >= w) x2 = FLAG_WRAP ? x2 % w : w  1;180 181 161 R += f * srcdata[(y2 * w + x2) * 4]; 182 162 G += f * srcdata[(y2 * w + x2) * 4 + 1]; … … 184 164 } 185 165 } 186 166 } 167 168 if(FLAG_GRAY) 169 dstdata[y * w + x] = Y < 0.0 ? 0.0 : Y > 1.0 ? 1.0 : Y; 170 else 171 { 187 172 dstdata[off] = R < 0.0 ? 0.0 : R > 1.0 ? 1.0 : R; 188 173 dstdata[off + 1] = G < 0.0 ? 0.0 : G > 1.0 ? 1.0 : G; … … 222 207 for(x = 0; x < w; x++) 223 208 { 224 if(FLAG_GRAY) 225 { 226 double Y = 0.; 227 int x2; 228 229 for(i = 0; i < m; i++) 230 { 231 x2 = x + i  m / 2; 232 if(x2 < 0) x2 = FLAG_WRAP ? w  1  ((x2  1) % w) : 0; 233 else if(x2 >= w) x2 = FLAG_WRAP ? x2 % w : w  1; 234 235 Y += hvec[i] * srcdata[y * w + x2]; 236 } 237 238 buffer[y * w + x] = Y; 239 } 240 else 241 { 242 double R = 0., G = 0., B = 0.; 243 int x2, off = 4 * (y * w + x); 244 245 for(i = 0; i < m; i++) 246 { 247 double f = hvec[i]; 248 249 x2 = x + i  m / 2; 250 if(x2 < 0) x2 = FLAG_WRAP ? w  1  ((x2  1) % w) : 0; 251 else if(x2 >= w) x2 = FLAG_WRAP ? x2 % w : w  1; 252 209 double R = 0., G = 0., B = 0.; 210 double Y = 0.; 211 int x2, off = 4 * (y * w + x); 212 213 for(i = 0; i < m; i++) 214 { 215 double f = hvec[i]; 216 217 x2 = x + i  m / 2; 218 if(x2 < 0) x2 = FLAG_WRAP ? w  1  ((x2  1) % w) : 0; 219 else if(x2 >= w) x2 = FLAG_WRAP ? x2 % w : w  1; 220 221 if(FLAG_GRAY) 222 Y += f * srcdata[y * w + x2]; 223 else 224 { 253 225 R += f * srcdata[(y * w + x2) * 4]; 254 226 G += f * srcdata[(y * w + x2) * 4 + 1]; 255 227 B += f * srcdata[(y * w + x2) * 4 + 2]; 256 228 } 257 229 } 230 231 if(FLAG_GRAY) 232 buffer[y * w + x] = Y; 233 else 234 { 258 235 buffer[off] = R; 259 236 buffer[off + 1] = G; … … 267 244 for(x = 0; x < w; x++) 268 245 { 269 if(FLAG_GRAY) 270 { 271 double Y = 0.; 272 int y2; 273 274 for(j = 0; j < n; j++) 275 { 276 y2 = y + j  n / 2; 277 if(y2 < 0) y2 = FLAG_WRAP ? h  1  ((y2  1) % h) : 0; 278 else if(y2 >= h) y2 = FLAG_WRAP ? y2 % h : h  1; 279 280 Y += vvec[j] * buffer[y2 * w + x]; 281 } 282 283 dstdata[y * w + x] = Y < 0.0 ? 0.0 : Y > 1.0 ? 1.0 : Y; 284 } 285 else 286 { 287 double R = 0., G = 0., B = 0.; 288 int y2, off = 4 * (y * w + x); 289 290 for(j = 0; j < n; j++) 291 { 292 double f = vvec[j]; 293 294 y2 = y + j  n / 2; 295 if(y2 < 0) y2 = FLAG_WRAP ? h  1  ((y2  1) % h) : 0; 296 else if(y2 >= h) y2 = FLAG_WRAP ? y2 % h : h  1; 297 246 double R = 0., G = 0., B = 0.; 247 double Y = 0.; 248 int y2, off = 4 * (y * w + x); 249 250 for(j = 0; j < n; j++) 251 { 252 double f = vvec[j]; 253 254 y2 = y + j  n / 2; 255 if(y2 < 0) y2 = FLAG_WRAP ? h  1  ((y2  1) % h) : 0; 256 else if(y2 >= h) y2 = FLAG_WRAP ? y2 % h : h  1; 257 258 if(FLAG_GRAY) 259 Y += f * buffer[y2 * w + x]; 260 else 261 { 298 262 R += f * buffer[(y2 * w + x) * 4]; 299 263 G += f * buffer[(y2 * w + x) * 4 + 1]; 300 264 B += f * buffer[(y2 * w + x) * 4 + 2]; 301 265 } 302 266 } 267 268 if(FLAG_GRAY) 269 dstdata[y * w + x] = Y < 0.0 ? 0.0 : Y > 1.0 ? 1.0 : Y; 270 else 271 { 303 272 dstdata[off] = R < 0.0 ? 0.0 : R > 1.0 ? 1.0 : R; 304 273 dstdata[off + 1] = G < 0.0 ? 0.0 : G > 1.0 ? 1.0 : G;
Note: See TracChangeset
for help on using the changeset viewer.