SourceXtractorPlusPlus
1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEFramework
SEFramework
Image
FunctionalImage.h
Go to the documentation of this file.
1
17
/*
18
* @file SEFramework/Image/FunctionalImage.h
19
* @date 27/03/19
20
* @author Alejandro Alvarez Ayllon
21
*/
22
23
#ifndef _SEFRAMEWORK_IMAGE_FUNCTIONALIMAGE_H
24
#define _SEFRAMEWORK_IMAGE_FUNCTIONALIMAGE_H
25
26
#include "
SEFramework/Image/Image.h
"
27
#include "
SEFramework/Image/ImageChunk.h
"
28
29
namespace
SourceXtractor
{
30
42
template
<
typename
T,
typename
I = T>
43
class
FunctionalImage
:
public
Image
<T> {
44
public
:
45
using
FunctorType
=
std::function
<T(
int
x,
int
y, I v)>;
46
47
protected
:
48
FunctionalImage
(
std::shared_ptr
<
const
Image<I>
> img,
FunctorType
functor)
49
:
m_img
{
std
::
move
(img)},
m_functor
{functor} {
50
}
51
52
public
:
53
virtual
~FunctionalImage
() =
default
;
54
55
template
<
typename
...Args>
56
static
std::shared_ptr<FunctionalImage<T, I>
>
create
(Args&& ... args) {
57
return
std::shared_ptr<FunctionalImage<T, I>
>(
new
FunctionalImage
{
std::forward<Args>
(args)...});
58
}
59
60
std::string
getRepr
() const final {
61
return
"FunctionalImage<"
+
std::string
(
m_functor
.target_type().name()) +
">"
;
62
}
63
64
int
getWidth
() const final {
65
return
m_img
->getWidth();
66
}
67
68
int
getHeight
() const final {
69
return
m_img
->getHeight();
70
}
71
72
std::shared_ptr<ImageChunk<T>
>
getChunk
(
int
x,
int
y,
int
width,
int
height)
const
final
{
73
auto
in_chunk =
m_img
->getChunk(x, y, width, height);
74
auto
chunk =
UniversalImageChunk<T>::create
(width, height);
75
for
(
int
iy = 0; iy < height; ++iy) {
76
for
(
int
ix = 0; ix < width; ++ix) {
77
chunk->at(ix, iy) =
m_functor
(ix + x, iy + y, in_chunk->getValue(ix, iy));
78
}
79
}
80
return
chunk;
81
}
82
83
private
:
84
std::shared_ptr<const Image<I>
>
m_img
;
85
FunctorType
m_functor
;
86
};
87
88
}
// end SourceXtractor
89
90
#endif
// _SEFRAMEWORK_IMAGE_FUNCTIONALIMAGE_H
ImageChunk.h
Image.h
std::string
SourceXtractor::FunctionalImage::getRepr
std::string getRepr() const final
Get a string identifying this image in a human readable manner.
Definition
FunctionalImage.h:60
SourceXtractor::FunctionalImage::create
static std::shared_ptr< FunctionalImage< T, I > > create(Args &&... args)
Definition
FunctionalImage.h:56
SourceXtractor::FunctionalImage::getChunk
std::shared_ptr< ImageChunk< T > > getChunk(int x, int y, int width, int height) const final
Definition
FunctionalImage.h:72
SourceXtractor::FunctionalImage::FunctorType
std::function< T(int x, int y, I v)> FunctorType
Definition
FunctionalImage.h:45
SourceXtractor::FunctionalImage::getHeight
int getHeight() const final
Returns the height of the image in pixels.
Definition
FunctionalImage.h:68
SourceXtractor::FunctionalImage::getWidth
int getWidth() const final
Returns the width of the image in pixels.
Definition
FunctionalImage.h:64
SourceXtractor::FunctionalImage::m_functor
FunctorType m_functor
Definition
FunctionalImage.h:85
SourceXtractor::FunctionalImage::FunctionalImage
FunctionalImage(std::shared_ptr< const Image< I > > img, FunctorType functor)
Definition
FunctionalImage.h:48
SourceXtractor::FunctionalImage::~FunctionalImage
virtual ~FunctionalImage()=default
SourceXtractor::FunctionalImage::m_img
std::shared_ptr< const Image< I > > m_img
Definition
FunctionalImage.h:84
SourceXtractor::Image
Interface representing an image.
Definition
Image.h:44
SourceXtractor::UniversalImageChunk::create
static std::shared_ptr< UniversalImageChunk< T > > create(Args &&... args)
Definition
ImageChunk.h:144
std::forward
T forward(T... args)
std::function
std::move
T move(T... args)
SourceXtractor
Definition
Aperture.h:30
std
STL namespace.
std::shared_ptr
Generated by
1.14.0