Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
denoise.h
Go to the documentation of this file.
1 
21 #include <vigra/stdimage.hxx>
22 #include <vigra/pixelneighborhood.hxx>
23 
24 template <class SrcIterator, class SrcAccessor,
25  class DestIterator, class DestAccessor>
26 void simpleDenoise(SrcIterator sy, SrcIterator send, SrcAccessor sa,
27  DestIterator dy, DestAccessor da) {
28  int width = send.x - sy.x;
29  int height = send.y - sy.y;
30 
31  sy.y++, dy.y++;
32 
33  for (int y=1; y<height-1; ++y, ++dy.y, ++sy.y) {
34  SrcIterator sx = sy;
35  DestIterator dx = dy;
36  sx.x++, dx.x++;
37 
38  for (int x=1; x<width-1; ++x, ++dx.x, ++sx.x) {
39  vigra::NeighborhoodCirculator<SrcIterator, vigra::EightNeighborCode>
40  circulator(sx),
41  end(circulator);
42  int whitePixels = 0;
43  int blackPixels = 0;
44  do
45  {
46  if (*circulator > 127)
47  whitePixels++;
48  else
49  blackPixels++;
50  }
51  while(++circulator != end);
52 
53  if (whitePixels > 6) {
54  *dx = 255;
55  } else if (blackPixels > 6) {
56  *dx = 0;
57  } else {
58  *dx = *sx;
59  }
60  }
61  }
62 }
63 
64 template <class SrcIterator, class SrcAccessor,
65  class DestIterator, class DestAccessor>
66 void simpleDenoise(vigra::triple<SrcIterator, SrcIterator, SrcAccessor> src,
67  std::pair<DestIterator, DestAccessor> dest) {
68  simpleDenoise(src.first, src.second, src.third, dest.first, dest.second);
69 }
void simpleDenoise(SrcIterator sy, SrcIterator send, SrcAccessor sa, DestIterator dy, DestAccessor da)
Simple denoising algorithm Copyright (C) 2009 Lukáš Jirkovský l.jirkovsky@gmail.com
Definition: denoise.h:26