00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "3BandGate.hxx"
00023 #include "ProcessingFactory.hxx"
00024
00025 namespace CLAM
00026 {
00027
00028 namespace Hidden
00029 {
00030 static FactoryRegistrator<ProcessingFactory, ThreeBandGate> regThreeBandGate("ThreeBandGate");
00031 }
00032
00033
00034 bool ThreeBandGate::Do(const Spectrum& in, Spectrum& out)
00035 {
00036 out = in;
00037
00038 DataArray& oMag = out.GetMagBuffer();
00039 DataArray& iMag = in.GetMagBuffer();
00040
00041 int spectrumSize = in.GetSize();
00042
00043 TData spectralResolution = spectrumSize/in.GetSpectralRange();
00044
00045 int lowCutoff = Round(mLowCutoffFreqCtl.GetLastValue()* spectralResolution);
00046 int highCutoff = Round(mHighCutoffFreqCtl.GetLastValue()* spectralResolution);
00047
00048
00049 TData lowThreshold = log2lin(mLowThresholdCtl.GetLastValue());
00050 TData midThreshold = log2lin(mMidThresholdCtl.GetLastValue());
00051 TData highThreshold = log2lin(mHighThresholdCtl.GetLastValue());
00052
00053 int i;
00054 TData currentThreshold = lowThreshold;
00055 for( i = 0; i<lowCutoff; i++)
00056 {
00057 if(iMag[i]<lowThreshold)
00058 oMag[i] = 0;
00059 }
00060 for( i = lowCutoff; i<highCutoff; i++)
00061 {
00062 if(iMag[i]<midThreshold)
00063 oMag[i] = 0;
00064 }
00065 for( i = highCutoff; i<spectrumSize; i++)
00066 {
00067 if(iMag[i]<highThreshold)
00068 oMag[i] = 0;
00069 }
00070 return true;
00071 }
00072
00073
00074
00075 }
00076