Loading [MathJax]/extensions/tex2jax.js
LSST Applications g04a91732dc+a3f7a6a005,g07dc498a13+5ab4d22ec3,g0fba68d861+870ee37b31,g1409bbee79+5ab4d22ec3,g1a7e361dbc+5ab4d22ec3,g1fd858c14a+11200c7927,g20f46db602+25d63fd678,g35bb328faa+fcb1d3bbc8,g4d2262a081+cc8af5cafb,g4d39ba7253+6b9d64fe03,g4e0f332c67+5d362be553,g53246c7159+fcb1d3bbc8,g60b5630c4e+6b9d64fe03,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g8048e755c2+a1301e4c20,g8852436030+a750987b4a,g89139ef638+5ab4d22ec3,g89e1512fd8+a86d53a4aa,g8d6b6b353c+6b9d64fe03,g9125e01d80+fcb1d3bbc8,g989de1cb63+5ab4d22ec3,g9f33ca652e+38ca901d1a,ga9baa6287d+6b9d64fe03,gaaedd4e678+5ab4d22ec3,gabe3b4be73+1e0a283bba,gb1101e3267+aa269f591c,gb58c049af0+f03b321e39,gb90eeb9370+af74afe682,gc741bbaa4f+7f5db660ea,gcf25f946ba+a750987b4a,gd315a588df+b78635c672,gd6cbbdb0b4+c8606af20c,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+5839af1903,ge278dab8ac+932305ba37,ge82c20c137+76d20ab76d,w.2025.11
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DecoratedImage.cc
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/*
24 * An Image with associated metadata
25 */
26#include <cstdint>
27#include <iostream>
28#include "lsst/afw/fits.h"
30
31namespace lsst {
32namespace afw {
33namespace image {
34
35template <typename PixelT>
36void DecoratedImage<PixelT>::init() {
37 // safer to initialize a smart pointer as a named variable
38 std::shared_ptr<daf::base::PropertySet> metadata(new daf::base::PropertyList);
39 setMetadata(metadata);
40 _gain = 0;
41}
42
43template <typename PixelT>
45 : _image(new Image<PixelT>(dimensions)) {
46 init();
47}
48template <typename PixelT>
49DecoratedImage<PixelT>::DecoratedImage(lsst::geom::Box2I const& bbox) : _image(new Image<PixelT>(bbox)) {
50 init();
51}
52template <typename PixelT>
56template <typename PixelT>
58 : _image(new Image<PixelT>(*src._image, deep)), _gain(src._gain) {
59 setMetadata(src.getMetadata());
60}
61template <typename PixelT>
63 DecoratedImage tmp(src);
64 swap(tmp); // See Meyers, Effective C++, Item 11
65
66 return *this;
67}
68
69template <typename PixelT>
71 using std::swap; // See Meyers, Effective C++, Item 25
72
73 swap(_image, rhs._image); // just swapping the pointers
74 swap(_gain, rhs._gain);
75}
76
77template <typename PixelT>
79 a.swap(b);
80}
81
82//
83// FITS code
84//
85template <typename PixelT>
87 lsst::geom::Box2I const& bbox, ImageOrigin const origin,
88 bool allowUnsafe) {
89 init();
91 new Image<PixelT>(fileName, hdu, getMetadata(), bbox, origin, allowUnsafe));
92}
93
94template <typename PixelT>
96 daf::base::PropertySet const * metadata,
97 std::string const& mode) const {
99 writeFits(fileName, options, metadata, mode);
100}
101
102template <typename PixelT>
104 daf::base::PropertySet const * metadata_i,
105 std::string const& mode) const {
107
108 if (metadata_i) {
109 metadata = getMetadata()->deepCopy();
110 metadata->combine(*metadata_i);
111 } else {
112 metadata = getMetadata();
113 }
114
115 getImage()->writeFits(fileName, options, mode, metadata.get());
116}
117
118
119//
120// Explicit instantiations
121//
122template class DecoratedImage<std::uint16_t>;
123template class DecoratedImage<int>;
124template class DecoratedImage<float>;
125template class DecoratedImage<double>;
126template class DecoratedImage<std::uint64_t>;
127} // namespace image
128} // namespace afw
129} // namespace lsst
A container for an Image and its associated metadata.
Definition Image.h:406
DecoratedImage(const lsst::geom::Extent2I &dimensions=lsst::geom::Extent2I())
Create an image of the specified size.
DecoratedImage & operator=(const DecoratedImage &image)
Assignment operator.
void swap(DecoratedImage &rhs)
void setMetadata(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Definition Image.h:462
void writeFits(std::string const &fileName, daf::base::PropertySet const *metadata=nullptr, std::string const &mode="w") const
Write a FITS file.
std::shared_ptr< lsst::daf::base::PropertySet > getMetadata() const
Definition Image.h:461
std::shared_ptr< Image< PixelT > > getImage()
Return a shared_ptr to the DecoratedImage's Image.
Definition Image.h:507
A class to represent a 2-dimensional array of pixels.
Definition Image.h:51
Class for storing generic metadata.
Definition PropertySet.h:67
An integer coordinate rectangle.
Definition Box.h:55
T get(T... args)
void swap(Image< PixelT > &a, Image< PixelT > &b)
Definition Image.cc:443
Extent< int, 2 > Extent2I
Definition Extent.h:397
Options for writing an image to FITS.
Definition fits.h:223
T swap(T... args)
g2d::python::Image< double > Image
Definition test_image.cc:14