stackdisttrans.hh
Go to the documentation of this file.
/* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2017 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_3d_stackdisttrans_hh
#define mia_3d_stackdisttrans_hh
#include <vector>
#include <mia/3d/defines3d.hh>
#include <mia/3d/vector.hh>
#include <mia/2d/image.hh>
#include <mia/core/iohandler.hh>
#include <mia/core/ioplugin.hh>
NS_MIA_BEGIN
class EXPORT_3D C2DStackDistanceTransform: public CIOData
{
public:
typedef C2DStackDistanceTransform type;
static const char *const data_descr;
static const char *const type_descr;
struct DistanceFromPoint {
DistanceFromPoint(C3DBounds _point, float _distance):
point(_point),
distance(_distance)
{};
C3DBounds point;
float distance;
};
C2DStackDistanceTransform() = default;
C2DStackDistanceTransform(const C2DStackDistanceTransform& /*other*/) = default;
C2DStackDistanceTransform *clone() const __attribute__((warn_unused_result));
C2DStackDistanceTransform(const C2DImage& slice, const C3DFVector& voxel_size = C3DFVector::_1);
void read( const C2DImage& slice, int q);
std::vector<DistanceFromPoint> get_slice(size_t s, const C2DImage& image) const;
bool save(const std::string& filename);
private:
float d(float fq, float q, float fv, float v)const;
void dt1d(std::vector<float>& f, float scale)const;
void dt2d(C2DFImage& image)const;
struct SParabola {
int k;
int v;
float z;
float fv;
};
C2DBounds m_size;
C3DFVector m_voxel_size;
std::vector<int> m_k;
std::vector< std::vector<SParabola>> m_zdt;
};
inline std::ostream& operator << (std::ostream& os, const C2DStackDistanceTransform::DistanceFromPoint& v)
{
os << "[" << v.point << ":" << v.distance << "]";
return os;
}
inline bool operator == (const C2DStackDistanceTransform::DistanceFromPoint& lhs,
const C2DStackDistanceTransform::DistanceFromPoint& rhs)
{
return (lhs.point == rhs.point) && (lhs.distance == rhs.distance);
}
typedef TIOPlugin<C2DStackDistanceTransform> C2DStackDistanceTransformIO;
typedef THandlerSingleton< TIOPluginHandler<C2DStackDistanceTransformIO>> C2DStackDistanceTransformIOPluginHandler;
typedef C2DStackDistanceTransformIOPluginHandler::Instance::DataKey C2DStackDistanceTransformIODataKey;
NS_MIA_END
#endif
image.hh
C2DFImage
T2DImage< float > C2DFImage
2D image with single precsion floating point values
Definition 2d/image.hh:469
_1
const T2DMatrix< T > T2DMatrix< T >::_1(T2DVector< T >(1, 0), T2DVector< T >(0, 1))
C2DBounds
T2DVector< unsigned int > C2DBounds
unsigned int valued 2D vector - used as 2D size parameter
Definition 2d/vector.hh:540
vector.hh
C3DBounds
T3DVector< unsigned int > C3DBounds
A unsinged int 3D Vector (used for 3D field sizes).
Definition 3d/vector.hh:415
C3DFVector
T3DVector< float > C3DFVector
A float 3D Vector.
Definition 3d/vector.hh:409
C2DImage
This is the base class for 2D images that can hold generic pixel data.
Definition 2d/image.hh:48
C2DStackDistanceTransform::read
void read(const C2DImage &slice, int q)
C2DStackDistanceTransform::C2DStackDistanceTransform
C2DStackDistanceTransform(const C2DStackDistanceTransform &)=default
C2DStackDistanceTransform::type
C2DStackDistanceTransform type
helper type for IO plugin handling
Definition stackdisttrans.hh:51
C2DStackDistanceTransform::type_descr
static const char *const type_descr
search path component for the plugin handling
Definition stackdisttrans.hh:57
C2DStackDistanceTransform::get_slice
std::vector< DistanceFromPoint > get_slice(size_t s, const C2DImage &image) const
C2DStackDistanceTransform::C2DStackDistanceTransform
C2DStackDistanceTransform()=default
C2DStackDistanceTransform::data_descr
static const char *const data_descr
search path component for the plugin handling
Definition stackdisttrans.hh:54
C2DStackDistanceTransform::save
bool save(const std::string &filename)
C2DStackDistanceTransform::clone
C2DStackDistanceTransform * clone() const __attribute__((warn_unused_result))
CIOData
helper class to derive from for data that can be loaded and stored to a disk.
Definition iodata.hh:37
THandlerSingleton
the singleton that a plug-in handler really is
Definition handler.hh:159
TIOPluginHandler::DataKey
TDelayedParameter< PData > DataKey
The type of the key used for the CDatapool access.
Definition iohandler.hh:64
TIOPlugin
The templatex basis class of all IO plug-ins.
Definition ioplugin.hh:58
defines3d.hh
EXPORT_3D
#define EXPORT_3D
Definition defines3d.hh:45
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
iohandler.hh
ioplugin.hh
std
Definition gsl_iterator.hh:324
operator<<
std::ostream & operator<<(std::ostream &os, const C2DStackDistanceTransform::DistanceFromPoint &v)
Definition stackdisttrans.hh:151
operator==
bool operator==(const C2DStackDistanceTransform::DistanceFromPoint &lhs, const C2DStackDistanceTransform::DistanceFromPoint &rhs)
Definition stackdisttrans.hh:157
C2DStackDistanceTransformIOPluginHandler
THandlerSingleton< TIOPluginHandler< C2DStackDistanceTransformIO > > C2DStackDistanceTransformIOPluginHandler
Plug-in handler for the transformation IO plug-ins.
Definition stackdisttrans.hh:168
C2DStackDistanceTransformIO
TIOPlugin< C2DStackDistanceTransform > C2DStackDistanceTransformIO
Base class for the generic IO of transformations.
Definition stackdisttrans.hh:165
C2DStackDistanceTransformIODataKey
C2DStackDistanceTransformIOPluginHandler::Instance::DataKey C2DStackDistanceTransformIODataKey
data key type for temporary storage of 3D transformations
Definition stackdisttrans.hh:171
C2DStackDistanceTransform::DistanceFromPoint
Definition stackdisttrans.hh:63
C2DStackDistanceTransform::DistanceFromPoint::distance
float distance
Definition stackdisttrans.hh:75
C2DStackDistanceTransform::DistanceFromPoint::point
C3DBounds point
Definition stackdisttrans.hh:74
C2DStackDistanceTransform::DistanceFromPoint::DistanceFromPoint
DistanceFromPoint(C3DBounds _point, float _distance)
Definition stackdisttrans.hh:70