IMP logo
IMP Reference Guide  develop.d36d3deffb,2026/11/09
The Integrative Modeling Platform
TIFFImageReaderWriter.h
Go to the documentation of this file.
1 /**
2  * \file IMP/em2d/TIFFImageReaderWriter.h
3  * \brief Management of reading/writing TIFF images
4  *
5  * Copyright 2007-2026 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPEM2D_TIFF_IMAGE_READER_WRITER_H
10 #define IMPEM2D_TIFF_IMAGE_READER_WRITER_H
11 
12 #include <IMP/em2d/em2d_config.h>
14 
15 IMPEM2D_BEGIN_NAMESPACE
16 
17 //! Management of reading/writing TIFF images
18 class IMPEM2DEXPORT TIFFImageReaderWriter : public ImageReaderWriter {
19 
20  public:
22 
23  void read(const String &filename, em::ImageHeader &header,
24  DoubleMatrix &data) const override {
25  this->read_from_ints(filename, header, data);
26  }
27 
28  void write(const String &filename, em::ImageHeader &header,
29  const DoubleMatrix &data) const override {
30  this->write_to_ints(filename, header, data);
31  }
32 
33  void write_to_floats(const String &, em::ImageHeader &,
34  const DoubleMatrix &) const override {}
35 
36  void read_from_floats(const String &, em::ImageHeader &,
37  DoubleMatrix &) const override {}
38 
39  //! Reads an image file in TIFF format
40  /*!
41  \param[in] filename file to read
42  \param[in] header header to store the info
43  \param[in] data a matrix to store the grid of data of the image
44  \note Only the first image in the file is read, at 8 bits per pixel.
45  Color images are converted to grayscale.
46  \warning: The header passed is filled with standard values
47  If you need full header information you must work with other
48  format. Eg, Spider.
49  */
50  void read_from_ints(const String &filename, em::ImageHeader &header,
51  DoubleMatrix &data) const override;
52 
53  //! Writes an EM image in TIFF format
54  /*!
55  \param[in] filename file to write
56  \param[in] header header with the image info
57  \param[in] data a matrix with the grid of data of the image
58  \warning: Careful: This function writes a 8-bit image.
59  You might be discarding float information.
60  */
61  void write_to_ints(const String &filename, em::ImageHeader &header,
62  const DoubleMatrix &data) const override;
63 
65 };
66 
67 IMPEM2D_END_NAMESPACE
68 
69 #endif /* IMPEM2D_TIFF_IMAGE_READER_WRITER_H */
Class to deal with the header of Electron Microscopy images in IMP.
Definition: ImageHeader.h:28
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Virtual class for reader/writers of images.
Virtual class for reader/writers of images Copyright 2007-2026 IMP Inventors. All rights reserved...
Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > DoubleMatrix
Matrix of doubles, used to store the data of an image.
Definition: Matrix.h:28
std::string String
Basic string value.
Definition: types.h:43
Management of reading/writing TIFF images.