Changeset 2278 for trunk/MagicSoft/Cosy/videodev
- Timestamp:
- 07/15/03 15:05:21 (21 years ago)
- Location:
- trunk/MagicSoft/Cosy/videodev
- Files:
-
- 4 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/videodev/Camera.cc
r1802 r2278 47 47 void Camera::SigInit() 48 48 { 49 return; 49 50 struct sigaction act, old; 50 51 … … 215 216 while (img < end) 216 217 { 217 *beg = *img; 218 218 *beg++ = *img; 219 219 img += depth; 220 beg++;221 220 } 222 221 } -
trunk/MagicSoft/Cosy/videodev/Camera.h
r1802 r2278 14 14 #endif 15 15 16 #include "PixGetter.h" 16 17 #include "PixClient.h" 17 18 18 class Camera 19 class Camera : public PixGetter 19 20 { 20 21 private: -
trunk/MagicSoft/Cosy/videodev/CaosFilter.cc
r1810 r2278 28 28 } 29 29 30 float CaosFilter::Mean(const byte *buffer, const int offset, int *min, int *max) 31 { 32 double mean = 0.0; 33 34 *min = 0xff; 35 *max = 0x00; 30 void CaosFilter::GetStat(const byte *buffer, const int offset, double *mean, double *sdev) 31 { 32 double sum = 0; 33 double sq = 0; 34 35 byte *s = (byte*)buffer; 36 const byte *e0 = s+768*576; 36 37 37 38 // 38 39 // calculate mean value 39 40 // 40 for (int x=offset; x<768-offset; x++) 41 for (int y=offset; y<576-offset; y++) 42 { 43 byte val = buffer[y*768+x]; 44 45 mean += val; 46 47 if (val>*max) 48 *max = val; 49 50 if (val<*min) 51 *min = val; 52 } 53 54 mean /= (768-2*offset)*(576-2*offset); 55 56 return mean; 41 while (s<e0) 42 { 43 const byte *e = s+576-offset; 44 s += offset; 45 46 while (s<e) 47 { 48 sum += *s; 49 sq += *s * *s; 50 s++; 51 } 52 53 s+=offset; 54 } 55 56 const Int_t sz = (768-2*offset)*(576-2*offset); 57 58 sum /= sz; 59 sq /= sz; 60 61 *mean = sum; 62 *sdev = sqrt(sq-sum*sum); 57 63 } 58 64 … … 80 86 return (int)my*768 + (int)mx; 81 87 } 82 83 float CaosFilter::SDev(const byte *buffer, const int offset, const double mean)84 {85 //86 // calculate sigma87 //88 double sdev=0.0;89 90 for (int x=offset; x<768-offset; x++)91 for (int y=offset; y<576-offset; y++)92 {93 const float val = mean - buffer[y*768+x];94 95 sdev += val*val;96 }97 98 sdev /= (768-2*offset)*(576-2*offset)-1;99 100 return sqrt(sdev);101 }102 103 88 104 89 int CaosFilter::GetMeanPosition(const byte *bitmap, const int x, const int y, … … 389 374 const int offset = 10; 390 375 391 int max; 392 int min; 393 394 const float mean = Mean(img, offset, &min, &max); 395 const float sdev = SDev(img, offset, mean); 396 397 const float cut = mean + 2.5*sdev; 376 double mean, sdev; 377 GetStat(img, offset, &mean, &sdev); 378 379 const byte max = mean+2.5*sdev>254 ? 254 : (byte)(mean+2.5*sdev); 398 380 399 381 // 400 382 // clean image from noise 401 383 // 402 for (int x=0; x<768; x++) 403 for (int y=0; y<576; y++) 404 { 405 if (img[y*768+x]>cut) 406 continue; 407 408 // 409 // FIXME: Create LOOKUP Table! 410 // 411 412 img[y*768+x] = 0; 413 } 384 const byte *e = img+768*576; 385 byte *i = img; 386 while (i<e) 387 { 388 if (*i<=max) 389 *i = 0; 390 i++; 391 } 414 392 415 393 // … … 511 489 const int offset = 10; 512 490 513 int max; 514 int min; 515 516 const float mean = Mean(img, offset, &min, &max); 517 const float sdev = SDev(img, offset, mean); 518 519 const float cut = mean + 2.5*sdev; 491 double mean, sdev; 492 GetStat(img, offset, &mean, &sdev); 493 494 const byte cut = mean+2.5*sdev>254 ? 254 : (byte)(mean + 2.5*sdev); 520 495 521 496 // 522 497 // clean image from noise 523 498 // 524 for (int x=0; x<768; x++) 525 for (int y=0; y<576; y++) 526 { 527 if (img[y*768+x]>cut) 528 continue; 529 530 // 531 // FIXME: Create LOOKUP Table! 532 // 533 534 img[y*768+x] = 0; 535 } 499 const byte *e = img+768*576; 500 byte *i = img; 501 while (i<e) 502 { 503 if (*i<=cut) 504 *i = 0; 505 i++; 506 } 536 507 537 508 // -
trunk/MagicSoft/Cosy/videodev/CaosFilter.h
r1810 r2278 19 19 byte *buffer, const int col); 20 20 21 static float Mean(const byte *buffer, const int offset, 22 int *min, int *max); 23 24 static float SDev(const byte *buffer, const int offset, 25 const double mean); 21 static void GetStat(const byte *buffer, const int offset, 22 double *mean, double *sdev); 26 23 27 24 static int GetMeanPosition(const byte *bitmap, -
trunk/MagicSoft/Cosy/videodev/Filter.cc
r2019 r2278 24 24 } 25 25 26 float Filter::Mean(const byte *buffer, const int offset , int *min, int *max)26 float Filter::Mean(const byte *buffer, const int offset) 27 27 { 28 28 double mean = 0.0; 29 29 30 *min = 0xff;31 *max = 0x00;30 byte *s = (byte*)buffer; 31 const byte *e0 = s+768*576; 32 32 33 33 // 34 34 // calculate mean value 35 35 // 36 for (int x=offset; x<768-offset; x++)37 for (int y=offset; y<576-offset; y++)38 {39 byte val = buffer[y*768+x];36 while (s<e0) 37 { 38 const byte *e = s+576-offset; 39 s += offset; 40 40 41 mean += val; 41 while (s<e) 42 mean += *s++; 42 43 43 if (val>*max)44 *max = val;44 s+=offset; 45 } 45 46 46 if (val<*min) 47 *min = val; 48 } 47 return mean / ((768-2*offset)*(576-2*offset)); 48 } 49 49 50 mean /= (768-2*offset)*(576-2*offset);51 52 return mean;53 }54 50 55 51 float Filter::SDev(const byte *buffer, const int offset, const double mean) … … 101 97 const int offset = 10; 102 98 103 int max; 104 int min; 105 106 const float mean = Mean(img, offset, &min, &max); 99 const float mean = Mean(img, offset); 107 100 const float sdev = SDev(img, offset, mean); 108 101 109 const float cut = mean + 2.5*sdev;102 const byte cut = mean+2.5*sdev>254 ? 254 : (byte)(mean + 2.5*sdev); 110 103 111 104 // 112 105 // clean image from noise 113 106 // 114 for (int x=0; x<768; x++) 115 for (int y=0; y<576; y++) 116 { 117 if (img[y*768+x]>cut) 118 continue; 119 120 // 121 // FIXME: Create LOOKUP Table! 122 // 123 124 img[y*768+x] = 0; 125 } 107 const byte *e = img+768*576; 108 byte *i = img; 109 while (i<e) 110 { 111 if (*i<=cut) 112 *i = 0; 113 i++; 114 } 126 115 127 116 // … … 203 192 } 204 193 205 void Filter::Stretch(byte *img)206 {207 const int offset = 25;208 209 int max;210 int min;211 212 /*const float mean =*/Mean(img, offset, &min, &max);213 214 const byte diff = max-min;215 216 for (int x=0; x<768; x++)217 for (int y=0; y<576; y++)218 {219 byte &b = img[y*768+x];220 221 if (b<min)222 {223 b=0;224 continue;225 }226 if (b>max)227 {228 b=max;229 continue;230 }231 b -= min;232 b *= 255/diff;233 }234 } -
trunk/MagicSoft/Cosy/videodev/Filter.h
r1959 r2278 17 17 byte *buffer, const int col); 18 18 19 static float Mean(const byte *buffer, const int offset, 20 int *min, int *max); 19 static float Mean(const byte *buffer, const int offset); 21 20 22 21 static float SDev(const byte *buffer, const int offset, … … 29 28 public: 30 29 static void Execute(byte *img); 31 static void Stretch(byte *img);32 30 33 31 ClassDef(Filter, 0) -
trunk/MagicSoft/Cosy/videodev/Makefile
r1802 r2278 34 34 PngReader.cc \ 35 35 PixClient.cc \ 36 Filter.cc \ 37 Filter2.cc \ 38 CaosFilter.cc \ 36 PixGetter.cc \ 37 FilterLed.cc \ 39 38 Writer.cc 40 39 -
trunk/MagicSoft/Cosy/videodev/PngReader.h
r1803 r2278 14 14 #endif 15 15 16 #include "PixGetter.h" 17 16 18 class PixClient; 17 19 18 20 typedef unsigned char byte; 19 21 20 class PngReader 22 class PngReader : public PixGetter 21 23 { 22 24 private: -
trunk/MagicSoft/Cosy/videodev/VideodevLinkDef.h
r1802 r2278 6 6 7 7 #pragma link C++ class Writer+; 8 #pragma link C++ class Filter+; 9 #pragma link C++ class Filter2+; 10 #pragma link C++ class CaosFilter+; 8 //#pragma link C++ class Filter+; 9 //#pragma link C++ class Filter2+; 10 #pragma link C++ class FilterLed+; 11 //#pragma link C++ class CaosFilter+; 11 12 12 13 #pragma link C++ class Camera+;
Note:
See TracChangeset
for help on using the changeset viewer.