SpectralPeakDescriptors.hxx
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 #ifndef __SpectralPeakDescriptors_H__
00023 #define __SpectralPeakDescriptors_H__
00024 #include <typeinfo>
00025 #include "Descriptor.hxx"
00026
00027
00028
00029
00030
00031
00032
00033 namespace CLAM {
00034
00035
00036 class SpectralPeakArray;
00037
00038
00039 class SpectralPeakDescriptors : public Descriptor {
00040 public:
00041 DYNAMIC_TYPE_USING_INTERFACE (SpectralPeakDescriptors, 10, Descriptor);
00047 DYN_ATTRIBUTE (0, public, TData, MagnitudeMean);
00059 DYN_ATTRIBUTE (1, public, TData, HarmonicCentroid);
00078 DYN_ATTRIBUTE (2, public, TData, HarmonicDeviation);
00084 DYN_ATTRIBUTE (3, public, TData, FirstTristimulus);
00089 DYN_ATTRIBUTE (4, public, TData, SecondTristimulus);
00094 DYN_ATTRIBUTE (5, public, TData, ThirdTristimulus);
00101 DYN_ATTRIBUTE (6, public, TData, OddHarmonics);
00110 DYN_ATTRIBUTE (7, public, TData, EvenHarmonics);
00124 DYN_ATTRIBUTE (8, public, TData, OddToEvenRatio);
00125 DYN_ATTRIBUTE (9,public, Array<TData>, HPCP);
00126
00127 public:
00128 SpectralPeakDescriptors(SpectralPeakArray* pSpectralPeakArray);
00129 SpectralPeakDescriptors(TData initVal);
00130
00131 const SpectralPeakArray* GetpSpectralPeakArray() const;
00132 void SetpSpectralPeakArray(SpectralPeakArray* pSpectralPeakArray);
00133 void ConcreteCompute();
00134
00135 private:
00136 void DefaultInit();
00137 void CopyInit(const SpectralPeakDescriptors & copied);
00138
00139 TData ComputeCentroid();
00140 TData ComputeFirstTristimulus();
00141 TData ComputeSecondTristimulus();
00142 TData ComputeThirdTristimulus();
00143 TData ComputeHarmonicDeviation();
00144 TData ComputeOddHarmonics();
00145 TData ComputeEvenHarmonics();
00146 TData ComputeOddToEvenRatio();
00147
00148 private:
00149 const SpectralPeakArray* mpSpectralPeakArray;
00150 CrossCenterOfGravity<1> mCentroid;
00151
00152 };
00153
00154
00155 SpectralPeakDescriptors operator / (const SpectralPeakDescriptors& a,TData div) ;
00156 SpectralPeakDescriptors operator * (const SpectralPeakDescriptors& a,TData mult) ;
00157 SpectralPeakDescriptors operator * (const SpectralPeakDescriptors& a,const SpectralPeakDescriptors& b) ;
00158 SpectralPeakDescriptors operator + (const SpectralPeakDescriptors& a,const SpectralPeakDescriptors& b) ;
00159
00160 template<>
00161 inline SpectralPeakDescriptors CLAM_max (const SpectralPeakDescriptors& a,const SpectralPeakDescriptors& b)
00162 {
00163 SpectralPeakDescriptors tmpD(a);
00164
00165 if (a.HasMagnitudeMean() && b.HasMagnitudeMean())
00166 {
00167 if(b.GetMagnitudeMean()>a.GetMagnitudeMean())
00168 tmpD.SetMagnitudeMean(b.GetMagnitudeMean());
00169 }
00170 if (a.HasHarmonicCentroid() && b.HasHarmonicCentroid())
00171 {
00172 if(b.GetHarmonicCentroid()>a.GetHarmonicCentroid())
00173 tmpD.SetHarmonicCentroid(b.GetHarmonicCentroid());
00174 }
00175 if (a.HasFirstTristimulus() && b.HasFirstTristimulus())
00176 {
00177 if(b.GetFirstTristimulus()>a.GetFirstTristimulus())
00178 tmpD.SetFirstTristimulus(b.GetFirstTristimulus());
00179 }
00180 if (a.HasSecondTristimulus() && b.HasSecondTristimulus())
00181 {
00182 if(b.GetSecondTristimulus()>a.GetSecondTristimulus())
00183 tmpD.SetSecondTristimulus(b.GetSecondTristimulus());
00184 }
00185 if (a.HasThirdTristimulus() && b.HasThirdTristimulus())
00186 {
00187 if(b.GetThirdTristimulus()>a.GetThirdTristimulus())
00188 tmpD.SetThirdTristimulus(b.GetThirdTristimulus());
00189 }
00190 if (a.HasHarmonicDeviation() && b.HasHarmonicDeviation())
00191 {
00192 if(b.GetHarmonicDeviation()>a.GetHarmonicDeviation())
00193 tmpD.SetHarmonicDeviation(b.GetHarmonicDeviation());
00194 }
00195 if (a.HasOddHarmonics() && b.HasOddHarmonics())
00196 {
00197 if(b.GetOddHarmonics()>a.GetOddHarmonics())
00198 tmpD.SetOddHarmonics(b.GetOddHarmonics());
00199 }
00200 if (a.HasEvenHarmonics() && b.HasEvenHarmonics())
00201 {
00202 if(b.GetEvenHarmonics()>a.GetEvenHarmonics())
00203 tmpD.SetEvenHarmonics(b.GetEvenHarmonics());
00204 }
00205 if (a.HasOddToEvenRatio() && b.HasOddToEvenRatio())
00206 {
00207 if(b.GetOddToEvenRatio()>a.GetOddToEvenRatio())
00208 tmpD.SetOddToEvenRatio(b.GetOddToEvenRatio());
00209 }
00210
00211 return tmpD;
00212 }
00213
00214 template<>
00215 inline SpectralPeakDescriptors CLAM_min (const SpectralPeakDescriptors& a,const SpectralPeakDescriptors& b)
00216 {
00217 SpectralPeakDescriptors tmpD(a);
00218
00219 if (a.HasMagnitudeMean() && b.HasMagnitudeMean())
00220 {
00221 if(b.GetMagnitudeMean()<a.GetMagnitudeMean())
00222 tmpD.SetMagnitudeMean(b.GetMagnitudeMean());
00223 }
00224 if (a.HasHarmonicCentroid() && b.HasHarmonicCentroid())
00225 {
00226 if(b.GetHarmonicCentroid()<a.GetHarmonicCentroid())
00227 tmpD.SetHarmonicCentroid(b.GetHarmonicCentroid());
00228 }
00229 if (a.HasFirstTristimulus() && b.HasFirstTristimulus())
00230 {
00231 if(b.GetFirstTristimulus()<a.GetFirstTristimulus())
00232 tmpD.SetFirstTristimulus(b.GetFirstTristimulus());
00233 }
00234 if (a.HasSecondTristimulus() && b.HasSecondTristimulus())
00235 {
00236 if(b.GetSecondTristimulus()<a.GetSecondTristimulus())
00237 tmpD.SetSecondTristimulus(b.GetSecondTristimulus());
00238 }
00239 if (a.HasThirdTristimulus() && b.HasThirdTristimulus())
00240 {
00241 if(b.GetThirdTristimulus()<a.GetThirdTristimulus())
00242 tmpD.SetThirdTristimulus(b.GetThirdTristimulus());
00243 }
00244 if (a.HasHarmonicDeviation() && b.HasHarmonicDeviation())
00245 {
00246 if(b.GetHarmonicDeviation()<a.GetHarmonicDeviation())
00247 tmpD.SetHarmonicDeviation(b.GetHarmonicDeviation());
00248 }
00249 if (a.HasOddHarmonics() && b.HasOddHarmonics())
00250 {
00251 if(b.GetOddHarmonics()<a.GetOddHarmonics())
00252 tmpD.SetOddHarmonics(b.GetOddHarmonics());
00253 }
00254 if (a.HasEvenHarmonics() && b.HasEvenHarmonics())
00255 {
00256 if(b.GetEvenHarmonics()<a.GetEvenHarmonics())
00257 tmpD.SetEvenHarmonics(b.GetEvenHarmonics());
00258 }
00259 if (a.HasOddToEvenRatio() && b.HasOddToEvenRatio())
00260 {
00261 if(b.GetOddToEvenRatio()<a.GetOddToEvenRatio())
00262 tmpD.SetOddToEvenRatio(b.GetOddToEvenRatio());
00263 }
00264
00265 return tmpD;
00266 }
00267
00268
00269
00270 }
00271
00272
00273 #endif
00274