/usr/include/mia-2.4/mia/2d/deformer.hh is in libmia-2.4-dev 2.4.3-5.
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 | /* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2016 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_2d_deformer_hh
#define mia_2d_deformer_hh
#include <mia/2d/image.hh>
#include <mia/2d/filter.hh>
#include <mia/2d/interpolator.hh>
NS_MIA_BEGIN
/**
@ingroup filtering
Deform an image by using a dense vector field as transformation.
\remark obsolete-should be done by using C2DTransform
*/
struct FDeformer2D: public TFilter<P2DImage> {
/**
Construor taking the
\param vf vector field defining the transformation like T(x) := x - vf(x)
\param ipfac the interpolation factory used for image interpolation
*/
FDeformer2D(const C2DFVectorfield& vf, const C2DInterpolatorFactory& ipfac):
m_vf(vf),
m_ipfac(ipfac)
{
}
/**
Operator to run the transformation like a filter to be called by mia::filter
\tparam T pixel type if the input image
\param image the input image
\returns the transformed image
*/
template <typename T>
P2DImage operator () (const T2DImage<T>& image) const {
T2DImage<T> *timage = new T2DImage<T>(image.get_size());
std::shared_ptr<T2DInterpolator<T> > interp(m_ipfac.create(image.data()));
typename T2DImage<T>::iterator r = timage->begin();
C2DFVectorfield::const_iterator v = m_vf.begin();
for (size_t y = 0; y < image.get_size().y; ++y)
for (size_t x = 0; x < image.get_size().x; ++x, ++r, ++v) {
*r = (*interp)(C2DFVector(x - v->x, y - v->y));
}
return P2DImage(timage);
}
/**
Operator to transform the image and store the result in a pre-allocated
image
\param[in] image the input image
\param[out] result the output image
*/
template <typename T>
void operator () (const T2DImage<T>& image, T2DImage<T>& result) const {
assert(image.get_size() == result.get_size());
std::shared_ptr<T2DInterpolator<T> > interp(m_ipfac.create(image.data()));
typename T2DImage<T>::iterator r = result.begin();
C2DFVectorfield::const_iterator v = m_vf.begin();
for (size_t y = 0; y < image.get_size().y; ++y)
for (size_t x = 0; x < image.get_size().x; ++x, ++r, ++v) {
*r = (*interp)(C2DFVector(x - v->x, y - v->y));
}
}
private:
C2DFVectorfield m_vf;
C2DInterpolatorFactory m_ipfac;
};
NS_MIA_END
#endif
|