SourceXtractorPlusPlus
0.15
Please provide a description of the project.
SEImplementation
SEImplementation
Background
SE2
TypedSplineModelWrapper.h
Go to the documentation of this file.
1
17
/*
18
* Created on Jan 05, 2015
19
* @author: mkuemmel@usm.lmu.de
20
*
21
* Date: $Date$
22
* Revision: $Revision$
23
* Author: $Author$
24
*/
25
#ifndef TYPEDSPLINEMODELWRAPPER_H
26
#define TYPEDSPLINEMODELWRAPPER_H
27
28
#include <boost/filesystem.hpp>
29
#include "
SEFramework/Image/ImageSource.h
"
30
#include "
SEImplementation/Background/SE2/SplineModel.h
"
31
32
namespace
SourceXtractor
{
33
34
template
<
typename
T>
35
class
TypedSplineModelWrapper
final :
public
ImageSource
{
36
37
public
:
38
39
//TypedSplineModelWrapper(const size_t* naxes, const size_t* gridCellSize, const size_t* nGrid, PIXTYPE* gridData){
40
// m_spline_model = new SplineModel(naxes, gridCellSize, nGrid, gridData);
41
//};
42
43
virtual
~TypedSplineModelWrapper
(){
44
if
(
m_spline_model
){
45
delete
m_spline_model
;
46
}
47
};
48
49
static
std::shared_ptr<TypedSplineModelWrapper<T>
>
create
(
const
size_t
* naxes,
const
size_t
* gridCellSize,
const
size_t
* nGrid,
PIXTYPE
* gridData) {
50
return
std::shared_ptr<TypedSplineModelWrapper<T>
>(
new
TypedSplineModelWrapper<T>
(naxes, gridCellSize, nGrid, gridData));
51
}
52
54
std::string
getRepr
()
const override
{
55
return
"TypedSplineModel"
;
56
}
57
59
T
getValue
(
int
x
,
int
y
)
const
{
60
return
(T)
m_spline_model
->
getValue
((
size_t
)
x
, (
size_t
)
y
);
61
};
62
64
int
getWidth
()
const override
{
65
return
(
int
)(
m_spline_model
->
getNaxes
())[0];
66
};
67
69
int
getHeight
()
const override
{
70
return
(
int
)(
m_spline_model
->
getNaxes
())[1];
71
};
72
74
T
getMedian
()
const
{
75
return
(T)
m_spline_model
->
getMedian
();
76
};
77
78
std::shared_ptr<ImageTile>
getImageTile
(
int
x
,
int
y
,
int
width,
int
height)
const override
{
79
auto
tile =
ImageTile::create
(
ImageTile::getTypeValue
(T()),
x
,
y
, width, height);
80
// Splines are calculated and cached per row. We fill
81
// the tile with the Y axis on the outer loop, so we can
82
// benefit from that caching
83
// @see SplineModel::getValue
84
for
(
auto
j =
y
; j <
y
+ height; ++j) {
85
for
(
auto
i =
x
; i <
x
+ width; ++i) {
86
tile->setValue(i, j,
getValue
(i, j));
87
}
88
}
89
return
tile;
90
}
91
92
void
gridToFits
(boost::filesystem::path
path
)
const
{
93
m_spline_model
->
gridToFits
(
path
);
94
}
95
96
void
saveTile
(
ImageTile
&
/*tile*/
)
override
{
97
assert(
false
);
98
}
99
100
ImageTile::ImageType
getType
()
const override
{
101
return
ImageTile::getTypeValue
(T());
102
}
103
104
private
:
105
TypedSplineModelWrapper
(
const
size_t
* naxes,
const
size_t
* gridCellSize,
const
size_t
* nGrid,
PIXTYPE
* gridData){
106
m_spline_model
=
new
SplineModel
(naxes, gridCellSize, nGrid, gridData);
107
};
108
SplineModel
*
m_spline_model
=
nullptr
;
109
};
110
111
}
// end of namespace SourceXtractor
112
113
#endif // TYPEDSPLINEMODELWRAPPER_H
114
SourceXtractor::PIXTYPE
float PIXTYPE
Definition:
BackgroundDefine.h:30
std::string
STL class.
std::shared_ptr
STL class.
SourceXtractor::TypedSplineModelWrapper::getType
ImageTile::ImageType getType() const override
Definition:
TypedSplineModelWrapper.h:100
SourceXtractor::TypedSplineModelWrapper::create
static std::shared_ptr< TypedSplineModelWrapper< T > > create(const size_t *naxes, const size_t *gridCellSize, const size_t *nGrid, PIXTYPE *gridData)
Definition:
TypedSplineModelWrapper.h:49
SourceXtractor::TypedSplineModelWrapper::getWidth
int getWidth() const override
Returns the width of the image in pixels.
Definition:
TypedSplineModelWrapper.h:64
SourceXtractor::TypedSplineModelWrapper::~TypedSplineModelWrapper
virtual ~TypedSplineModelWrapper()
Definition:
TypedSplineModelWrapper.h:43
SourceXtractor::TypedSplineModelWrapper::getImageTile
std::shared_ptr< ImageTile > getImageTile(int x, int y, int width, int height) const override
Definition:
TypedSplineModelWrapper.h:78
SourceXtractor::ImageTile::create
static std::shared_ptr< ImageTile > create(ImageType image_type, int x, int y, int width, int height, std::shared_ptr< ImageSource > source=nullptr)
Definition:
ImageTile.cpp:24
SourceXtractor::SplineModel
Definition:
SplineModel.h:33
SourceXtractor::ImageTile
Definition:
ImageTile.h:34
SourceXtractor::SplineModel::getMedian
PIXTYPE & getMedian()
Definition:
SplineModel.cpp:80
SourceXtractor::TypedSplineModelWrapper::getRepr
std::string getRepr() const override
Human readable representation.
Definition:
TypedSplineModelWrapper.h:54
SourceXtractor
Definition:
Aperture.h:30
SourceXtractor::TypedSplineModelWrapper::getValue
T getValue(int x, int y) const
Returns the value of the pixel with the coordinates (x,y)
Definition:
TypedSplineModelWrapper.h:59
SourceXtractor::ImageTile::getTypeValue
static ImageType getTypeValue(float)
Definition:
ImageTile.h:99
SourceXtractor::TypedSplineModelWrapper::getHeight
int getHeight() const override
Returns the height of the image in pixels.
Definition:
TypedSplineModelWrapper.h:69
SourceXtractor::ImageSource
Definition:
ImageSource.h:52
SourceXtractor::TypedSplineModelWrapper::getMedian
T getMedian() const
Returns the median of the spline.
Definition:
TypedSplineModelWrapper.h:74
SourceXtractor::SplineModel::getNaxes
size_t * getNaxes()
Definition:
SplineModel.cpp:76
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition:
MoffatModelFittingTask.cpp:94
SourceXtractor::SplineModel::getValue
PIXTYPE getValue(size_t x, size_t y)
Definition:
SplineModel.cpp:276
SourceXtractor::SplineModel::gridToFits
void gridToFits(boost::filesystem::path &fitsName, const bool overwrite=true)
Definition:
SplineModel.cpp:105
SourceXtractor::TypedSplineModelWrapper::saveTile
void saveTile(ImageTile &) override
Definition:
TypedSplineModelWrapper.h:96
ImageSource.h
SplineModel.h
SourceXtractor::TypedSplineModelWrapper::TypedSplineModelWrapper
TypedSplineModelWrapper(const size_t *naxes, const size_t *gridCellSize, const size_t *nGrid, PIXTYPE *gridData)
Definition:
TypedSplineModelWrapper.h:105
path
Elements::Path::Item path
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition:
MoffatModelFittingTask.cpp:94
SourceXtractor::ImageTile::ImageType
ImageType
Definition:
ImageTile.h:37
SourceXtractor::TypedSplineModelWrapper
Definition:
TypedSplineModelWrapper.h:35
SourceXtractor::TypedSplineModelWrapper::gridToFits
void gridToFits(boost::filesystem::path path) const
Definition:
TypedSplineModelWrapper.h:92
SourceXtractor::TypedSplineModelWrapper::m_spline_model
SplineModel * m_spline_model
Definition:
TypedSplineModelWrapper.h:108
Generated by
1.8.20