Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
mitkBasicCombinationOpenCVImageFilter.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 
15 #include <algorithm>
16 
17 namespace mitk {
18 
20 {
21  int imageId = this->GetCurrentImageId();
22 
23  // go through the list of all filters
24  for ( auto it
25  = m_FilterList.begin(); it != m_FilterList.end(); ++it )
26  {
27  // apply current filter and return false if the filter returned false
28  if (! (*it)->FilterImage(image, imageId) ) { return false; }
29  }
30 
31  return true;
32 }
33 
34 void BasicCombinationOpenCVImageFilter::PushFilter( AbstractOpenCVImageFilter::Pointer filter )
35 {
36  m_FilterList.push_back(filter);
37 }
38 
39 AbstractOpenCVImageFilter::Pointer BasicCombinationOpenCVImageFilter::PopFilter( )
40 {
41  AbstractOpenCVImageFilter::Pointer lastFilter = m_FilterList.at(m_FilterList.size()-1);
42  m_FilterList.pop_back();
43  return lastFilter;
44 }
45 
46 bool BasicCombinationOpenCVImageFilter::RemoveFilter( AbstractOpenCVImageFilter::Pointer filter )
47 {
48  for ( auto it
49  = m_FilterList.begin(); it != m_FilterList.end(); it++ )
50  {
51  if (*it == filter) {
52  m_FilterList.erase(it);
53  return true;
54  }
55  }
56 
57  return false;
58 }
59 
60 bool BasicCombinationOpenCVImageFilter::GetIsFilterOnTheList( AbstractOpenCVImageFilter::Pointer filter )
61 {
62  return std::find(m_FilterList.begin(), m_FilterList.end(), filter) != m_FilterList.end();
63 }
64 
66 {
67  return m_FilterList.empty();
68 }
69 } // namespace mitk
bool GetIsEmpty()
Get the information if no filter is on the filter list.
bool OnFilterImage(cv::Mat &image) override
Apply list of filters to the given image.
DataCollection - Class to facilitate loading/accessing structured data.
bool RemoveFilter(AbstractOpenCVImageFilter::Pointer filter)
Remove the given filter from the list of filters.
AbstractOpenCVImageFilter::Pointer PopFilter()
Remove and return the last filter added to the list of filters.
void PushFilter(AbstractOpenCVImageFilter::Pointer filter)
Push an additional filter to the list of filters for applying to an image.
mitk::Image::Pointer image
std::vector< AbstractOpenCVImageFilter::Pointer > m_FilterList
All filters applied to the given image during call of mitk::mitkBasicCombinationOpenCVImageFilter::Fi...
bool GetIsFilterOnTheList(AbstractOpenCVImageFilter::Pointer filter)
Get the information if the given filter is on the filter list.