eLynx SDK
v3.3.0 C++ image processing API reference |
00001 //============================================================================ 00002 // Ramp.h Math.Component package 00003 //============================================================================ 00004 // Usage : Tool for look-up table transformations 00005 //---------------------------------------------------------------------------- 00006 // Copyright (C) 2006 by eLynx project 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 // See the GNU Library General Public License for more details. 00017 //---------------------------------------------------------------------------- 00018 #ifndef __ramp_h__ 00019 #define __ramp_h__ 00020 00021 #include <elx/core/CoreTypes.h> 00022 #include <elx/math/MathCore.h> 00023 00024 namespace eLynx { 00025 namespace Math { 00026 00029 template<typename T> 00030 class Ramp 00031 { 00032 public: 00033 Ramp(); 00035 00036 void Reset(); 00037 00038 void Set(T iScalar); 00039 void SetNorm(double iScalar); 00040 00041 void Complement(); 00042 void Add(T iScalar, EValueAction iAction=R_Clamp); 00043 void Sub(T iScalar, EValueAction iAction=R_Clamp); 00044 void Mul(T iScalar, EValueAction iAction=R_Clamp); 00045 void Div(T iScalar, EValueAction iAction=R_Clamp); 00046 void Mul(double iScalar, EValueAction iAction=R_Clamp); 00047 void Div(double iScalar, EValueAction iAction=R_Clamp); 00048 // normalized signed value : iScalar in range [-1, 1] 00049 00050 void AddNorm(double iScalar, EValueAction iAction=R_Clamp); 00051 void SubNorm(double iScalar, EValueAction iAction=R_Clamp); 00052 00053 void Dif(T iScalar); 00054 void Min(T iValue); 00055 void Max(T iValue); 00056 void DifNorm(double iScalar); 00057 void MinNorm(double iValue); 00058 void MaxNorm(double iValue); 00059 00060 void Contrast(double iScalar); 00061 void Posterize(T iLevels); 00062 void Solarize(T iThreshold); 00063 void SolarizeNorm(double iThreshold); 00064 00065 bool Stretch(T iMin, T iMax); 00066 bool StretchNorm(double iMin=0.0, double iMax=1.0); 00067 00068 void Gamma(double iGamma, double iMin=0.0, double iMax=1.0); 00069 void Midtone(double iMidtone, double iMin=0.0, double iMax=1.0); 00070 void Sigmoid(double iAlpha, double iBeta); 00071 void DDP(double iK, double iA, double iB); 00072 00073 T Pick(T iIndex) const; 00074 const T * GetRamp(T iIndx = 0) const; 00075 bool Transform(T * ioprDst, size_t iSize) const; 00076 bool Transform(T * iprDst, const T * iprSrc, size_t iSize) const; 00077 00078 private: 00079 // note that this pointer can't be NULL, no need to check it ! 00080 T * GetFirst(); 00081 T * GetLast(); 00082 size_t GetSize() const; 00083 T _ramp[1 << ResolutionTypeTraits<T>::_bits]; 00084 00085 // useless default methods intentionally not accessible (and not generated) 00086 Ramp(const Ramp&); 00087 const Ramp& operator=(const Ramp&); 00088 }; 00089 00090 00092 template<typename T> 00093 bool elxApplyRamp(const Ramp<T>& iRamp, 00094 T * iprSrc, size_t iSize, uint32 iChannelCount, uint32 iChannelMask); 00095 00097 template<typename T> 00098 bool elxApplyRamp(const Ramp<T>& iRamp0, const Ramp<T>& iRamp1, 00099 T * iprSrc, size_t iSize, uint32 iChannelMask); 00100 00102 template<typename T> 00103 bool elxApplyRamp(const Ramp<T>& iRamp0, const Ramp<T>& iRamp1, const Ramp<T>& iRamp2, 00104 T * iprSrc, size_t iSize, uint32 iChannelMask); 00105 00106 /* 00108 template<typename T> 00109 bool elxApplyRamp(const Ramp<T>& iRamp0, const Ramp<T>& iRamp1, const Ramp<T>& iRamp2, const Ramp<T>& iRamp3, 00110 T * iprSrc, size_t iSize, uint32 iChannelMask); 00111 */ 00112 00114 template<typename T> 00115 bool elxApplyRampFast(const Ramp<T>& iRamp, 00116 T * iprSrc, size_t iSize, uint32 iChannelCount, uint32 iChannelMask); 00117 00119 template<typename T> 00120 bool elxApplyRampFast(const Ramp<T>& iRamp0, const Ramp<T>& iRamp1, 00121 T * iprSrc, size_t iSize, uint32 iChannelMask); 00122 00124 template<typename T> 00125 bool elxApplyRampFast(const Ramp<T>& iRamp0, const Ramp<T>& iRamp1, const Ramp<T>& iRamp2, 00126 T * iprSrc, size_t iSize, uint32 iChannelMask); 00127 00128 /* 00130 template<typename T> 00131 bool elxApplyRampFast(const Ramp<T>& iRamp0, const Ramp<T>& iRamp1, const Ramp<T>& iRamp2, const Ramp<T>& iRamp3, 00132 T * iprSrc, size_t iSize, uint32 iChannelMask); 00133 */ 00134 } // namespace Image 00135 } // namespace eLynx 00136 00137 #include "inl/Ramp.inl" 00138 00139 #endif // __ramp_h__