Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Threshold.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010, The Barbarian Group
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
6  the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and
9  the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
11  the following disclaimer in the documentation and/or other materials provided with the distribution.
12 
13  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
14  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
15  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
16  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
17  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
19  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20  POSSIBILITY OF SUCH DAMAGE.
21 */
22 
23 #pragma once
24 
25 #include "cinder/Cinder.h"
26 #include "cinder/Surface.h"
27 
28 namespace cinder { namespace ip {
29 
31 template<typename T>
32 void threshold( SurfaceT<T> *surface, T value, const Area &area );
34 template<typename T>
35 void threshold( SurfaceT<T> *surface, T value );
37 template<typename T>
38 void threshold( const SurfaceT<T> &srcSurface, T value, SurfaceT<T> *dstSurface );
40 template<typename T>
41 void threshold( const ChannelT<T> &srcSurface, T value, ChannelT<T> *dstSurface );
43 
44 template<typename T>
45 void adaptiveThreshold( const ChannelT<T> &srcChannel, int32_t windowSize, float percentageDelta, ChannelT<T> *dstChannel );
47 
48 template<typename T>
49 void adaptiveThreshold( ChannelT<T> *channel, int32_t windowSize, float percentageDelta );
51 
52 template<typename T>
53 void adaptiveThresholdZero( ChannelT<T> *channel, int32_t windowSize );
54 
55 template<typename T>
56 void adaptiveThresholdZero( const ChannelT<T> &srcChannel, int32_t windowSize, ChannelT<T> *dstChannel );
57 
58 template<typename T>
60  private:
61  typedef typename CHANTRAIT<T>::Accum SUMT;
62  struct Obj {
63  Obj( ChannelT<T> *channel );
64  ~Obj();
65 
66  ChannelT<T> * mChannel;
67  int32_t mImageWidth;
68  int32_t mImageHeight;
69  int8_t mIncrement;
70  SUMT * mIntegralImage;
71  };
72  public:
75  void calculate( int32_t windowSize, float percentageDelta, ChannelT<T> *dstChannel );
76 
78  typedef std::shared_ptr<Obj> AdaptiveThresholdT::*unspecified_bool_type;
80  operator unspecified_bool_type() const { return ( mObj.get() == 0 ) ? 0 : &AdaptiveThresholdT::mObj; }
81  void reset() { mObj.reset(); }
83  private:
84  std::shared_ptr<Obj> mObj;
85 };
86 
90 
91 } } // namespace cinder::ip
void calculate(int32_t windowSize, float percentageDelta, ChannelT< T > *dstChannel)
Definition: Threshold.cpp:351
AdaptiveThresholdT< uint8_t > AdaptiveThreshold8u
Definition: Threshold.h:88
AdaptiveThresholdT< uint8_t > AdaptiveThreshold
Definition: Threshold.h:87
std::shared_ptr< Obj > AdaptiveThresholdT::* unspecified_bool_type
Emulates shared_ptr-like behavior.
Definition: Threshold.h:79
AdaptiveThresholdT()
Definition: Threshold.h:73
Definition: ChanTraits.h:30
A single channel of image data, either a color channel of a Surface or a grayscale image...
Definition: Channel.h:37
AdaptiveThresholdT< float > AdaptiveThreshold32f
Definition: Threshold.h:89
void adaptiveThreshold(const ChannelT< T > &srcChannel, int32_t windowSize, float percentageDelta, ChannelT< T > *dstChannel)
Thresholds srcChannel using an adaptive thresholding algorithm which considers a window of size windo...
Definition: Threshold.cpp:257
GLsizei const GLfloat * value
Definition: GLee.h:2487
void reset()
Emulates shared_ptr-like behavior.
Definition: Threshold.h:81
int int channel
Definition: GLee.h:17150
Definition: Threshold.h:59
void adaptiveThresholdZero(ChannelT< T > *channel, int32_t windowSize)
Thresholds srcChannel using an adaptive thresholding algorithm which considers a window of size windo...
Definition: Threshold.cpp:293
void threshold(SurfaceT< T > *surface, T value, const Area &area)
Thresholds surface setting any values below value to zero and any values above to unity inside the Ar...
Definition: Threshold.cpp:100