lsst.afw  16.0-10-gd1b3a1c94
SpanSet.cc
Go to the documentation of this file.
1 
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2016 AURA/LSST.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <https://www.lsstcorp.org/LegalNotices/>.
22  */
23 
24 #include <algorithm>
25 #include <iterator>
26 #include "lsst/afw/geom/SpanSet.h"
33 
34 namespace lsst {
35 namespace afw {
36 namespace geom {
37 namespace {
38 
39 /* These classes are used in the erode operator to quickly calculate the
40  * contents of the shrunken SpanSet
41  */
42 
43 struct PrimaryRun {
44  int m, y, xmin, xmax;
45 };
46 
47 bool comparePrimaryRun(PrimaryRun const& first, PrimaryRun const& second) {
48  if (first.y != second.y) {
49  return first.y < second.y;
50  } else if (first.m != second.m) {
51  return first.m < second.m;
52  } else {
53  return first.xmin < second.xmin;
54  }
55 }
56 
57 class ComparePrimaryRunY {
58 public:
59  bool operator()(PrimaryRun const& pr, int yval) { return pr.y < yval; }
60  bool operator()(int yval, PrimaryRun const& pr) { return yval < pr.y; }
61 };
62 
63 class ComparePrimaryRunM {
64 public:
65  bool operator()(PrimaryRun const& pr, int mval) { return pr.m < mval; }
66  bool operator()(int mval, PrimaryRun const& pr) { return mval < pr.m; }
67 };
68 
69 /* Determine if two spans overlap
70  *
71  * a First Span in comparison
72  * b Second Span in comparison
73  * compareY a boolean to control if the comparison takes into account the y position of the spans
74  */
75 bool spansOverlap(Span const& a, Span const& b, bool compareY = true) {
76  bool yTruth = true;
77  if (compareY) {
78  yTruth = a.getY() == b.getY();
79  }
80  return (yTruth && ((a.getMaxX() >= b.getMinX() && a.getMinX() <= b.getMinX()) ||
81  (b.getMaxX() >= a.getMinX() && b.getMinX() <= a.getMinX())))
82  ? true
83  : false;
84 }
85 
86 /* Determine if two spans are contiguous, that is they can overlap or the end of one span is
87  * one pixel before the beginning of the next
88  *
89  * a First Span in comparison
90  * b Second Span in comparison
91  * compareY a boolean to control if the comparison takes into account the y position of the spans
92  */
93 bool spansContiguous(Span const& a, Span const& b, bool compareY = true) {
94  bool yTruth(true);
95  if (compareY) {
96  yTruth = a.getY() == b.getY();
97  }
98  return (yTruth && ((a.getMaxX() + 1 >= b.getMinX() && a.getMinX() <= b.getMinX()) ||
99  (b.getMaxX() + 1 >= a.getMinX() && b.getMinX() <= a.getMinX())))
100  ? true
101  : false;
102 }
103 
104 /* Determine the intersection with a mask or its logical inverse
105  *
106  * spanSet - SpanSet object with which to intersect the mask
107  * mask - Mask object to be intersectedNot
108  * bitmask - bitpattern to used when deciding pixel membership in the mask
109  *
110  * Templates:
111  * T - pixel type of the mask
112  * invert - boolean indicating if the intersection is with the mask or the inverse of the mask
113  templated parameter to ensure the check is compiled away if it can be
114 */
115 template <typename T, bool invert>
116 std::shared_ptr<SpanSet> maskIntersect(SpanSet const& spanSet, image::Mask<T> const& mask, T bitmask) {
117  // This vector will store our output spans
118  std::vector<Span> newVec;
119  auto maskBBox = mask.getBBox();
120  for (auto const& spn : spanSet) {
121  // Variable to mark if a new span has been started
122  // Reset the started flag for each different span
123  bool started = false;
124  // Limit the y iteration to be within the mask's bounding box
125  int y = spn.getY();
126  if (y < maskBBox.getMinY() || y > maskBBox.getMaxY()) {
127  continue;
128  }
129  // Reset the min and max variables
130  int minX = 0;
131  int maxX = 0;
132  // Limit the scope of iteration to be within the mask's bounds
133  int startX = std::max(spn.getMinX(), maskBBox.getMinX());
134  int endX = std::min(spn.getMaxX(), maskBBox.getMaxX());
135  for (int x = startX; x <= endX; ++x) {
136  // Find if the pixel matches the given bit pattern
137  bool pixelCompare = mask.get0(x, y) & bitmask;
138  // if the templated boolean indicates the compliment of the mask is desired, invert the
139  // pixel comparison
140  if (invert) {
141  pixelCompare = !pixelCompare;
142  }
143  // If the pixel is to be included in the operation, start or append recording values
144  // needed to later construct a Span
145  if (pixelCompare) {
146  if (!started) {
147  started = true;
148  minX = x;
149  maxX = x;
150  } else {
151  maxX = x;
152  }
153  if (x == endX) {
154  // We have reached the end of a row and the pixel evaluates true, should add the
155  // Span
156  newVec.push_back(Span(y, minX, maxX));
157  }
158  } else if (started) {
159  // A span was started but the current pixel is not to be included in the new SpanSet,
160  // the current SpanSet should be close and added to the vector
161  newVec.push_back(Span(y, minX, maxX));
162  started = false;
163  }
164  }
165  }
166  return std::make_shared<SpanSet>(std::move(newVec));
167 }
168 
169 } // namespace
170 
171 // Default constructor, creates a null SpanSet which may be useful for
172 // comparisons
173 SpanSet::SpanSet() : _spanVector(), _bbox(), _area(0) {}
174 
175 // Construct a SpanSet from an lsst::geom::Box2I object
176 SpanSet::SpanSet(lsst::geom::Box2I const& box) : _bbox(box), _area(box.getArea()) {
177  int beginY = box.getMinY();
178 
179  int beginX = box.getMinX();
180  int maxX = box.getMaxX();
181 
182  for (int i = beginY; i < _bbox.getEndY(); ++i) {
183  _spanVector.push_back(Span(i, beginX, maxX));
184  }
185 }
186 
187 // Construct a SpanSet from a std vector by copying
188 SpanSet::SpanSet(std::vector<Span> const& vec, bool normalize) : _spanVector(vec) {
189  // If the incoming vector is zero, should create an empty spanSet
190  if (_spanVector.empty()) {
191  _bbox = lsst::geom::Box2I();
192  _area = 0;
193  } else {
194  if (normalize) {
195  _runNormalize();
196  }
197  _initialize();
198  }
199 }
200 
201 // Construct a SpanSet from a std vector by moving
202 SpanSet::SpanSet(std::vector<Span>&& vec, bool normalize) : _spanVector(std::move(vec)) {
203  // If the incoming vector is zero, should create an empty SpanSet
204  if (_spanVector.size() == 0) {
205  _bbox = lsst::geom::Box2I();
206  _area = 0;
207  } else {
208  if (normalize) {
209  _runNormalize();
210  }
211  _initialize();
212  }
213 }
214 
215 void SpanSet::_runNormalize() {
216  // This bit of code is not safe if the _spanVector is empty. However, this function will only be executed
217  // with a non-empty _spanVector as it is called internally by the class constructors, and cannot be
218  // executed from outside the class
219 
220  // Ensure the span set is sorted according to Span < operator
221  std::sort(_spanVector.begin(), _spanVector.end());
222 
223  // Create a new vector to hold the possibly combined Spans
224  std::vector<Span> newSpans;
225  // Reserve the size of the original as it is the maximum possible size
226  newSpans.reserve(_spanVector.size());
227  // push back the first element, as it is certain to be included
228  newSpans.push_back(*_spanVector.begin());
229 
230  // With the sorted span array, spans that are contiguous with the end of the last span in the new vector
231  // should be combined with the last span in the new vector. Only when there is no longer continuity
232  // between spans should a new span be added.
233  // Start iteration from "1" as the 0th element is already in the newSpans vector
234  for (auto iter = ++(_spanVector.begin()); iter != _spanVector.end(); ++iter) {
235  auto& newSpansEnd = newSpans.back();
236  if (spansContiguous(newSpansEnd, *iter)) {
237  newSpansEnd = Span(newSpansEnd.getY(), std::min(newSpansEnd.getMinX(), iter->getMinX()),
238  std::max(newSpansEnd.getMaxX(), iter->getMaxX()));
239  } else {
240  newSpans.push_back(Span(*iter));
241  }
242  }
243 
244  // Set the new normalized vector of spans to the internal span vector container
245  _spanVector = std::move(newSpans);
246 }
247 
248 void SpanSet::_initialize() {
249  /* This function exists to handle common functionality for most of the constructors. It calculates the
250  * bounding box for the SpanSet, and the area covered by the SpanSet
251  */
252 
253  /* Because the array is sorted, the minimum and maximum values for Y will
254  be in the first and last elements, only need to find the min and max X
255  values */
256 
257  // This bit of code will only be executed with a non-empty _spanVector internally
258  // and is not accessable from outside the class
259 
260  int minX = _spanVector[0].getMinX();
261  int maxX = _spanVector[0].getMaxX();
262  _area = 0;
263 
264  for (const auto& span : _spanVector) {
265  if (span.getMinX() < minX) {
266  minX = span.getMinX();
267  }
268  if (span.getMaxX() > maxX) {
269  maxX = span.getMaxX();
270  }
271  // Plus one, because end point is inclusive
272  _area += span.getMaxX() - span.getMinX() + 1;
273  }
274  _bbox = lsst::geom::Box2I(lsst::geom::Point2I(minX, _spanVector.front().getY()),
275  lsst::geom::Point2I(maxX, _spanVector.back().getY()));
276 }
277 
278 // Getter for the area property
279 std::size_t SpanSet::getArea() const { return _area; }
280 
281 // Getter for the bounding box of the SpanSet
282 lsst::geom::Box2I SpanSet::getBBox() const { return _bbox; }
283 
284 /* Here is a description of how the _makeLabels and _label function works. In the
285  _makeLabels function, a vector is created with the same number of elements as
286  spans in the SpanSet. This vector will contain the label for each Span in the
287  SpanSet. These labels correspond to which connected region the span falls in.
288  If the whole SpanSet is connected than there will only be one region and every
289  Span will be labeled with a 1. If there are two regions (i.e. there are points
290  in between not contained in the SpanSet) then Some of the Spans will be labeled
291  1, and the rest labeled 2. _makeLabels also sorts each of the Spans in the
292  current span into an unordered map that is indexed by the y position of each
293  span. This allows efficient lookups of corresponding rows.
294 
295  The function loops over all the Spans in the Spanset. If the Span has not been
296  labeled, the _label function is called, with the current span, the vector
297  containing the labels, the label for the current region under consideration,
298  and the indexed map of Spans.
299 
300  The _label function will then loop over all Spans in the SpanSet looking for
301  rows adjacent to the currently being labeled Span which overlap in the x
302  dimension and have not yet been labeled, and mark them with the current label,
303  and recursively call the _label function with the adjacent row as the new Span
304  under consideration. This results in all Spans which overlap each other in x
305  being labeled with the current label.
306 
307  Once _label reaches the end of Spans which meet it's criteria, control falls
308  back to the _makeLabels function and the current label is incremented. The
309  function then moves onto the next Span in the SpanSet which has not been
310  labeled. If all spans were labeled in the recursive call the loop falls to the
311  end, and the label vector and one past the last label number (number of labels +1)
312  are returned to the caller. If instead _makeLabels finds a Span that has not
313  been labeled, the next label is assigned and the process is repeated until
314  all Spans have been labeled.
315  */
316 
317 void SpanSet::_label(
318  Span const& spn, std::vector<std::size_t>& labelVector, std::size_t currentLabel,
320  auto currentIndex = spn.getY();
321  if (currentIndex > 0) {
322  // loop over the prevous row
323  for (auto const& tup : sortMap[currentIndex - 1]) {
324  if (!labelVector[tup.first] && spansOverlap(spn, *(tup.second), false)) {
325  labelVector[tup.first] = currentLabel;
326  _label(*(tup.second), labelVector, currentLabel, sortMap);
327  }
328  }
329  }
330  if (currentIndex <= _spanVector.back().getY() - 1) {
331  // loop over the next row
332  for (auto& tup : sortMap[currentIndex + 1]) {
333  if (!labelVector[tup.first] && spansOverlap(spn, *(tup.second), false)) {
334  labelVector[tup.first] = currentLabel;
335  _label(*(tup.second), labelVector, currentLabel, sortMap);
336  }
337  }
338  }
339 }
340 
341 std::pair<std::vector<std::size_t>, std::size_t> SpanSet::_makeLabels() const {
342  std::vector<std::size_t> labelVector(_spanVector.size(), 0);
343  std::size_t currentLabel = 1;
344  std::size_t index = 0;
345  // Create a sorted array of arrays
347  std::size_t tempIndex = 0;
348  for (auto const& spn : _spanVector) {
349  sortMap[spn.getY()].push_back(std::make_pair(tempIndex, &spn));
350  tempIndex++;
351  }
352  for (auto const& currentSpan : _spanVector) {
353  if (!labelVector[index]) {
354  labelVector[index] = currentLabel;
355  _label(currentSpan, labelVector, currentLabel, sortMap);
356  /* At this point we have recursed enough to reach all of the connected
357  * region, and should increment the label such that any spans not
358  * labeled in the first loop will get a new value. If all of the spans
359  * were connected in the first pass, the rest of this loop will just
360  * fall though.
361  */
362  ++currentLabel;
363  }
364  ++index;
365  }
366  return std::pair<std::vector<std::size_t>, std::size_t>(labelVector, currentLabel);
367 }
368 
369 bool SpanSet::isContiguous() const {
370  auto labeledPair = _makeLabels();
371  // Here we want to check if there is only one label. Since _makeLabels always increments
372  // at the end of each loop, we need to compare against the number 2. I.e. if everything
373  // gets labeled 1, the label counter will increment to 2, and the if statement will always
374  // be false and _makeLabels will fall through to the end and return to here.
375  return labeledPair.second <= 2;
376 }
377 
379  auto labeledPair = _makeLabels();
380  auto labels = labeledPair.first;
381  auto numberOfLabels = labeledPair.second;
383  // As the number of labels is known, the number of SpanSets to be created is also known
384  // make a vector of vectors to hold the Spans which will correspond to each SpanSet
385  std::vector<std::vector<Span>> subSpanLists(numberOfLabels - 1);
386 
387  // if numberOfLabels is 1, that means a null SpanSet is being operated on,
388  // and we should return like
389  if (numberOfLabels == 1) {
390  subRegions.push_back(std::make_shared<SpanSet>());
391  return subRegions;
392  }
393  subRegions.reserve(numberOfLabels - 1);
394 
395  // loop over the current SpanSet's spans sorting each of the spans according to the label
396  // that was assigned
397  for (std::size_t i = 0; i < _spanVector.size(); ++i) {
398  subSpanLists[labels[i] - 1].push_back(_spanVector[i]);
399  }
400  // Transform each of the vectors of Spans into a SpanSet
401  for (std::size_t i = 0; i < numberOfLabels - 1; ++i) {
402  subRegions.push_back(std::make_shared<SpanSet>(subSpanLists[i]));
403  }
404  return subRegions;
405 }
406 
409  setMask(tempMask, static_cast<image::MaskPixel>(1));
410  auto erodedSpanSet = eroded(1, Stencil::CIRCLE);
411  erodedSpanSet->clearMask(tempMask, static_cast<image::MaskPixel>(1));
412  return SpanSet::fromMask(tempMask);
413 }
414 
416  // Function to create a new SpanSet which is a copy of this, shifted by x and y
417  return makeShift(x, y);
418 }
419 
421  // Function to create a new SpanSet which is a copy of this, shifted by an extent object
422  return makeShift(offset.getX(), offset.getY());
423 }
424 
425 std::shared_ptr<SpanSet> SpanSet::makeShift(int x, int y) const {
426  // Implementation method common to all overloads of the shiftedBy method
427  std::vector<Span> tempVec;
428  tempVec.reserve(_spanVector.size());
429  for (auto const& spn : _spanVector) {
430  tempVec.push_back(Span(spn.getY() + y, spn.getMinX() + x, spn.getMaxX() + x));
431  }
432  return std::make_shared<SpanSet>(std::move(tempVec), false);
433 }
434 
436  /* Return a copy of the current SpanSet but only with values which are contained within
437  * the supplied box
438  */
439  std::vector<Span> tempVec;
440  for (auto const& spn : _spanVector) {
441  if (spn.getY() >= box.getMinY() && spn.getY() <= box.getMaxY() &&
442  spansOverlap(spn, Span(spn.getY(), box.getMinX(), box.getMaxX()))) {
443  tempVec.push_back(Span(spn.getY(), std::max(box.getMinX(), spn.getMinX()),
444  std::min(box.getMaxX(), spn.getMaxX())));
445  }
446  }
447  return std::make_shared<SpanSet>(std::move(tempVec), false);
448 }
449 
450 bool SpanSet::overlaps(SpanSet const& other) const {
451  // Function to check if two SpanSets overlap
452  for (auto const& otherSpan : other) {
453  for (auto const& spn : _spanVector) {
454  if (spansOverlap(otherSpan, spn)) {
455  return true;
456  }
457  }
458  }
459  return false;
460 }
461 
462 bool SpanSet::contains(SpanSet const& other) const {
463  // Handle null SpanSet passed as other
464  if (other.empty()) {
465  return false;
466  }
467  // Function to check if a SpanSet is entirely contained within this
468  for (auto const& otherSpn : other) {
469  std::size_t counter = 0;
470  for (auto const& spn : _spanVector) {
471  // Check that the end points of the span from other are contained in the
472  // span from this
473  if (spn.contains(lsst::geom::Point2I(otherSpn.getMinX(), otherSpn.getY())) &&
474  spn.contains(lsst::geom::Point2I(otherSpn.getMaxX(), otherSpn.getY()))) {
475  ++counter;
476  }
477  }
478  // if counter is equal to zero, then the current span from other is not
479  // contained in any span in this, and the function should return false
480  // short circuiting any other spans from other
481  if (counter == 0) {
482  return false;
483  }
484  }
485  return true;
486 }
487 
488 bool SpanSet::contains(lsst::geom::Point2I const& point) const {
489  // Check to see if a given point is found within any spans in this
490  for (auto& spn : _spanVector) {
491  if (spn.contains(point)) {
492  return true;
493  }
494  }
495  return false;
496 }
497 
499  // Find the centroid of the SpanSet
500  std::size_t n = 0;
501  double xc = 0, yc = 0;
502  for (auto const& spn : _spanVector) {
503  int const y = spn.getY();
504  int const x0 = spn.getMinX();
505  int const x1 = spn.getMaxX();
506  int const npix = x1 - x0 + 1;
507 
508  n += npix;
509  xc += npix * 0.5 * (x1 + x0);
510  yc += npix * y;
511  }
512  assert(n == _area);
513 
514  return lsst::geom::Point2D(xc / _area, yc / _area);
515 }
516 
518  // Compute the shape of the SpanSet
520  double const xc = cen.getX();
521  double const yc = cen.getY();
522 
523  double sumxx = 0, sumxy = 0, sumyy = 0;
524  for (auto const& spn : _spanVector) {
525  int const y = spn.getY();
526  int const x0 = spn.getX0();
527  int const x1 = spn.getX1();
528  int const npix = x1 - x0 + 1;
529 
530  for (int x = x0; x <= x1; ++x) {
531  sumxx += (x - xc) * (x - xc);
532  }
533  sumxy += npix * (0.5 * (x1 + x0) - xc) * (y - yc);
534  sumyy += npix * (y - yc) * (y - yc);
535  }
536 
537  return ellipses::Quadrupole(sumxx / _area, sumyy / _area, sumxy / _area);
538 }
539 
541  // Return a dilated SpanSet made with the given stencil, by creating a SpanSet
542  // from the stencil and forwarding to the appropriate overloaded method
543  std::shared_ptr<SpanSet> stencilToSpanSet = fromShape(r, s);
544  return dilated(*stencilToSpanSet);
545 }
546 
548  // Handle a null SpanSet nothing should be dilated
549  if (other.size() == 0) {
550  return std::make_shared<SpanSet>(_spanVector.begin(), _spanVector.end(), false);
551  }
552 
553  // Return a dilated Spanset by the given SpanSet
554  std::vector<Span> tempVec;
555 
556  for (auto const& spn : _spanVector) {
557  for (auto const& otherSpn : other) {
558  int const xmin = spn.getMinX() + otherSpn.getMinX();
559  int const xmax = spn.getMaxX() + otherSpn.getMaxX();
560  int const yval = spn.getY() + otherSpn.getY();
561  tempVec.push_back(Span(yval, xmin, xmax));
562  }
563  }
564  // Allow constructor to handle merging adjacent and overlapping spans
565  return std::make_shared<SpanSet>(std::move(tempVec));
566 }
567 
569  // Return an eroded SpanSet made with the given stencil, by creating a SpanSet
570  // from the stencil and forwarding to the appropriate overloaded method
571  std::shared_ptr<SpanSet> stencilToSpanSet = fromShape(r, s);
572  return eroded(*stencilToSpanSet);
573 }
574 
576  // Handle a null SpanSet nothing should be eroded
577  if (other.size() == 0 || this->size() == 0) {
578  return std::make_shared<SpanSet>(_spanVector.begin(), _spanVector.end(), false);
579  }
580 
581  // Return a SpanSet eroded by the given SpanSet
582  std::vector<Span> tempVec;
583 
584  // Calculate all possible primary runs.
585  std::vector<PrimaryRun> primaryRuns;
586  for (auto const& spn : _spanVector) {
587  int m = 0;
588  for (auto const& otherSpn : other) {
589  if ((otherSpn.getMaxX() - otherSpn.getMinX()) <= (spn.getMaxX() - spn.getMinX())) {
590  int xmin = spn.getMinX() - otherSpn.getMinX();
591  int xmax = spn.getMaxX() - otherSpn.getMaxX();
592  int y = spn.getY() - otherSpn.getY();
593  primaryRuns.push_back(PrimaryRun({m, y, xmin, xmax}));
594  }
595  ++m;
596  }
597  }
598 
599  // Iterate over the primary runs in such a way that we consider all values of m
600  // for a given y, then all m for y+1 etc.
601  std::sort(primaryRuns.begin(), primaryRuns.end(), comparePrimaryRun);
602 
603  for (int y = primaryRuns.front().y; y <= primaryRuns.back().y; ++y) {
604  auto yRange = std::equal_range(primaryRuns.begin(), primaryRuns.end(), y, ComparePrimaryRunY());
605 
606  /* Discard runs for any value of y for which we find fewer groups than M,
607  * the total Y range of the structuring element. This is step 3.1 of the
608  * Kim et al. algorithm.
609  */
610  // Plus one because end points are inclusive
611  auto otherYRange = other.back().getY() - other.front().getY() + 1;
612  if (std::distance(yRange.first, yRange.second) < otherYRange) {
613  continue;
614  }
615 
616  /* "good" runs are those which are covered by each value of m, ie by each
617  * row in the structuring element. Our algorithm will consider each value
618  * of m in turn, gradually whittling down the list of good runs, then
619  * finally convert the remainder into Spans.
620  */
621  std::list<PrimaryRun> goodRuns;
622 
623  for (int m = 0; m < otherYRange; ++m) {
624  auto mRange = std::equal_range(yRange.first, yRange.second, m, ComparePrimaryRunM());
625  if ((mRange.first == mRange.second)) {
626  // If a particular m is missing, we known that this y contains
627  // no good runs; this is equivalent to Kim et al. step 3.2.
628  goodRuns.clear();
629  } else {
630  // Consolidate all primary runs at this m so that they don't overlap.
631  std::list<PrimaryRun> candidateRuns;
632  int startX = mRange.first->xmin;
633  int endX = mRange.first->xmax;
634  for (auto run = mRange.first + 1; run != mRange.second; ++run) {
635  if (run->xmin > endX) {
636  // Start of a new run
637  candidateRuns.push_back(PrimaryRun{m, y, startX, endX});
638  startX = run->xmin;
639  endX = run->xmax;
640  } else {
641  // Continuation of an existing run
642  endX = run->xmax;
643  }
644  }
645  candidateRuns.push_back(PrimaryRun{m, y, startX, endX});
646 
647  // Otherwise, calculate the intersection of candidate runs at
648  // this m with good runs from all previous m.
649  if (m == 0) {
650  // For m = 0 we have nothing to compare to; all runs are accepted
651  std::swap(goodRuns, candidateRuns);
652  } else {
653  std::list<PrimaryRun> newlist;
654  for (auto& good : goodRuns) {
655  for (auto& cand : candidateRuns) {
656  int start = std::max(good.xmin, cand.xmin);
657  int end = std::min(good.xmax, cand.xmax);
658  if (end >= start) {
659  newlist.push_back(PrimaryRun({m, y, start, end}));
660  }
661  }
662  }
663  std::swap(newlist, goodRuns);
664  }
665  }
666  }
667  for (auto& run : goodRuns) {
668  tempVec.push_back(Span(run.y, run.xmin, run.xmax));
669  }
670  }
671  return std::make_shared<SpanSet>(std::move(tempVec));
672 }
673 
674 bool SpanSet::operator==(SpanSet const& other) const {
675  // Check the equivalence of this SpanSet with another
676  return _spanVector == other._spanVector;
677 }
678 
679 bool SpanSet::operator!=(SpanSet const& other) const {
680  // Check the equivalence of this SpanSet with another
681  return _spanVector != other._spanVector;
682 }
683 
685  // Create a SpanSet from a given Stencil
686  std::vector<Span> tempVec;
687  tempVec.reserve(2 * r + 1);
688  switch (s) {
689  case Stencil::CIRCLE:
690  for (auto dy = -r; dy <= r; ++dy) {
691  int dx = static_cast<int>(sqrt(r * r - dy * dy));
692  tempVec.push_back(Span(dy + offset.getY(), -dx + offset.getX(), dx + offset.getX()));
693  }
694  break;
695  case Stencil::MANHATTAN:
696  for (auto dy = -r; dy <= r; ++dy) {
697  int dx = r - abs(dy);
698  tempVec.push_back(Span(dy + offset.getY(), -dx + offset.getX(), dx + offset.getX()));
699  }
700  break;
701  case Stencil::BOX:
702  for (auto dy = -r; dy <= r; ++dy) {
703  int dx = r;
704  tempVec.push_back(Span(dy + offset.getY(), -dx + offset.getX(), dx + offset.getX()));
705  }
706  break;
707  }
708  return std::make_shared<SpanSet>(std::move(tempVec), false);
709 }
710 
712  ellipses::PixelRegion pr(ellipse);
713  return std::make_shared<SpanSet>(pr.begin(), pr.end());
714 }
715 
717  // Check if the bounding boxes overlap, if not return null SpanSet
718  if (!_bbox.overlaps(other.getBBox())) {
719  return std::make_shared<SpanSet>();
720  }
721  // Handel intersecting a SpanSet with itself
722  if (other == *this) {
723  return std::make_shared<SpanSet>(this->_spanVector);
724  }
725  std::vector<Span> tempVec;
726  auto otherIter = other.begin();
727  for (auto const& spn : _spanVector) {
728  while (otherIter != other.end() && otherIter->getY() <= spn.getY()) {
729  if (spansOverlap(spn, *otherIter)) {
730  auto newMin = std::max(spn.getMinX(), otherIter->getMinX());
731  auto newMax = std::min(spn.getMaxX(), otherIter->getMaxX());
732  auto newSpan = Span(spn.getY(), newMin, newMax);
733  tempVec.push_back(newSpan);
734  }
735  ++otherIter;
736  }
737  }
738  return std::make_shared<SpanSet>(std::move(tempVec));
739 }
740 
742  // Check if the bounding boxes overlap, if not simply return a copy of this
743  if (!getBBox().overlaps(other.getBBox())) {
744  return std::make_shared<SpanSet>(this->begin(), this->end());
745  }
746  // Handle calling a SpanSet's intersectNot with itself as an argument
747  if (other == *this) {
748  return std::make_shared<SpanSet>();
749  }
750  /* This function must find all the areas in this and not in other. These SpanSets
751  * may be overlapping with this less than other a1| b1| a2| b2|,
752  * with this greater than other b1| a1| b2| a2|,
753  * with this containing other a1| b1| b2| a2|,
754  * or with other containing this b1| a1| a2| b2|
755  */
756  std::vector<Span> tempVec;
757  auto otherIter = other.begin();
758  for (auto const& spn : _spanVector) {
759  bool added = false;
760  bool spanStarted = false;
761  int spanBottom = 0;
762  while (otherIter != other.end() && otherIter->getY() <= spn.getY()) {
763  if (spansOverlap(spn, *otherIter)) {
764  added = true;
765  /* To handle one span containing the other, the spans will be added
766  * piecewise, and let the SpanSet constructor normalize spans which
767  * end up contiguous. In the case where this is contained in other,
768  * these statements will all be false, and nothing will be added,
769  * which is the expected behavior.
770  *
771  * Intersection with the logical not of another SpanSet requires that the Intersection
772  * be tested against the condition that multiple Spans may be present in the other
773  * SpanSet at the same Y coordinate. I.E. If one row in *this would contain two
774  * disconnected Spans in other, the result should be three new Spans.
775  */
776  // Check if a span is in the process of being created
777  if (!spanStarted) {
778  // If the minimum value of the Span in *this is less than that of other, add a new Span
779  if (spn.getMinX() < otherIter->getMinX()) {
780  tempVec.push_back(Span(spn.getY(), spn.getMinX(), otherIter->getMinX() - 1));
781  }
782  // Conversely if the maximum value of the Span in *this is greater than that of other,
783  // Start a new span, and record what the minimum value of that span should be. This is
784  // because SpanSets can be disconnected, and the function must check if there are any
785  // additional Spans which fall in the same row
786  if (spn.getMaxX() > otherIter->getMaxX()) {
787  spanStarted = true;
788  spanBottom = otherIter->getMaxX() + 1;
789  }
790  } else {
791  // A span is in the process of being created and should be finished and added
792  tempVec.push_back(
793  Span(spn.getY(), spanBottom, std::min(spn.getMaxX(), otherIter->getMinX() - 1)));
794  spanStarted = false;
795  // Check if the span in *this extends past that of the Span from other, if so
796  // begin a new Span
797  if (spn.getMaxX() > otherIter->getMaxX()) {
798  spanStarted = true;
799  spanBottom = otherIter->getMaxX() + 1;
800  }
801  }
802  }
803  if (otherIter->getMaxX() > spn.getMaxX()) {
804  break;
805  }
806  ++otherIter;
807  }
808  // Check if a span has been started but not finished, if that is the case that means there are
809  // no further spans on this row to consider and the span should be closed and added
810  if (spanStarted) {
811  tempVec.push_back(Span(spn.getY(), spanBottom, spn.getMaxX()));
812  }
813  /* If added is still zero, that means it did not overlap any of the spans in other
814  * and should be included in the new span
815  */
816  if (!added) {
817  tempVec.push_back(Span(spn));
818  }
819  }
820  return std::make_shared<SpanSet>(std::move(tempVec));
821 }
822 
824  /* Simply include Spans from both SpanSets in a new vector and let the SpanSet
825  * constructor normalize any of the SpanSets which may be contiguous
826  */
827  std::size_t combineSize = size() + other.size();
828  std::vector<Span> tempVec;
829  tempVec.reserve(combineSize);
830  // Copy this
831  tempVec.insert(tempVec.end(), _spanVector.begin(), _spanVector.end());
832  // Copy other
833  tempVec.insert(tempVec.end(), other.begin(), other.end());
834  return std::make_shared<SpanSet>(std::move(tempVec));
835 }
836 
838  // Transform points in SpanSet by the LinearTransform
840 }
841 
843  // Transform points in SpanSet by the AffineTransform
844  return transformedBy(*makeTransform(t));
845 }
846 
848  // Transform points in SpanSet by Transform<Point2Endpoint, Point2Endpoint>
849  // Transform the original bounding box
850  lsst::geom::Box2D newBBoxD;
852  fromCorners.reserve(4);
853  for (auto const& fc : _bbox.getCorners()) {
854  fromCorners.emplace_back(lsst::geom::Point2D(fc));
855  }
856  auto toPoints = t.applyForward(fromCorners);
857  for (auto const& tc : toPoints) {
858  newBBoxD.include(tc);
859  }
860 
861  lsst::geom::Box2I newBBoxI(newBBoxD);
862 
864  newBoxPoints.reserve(newBBoxI.getWidth());
865  std::vector<Span> tempVec;
866  for (int y = newBBoxI.getBeginY(); y < newBBoxI.getEndY(); ++y) {
867  bool inSpan = false; // Are we in a span?
868  int start = -1; // Start of span
869 
870  // vectorize one row at a time (vectorizing the whole bbox would further improve performance
871  // but could lead to memory issues for very large bounding boxes)
872  newBoxPoints.clear();
873  for (int x = newBBoxI.getBeginX(); x < newBBoxI.getEndX(); ++x) {
874  newBoxPoints.emplace_back(lsst::geom::Point2D(x, y));
875  }
876  auto oldBoxPoints = t.applyInverse(newBoxPoints);
877  auto oldBoxPointIter = oldBoxPoints.cbegin();
878  for (int x = newBBoxI.getBeginX(); x < newBBoxI.getEndX(); ++x, ++oldBoxPointIter) {
879  auto p = *oldBoxPointIter;
880  int const xSource = std::floor(0.5 + p.getX());
881  int const ySource = std::floor(0.5 + p.getY());
882 
883  if (contains(lsst::geom::Point2I(xSource, ySource))) {
884  if (!inSpan) {
885  inSpan = true;
886  start = x;
887  }
888  } else if (inSpan) {
889  inSpan = false;
890  tempVec.push_back(Span(y, start, x - 1));
891  }
892  }
893  if (inSpan) {
894  tempVec.push_back(Span(y, start, newBBoxI.getMaxX()));
895  }
896  }
897  return std::make_shared<SpanSet>(std::move(tempVec));
898 }
899 
900 template <typename ImageT>
902  bool doClip) const {
904  if (region.isEmpty()) {
905  bbox = image.getBBox();
906  } else {
907  bbox = region;
908  }
909  auto setterFunc = [](lsst::geom::Point2I const& point, ImageT& out, ImageT in) { out = in; };
910  try {
911  if (doClip) {
912  auto tmpSpan = this->clippedTo(bbox);
913  tmpSpan->applyFunctor(setterFunc, image, val);
914  } else {
915  applyFunctor(setterFunc, image, val);
916  }
919  "Footprint Bounds Outside image, set doClip to true");
920  }
921 }
922 
923 template <typename T>
924 void SpanSet::setMask(image::Mask<T>& target, T bitmask) const {
925  // Use a lambda to set bits in a mask at the locations given by SpanSet
926  auto targetArray = target.getArray();
927  auto xy0 = target.getBBox().getMin();
928  auto maskFunctor = [](lsst::geom::Point2I const& point,
930  T bitmask) { maskVal |= bitmask; };
931  applyFunctor(maskFunctor, ndarray::ndImage(targetArray, xy0), bitmask);
932 }
933 
934 template <typename T>
935 void SpanSet::clearMask(image::Mask<T>& target, T bitmask) const {
936  // Use a lambda to clear bits in a mask at the locations given by SpanSet
937  auto targetArray = target.getArray();
938  auto xy0 = target.getBBox().getMin();
939  auto clearMaskFunctor = [](lsst::geom::Point2I const& point,
941  T bitmask) { maskVal &= ~bitmask; };
942  applyFunctor(clearMaskFunctor, ndarray::ndImage(targetArray, xy0), bitmask);
943 }
944 
945 template <typename T>
947  return maskIntersect<T, false>(*this, other, bitmask);
948 }
949 
950 template <typename T>
952  return maskIntersect<T, true>(*this, other, bitmask);
953 }
954 
955 template <typename T>
957  auto comparator = [bitmask](T pixelValue) { return (pixelValue & bitmask); };
958  auto spanSetFromMask = fromMask(other, comparator);
959  return union_(*spanSetFromMask);
960 }
961 
962 namespace {
963 // Singleton helper class that manages the schema and keys for the persistence of SpanSets
964 class SpanSetPersistenceHelper {
965 public:
966  table::Schema spanSetSchema;
967  table::Key<int> spanY;
968  table::Key<int> spanX0;
969  table::Key<int> spanX1;
970 
971  static SpanSetPersistenceHelper const& get() {
972  static SpanSetPersistenceHelper instance;
973  return instance;
974  }
975 
976  // No copying
977  SpanSetPersistenceHelper(const SpanSetPersistenceHelper&) = delete;
978  SpanSetPersistenceHelper& operator=(const SpanSetPersistenceHelper&) = delete;
979 
980  // No Moving
981  SpanSetPersistenceHelper(SpanSetPersistenceHelper&&) = delete;
982  SpanSetPersistenceHelper& operator=(SpanSetPersistenceHelper&&) = delete;
983 
984 private:
985  SpanSetPersistenceHelper()
986  : spanSetSchema(),
987  spanY(spanSetSchema.addField<int>("y", "The row of the span", "pixel")),
988  spanX0(spanSetSchema.addField<int>("x0", "First column of span (inclusive)", "pixel")),
989  spanX1(spanSetSchema.addField<int>("x1", "Second column of span (inclusive)", "pixel")) {
990  spanSetSchema.getCitizen().markPersistent();
991  }
992 };
993 
994 std::string getSpanSetPersistenceName() { return "SpanSet"; }
995 
996 class SpanSetFactory : public table::io::PersistableFactory {
997 public:
998  virtual std::shared_ptr<table::io::Persistable> read(InputArchive const& archive,
999  CatalogVector const& catalogs) const {
1000  // There should only be one catalog saved
1001  LSST_ARCHIVE_ASSERT(catalogs.size() == 1u);
1002  // Get the catalog with the spans
1003  auto spansCatalog = catalogs.front();
1004  // Retrieve the keys that will be used to reference the catalog
1005  auto const& keys = SpanSetPersistenceHelper::get();
1006  // Construct a temporary container which will later be turned into the SpanSet
1007  std::vector<Span> tempVec;
1008  tempVec.reserve(spansCatalog.size());
1009  for (auto const& val : spansCatalog) {
1010  tempVec.push_back(Span(val.get(keys.spanY), val.get(keys.spanX0), val.get(keys.spanX1)));
1011  }
1012  return std::make_shared<SpanSet>(std::move(tempVec));
1013  }
1014  explicit SpanSetFactory(std::string const& name) : table::io::PersistableFactory(name) {}
1015 };
1016 
1017 // insert the factory into the registry (instantiating an instance is sufficient, because the code
1018 // that does the work is in the base class ctor)
1019 SpanSetFactory registration(getSpanSetPersistenceName());
1020 
1021 } // namespace
1022 
1023 std::string SpanSet::getPersistenceName() const { return getSpanSetPersistenceName(); }
1024 
1025 void SpanSet::write(OutputArchiveHandle& handle) const {
1026  auto const& keys = SpanSetPersistenceHelper::get();
1027  auto spanCat = handle.makeCatalog(keys.spanSetSchema);
1028  spanCat.reserve(size());
1029  for (auto const& val : *this) {
1030  auto record = spanCat.addNew();
1031  record->set(keys.spanY, val.getY());
1032  record->set(keys.spanX0, val.getX0());
1033  record->set(keys.spanX1, val.getX1());
1034  }
1035  handle.saveCatalog(spanCat);
1036 }
1037 
1038 //
1039 // Explicit instantiations
1040 #define INSTANTIATE_IMAGE_TYPE(T) \
1041  template void SpanSet::setImage<T>(image::Image<T> & image, T val, \
1042  lsst::geom::Box2I const& region = lsst::geom::Box2I(), \
1043  bool doClip = false) const;
1044 
1045 #define INSTANTIATE_MASK_TYPE(T) \
1046  template void SpanSet::setMask<T>(image::Mask<T> & target, T bitmask) const; \
1047  template void SpanSet::clearMask<T>(image::Mask<T> & target, T bitmask) const; \
1048  template std::shared_ptr<SpanSet> SpanSet::intersect<T>(image::Mask<T> const& other, T bitmask) const; \
1049  template std::shared_ptr<SpanSet> SpanSet::intersectNot<T>(image::Mask<T> const& other, T bitmask) \
1050  const; \
1051  template std::shared_ptr<SpanSet> SpanSet::union_<T>(image::Mask<T> const& other, T bitmask) const;
1052 
1056 INSTANTIATE_IMAGE_TYPE(float);
1057 INSTANTIATE_IMAGE_TYPE(double);
1058 
1060 } // namespace geom
1061 } // namespace afw
1062 } // namespace lsst
An ellipse core with quadrupole moments as parameters.
Definition: Quadrupole.h:47
std::shared_ptr< SpanSet > union_(SpanSet const &other) const
Create a new SpanSet that contains all points from two SpanSets.
Definition: SpanSet.cc:823
std::shared_ptr< geom::SpanSet > findEdgePixels() const
Select pixels within the SpanSet which touch its edge.
Definition: SpanSet.cc:407
int m
Definition: SpanSet.cc:44
std::vector< std::shared_ptr< geom::SpanSet > > split() const
Split a discontinuous SpanSet into multiple SpanSets which are contiguous.
Definition: SpanSet.cc:378
ToPoint applyForward(FromPoint const &point) const
Transform one point in the forward direction ("from" to "to")
Definition: Transform.cc:78
bool operator!=(SpanSet const &other) const
Definition: SpanSet.cc:679
Stencil
An enumeration class which describes the shapes.
Definition: SpanSet.h:66
std::shared_ptr< SpanSet > intersect(SpanSet const &other) const
Determine the common points between two SpanSets, and create a new SpanSet.
Definition: SpanSet.cc:716
int getEndY() const
def keys(self)
T distance(T... args)
int getMaxY() const
Key< Flag > const & target
bool contains(SpanSet const &other) const
Check if a SpanSet instance entirely contains another SpanSet.
Definition: SpanSet.cc:462
size_type size() const
Definition: SpanSet.h:94
bool isEmpty() const
afw::table::Key< afw::table::Array< MaskPixelT > > mask
const_iterator end() const
Definition: SpanSet.h:89
Point2I const getMin() const
T swap(T... args)
T front(T... args)
static std::shared_ptr< geom::SpanSet > fromMask(image::Mask< T > const &mask, UnaryPredicate comparator=details::AnyBitSetFunctor< T >())
Create a SpanSet from a mask.
Definition: SpanSet.h:644
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
Definition: Persistable.h:48
A compact representation of a collection of pixels.
Definition: SpanSet.h:77
A range of pixels within one row of an Image.
Definition: Span.h:54
void applyFunctor(Functor &&func, Args &&... args) const
Apply functor on individual elements from the supplied parameters.
Definition: SpanSet.h:512
std::shared_ptr< SpanSet > shiftedBy(int x, int y) const
Return a new SpanSet shifted by specified amount.
Definition: SpanSet.cc:415
table::Key< int > spanX0
Definition: SpanSet.cc:968
std::shared_ptr< SpanSet > dilated(int r, Stencil s=Stencil::CIRCLE) const
Perform a set dilation operation, and return a new object.
Definition: SpanSet.cc:540
typename ndarray::Array< T, N, C >::Reference::Reference Reference
STL namespace.
static std::shared_ptr< geom::SpanSet > fromShape(int r, Stencil s=Stencil::CIRCLE, lsst::geom::Point2I offset=lsst::geom::Point2I())
Factory function for creating SpanSets from a Stencil.
Definition: SpanSet.cc:684
T end(T... args)
const_iterator begin() const
Definition: SpanSet.h:88
std::shared_ptr< SpanSet > intersectNot(SpanSet const &other) const
Determine the common points between a SpanSet and the logical inverse of a second SpanSet and return ...
Definition: SpanSet.cc:741
T floor(T... args)
ItemVariant const * other
Definition: Schema.cc:55
bool isContiguous() const
Defines if the SpanSet is simply contiguous.
Definition: SpanSet.cc:369
std::vector< Point2I > getCorners() const
ellipses::Quadrupole computeShape() const
Compute the shape parameters for the distribution of points in the SpanSet.
Definition: SpanSet.cc:517
void setImage(image::Image< ImageT > &image, ImageT val, lsst::geom::Box2I const &region=lsst::geom::Box2I(), bool doClip=false) const
Set the values of an Image at points defined by the SpanSet.
Definition: SpanSet.cc:901
int getEndX() const
lsst::geom::Point2D computeCentroid() const
Compute the point about which the SpanSet&#39;s first moment is zero.
Definition: SpanSet.cc:498
Point< double, 2 > Point2D
STL class.
lsst::geom::Box2I getBBox() const
Return a new integer box which is the minimum size to contain the pixels.
Definition: SpanSet.cc:282
T min(T... args)
table::Key< int > spanX1
Definition: SpanSet.cc:969
int getX0() const
Return the starting x-value.
Definition: Span.h:79
T push_back(T... args)
table::Key< int > spanY
Definition: SpanSet.cc:967
Relationship invert(Relationship r)
A base class for image defects.
FromPoint applyInverse(ToPoint const &point) const
Transform one point in the inverse direction ("to" to "from")
Definition: Transform.cc:94
table::Schema spanSetSchema
Definition: SpanSet.cc:966
lsst::geom::Box2I getBBox(ImageOrigin origin=PARENT) const
Definition: ImageBase.h:448
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:84
int getMinX() const
table::Key< int > b
int getBeginY() const
T make_pair(T... args)
int getMinY() const
bool empty() const
Definition: SpanSet.h:95
double x
const_reference front() const
Definition: SpanSet.h:92
T clear(T... args)
STL class.
T max(T... args)
def run(suite, exit=True)
T move(T... args)
T insert(T... args)
#define LSST_EXCEPT(type,...)
int getWidth() const
STL class.
SpanSet()
Default constructor.
Definition: SpanSet.cc:173
size_type getArea() const
Return the number of pixels in the SpanSet.
Definition: SpanSet.cc:279
void setMask(lsst::afw::image::Mask< T > &target, T bitmask) const
Set a Mask at pixels defined by the SpanSet.
Definition: SpanSet.cc:924
int getMaxX() const
T begin(T... args)
int getMaxX() const
Maximum x-value.
Definition: Span.h:87
int getX1() const
Return the ending x-value.
Definition: Span.h:81
bool overlaps(Box2I const &other) const
T back(T... args)
const_reference back() const
Definition: SpanSet.h:93
io::OutputArchiveHandle OutputArchiveHandle
Definition: Persistable.h:108
std::shared_ptr< SpanSet > clippedTo(lsst::geom::Box2I const &box) const
Return a new SpanSet which has all pixel values inside specified box.
Definition: SpanSet.cc:435
table::Box2IKey bbox
std::shared_ptr< SpanSet > transformedBy(lsst::geom::LinearTransform const &t) const
Return a new SpanSet who&#39;s pixels are the product of applying the specified transformation.
Definition: SpanSet.cc:837
void clearMask(lsst::afw::image::Mask< T > &target, T bitmask) const
Unset a Mask at pixels defined by the SpanSet.
Definition: SpanSet.cc:935
int getY() const
Return the y-value.
Definition: Span.h:83
SpanSet & operator=(SpanSet const &)=default
table::Key< int > a
#define INSTANTIATE_MASK_TYPE(T)
Definition: SpanSet.cc:1045
T sort(T... args)
bool overlaps(SpanSet const &other) const
Specifies if this SpanSet overlaps with another SpanSet.
Definition: SpanSet.cc:450
bool contains(int x) const
Definition: Span.h:97
void include(Point2D const &point)
details::ImageNdGetter< T, inA, inB > ndImage(ndarray::Array< T, inA, inB > const &array, lsst::geom::Point2I xy0=lsst::geom::Point2I())
Marks a ndarray to be interpreted as an image when applying a functor from a SpanSet.
int getMinX() const
Minimum x-value.
Definition: Span.h:86
#define INSTANTIATE_IMAGE_TYPE(T)
Definition: SpanSet.cc:1040
int xmax
Definition: SpanSet.cc:44
bool operator==(SpanSet const &other) const
Compute equality between two SpanSets.
Definition: SpanSet.cc:674
PixelConstReference get0(int x, int y) const
Definition: ImageBase.h:289
int xmin
Definition: SpanSet.cc:44
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:67
int y
Definition: SpanSet.cc:44
T equal_range(T... args)
std::shared_ptr< SpanSet > eroded(int r, Stencil s=Stencil::CIRCLE) const
Perform a set erosion, and return a new object.
Definition: SpanSet.cc:568
Transform LSST spatial data, such as lsst::geom::Point2D and lsst::geom::SpherePoint, using an AST mapping.
Definition: Transform.h:67
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(lsst::geom::AffineTransform const &affine)
Wrap an lsst::geom::AffineTransform as a Transform.
T reserve(T... args)
int getBeginX() const
T emplace_back(T... args)