libpappsomspp
Library for mass spectrometry
filtermorpho.h
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/filers/filtermorpho.h
3  * \date 02/05/2019
4  * \author Olivier Langella
5  * \brief collection of morphological filters
6  */
7 
8 /*******************************************************************************
9  * Copyright (c) 2019 Olivier Langella <Olivier.Langella@u-psud.fr>.
10  *
11  * This file is part of the PAPPSOms++ library.
12  *
13  * PAPPSOms++ is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * PAPPSOms++ is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
25  *
26  ******************************************************************************/
27 
28 #pragma once
29 
30 #include "filtersuite.h"
31 #include <cstddef>
32 
33 namespace pappso
34 {
35 
36 struct DataPoint;
37 
38 /** @brief base class that apply a signal treatment based on a window
39  */
41 {
42  protected:
43  std::size_t m_halfWindowSize = 0;
44 
45  virtual double
46  getWindowValue(std::vector<DataPoint>::const_iterator begin,
47  std::vector<DataPoint>::const_iterator end) const = 0;
48 
49  public:
50  FilterMorphoWindowBase(std::size_t half_window_size);
53 
55 
56  virtual Trace &filter(Trace &data_points) const override;
57 
58  virtual std::size_t getHalfWindowSize() const;
59 };
60 
61 /** @brief test purpose
62  */
64 {
65 
66  public:
67  FilterMorphoSum(std::size_t half_window_size);
68  FilterMorphoSum(const FilterMorphoSum &other);
69  virtual ~FilterMorphoSum(){};
70 
71  FilterMorphoSum &operator=(const FilterMorphoSum &other);
72 
73  double
74  getWindowValue(std::vector<DataPoint>::const_iterator begin,
75  std::vector<DataPoint>::const_iterator end) const override;
76 };
77 
78 /** @brief transform the trace into its maximum over a window
79  */
81 {
82 
83  public:
84  FilterMorphoMax(std::size_t half_window_size);
85  FilterMorphoMax(const FilterMorphoMax &other);
86  virtual ~FilterMorphoMax(){};
87 
88  FilterMorphoMax &operator=(const FilterMorphoMax &other);
89  double
90  getWindowValue(std::vector<DataPoint>::const_iterator begin,
91  std::vector<DataPoint>::const_iterator end) const override;
92 
93  std::size_t getMaxHalfEdgeWindows() const;
94 };
95 
96 /** @brief transform the trace into its minimum over a window
97  */
99 {
100 
101  public:
102  FilterMorphoMin(std::size_t half_window_size);
103  FilterMorphoMin(const FilterMorphoMin &other);
104  virtual ~FilterMorphoMin(){};
105 
106  FilterMorphoMin &operator=(const FilterMorphoMin &other);
107  double
108  getWindowValue(std::vector<DataPoint>::const_iterator begin,
109  std::vector<DataPoint>::const_iterator end) const override;
110 
111  std::size_t getMinHalfEdgeWindows() const;
112 };
113 
114 /** @brief transform the trace with the minimum of the maximum
115  * equivalent of the dilate filter for pictures
116  */
118 {
119  private:
122 
123  public:
124  FilterMorphoMinMax(std::size_t half_window_size);
126  virtual ~FilterMorphoMinMax(){};
127 
128  FilterMorphoMinMax &operator=(const FilterMorphoMinMax &other);
129  Trace &filter(Trace &data_points) const override;
130 
131  std::size_t getMinMaxHalfEdgeWindows() const;
132 };
133 
134 /** @brief transform the trace with the maximum of the minimum
135  * equivalent of the erode filter for pictures
136  */
138 {
139  private:
142 
143  public:
144  FilterMorphoMaxMin(std::size_t half_window_size);
146  virtual ~FilterMorphoMaxMin(){};
147 
148  FilterMorphoMaxMin &operator=(const FilterMorphoMaxMin &other);
149  Trace &filter(Trace &data_points) const override;
150 
151  std::size_t getMaxMinHalfEdgeWindows() const;
152 };
153 
154 /** @brief anti spike filter
155  * set to zero alone values inside the window
156  */
158 {
159  private:
160  std::size_t m_halfWindowSize = 0;
161 
162  public:
163  FilterMorphoAntiSpike(std::size_t half_window_size);
166 
167  FilterMorphoAntiSpike &operator=(const FilterMorphoAntiSpike &other);
168  Trace &filter(Trace &data_points) const override;
169 
170  std::size_t getHalfWindowSize() const;
171 };
172 
173 
174 /** @brief median filter
175  * apply median of y values inside the window
176  */
178 {
179 
180  public:
181  FilterMorphoMedian(std::size_t half_window_size);
183  virtual ~FilterMorphoMedian(){};
184 
185  FilterMorphoMedian &operator=(const FilterMorphoMedian &other);
186  double
187  getWindowValue(std::vector<DataPoint>::const_iterator begin,
188  std::vector<DataPoint>::const_iterator end) const override;
189 };
190 
191 
192 /** @brief mean filter
193  * apply mean of y values inside the window : this results in a kind of
194  * smoothing
195  */
197 {
198 
199  public:
200  FilterMorphoMean(std::size_t half_window_size);
201  FilterMorphoMean(const FilterMorphoMean &other);
202  virtual ~FilterMorphoMean(){};
203 
204  FilterMorphoMean &operator=(const FilterMorphoMean &other);
205  double
206  getWindowValue(std::vector<DataPoint>::const_iterator begin,
207  std::vector<DataPoint>::const_iterator end) const override;
208 
209  std::size_t getMeanHalfEdgeWindows() const;
210 };
211 
212 /** @brief compute background of a trace
213  * compute background noise on a trace
214  */
216 {
217  private:
220 
221  public:
222  FilterMorphoBackground(std::size_t median_half_window_size,
223  std::size_t minmax_half_window_size);
226 
227  FilterMorphoBackground &operator=(const FilterMorphoBackground &other);
228  const FilterMorphoMedian &getFilterMorphoMedian() const;
229  const FilterMorphoMinMax &getFilterMorphoMinMax() const;
230 
231  Trace &filter(Trace &data_points) const override;
232 };
233 } // namespace pappso
pappso::FilterMorphoMax::~FilterMorphoMax
virtual ~FilterMorphoMax()
Definition: filtermorpho.h:86
pappso::FilterMorphoMinMax::m_filterMax
FilterMorphoMax m_filterMax
Definition: filtermorpho.h:120
pappso::FilterMorphoWindowBase::FilterMorphoWindowBase
FilterMorphoWindowBase(std::size_t half_window_size)
Definition: filtermorpho.cpp:35
pappso::FilterMorphoWindowBase::getWindowValue
virtual double getWindowValue(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end) const =0
pappso::FilterMorphoMedian
median filter apply median of y values inside the window
Definition: filtermorpho.h:178
pappso::FilterMorphoMinMax::~FilterMorphoMinMax
virtual ~FilterMorphoMinMax()
Definition: filtermorpho.h:126
pappso::FilterMorphoWindowBase
base class that apply a signal treatment based on a window
Definition: filtermorpho.h:41
pappso::FilterMorphoBackground::m_filterMorphoMedian
FilterMorphoMedian m_filterMorphoMedian
Definition: filtermorpho.h:218
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition: exportinmportconfig.h:14
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
pappso::FilterMorphoWindowBase::~FilterMorphoWindowBase
virtual ~FilterMorphoWindowBase()
Definition: filtermorpho.h:52
pappso::FilterMorphoAntiSpike::~FilterMorphoAntiSpike
virtual ~FilterMorphoAntiSpike()
Definition: filtermorpho.h:165
pappso::FilterMorphoWindowBase::filter
virtual Trace & filter(Trace &data_points) const override
Definition: filtermorpho.cpp:60
filtersuite.h
pappso::FilterMorphoMedian::~FilterMorphoMedian
virtual ~FilterMorphoMedian()
Definition: filtermorpho.h:183
pappso::FilterMorphoMin
transform the trace into its minimum over a window
Definition: filtermorpho.h:99
pappso::FilterMorphoMax
transform the trace into its maximum over a window
Definition: filtermorpho.h:81
pappso::FilterInterface
generic interface to apply a filter on a trace
Definition: filterinterface.h:40
pappso::FilterMorphoSum::~FilterMorphoSum
virtual ~FilterMorphoSum()
Definition: filtermorpho.h:69
pappso::FilterMorphoMaxMin::m_filterMax
FilterMorphoMax m_filterMax
Definition: filtermorpho.h:141
pappso::FilterMorphoMaxMin::~FilterMorphoMaxMin
virtual ~FilterMorphoMaxMin()
Definition: filtermorpho.h:146
pappso::Trace
A simple container of DataPoint instances.
Definition: trace.h:132
pappso::FilterMorphoWindowBase::getHalfWindowSize
virtual std::size_t getHalfWindowSize() const
Definition: filtermorpho.cpp:45
pappso::FilterMorphoBackground::m_filterMorphoMinMax
FilterMorphoMinMax m_filterMorphoMinMax
Definition: filtermorpho.h:219
pappso::FilterMorphoBackground::~FilterMorphoBackground
virtual ~FilterMorphoBackground()
Definition: filtermorpho.h:225
pappso::FilterMorphoWindowBase::m_halfWindowSize
std::size_t m_halfWindowSize
Definition: filtermorpho.h:43
pappso::FilterMorphoMaxMin::m_filterMin
FilterMorphoMin m_filterMin
Definition: filtermorpho.h:140
pappso::FilterMorphoMean
mean filter apply mean of y values inside the window : this results in a kind of smoothing
Definition: filtermorpho.h:197
pappso::FilterMorphoMinMax
transform the trace with the minimum of the maximum equivalent of the dilate filter for pictures
Definition: filtermorpho.h:118
pappso::FilterMorphoMean::~FilterMorphoMean
virtual ~FilterMorphoMean()
Definition: filtermorpho.h:202
pappso::FilterMorphoSum
test purpose
Definition: filtermorpho.h:64
pappso::FilterMorphoWindowBase::operator=
FilterMorphoWindowBase & operator=(const FilterMorphoWindowBase &other)
Definition: filtermorpho.cpp:51
pappso::FilterMorphoMin::~FilterMorphoMin
virtual ~FilterMorphoMin()
Definition: filtermorpho.h:104
pappso::FilterMorphoMaxMin
transform the trace with the maximum of the minimum equivalent of the erode filter for pictures
Definition: filtermorpho.h:138
pappso::FilterMorphoBackground
compute background of a trace compute background noise on a trace
Definition: filtermorpho.h:216
pappso::FilterMorphoAntiSpike
anti spike filter set to zero alone values inside the window
Definition: filtermorpho.h:158
pappso::FilterMorphoMinMax::m_filterMin
FilterMorphoMin m_filterMin
Definition: filtermorpho.h:121