LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
home
lsstsw
stack
Linux64
afw
11.0-2-g04d2804
include
lsst
afw
detection
FootprintFunctor.h
Go to the documentation of this file.
1
/*
2
* LSST Data Management System
3
* Copyright 2008, 2009, 2010 LSST Corporation.
4
*
5
* This product includes software developed by the
6
* LSST Project (http://www.lsst.org/).
7
*
8
* This program is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the LSST License Statement and
19
* the GNU General Public License along with this program. If not,
20
* see <http://www.lsstcorp.org/LegalNotices/>.
21
*/
22
23
#if !defined(LSST_DETECTION_FOOTPRINT_FUNCTOR_H)
24
#define LSST_DETECTION_FOOTPRINT_FUNCTOR_H
25
26
#include "
lsst/afw/detection/Footprint.h
"
27
#include "
lsst/afw/image/MaskedImage.h
"
28
29
namespace
lsst {
30
namespace
afw {
31
namespace
detection {
32
/************************************************************************************************************/
39
template
<
typename
ImageT>
40
class
FootprintFunctor
{
41
public
:
42
FootprintFunctor
(ImageT
const
&
image
43
) :
_image
(image) {}
44
45
virtual
~FootprintFunctor
() = 0;
46
51
virtual
void
reset
() {}
52
virtual
void
reset
(
Footprint
const
&) {}
53
57
void
apply
(
Footprint
const
& foot,
58
int
const
margin=0
59
) {
60
reset
();
61
reset
(foot);
62
63
if
(foot.
getSpans
().empty()) {
64
return
;
65
}
66
67
geom::Box2I
const
bbox = foot.
getBBox
();
68
geom::Box2I
region = foot.
getRegion
();
69
if
(!region.
isEmpty
() &&
70
(!region.
contains
(bbox.
getMin
()) || !region.
contains
(bbox.
getMax
()))) {
71
throw
LSST_EXCEPT
(
72
lsst::pex::exceptions::LengthError,
73
(
boost::format
(
"Footprint with BBox (%d,%d) -- (%dx%d)"
74
"doesn't fit in image with BBox (%d,%d) -- (%dx%d)"
75
) % bbox.
getMinX
() % bbox.
getMinY
()
76
% bbox.
getMaxX
() % bbox.
getMaxY
()
77
% region.
getMinX
() % region.
getMinY
()
78
% region.
getMaxX
() % region.
getMaxY
()
79
).str()
80
);
81
}
82
83
// Current position of the locator (in the SpanList loop)
84
int
ox1 = 0, oy = 0;
85
86
int
const
x0
=
_image
.getX0();
87
int
const
y0
=
_image
.getY0();
88
89
typename
ImageT::xy_locator loc =
_image
.xy_at(-x0, -y0);
// Origin of the Image's pixels
90
91
int
const
width
=
_image
.getWidth();
92
int
const
height
=
_image
.getHeight();
93
for
(Footprint::SpanList::const_iterator siter = foot.
getSpans
().begin();
94
siter != foot.
getSpans
().end(); siter++) {
95
Span::Ptr
const
span = *siter;
96
97
int
const
y
= span->getY();
98
if
(y - y0 < margin || y - y0 >= height - margin) {
99
continue
;
100
}
101
int
sx0 = span->getX0();
102
int
sx1 = span->getX1();
103
if
(sx0 - x0 < margin) {
104
sx0 = margin +
x0
;
105
}
106
if
(sx1 - x0 >= width - margin) {
107
sx1 = width + x0 - margin - 1;
108
}
109
110
loc += lsst::afw::image::pair2I(sx0 - ox1, y - oy);
111
112
for
(
int
x
= sx0;
x
<= sx1; ++
x
, ++loc.x()) {
113
operator()
(loc,
x
, y);
114
}
115
116
ox1 = sx1 + 1; oy =
y
;
117
}
118
}
120
ImageT
const
&
getImage
()
const
{
return
_image
; }
121
126
virtual
void
operator()
(
typename
ImageT::xy_locator loc,
int
x
,
int
y
) = 0;
127
private
:
128
ImageT
const
_image
;
// The image that the Footprints live in
129
};
130
136
template
<
typename
ImageT>
137
FootprintFunctor<ImageT>::~FootprintFunctor
() {}
138
139
}}}
140
#endif
y
int y
Definition:
GaussianCentroid.cc:36
lsst::pex.config.history.format
def format
Definition:
history.py:127
lsst::afw::detection::FootprintFunctor::_image
ImageT const _image
Definition:
FootprintFunctor.h:128
lsst::afw::geom::Box2I::getMaxY
int getMaxY() const
Definition:
Box.h:129
Footprint.h
Represent a set of pixels of an arbitrary shape and size.
lsst::afw::geom::Box2I::contains
bool contains(Point2I const &point) const
Return true if the box contains the point.
lsst::afw::geom::Box2I::getMax
Point2I const getMax() const
Definition:
Box.h:127
lsst::afw::detection::FootprintFunctor::operator()
virtual void operator()(typename ImageT::xy_locator loc, int x, int y)=0
lsst::afw.display::x0
int const x0
Definition:
saturated.cc:45
lsst::afw::geom::Box2I
An integer coordinate rectangle.
Definition:
Box.h:53
image
table::Key< table::Array< Kernel::Pixel > > image
Definition:
FixedKernel.cc:117
lsst::afw::detection::FootprintFunctor::reset
virtual void reset()
Definition:
FootprintFunctor.h:51
lsst::afw.display::width
void ImageT ImageT int float saturatedPixelValue int const width
Definition:
saturated.cc:44
lsst::afw::geom::Box2I::getMinY
int getMinY() const
Definition:
Box.h:125
lsst::afw::detection::FootprintFunctor::apply
void apply(Footprint const &foot, int const margin=0)
Apply operator() to each pixel in the Footprint.
Definition:
FootprintFunctor.h:57
lsst::afw::geom::Box2I::getMinX
int getMinX() const
Definition:
Box.h:124
lsst::afw::detection::FootprintFunctor::getImage
ImageT const & getImage() const
Return the image.
Definition:
FootprintFunctor.h:120
x
double x
Definition:
ChebyshevBoundedField.cc:305
lsst::afw::geom::Box2I::isEmpty
bool isEmpty() const
Return true if the box contains no points.
Definition:
Box.h:166
lsst::afw::detection::Footprint
A set of pixels in an Image.
Definition:
Footprint.h:62
lsst::afw.display::height
void ImageT ImageT int float saturatedPixelValue int const height
Definition:
saturated.cc:44
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Definition:
Exception.h:46
lsst::afw::detection::Footprint::getSpans
SpanList & getSpans()
Definition:
Footprint.h:112
lsst::afw::detection::FootprintFunctor::~FootprintFunctor
virtual ~FootprintFunctor()=0
Definition:
FootprintFunctor.h:137
MaskedImage.h
Implementation of the Class MaskedImage.
lsst::afw::geom::Box2I::getMaxX
int getMaxX() const
Definition:
Box.h:128
lsst::afw::geom::Box2I::getMin
Point2I const getMin() const
Definition:
Box.h:123
lsst::afw.display::y0
int const y0
Definition:
saturated.cc:45
lsst::afw::detection::FootprintFunctor
A functor class to allow users to process all the pixels in a Footprint.
Definition:
FootprintFunctor.h:40
lsst::afw::detection::Footprint::getRegion
geom::Box2I const & getRegion() const
Return the corners of the MaskedImage the footprints live in.
Definition:
Footprint.h:209
lsst::afw::detection::FootprintFunctor::reset
virtual void reset(Footprint const &)
Definition:
FootprintFunctor.h:52
lsst::afw::detection::Footprint::getBBox
geom::Box2I getBBox() const
Return the Footprint's bounding box.
Definition:
Footprint.h:206
lsst::afw::detection::FootprintFunctor::FootprintFunctor
FootprintFunctor(ImageT const &image)
Definition:
FootprintFunctor.h:42
Generated on Thu Sep 24 2015 02:29:14 for LSSTApplications by
1.8.5