Skip to content

Commit feb772b

Browse files
Initial commit to main
1 parent 214c88a commit feb772b

25 files changed

Lines changed: 4433 additions & 1 deletion

.clang-format

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
QualifierAlignment: Right
5+
PointerAlignment: Right

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
permissions:
10+
actions: read
11+
contents: read
12+
security-events: write
13+
14+
env:
15+
BUILD_TYPE: Release
16+
17+
jobs:
18+
build-linux:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v5
23+
- name: Build on Linux
24+
run: ./build.sh ${{env.BUILD_TYPE}}
25+
- name: Run tests on Linux
26+
run: ./build/tests/dcmtkhtj2k_tests
27+
- name: Archive production artifacts
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: dcmtk-htj2k-build-linux
31+
path: |
32+
build/${{env.BUILD_TYPE}}
33+
compression-level: 9
34+
build-macos:
35+
runs-on: macos-latest
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v5
39+
- name: Build on macOS
40+
run: ./build.sh ${{env.BUILD_TYPE}}
41+
- name: Run tests on macOS
42+
run: ./build/tests/dcmtkhtj2k_tests
43+
- name: Archive production artifacts
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: dcmtk-htj2k-build-osx
47+
path: |
48+
build/${{env.BUILD_TYPE}}
49+
compression-level: 9

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/
2+
ots/
3+
.DS_Store

CMakeLists.txt

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
cmake_minimum_required(VERSION 3.12.0)
2+
3+
project(DCMTKHTJ2K)
4+
5+
set (DCMTKHTJ2K_VERSION_MAJOR 1)
6+
set (DCMTKHTJ2K_VERSION_MINOR 0)
7+
set (DCMTKHTJ2K_VERSION_BUILD 0)
8+
set(DCMTKHTJ2K_VERSION "${DCMTKHTJ2K_VERSION_MAJOR}.${DCMTKHTJ2K_VERSION_MINOR}.${DCMTKHTJ2K_VERSION_BUILD}")
9+
10+
option(BUILD_SHARED_LIBS "Build DCMTKHTJ2K shared library" ON)
11+
12+
set (CMAKE_CXX_STANDARD 11)
13+
14+
find_package(DCMTK REQUIRED)
15+
find_package(OPENJPH REQUIRED)
16+
17+
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${DCMTK_INCLUDE_DIRS} ${OPENJPH_INCLUDE_DIRS})
18+
LINK_DIRECTORIES(${DCMTKHTJ2K}/lib)
19+
20+
add_definitions(-DDCMTKHTJ2K_EXPORTS)
21+
22+
set(DCMTKHTJ2K_HEADERS
23+
include/dcmtkhtj2k/djcodecd.h
24+
include/dcmtkhtj2k/djcodece.h
25+
include/dcmtkhtj2k/djcparam.h
26+
include/dcmtkhtj2k/djdecode.h
27+
include/dcmtkhtj2k/djencode.h
28+
include/dcmtkhtj2k/djutils.h
29+
include/dcmtkhtj2k/djrparam.h
30+
include/dcmtkhtj2k/dldefine.h
31+
)
32+
33+
set(DCMTKHTJ2K_SRCS
34+
${DCMTKHTJ2K_HEADERS}
35+
djcodecd.cc
36+
djcodece.cc
37+
djcparam.cc
38+
djdecode.cc
39+
djencode.cc
40+
djrparam.cc
41+
djutils.cc
42+
)
43+
44+
if (MSVC)
45+
add_compile_options(/Zc:__cplusplus)
46+
endif()
47+
if(WIN32)
48+
add_definitions(-D_BIND_TO_CURRENT_VCLIBS_VERSION=1)
49+
endif()
50+
51+
add_library(DCMTKHTJ2K ${DCMTKHTJ2K_SRCS})
52+
set(DCMTKHTJ2K_LIBRARY_NAME DCMTKHTJ2K)
53+
TARGET_LINK_LIBRARIES(DCMTKHTJ2K
54+
DCMTK::DCMTK
55+
openjph
56+
)
57+
58+
include(GenerateExportHeader)
59+
generate_export_header(DCMTKHTJ2K)
60+
set_property(TARGET DCMTKHTJ2K PROPERTY VERSION ${DCMTKHTJ2K_VERSION})
61+
set_property(TARGET DCMTKHTJ2K PROPERTY SOVERSION 1)
62+
set_property(TARGET DCMTKHTJ2K PROPERTY
63+
INTERFACE_DCMTKHTJ2K_MAJOR_VERSION 1)
64+
set_property(TARGET DCMTKHTJ2K APPEND PROPERTY
65+
COMPATIBLE_INTERFACE_STRING DCMTKHTJ2K_MAJOR_VERSION
66+
)
67+
68+
install(TARGETS DCMTKHTJ2K EXPORT DCMTKHTJ2KTargets
69+
LIBRARY DESTINATION lib
70+
ARCHIVE DESTINATION lib
71+
RUNTIME DESTINATION bin
72+
)
73+
74+
install(
75+
FILES
76+
${DCMTKHTJ2K_HEADERS}
77+
DESTINATION
78+
include/DCMTKHTJ2K
79+
COMPONENT
80+
Devel
81+
)
82+
83+
include(CMakePackageConfigHelpers)
84+
write_basic_package_version_file(
85+
"${CMAKE_CURRENT_BINARY_DIR}/DCMTKHTJ2KConfigVersion.cmake"
86+
VERSION ${DCMTKHTJ2K_VERSION}
87+
COMPATIBILITY AnyNewerVersion
88+
)
89+
90+
export(TARGETS DCMTKHTJ2K
91+
FILE "${CMAKE_CURRENT_BINARY_DIR}/DCMTKHTJ2KExports.cmake"
92+
)
93+
configure_file( ${CMAKE_SOURCE_DIR}/cmake/DCMTKHTJ2KConfig.cmake.in
94+
${CMAKE_CURRENT_BINARY_DIR}/DCMTKHTJ2KConfig.cmake
95+
@ONLY
96+
)
97+
98+
set(ConfigPackageLocation lib/cmake/DCMTKHTJ2K)
99+
install(EXPORT DCMTKHTJ2KTargets
100+
FILE
101+
DCMTKHTJ2KTargets.cmake
102+
DESTINATION
103+
${ConfigPackageLocation}
104+
)
105+
106+
install(
107+
FILES
108+
"${CMAKE_CURRENT_BINARY_DIR}/DCMTKHTJ2KConfig.cmake"
109+
"${CMAKE_CURRENT_BINARY_DIR}/DCMTKHTJ2KConfigVersion.cmake"
110+
DESTINATION
111+
${ConfigPackageLocation}
112+
COMPONENT
113+
Devel
114+
)
115+
116+
# Testing
117+
option(BUILD_TESTING "Build the testing tree" ON)
118+
119+
if(BUILD_TESTING)
120+
enable_testing()
121+
122+
# Fetch Google Test
123+
include(FetchContent)
124+
FetchContent_Declare(
125+
googletest
126+
GIT_REPOSITORY https://github.com/google/googletest.git
127+
GIT_TAG v1.14.0
128+
)
129+
130+
# For Windows: Prevent overriding the parent project's compiler/linker settings
131+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
132+
133+
FetchContent_MakeAvailable(googletest)
134+
135+
add_subdirectory(tests)
136+
endif()

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2026 Pantelis Georgiadis
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,113 @@
1-
# dcmtk-htj2kojph
1+
# DCMTK-HTJ2K
2+
3+
A DCMTK codec library for encoding and decoding DICOM images using the High-Throughput JPEG 2000 (HTJ2K) compression and decompression technique.
4+
5+
## Overview
6+
7+
DCMTK-HTJ2K provides HTJ2K codec support for [DCMTK](https://github.com/DCMTK/dcmtk), enabling seamless compression and decompression of DICOM images using the HTJ2K standard. The library integrates [OpenJPH](https://github.com/aous72/openjph) for HTJ2K operations with DCMTK's DICOM handling capabilities.
8+
9+
### Supported Transfer Syntaxes
10+
11+
- High Throughput JPEG 2000 Image Compression - Lossless Only (1.2.840.10008.1.2.4.201)
12+
- High Throughput JPEG 2000 with RPCL Options Image Compression - Lossless Only (1.2.840.10008.1.2.4.202)
13+
- High Throughput JPEG 2000 Image Compression (1.2.840.10008.1.2.4.203)
14+
15+
## Features
16+
17+
- **HTJ2K Encoding**: Compress DICOM images using HTJ2K lossless and lossy compression.
18+
- **HTJ2K Decoding**: Decompress HTJ2K-encoded DICOM images.
19+
- **DCMTK Integration**: Seamless integration with DCMTK codec framework.
20+
- **Configurable Parameters**: Support for codeblock dimensions, fragment sizes, and encoding options.
21+
22+
## Dependencies
23+
24+
- **DCMTK** (3.6.9 or higher)
25+
- **OpenJPH** (0.26.0 or higher)
26+
- **CMake** (3.12.0 or higher)
27+
28+
## Building
29+
30+
### Quick Build
31+
32+
```bash
33+
./build.sh [Release|Debug]
34+
```
35+
36+
The build script accepts an optional build configuration parameter (`Release` or `Debug`). If not specified, it defaults to `Release`.
37+
38+
The provided build script automatically downloads, builds, and installs dependencies. It also builds and installs DCMTK-HTJ2K:
39+
- Library files to `build/ReleaseOrDebug/lib/`.
40+
- Header files to `build/ReleaseOrDebug/include/DCMTKHTJ2K/`.
41+
- CMake configuration files to `build/ReleaseOrDebug/lib/cmake/DCMTKHTJ2K/`.
42+
43+
## Usage
44+
45+
### Registering Encoder
46+
47+
```cpp
48+
#include "dcmtkhtj2k/djencode.h"
49+
50+
// Register HTJ2K encoder with default parameters
51+
HtJ2kEncoderRegistration::registerCodecs();
52+
53+
// Or with custom parameters
54+
HtJ2kEncoderRegistration::registerCodecs(
55+
OFTrue, // jp2k_optionsEnabled
56+
5, // jp2k_decompositions (decompositions)
57+
64, // jp2k_cblkwidth (codeblock width)
58+
64, // jp2k_cblkheight (codeblock height)
59+
EJ2KPO_default, // jp2k_progressionOrder (progression order)
60+
OFTrue, // preferCookedEncoding
61+
0, // fragmentSize (0 = unlimited)
62+
OFTrue, // createOffsetTable
63+
EJ2KUC_default, // uidCreation
64+
OFFalse // convertToSC
65+
);
66+
```
67+
68+
### Registering Decoder
69+
70+
```cpp
71+
#include "dcmtkhtj2k/djdecode.h"
72+
73+
// Register HTJ2K decoder with default parameters
74+
HtJ2kDecoderRegistration::registerCodecs();
75+
76+
// Or with custom parameters
77+
HtJ2kDecoderRegistration::registerCodecs(
78+
EJ2KUC_default, // uidCreation
79+
EJ2KPC_restore, // planarConfig
80+
OFFalse // ignoreOffsetTable
81+
);
82+
```
83+
84+
### Cleanup
85+
86+
```cpp
87+
// Cleanup encoder
88+
HtJ2kEncoderRegistration::cleanup();
89+
90+
// Cleanup decoder
91+
HtJ2kDecoderRegistration::cleanup();
92+
```
93+
94+
## Using in Your Project
95+
96+
CMake Integration
97+
```bash
98+
find_package(DCMTKHTJ2K REQUIRED)
99+
target_link_libraries(your_target DCMTKHTJ2K)
100+
```
101+
102+
## API Documentation
103+
104+
The library provides the following main classes:
105+
106+
- **`HtJ2kEncoderRegistration`**: Singleton for registering HTJ2K encoder.
107+
- **`HtJ2kDecoderRegistration`**: Singleton for registering HTJ2K decoder.
108+
- **`HtJ2kCodecParameter`**: Codec configuration parameters.
109+
- **`HtJ2kEncoder`**: HTJ2K encoding implementation.
110+
- **`HtJ2kDecoder`**: HTJ2K decoding implementation.
111+
112+
## License
113+
DCMTK-HTJ2K is released under the MIT License.

0 commit comments

Comments
 (0)