SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEFramework
SEFramework
Image
ProcessedImage.h
Go to the documentation of this file.
1
18
#ifndef _SEFRAMEWORK_IMAGE_PROCESSEDIMAGE_H_
19
#define _SEFRAMEWORK_IMAGE_PROCESSEDIMAGE_H_
20
21
#include <memory>
22
23
#include "
SEFramework/Image/Image.h
"
24
#include "
SEFramework/Image/ConstantImage.h
"
25
#include "
SEFramework/Image/VectorImage.h
"
26
27
namespace
SourceXtractor
{
28
35
template
<
typename
T,
typename
P>
36
class
ProcessedImage
:
public
Image
<T> {
37
38
protected
:
39
40
ProcessedImage
(
std::shared_ptr
<
const
Image<T>
>
image_a
,
std::shared_ptr
<
const
Image<T>
>
image_b
)
41
:
m_image_a
(
image_a
),
m_image_b
(
image_b
) {
42
assert
(
m_image_a
->getWidth() ==
m_image_b
->getWidth());
43
assert
(
m_image_a
->getHeight() ==
m_image_b
->getHeight());
44
};
45
46
public
:
47
51
virtual
~ProcessedImage
() =
default
;
52
53
static
std::shared_ptr<ProcessedImage<T, P>
>
create
(
54
std::shared_ptr
<
const
Image<T>
>
image_a
,
std::shared_ptr
<
const
Image<T>
>
image_b
) {
55
return
std::shared_ptr<ProcessedImage<T, P>
>(
new
ProcessedImage<T, P>
(
image_a
,
image_b
));
56
}
57
58
static
std::shared_ptr<ProcessedImage<T, P>
>
create
(
std::shared_ptr
<
const
Image<T>
>
image_a
, T value) {
59
return
std::shared_ptr<ProcessedImage<T, P>
>(
new
ProcessedImage<T, P>
(
60
image_a
,
ConstantImage<T>::create
(
image_a
->getWidth(),
image_a
->getHeight(), value)));
61
}
62
63
std::string
getRepr
()
const override
{
64
return
"ProcessedImage("
+
m_image_a
->getRepr() +
","
+
m_image_b
->getRepr() +
")"
;
65
}
66
67
int
getWidth
()
const override
{
68
return
m_image_a
->getWidth();
69
}
70
71
int
getHeight
()
const override
{
72
return
m_image_a
->getHeight();
73
}
74
75
std::shared_ptr<ImageChunk<T>
>
getChunk
(
int
x
,
int
y
,
int
width,
int
height)
const override
{
76
std::vector<T>
new_chunk_data
(width * height);
77
auto
a_chunk
=
m_image_a
->getChunk(
x
,
y
, width, height);
78
auto
b_chunk
=
m_image_b
->getChunk(
x
,
y
, width, height);
79
for
(
int
iy
= 0;
iy
< height; ++
iy
) {
80
for
(
int
ix
= 0;
ix
< width; ++
ix
) {
81
new_chunk_data
[
ix
+
iy
* width] = P::process(
a_chunk
->getValue(
ix
,
iy
),
82
b_chunk
->getValue(
ix
,
iy
));
83
}
84
}
85
return
UniversalImageChunk<T>::create
(
std::move
(
new_chunk_data
), width, height);
86
}
87
88
private
:
89
std::shared_ptr<const Image<T>
>
m_image_a
;
90
std::shared_ptr<const Image<T>
>
m_image_b
;
91
92
};
/* End of ProcessedImage class */
93
94
95
template
<
typename
T>
96
struct
SubtractOperation
97
{
98
static
T
process
(
const
T& a,
const
T& b) {
return
a - b; }
99
};
100
101
template
<
typename
T>
102
using
SubtractImage
=
ProcessedImage<T, SubtractOperation<T>
> ;
103
104
template
<
typename
T>
105
struct
MultiplyOperation
106
{
107
static
T
process
(
const
T& a,
const
T& b) {
return
a * b; }
108
};
109
110
template
<
typename
T>
111
using
MultiplyImage
=
ProcessedImage<T, MultiplyOperation<T>
> ;
112
113
template
<
typename
T>
114
struct
SnrOperation
115
{
116
static
T
process
(
const
T& a,
const
T& b) {
return
a /
sqrt
(b); }
117
};
118
119
template
<
typename
T>
120
using
SnrImage
=
ProcessedImage<T, SnrOperation<T>
> ;
121
122
}
/* namespace SourceXtractor */
123
124
125
126
127
#endif
/* _SEFRAMEWORK_IMAGE_PROCESSEDIMAGE_H_ */
ConstantImage.h
Image.h
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition
MoffatModelFittingTask.cpp:94
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition
MoffatModelFittingTask.cpp:94
VectorImage.h
std::string
SourceXtractor::ConstantImage
Definition
ConstantImage.h:33
SourceXtractor::Image
Interface representing an image.
Definition
Image.h:44
SourceXtractor::ProcessedImage
Processes two images to create a third combining them by using any function.
Definition
ProcessedImage.h:36
SourceXtractor::ProcessedImage::ProcessedImage
ProcessedImage(std::shared_ptr< const Image< T > > image_a, std::shared_ptr< const Image< T > > image_b)
Definition
ProcessedImage.h:40
SourceXtractor::ProcessedImage::~ProcessedImage
virtual ~ProcessedImage()=default
Destructor.
SourceXtractor::ProcessedImage::create
static std::shared_ptr< ProcessedImage< T, P > > create(std::shared_ptr< const Image< T > > image_a, T value)
Definition
ProcessedImage.h:58
SourceXtractor::ProcessedImage::m_image_a
std::shared_ptr< const Image< T > > m_image_a
Definition
ProcessedImage.h:89
SourceXtractor::ProcessedImage::getRepr
std::string getRepr() const override
Get a string identifying this image in a human readable manner.
Definition
ProcessedImage.h:63
SourceXtractor::ProcessedImage::m_image_b
std::shared_ptr< const Image< T > > m_image_b
Definition
ProcessedImage.h:90
SourceXtractor::ProcessedImage::getHeight
int getHeight() const override
Returns the height of the image in pixels.
Definition
ProcessedImage.h:71
SourceXtractor::ProcessedImage::getChunk
std::shared_ptr< ImageChunk< T > > getChunk(int x, int y, int width, int height) const override
Definition
ProcessedImage.h:75
SourceXtractor::ProcessedImage::create
static std::shared_ptr< ProcessedImage< T, P > > create(std::shared_ptr< const Image< T > > image_a, std::shared_ptr< const Image< T > > image_b)
Definition
ProcessedImage.h:53
SourceXtractor::ProcessedImage::getWidth
int getWidth() const override
Returns the width of the image in pixels.
Definition
ProcessedImage.h:67
SourceXtractor::UniversalImageChunk::create
static std::shared_ptr< UniversalImageChunk< T > > create(Args &&... args)
Definition
ImageChunk.h:144
std::function
std::move
T move(T... args)
SourceXtractor
Definition
Aperture.h:30
std::shared_ptr
std::sqrt
T sqrt(T... args)
SourceXtractor::MultiplyOperation
Definition
ProcessedImage.h:106
SourceXtractor::MultiplyOperation::process
static T process(const T &a, const T &b)
Definition
ProcessedImage.h:107
SourceXtractor::SnrOperation
Definition
ProcessedImage.h:115
SourceXtractor::SnrOperation::process
static T process(const T &a, const T &b)
Definition
ProcessedImage.h:116
SourceXtractor::SubtractOperation
Definition
ProcessedImage.h:97
SourceXtractor::SubtractOperation::process
static T process(const T &a, const T &b)
Definition
ProcessedImage.h:98
Generated by
1.10.0