Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #pragma once
00024
00025 #include "cinder/Cinder.h"
00026 #include "cinder/Surface.h"
00027
00028 namespace cinder { namespace ip {
00029
00031 template<typename T>
00032 void threshold( SurfaceT<T> *surface, T value, const Area &area );
00034 template<typename T>
00035 void threshold( SurfaceT<T> *surface, T value );
00037 template<typename T>
00038 void threshold( const SurfaceT<T> &srcSurface, T value, SurfaceT<T> *dstSurface );
00040 template<typename T>
00041 void threshold( const ChannelT<T> &srcSurface, T value, ChannelT<T> *dstSurface );
00043
00044 template<typename T>
00045 void adaptiveThreshold( const ChannelT<T> &srcChannel, int32_t windowSize, float percentageDelta, ChannelT<T> *dstChannel );
00047
00048 template<typename T>
00049 void adaptiveThreshold( ChannelT<T> *channel, int32_t windowSize, float percentageDelta );
00051
00052 template<typename T>
00053 void adaptiveThresholdZero( ChannelT<T> *channel, int32_t windowSize );
00054
00055 template<typename T>
00056 void adaptiveThresholdZero( const ChannelT<T> &srcChannel, int32_t windowSize, ChannelT<T> *dstChannel );
00057
00058 template<typename T>
00059 class AdaptiveThresholdT {
00060 private:
00061 typedef typename CHANTRAIT<T>::Accum SUMT;
00062 struct Obj {
00063 Obj( ChannelT<T> *channel );
00064 ~Obj();
00065
00066 ChannelT<T> * mChannel;
00067 int32_t mImageWidth;
00068 int32_t mImageHeight;
00069 int8_t mIncrement;
00070 SUMT * mIntegralImage;
00071 };
00072 public:
00073 AdaptiveThresholdT() {};
00074 AdaptiveThresholdT( ChannelT<T> *channel );
00075 void calculate( int32_t windowSize, float percentageDelta, ChannelT<T> *dstChannel );
00076
00078
00079 typedef std::shared_ptr<Obj> AdaptiveThresholdT::*unspecified_bool_type;
00080 operator unspecified_bool_type() const { return ( mObj.get() == 0 ) ? 0 : &AdaptiveThresholdT::mObj; }
00081 void reset() { mObj.reset(); }
00083 private:
00084 std::shared_ptr<Obj> mObj;
00085 };
00086
00087 typedef AdaptiveThresholdT<uint8_t> AdaptiveThreshold;
00088 typedef AdaptiveThresholdT<uint8_t> AdaptiveThreshold8u;
00089 typedef AdaptiveThresholdT<float> AdaptiveThreshold32f;
00090
00091 } }