30 #define __attribute__(x) 37 #include "boost/serialization/shared_ptr.hpp" 38 #include "boost/serialization/binary_object.hpp" 39 #include "boost/serialization/nvp.hpp" 41 #include <boost/archive/text_oarchive.hpp> 42 #include <boost/archive/text_iarchive.hpp> 43 #include <boost/archive/binary_oarchive.hpp> 44 #include <boost/archive/binary_iarchive.hpp> 54 LOG_LOGGER _log =
LOG_GET(
"afw.ImageFormatter");
57 using boost::serialization::make_nvp;
70 namespace formatters {
72 template <
typename ImagePixelT>
104 template <
typename ImagePixelT>
108 template <
typename ImagePixelT>
112 template <
typename ImagePixelT>
120 template <
typename ImagePixelT>
124 LOGL_DEBUG(_log,
"ImageFormatter write start");
132 LOGL_DEBUG(_log,
"ImageFormatter write BoostStorage");
133 boost->getOArchive() & *ip;
139 LOGL_DEBUG(_log,
"ImageFormatter write XmlStorage");
140 xml->getOArchive() & make_nvp(
"img", *ip);
146 LOGL_DEBUG(_log,
"ImageFormatter write FitsStorage");
149 if (additionalData) {
153 LOGLS_WARN(_log,
"Unable to construct image write options (" << exc.
what() <<
154 "); writing with default options");
168 template <
typename ImagePixelT>
171 LOGL_DEBUG(_log,
"ImageFormatter read start");
175 LOGL_DEBUG(_log,
"ImageFormatter read BoostStorage");
177 boost->getIArchive() & *ip;
183 LOGL_DEBUG(_log,
"ImageFormatter read XmlStorage");
185 xml->getIArchive() & make_nvp(
"img", *ip);
191 LOGL_DEBUG(_log,
"ImageFormatter read FitsStorage");
193 if (additionalData->exists(
"llcX")) {
194 int llcX = additionalData->
get<
int>(
"llcX");
195 int llcY = additionalData->
get<
int>(
"llcY");
196 int width = additionalData->
get<
int>(
"width");
197 int height = additionalData->
get<
int>(
"height");
201 if (additionalData->exists(
"imageOrigin")) {
203 if (originStr ==
"LOCAL") {
205 }
else if (originStr ==
"PARENT") {
209 (boost::format(
"Unknown ImageOrigin type %s specified in additional" 210 "data for retrieving Image from fits") %
230 template <
typename ImagePixelT>
236 template <
typename ImagePixelT>
237 template <
class Archive>
239 LOGL_DEBUG(_log,
"ImageFormatter delegateSerialize start");
245 if (Archive::is_saving::value) {
249 ar& make_nvp(
"width", width) & make_nvp(
"height", height);
250 if (Archive::is_loading::value) {
253 ar& make_nvp(
"array", boost::serialization::make_array(array.getData(), array.getNumElements()));
256 ndarray::Array<ImagePixelT, 2, 2> array = ndarray::dynamic_dimension_cast<2>(ip->
getArray());
257 if (array.empty()) array = ndarray::copy(ip->
getArray());
258 ar& make_nvp(
"array", boost::serialization::make_array(array.getData(), array.getNumElements()));
262 template <
typename ImagePixelT>
268 #define InstantiateFormatter(ImagePixelT) \ 269 template class ImageFormatter<ImagePixelT>; \ 270 template void ImageFormatter<ImagePixelT>::delegateSerialize(boost::archive::text_oarchive&, int const, \ 272 template void ImageFormatter<ImagePixelT>::delegateSerialize(boost::archive::text_iarchive&, int const, \ 274 template void ImageFormatter<ImagePixelT>::delegateSerialize(boost::archive::xml_oarchive&, int const, \ 276 template void ImageFormatter<ImagePixelT>::delegateSerialize(boost::archive::xml_iarchive&, int const, \ 278 template void ImageFormatter<ImagePixelT>::delegateSerialize(boost::archive::binary_oarchive&, \ 279 int const, Persistable*); \ 280 template void ImageFormatter<ImagePixelT>::delegateSerialize(boost::archive::binary_iarchive&, \ 281 int const, Persistable*); 289 #undef InstantiateSerializer #define LOGLS_WARN(logger, message)
int getHeight() const
Return the number of rows in the image.
Options for writing an image to FITS.
void writeFits(std::string const &fileName, std::shared_ptr< lsst::daf::base::PropertySet const > metadata=std::shared_ptr< lsst::daf::base::PropertySet const >(), std::string const &mode="w") const
Write an image to a regular FITS file.
#define LOGL_DEBUG(logger, message...)
An integer coordinate rectangle.
A base class for image defects.
T dynamic_pointer_cast(T... args)
#define LSST_EXCEPT(type,...)
int getWidth() const
Return the number of columns in the image.
A class to represent a 2-dimensional array of pixels.