SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEImplementation
SEImplementation
Segmentation
BFSSegmentation.h
Go to the documentation of this file.
1
18
#ifndef _SEIMPLEMENTATION_SEGMENTATION_BFSSEGMENTATION_H_
19
#define _SEIMPLEMENTATION_SEGMENTATION_BFSSEGMENTATION_H_
20
21
#include "
SEFramework/Source/SourceFactory.h
"
22
#include "
SEFramework/Pipeline/Segmentation.h
"
23
24
namespace
SourceXtractor
{
25
26
31
class
BFSSegmentation
:
public
Segmentation::Labelling
{
32
public
:
33
34
virtual
~BFSSegmentation
() =
default
;
35
36
BFSSegmentation
(
std::shared_ptr<SourceFactory>
source_factory,
int
max_delta
)
37
:
m_source_factory
(source_factory),
m_max_delta
(
max_delta
) {
38
assert
(source_factory !=
nullptr
);
39
}
40
41
void
labelImage
(
Segmentation::LabellingListener
&
listener
,
std::shared_ptr<const DetectionImageFrame>
frame
)
override
;
42
43
private
:
44
class
VisitedMap
{
45
public
:
46
VisitedMap
(
int
width,
int
height) :
m_width
(width),
m_height
(height),
m_visited
(width * height,
false
) {}
47
48
void
markVisited
(
PixelCoordinate
pc) {
49
m_visited
[pc.m_x + pc.m_y *
m_width
] =
true
;
50
}
51
52
bool
wasVisited
(
PixelCoordinate
pc)
const
{
53
if
(pc.m_x >= 0 && pc.m_x <
m_width
&& pc.m_y >= 0 && pc.m_y <
m_height
) {
54
return
m_visited
[pc.m_x + pc.m_y *
m_width
];
55
}
else
{
56
return
true
;
57
}
58
}
59
60
private
:
61
int
m_width
,
m_height
;
62
std::vector<bool>
m_visited
;
63
};
64
65
struct
Tile
{
PixelCoordinate
offset
;
66
int
width
,
height
;
67
};
68
69
void
labelSource
(
PixelCoordinate
pc,
Segmentation::LabellingListener
&
listener
,
70
DetectionImage
&
detection_image
,
VisitedMap
&
visited_map
)
const
;
71
72
std::vector<BFSSegmentation::Tile>
getTiles
(
const
DetectionImage
&
image
)
const
;
73
74
75
std::shared_ptr<SourceFactory>
m_source_factory
;
76
int
m_max_delta
;
77
};
78
79
}
80
81
#endif
/* _SEIMPLEMENTATION_SEGMENTATION_BFSSEGMENTATION_H_ */
Segmentation.h
SourceFactory.h
SourceXtractor::BFSSegmentation::VisitedMap
Definition
BFSSegmentation.h:44
SourceXtractor::BFSSegmentation::VisitedMap::m_visited
std::vector< bool > m_visited
Definition
BFSSegmentation.h:62
SourceXtractor::BFSSegmentation::VisitedMap::wasVisited
bool wasVisited(PixelCoordinate pc) const
Definition
BFSSegmentation.h:52
SourceXtractor::BFSSegmentation::VisitedMap::m_width
int m_width
Definition
BFSSegmentation.h:61
SourceXtractor::BFSSegmentation::VisitedMap::VisitedMap
VisitedMap(int width, int height)
Definition
BFSSegmentation.h:46
SourceXtractor::BFSSegmentation::VisitedMap::m_height
int m_height
Definition
BFSSegmentation.h:61
SourceXtractor::BFSSegmentation::VisitedMap::markVisited
void markVisited(PixelCoordinate pc)
Definition
BFSSegmentation.h:48
SourceXtractor::BFSSegmentation
Implements a Segmentation based on the BFS algorithm.
Definition
BFSSegmentation.h:31
SourceXtractor::BFSSegmentation::m_max_delta
int m_max_delta
Definition
BFSSegmentation.h:76
SourceXtractor::BFSSegmentation::getTiles
std::vector< BFSSegmentation::Tile > getTiles(const DetectionImage &image) const
Definition
BFSSegmentation.cpp:109
SourceXtractor::BFSSegmentation::labelSource
void labelSource(PixelCoordinate pc, Segmentation::LabellingListener &listener, DetectionImage &detection_image, VisitedMap &visited_map) const
Definition
BFSSegmentation.cpp:59
SourceXtractor::BFSSegmentation::BFSSegmentation
BFSSegmentation(std::shared_ptr< SourceFactory > source_factory, int max_delta)
Definition
BFSSegmentation.h:36
SourceXtractor::BFSSegmentation::labelImage
void labelImage(Segmentation::LabellingListener &listener, std::shared_ptr< const DetectionImageFrame > frame) override
Definition
BFSSegmentation.cpp:39
SourceXtractor::BFSSegmentation::~BFSSegmentation
virtual ~BFSSegmentation()=default
SourceXtractor::BFSSegmentation::m_source_factory
std::shared_ptr< SourceFactory > m_source_factory
Definition
BFSSegmentation.h:75
SourceXtractor::Image< SeFloat >
SourceXtractor::Segmentation::LabellingListener
Definition
Segmentation.h:83
SourceXtractor::Segmentation::Labelling
Definition
Segmentation.h:109
std::function
SourceXtractor
Definition
Aperture.h:30
SourceXtractor::BFSSegmentation::Tile
Definition
BFSSegmentation.h:65
SourceXtractor::BFSSegmentation::Tile::width
int width
Definition
BFSSegmentation.h:66
SourceXtractor::BFSSegmentation::Tile::height
int height
Definition
BFSSegmentation.h:66
SourceXtractor::BFSSegmentation::Tile::offset
PixelCoordinate offset
Definition
BFSSegmentation.h:65
SourceXtractor::PixelCoordinate
A pixel coordinate made of two integers m_x and m_y.
Definition
PixelCoordinate.h:37
Generated by
1.10.0