Changeset 389 for pwntcha/trunk/src/filters.c
- Timestamp:
- Jan 3, 2005, 10:48:54 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pwntcha/trunk/src/filters.c
r387 r389 143 143 } 144 144 145 struct image *filter_equalize(struct image *img )145 struct image *filter_equalize(struct image *img, int threshold) 146 146 { 147 147 struct image *dst; … … 155 155 { 156 156 getpixel(img, x, y, &r, &g, &b); 157 if(r < 200) r = 50; else r = 200;157 if(r < threshold) r = 0; else r = 255; 158 158 setpixel(dst, x, y, r, r, r); 159 159 } … … 241 241 struct image *filter_median(struct image *img) 242 242 { 243 #define MSIZE 4243 #define MSIZE 3 244 244 struct image *dst; 245 245 int x, y, i, j, val[MSIZE*MSIZE]; … … 279 279 } 280 280 281 struct image *filter_contrast(struct image *img) 282 { 283 struct image *dst; 284 int histo[256]; 285 int x, y, i, min = 255, max = 0; 286 int r, g, b; 287 288 dst = image_new(img->width, img->height); 289 290 for(y = 0; y < img->height; y++) 291 for(x = 0; x < img->width; x++) 292 { 293 getgray(img, x, y, &r); 294 if(r < min) min = r; 295 if(r > max) max = r; 296 } 297 298 if(min == max) 299 histo[min] = 127; 300 else 301 for(i = min; i < max; i++) 302 histo[i] = (i - min) * 255 / (max - min); 303 304 for(y = 0; y < img->height; y++) 305 for(x = 0; x < img->width; x++) 306 { 307 getgray(img, x, y, &r); 308 setpixel(dst, x, y, histo[r], histo[r], histo[r]); 309 } 310 311 return dst; 312 } 313
Note: See TracChangeset
for help on using the changeset viewer.