PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
jpeg2000_codec.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
11#ifndef PACS_ENCODING_COMPRESSION_JPEG2000_CODEC_HPP
12#define PACS_ENCODING_COMPRESSION_JPEG2000_CODEC_HPP
13
15
17
51class jpeg2000_codec final : public compression_codec {
52public:
54 static constexpr std::string_view kTransferSyntaxUIDLossless =
55 "1.2.840.10008.1.2.4.90";
56
58 static constexpr std::string_view kTransferSyntaxUIDLossy =
59 "1.2.840.10008.1.2.4.91";
60
62 static constexpr float kDefaultCompressionRatio = 20.0f;
63
65 static constexpr int kDefaultResolutionLevels = 6;
66
78 explicit jpeg2000_codec(bool lossless = true,
81
82 ~jpeg2000_codec() override;
83
84 // Non-copyable but movable (internal state)
88 jpeg2000_codec& operator=(jpeg2000_codec&&) noexcept;
89
92
93 [[nodiscard]] std::string_view transfer_syntax_uid() const noexcept override;
94 [[nodiscard]] std::string_view name() const noexcept override;
95 [[nodiscard]] bool is_lossy() const noexcept override;
96 [[nodiscard]] bool can_encode(const image_params& params) const noexcept override;
97 [[nodiscard]] bool can_decode(const image_params& params) const noexcept override;
98
100
103
108 [[nodiscard]] bool is_lossless_mode() const noexcept;
109
114 [[nodiscard]] float compression_ratio() const noexcept;
115
120 [[nodiscard]] int resolution_levels() const noexcept;
121
123
126
145 [[nodiscard]] codec_result encode(
146 std::span<const uint8_t> pixel_data,
147 const image_params& params,
148 const compression_options& options = {}) const override;
149
161 [[nodiscard]] codec_result decode(
162 std::span<const uint8_t> compressed_data,
163 const image_params& params) const override;
164
166
167private:
168 class impl;
169 std::unique_ptr<impl> impl_;
170};
171
172} // namespace kcenon::pacs::encoding::compression
173
174#endif // PACS_ENCODING_COMPRESSION_JPEG2000_CODEC_HPP
Abstract base class for image compression codecs.
JPEG 2000 codec implementation supporting both lossless and lossy modes.
bool is_lossy() const noexcept override
Checks if this codec produces lossy compression.
jpeg2000_codec(const jpeg2000_codec &)=delete
bool can_encode(const image_params &params) const noexcept override
Checks if this codec supports the given image parameters.
codec_result encode(std::span< const uint8_t > pixel_data, const image_params &params, const compression_options &options={}) const override
Compresses pixel data to JPEG 2000 format.
bool can_decode(const image_params &params) const noexcept override
Checks if this codec can decode data with given parameters.
float compression_ratio() const noexcept
Gets the current compression ratio setting.
std::string_view transfer_syntax_uid() const noexcept override
Returns the Transfer Syntax UID supported by this codec.
jpeg2000_codec & operator=(const jpeg2000_codec &)=delete
jpeg2000_codec(bool lossless=true, float compression_ratio=kDefaultCompressionRatio, int resolution_levels=kDefaultResolutionLevels)
Constructs a JPEG 2000 codec instance.
codec_result decode(std::span< const uint8_t > compressed_data, const image_params &params) const override
Decompresses JPEG 2000 data.
static constexpr int kDefaultResolutionLevels
Default number of resolution levels.
int resolution_levels() const noexcept
Gets the number of DWT resolution levels.
std::string_view name() const noexcept override
Returns a human-readable name for the codec.
static constexpr std::string_view kTransferSyntaxUIDLossy
DICOM Transfer Syntax UID for JPEG 2000 (Lossy or Lossless)
static constexpr std::string_view kTransferSyntaxUIDLossless
DICOM Transfer Syntax UID for JPEG 2000 Lossless Only.
static constexpr float kDefaultCompressionRatio
Default compression ratio for lossy mode (20:1)
bool is_lossless_mode() const noexcept
Checks if this codec is configured for lossless mode.
Compression quality settings for lossy codecs.
Parameters describing image pixel data.