IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
JPGImageReaderWriter.h
Go to the documentation of this file.
1/**
2 * \file IMP/em2d/JPGImageReaderWriter.h
3 * \brief Management of JPG format for EM images
4 * Copyright 2007-2026 IMP Inventors. All rights reserved.
5*/
6
7#ifndef IMPEM2D_JPG_IMAGE_READER_WRITER_H
8#define IMPEM2D_JPG_IMAGE_READER_WRITER_H
9
10#include <IMP/em2d/em2d_config.h>
12#include "IMP/em/ImageHeader.h"
13
14IMPEM2D_BEGIN_NAMESPACE
15
16//! Class to read and write EM images in JPG format.
17class IMPEM2DEXPORT JPGImageReaderWriter : public ImageReaderWriter {
18 public:
19 JPGImageReaderWriter() {}
20
21 void read(const String &filename, em::ImageHeader &header,
22 DoubleMatrix &data) const override {
23 this->read_from_ints(filename, header, data);
24 }
25
26 void write(const String &filename, em::ImageHeader &header,
27 const DoubleMatrix &data) const override {
28 this->write_to_ints(filename, header, data);
29 }
30
31 //! Reads an image file in JPG format
32 /*!
33 \param[in] filename file to read
34 \param[in] header header to store the info
35 \param[in] data a matrix to store the grid of data of the image
36 \note Color images are converted to grayscale.
37 \warning: The header passed is filled with standard values
38 If you need full header information you must work with other
39 format. Eg, Spider.
40 */
41 void read_from_ints(const String &filename, em::ImageHeader &header,
42 DoubleMatrix &data) const override;
43
44 void write_to_floats(const String &, em::ImageHeader &,
45 const DoubleMatrix &) const override {}
46
47 void read_from_floats(const String &, em::ImageHeader &,
48 DoubleMatrix &) const override {}
49
50 //! Writes an EM image in JPG format
51 /*!
52 \param[in] filename file to write
53 \param[in] header header with the image info
54 \param[in] data a matrix with the grid of data of the image
55 \warning: Careful: This function writes a 8-bit image.
56 You might be discarding float information.
57 */
58 void write_to_ints(const String &filename, em::ImageHeader &header,
59 const DoubleMatrix &data) const override;
60
61 IMP_OBJECT_METHODS(JPGImageReaderWriter);
62};
63
64IMPEM2D_END_NAMESPACE
65
66#endif /* IMPEM2D_JPG_IMAGE_READER_WRITER_H */
Header for EM images. Compatible with Spider and Xmipp formats Copyright 2007-2022 IMP Inventors....
Virtual class for reader/writers of images Copyright 2007-2026 IMP Inventors. All rights reserved.
void read_from_ints(const String &filename, em::ImageHeader &header, DoubleMatrix &data) const override
Reads an image file in JPG format.
void write_to_ints(const String &filename, em::ImageHeader &header, const DoubleMatrix &data) const override
Writes an EM image in JPG format.
Class to deal with the header of Electron Microscopy images in IMP.
Definition ImageHeader.h:28
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
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.