vismap.h

来自「microsoft vision source code」· C头文件 代码 · 共 89 行

H
89
字号
///////////////////////////////////////////////////////////////////////////
//
// NAME
//  VisMap.h -- image mapping functions, based on function objects (~STL)
//
// SPECIFICATION
//  template <class OPERATOR, class PIXELTYPE1, ..., class PIXELTYPEn>
//  void VisMapn(OPERATOR& fn,
//               CVisImage<PIXELTYPE1> img1, ... ,
//               CVisImage<PIXELTYPEn> imgn);
//
//  or
//
//  template <class OPERATOR, class PIXELTYPE1, ..., class PIXELTYPEn>
//  void VisMapn(const RECT& refrect, OPERATOR& fn,
//               CVisImage<PIXELTYPE1> img1, ... ,
//               CVisImage<PIXELTYPEn> imgn);
//
//
// PARAMETERS
//  refrect				optional RECT giving coordinates of pixels used
//  fn                  instance of OPERATOR class which defines operator()
//  img0..imgn          input/output images
//
//
// DESCRIPTION
//  These routines are used to iterate over a collection of images,
//  applying the same function to all pixels.  Because the function is
//  passed in as a function object, the optimized (Release) version of
//  the code should be very efficient.
//
//  The OPERATOR class should look something like:
//      struct SampleFn1 {
//          inline void operator()(byte& out, float& in)
//              { out = __max(0, __min(255, int(in))); }
//      };
//
//  This function could then be called using
//      VisMap2(SampleFn1(), byte_img, float_img);
//
//  Note that it is also possible to pass non-image (scalar) parameters
//  to the inner function by making them member variables
//      struct SampleFn2 {
//          const float scale;
//          inline SampleFn2(float s) : scale(s) {};
//          inline void operator()(byte& out, float& in)
//              { out = __max(0, __min(255, int(in * scale))); }
//      };
//      VisMap2(SampleFn2(0.5f), byte_img, float_img);
//
//  This same style can be used to create functions with side-effects,
//  e.g., functions which (almost) return a value:
//      struct SumFn1 {
//          double sum;
//          inline SumFn1() : sum(0.0) {};
//          inline void operator()(float in)
//              { sum += in; }
//      };
//      SumFn1 op1;
//      VisMap2(op1, float_img);
//      double result = op1.sum;
//  
//  A RECT specifying the coordinates whose pixels should be passed to
//  the function operator can be passed as an optional first argument to
//  the VisMap functions.  If a RECT is not specified, the intersection
//  of the (active) image RECTs is used.
//
//
// SEE ALSO
//  VisImage.h        definition of image class library
//
//
// BUGS
//  
//
// DESIGN
//  LATER:
//  This is just a first pass at the desired functionality.  In
//  particular, we don't currently handle the non-safe regions,
//  or have support for window (neighborhood) operations.
//
//  LATER:
//  The current design uses indices when enumerating the pixels in an
//  image row.  This is efficient for byte and 4-byte RGBA pixel values,
//  but it may be better to use pointers that are incremented as we go
//  through rows containing non-standard pixel values.
//
//
// Copyright 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?