SourceXtractorPlusPlus
0.13
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/ImageBase.h
"
30
#include "
SEFramework/Image/ImageSource.h
"
31
#include "
SEImplementation/Background/SE2/SplineModel.h
"
32
33
namespace
SourceXtractor
{
34
35
template
<
typename
T>
36
class
TypedSplineModelWrapper
final :
public
ImageSource
{
37
38
public
:
39
40
//TypedSplineModelWrapper(const size_t* naxes, const size_t* gridCellSize, const size_t* nGrid, PIXTYPE* gridData){
41
// m_spline_model = new SplineModel(naxes, gridCellSize, nGrid, gridData);
42
//};
43
44
virtual
~TypedSplineModelWrapper
(){
45
if
(
m_spline_model
){
46
delete
m_spline_model
;
47
}
48
};
49
50
static
std::shared_ptr<TypedSplineModelWrapper<T>
>
create
(
const
size_t
* naxes,
const
size_t
* gridCellSize,
const
size_t
* nGrid,
PIXTYPE
* gridData) {
51
return
std::shared_ptr<TypedSplineModelWrapper<T>
>(
new
TypedSplineModelWrapper<T>
(naxes, gridCellSize, nGrid, gridData));
52
}
53
55
std::string
getRepr
()
const override
{
56
return
"TypedSplineModel"
;
57
}
58
60
T
getValue
(
int
x
,
int
y
)
const
{
61
return
(T)
m_spline_model
->
getValue
((
size_t
)
x
, (
size_t
)
y
);
62
};
63
65
int
getWidth
()
const override
{
66
return
(
int
)(
m_spline_model
->
getNaxes
())[0];
67
};
68
70
int
getHeight
()
const override
{
71
return
(
int
)(
m_spline_model
->
getNaxes
())[1];
72
};
73
75
T
getMedian
()
const
{
76
return
(T)
m_spline_model
->
getMedian
();
77
};
78
79
std::shared_ptr<ImageTile>
getImageTile
(
int
x
,
int
y
,
int
width,
int
height)
const override
{
80
auto
tile =
ImageTile::create
(
ImageTile::getTypeValue
(T()),
x
,
y
, width, height);
81
// Splines are calculated and cached per row. We fill
82
// the tile with the Y axis on the outer loop, so we can
83
// benefit from that caching
84
// @see SplineModel::getValue
85
for
(
auto
j =
y
; j <
y
+ height; ++j) {
86
for
(
auto
i =
x
; i <
x
+ width; ++i) {
87
tile->setValue(i, j,
getValue
(i, j));
88
}
89
}
90
return
tile;
91
}
92
93
void
gridToFits
(boost::filesystem::path
path
)
const
{
94
m_spline_model
->
gridToFits
(
path
);
95
}
96
97
void
saveTile
(
ImageTile
&
/*tile*/
)
override
{
98
assert(
false
);
99
}
100
101
ImageTile::ImageType
getType
()
const override
{
102
return
ImageTile::getTypeValue
(T());
103
}
104
105
private
:
106
TypedSplineModelWrapper
(
const
size_t
* naxes,
const
size_t
* gridCellSize,
const
size_t
* nGrid,
PIXTYPE
* gridData){
107
m_spline_model
=
new
SplineModel
(naxes, gridCellSize, nGrid, gridData);
108
};
109
SplineModel
*
m_spline_model
=
nullptr
;
110
};
111
112
}
// end of namespace SourceXtractor
113
114
#endif // TYPEDSPLINEMODELWRAPPER_H
115
ImageBase.h
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:101
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:50
SourceXtractor::TypedSplineModelWrapper::getWidth
int getWidth() const override
Returns the width of the image in pixels.
Definition:
TypedSplineModelWrapper.h:65
SourceXtractor::TypedSplineModelWrapper::~TypedSplineModelWrapper
virtual ~TypedSplineModelWrapper()
Definition:
TypedSplineModelWrapper.h:44
SourceXtractor::TypedSplineModelWrapper::getImageTile
std::shared_ptr< ImageTile > getImageTile(int x, int y, int width, int height) const override
Definition:
TypedSplineModelWrapper.h:79
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:96
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:55
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:60
SourceXtractor::ImageTile::getTypeValue
static ImageType getTypeValue(float)
Definition:
ImageTile.h:109
SourceXtractor::TypedSplineModelWrapper::getHeight
int getHeight() const override
Returns the height of the image in pixels.
Definition:
TypedSplineModelWrapper.h:70
SourceXtractor::ImageSource
Definition:
ImageSource.h:52
SourceXtractor::TypedSplineModelWrapper::getMedian
T getMedian() const
Returns the median of the spline.
Definition:
TypedSplineModelWrapper.h:75
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:97
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:106
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:36
SourceXtractor::TypedSplineModelWrapper::gridToFits
void gridToFits(boost::filesystem::path path) const
Definition:
TypedSplineModelWrapper.h:93
SourceXtractor::TypedSplineModelWrapper::m_spline_model
SplineModel * m_spline_model
Definition:
TypedSplineModelWrapper.h:109
Generated by
1.8.20