PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
htj2k_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_HTJ2K_CODEC_HPP
12#define PACS_ENCODING_COMPRESSION_HTJ2K_CODEC_HPP
13
15
17
47class htj2k_codec final : public compression_codec {
48public:
50 static constexpr std::string_view kTransferSyntaxUIDLossless =
51 "1.2.840.10008.1.2.4.201";
52
54 static constexpr std::string_view kTransferSyntaxUIDRPCL =
55 "1.2.840.10008.1.2.4.202";
56
58 static constexpr std::string_view kTransferSyntaxUIDLossy =
59 "1.2.840.10008.1.2.4.203";
60
62 static constexpr float kDefaultCompressionRatio = 20.0f;
63
65 static constexpr int kDefaultResolutionLevels = 6;
66
79 explicit htj2k_codec(bool lossless = true,
80 bool use_rpcl = false,
83
84 ~htj2k_codec() override;
85
86 // Non-copyable but movable
87 htj2k_codec(const htj2k_codec&) = delete;
90 htj2k_codec& operator=(htj2k_codec&&) noexcept;
91
94
95 [[nodiscard]] std::string_view transfer_syntax_uid() const noexcept override;
96 [[nodiscard]] std::string_view name() const noexcept override;
97 [[nodiscard]] bool is_lossy() const noexcept override;
98 [[nodiscard]] bool can_encode(const image_params& params) const noexcept override;
99 [[nodiscard]] bool can_decode(const image_params& params) const noexcept override;
100
102
105
110 [[nodiscard]] bool is_lossless_mode() const noexcept;
111
116 [[nodiscard]] bool is_rpcl_mode() const noexcept;
117
122 [[nodiscard]] float compression_ratio() const noexcept;
123
128 [[nodiscard]] int resolution_levels() const noexcept;
129
131
134
146 [[nodiscard]] codec_result encode(
147 std::span<const uint8_t> pixel_data,
148 const image_params& params,
149 const compression_options& options = {}) const override;
150
161 [[nodiscard]] codec_result decode(
162 std::span<const uint8_t> compressed_data,
163 const image_params& params) const override;
164
166
167private:
172};
173
174} // namespace kcenon::pacs::encoding::compression
175
176#endif // PACS_ENCODING_COMPRESSION_HTJ2K_CODEC_HPP
Abstract base class for image compression codecs.
High-Throughput JPEG 2000 (HTJ2K) codec implementation.
Definition htj2k_codec.h:47
static constexpr int kDefaultResolutionLevels
Default number of resolution levels.
Definition htj2k_codec.h:65
htj2k_codec & operator=(const htj2k_codec &)=delete
float compression_ratio() const noexcept
Gets the current compression ratio setting.
bool can_decode(const image_params &params) const noexcept override
Checks if this codec can decode data with given parameters.
bool is_rpcl_mode() const noexcept
Checks if RPCL progression order is enabled.
static constexpr std::string_view kTransferSyntaxUIDLossy
DICOM Transfer Syntax UID for HTJ2K (Lossy)
Definition htj2k_codec.h:58
bool can_encode(const image_params &params) const noexcept override
Checks if this codec supports the given image parameters.
bool is_lossless_mode() const noexcept
Checks if this codec is configured for lossless mode.
std::string_view name() const noexcept override
Returns a human-readable name for the codec.
static constexpr std::string_view kTransferSyntaxUIDLossless
DICOM Transfer Syntax UID for HTJ2K Lossless Only.
Definition htj2k_codec.h:50
std::string_view transfer_syntax_uid() const noexcept override
Returns the Transfer Syntax UID supported by this codec.
codec_result encode(std::span< const uint8_t > pixel_data, const image_params &params, const compression_options &options={}) const override
Compresses pixel data to HTJ2K format.
htj2k_codec(bool lossless=true, bool use_rpcl=false, float compression_ratio=kDefaultCompressionRatio, int resolution_levels=kDefaultResolutionLevels)
Constructs an HTJ2K codec instance.
int resolution_levels() const noexcept
Gets the number of DWT resolution levels.
static constexpr std::string_view kTransferSyntaxUIDRPCL
DICOM Transfer Syntax UID for HTJ2K with RPCL Options (Lossless Only)
Definition htj2k_codec.h:54
bool is_lossy() const noexcept override
Checks if this codec produces lossy compression.
static constexpr float kDefaultCompressionRatio
Default compression ratio for lossy mode (20:1)
Definition htj2k_codec.h:62
codec_result decode(std::span< const uint8_t > compressed_data, const image_params &params) const override
Decompresses HTJ2K data.
Compression quality settings for lossy codecs.
Parameters describing image pixel data.