eLynx SDK
v3.0.1 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 00091 // Apply 1 ramp 00092 template<typename T> 00093 bool elxApplyRamp(const Ramp<T>& iRamp, 00094 T * iprSrc, size_t iSize, uint32 iChannelCount, uint32 iChannelMask); 00095 00096 // Apply 1 ramp in parallel 00097 template<typename T> 00098 bool elxApplyRampFast(const Ramp<T>& iRamp, 00099 T * iprSrc, size_t iSize, uint32 iChannelCount, uint32 iChannelMask); 00100 00101 // Apply 2 ramps 00102 template<typename T> 00103 bool elxApplyRamp(const Ramp<T>& iRamp0, const Ramp<T>& iRamp1, 00104 T * iprSrc, size_t iSize, uint32 iChannelMask); 00105 // Apply 2 ramps in parallel 00106 template<typename T> 00107 bool elxApplyRampFast(const Ramp<T>& iRamp0, const Ramp<T>& iRamp1, 00108 T * iprSrc, size_t iSize, uint32 iChannelMask); 00109 00110 // Apply 3 ramps 00111 template<typename T> 00112 bool elxApplyRamp(const Ramp<T>& iRamp0, const Ramp<T>& iRamp1, const Ramp<T>& iRamp2, 00113 T * iprSrc, size_t iSize, uint32 iChannelMask); 00114 // Apply 3 ramps in parallel 00115 template<typename T> 00116 bool elxApplyRampFast(const Ramp<T>& iRamp0, const Ramp<T>& iRamp1, const Ramp<T>& iRamp2, 00117 T * iprSrc, size_t iSize, uint32 iChannelMask); 00118 /* 00119 // Apply 4 ramps 00120 template<typename T> 00121 bool elxApplyRamp(const Ramp<T>& iRamp0, const Ramp<T>& iRamp1, const Ramp<T>& iRamp2, const Ramp<T>& iRamp3, 00122 T * iprSrc, size_t iSize, uint32 iChannelMask); 00123 // Apply 4 ramps in parallel 00124 template<typename T> 00125 bool elxApplyRampFast(const Ramp<T>& iRamp0, const Ramp<T>& iRamp1, const Ramp<T>& iRamp2, const Ramp<T>& iRamp3, 00126 T * iprSrc, size_t iSize, uint32 iChannelMask); 00127 */ 00128 } // namespace Image 00129 } // namespace eLynx 00130 00131 #include "inl/Ramp.inl" 00132 00133 #endif // __Ramp_h__