/usr/include/mia-2.2/mia/template/combiner_filter.hh is in libmia-2.2-dev 2.2.2-1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | /* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2014 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef mia_template_combiner_filter_hh
#define mia_template_combiner_filter_hh
#include <mia/template/combiner.hh>
#include <mia/core/iohandler.hh>
NS_MIA_BEGIN
template <typename Image>
class TImageCombinerFilter: public TDataFilter<Image> {
public:
TImageCombinerFilter(std::shared_ptr<TImageCombiner<Image>> combiner,
const std::string& other_image_file, bool reverse);
typename Image::Pointer do_filter(const Image& image) const;
std::shared_ptr<TImageCombiner<Image>> m_combiner;
std::string m_other_image;
bool m_reverse;
};
template <class Image>
class TImageCombinerFilterPlugin: public TDataFilterPlugin<Image> {
public:
TImageCombinerFilterPlugin();
virtual TDataFilter<Image> *do_create()const;
virtual const std::string do_get_descr()const;
private:
std::shared_ptr<TImageCombiner<Image>> m_combiner;
std::string m_other_image;
bool m_reverse;
};
template <typename Image>
TImageCombinerFilter<Image>::TImageCombinerFilter(std::shared_ptr<TImageCombiner<Image>> combiner,
const std::string& other_image_file, bool reverse):
m_combiner(combiner),
m_other_image(other_image_file),
m_reverse(reverse)
{
}
template <typename Image>
typename Image::Pointer TImageCombinerFilter<Image>::do_filter(const Image& image) const
{
auto other_image = load_image<typename Image::Pointer>(m_other_image);
if (m_reverse)
return m_combiner->combine(*other_image, image);
else
return m_combiner->combine(image, *other_image);
}
template <typename Image>
TImageCombinerFilterPlugin<Image>::TImageCombinerFilterPlugin():
TDataFilterPlugin<Image>("combiner"),
m_reverse(false)
{
typedef typename IOHandler_of<Image>::type IOHandler;
this->add_parameter("op", make_param(m_combiner, "", true, "Image combiner to be applied to the images"));
this->add_parameter("image", new CStringParameter(m_other_image, CCmdOptionFlags::required_input, "second image that is needed in the combiner",
&IOHandler::instance()));
this->add_parameter("reverse", new CBoolParameter(m_reverse, false, "reverse the order in which the images passed to the combiner"));
}
template <typename Image>
TDataFilter<Image> *TImageCombinerFilterPlugin<Image>::do_create()const
{
return new TImageCombinerFilter<Image>(m_combiner, m_other_image, m_reverse);
}
template <typename Image>
const std::string TImageCombinerFilterPlugin<Image>::do_get_descr()const
{
return "Combine two images with the given combiner operator. if 'reverse' is set to false, the first "
"operator is the image passed through the filter pipeline, and the second image is loaded "
"from the file given with the 'image' parameter the moment the filter is run.";
}
NS_MIA_END
#endif
|