Skip to content

Commit

Permalink
Update note and warning message on OpenJPEG.
Browse files Browse the repository at this point in the history
  • Loading branch information
ningfei committed Jun 29, 2017
1 parent 00d8f27 commit e326fa8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions COMPILE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ g++ -dead_strip -O3 -I. main_console.cpp nii_dicom.cpp jpg_0XC3.cpp ujpeg.cpp ni

##### JPEG2000 BUILD

You can compile dcm2niix to convert DICOM images compressed with the JPEG2000 [transfer syntaxes 1.2.840.10008.1.2.4.90 and 1.2.840.10008.1.2.4.91](https://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage#Transfer_Syntaxes_and_Compressed_Images). This is optional, as JPEG2000 is very rare in DICOMs (usually only created by the proprietary DCMJP2K or OsiriX). Due to the challenges discussed below this is a poor choice for archiving DICOM data. Rather than support conversion with dcm2niix, a better solution would be to use DCMJP2K to do a DICOM-to-DICOM conversion to a more widely supported transfer syntax. Unfortunately, JPEG2000 saw poor adoption as a general image format. This situation is unlikely to change, as JPEG2000 only offered incremental benefits over the simpler classic JPEG, and is outperformed by the more recent HEIF. This has implications for DICOM, as there is little active development on libraries to decode JPEG2000. Indeed, the two popular open-source libraries that decode JPEG2000 have serious limitations for processing these images. Some JPEG2000 DICOM images can not be decoded by the default compilation of OpenJPEG after [2.1.0](https://github.com/uclouvain/openjpeg/issues/962). On the other hand, the Jasper does not handle lossy [16-bit](https://en.wikipedia.org/wiki/JPEG_2000) images with good precision.
You can compile dcm2niix to convert DICOM images compressed with the JPEG2000 [transfer syntaxes 1.2.840.10008.1.2.4.90 and 1.2.840.10008.1.2.4.91](https://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage#Transfer_Syntaxes_and_Compressed_Images). This is optional, as JPEG2000 is very rare in DICOMs (usually only created by the proprietary DCMJP2K or OsiriX). Due to the challenges discussed below this is a poor choice for archiving DICOM data. Rather than support conversion with dcm2niix, a better solution would be to use DCMJP2K to do a DICOM-to-DICOM conversion to a more widely supported transfer syntax. Unfortunately, JPEG2000 saw poor adoption as a general image format. This situation is unlikely to change, as JPEG2000 only offered incremental benefits over the simpler classic JPEG, and is outperformed by the more recent HEIF. This has implications for DICOM, as there is little active development on libraries to decode JPEG2000. Indeed, the two popular open-source libraries that decode JPEG2000 have serious limitations for processing these images. Some JPEG2000 DICOM images can not be decoded by the default compilation of OpenJPEG after [2.1.0](https://github.com/uclouvain/openjpeg/issues/962). On the other hand, the Jasper does not handle lossy [16-bit](https://en.wikipedia.org/wiki/JPEG_2000) images with good precision.

You can build dcm2niix with JPEG2000 decompression support using OpenJPEG 2.1.0 or earlier. You will need to have the OpenJPEG 2.1.0 (or earlier) libraries installed (https://code.google.com/p/openjpeg/wiki/Installation). If you want to use a more recent version of OpenJPEG, it must be custom-compiled with `m_nb_tile_parts_correction_checked = 0` compiler flag. I suggest building static libraries where you would [download the code](https://github.com/uclouvain/openjpeg) and run
You can build dcm2niix with JPEG2000 decompression support using OpenJPEG 2.1.0. You will need to have the OpenJPEG 2.1.0 library installed (use the package manager of your linux distribution, Homebrew for macOS, or see [here](https://github.com/uclouvain/openjpeg/blob/master/INSTALL.md) if you want to build it yourself). If you want to use a more recent version of OpenJPEG, it must be custom-compiled with `-DOPJ_DISABLE_TPSOT_FIX` compiler flag. I suggest building static libraries where you would [download the code](https://github.com/uclouvain/openjpeg) and run
```
cmake -DBUILD_SHARED_LIBS:bool=off .
cmake -DBUILD_SHARED_LIBS:bool=off -DOPJ_DISABLE_TPSOT_FIX:bool=on .
make
sudo make install
```
Expand Down Expand Up @@ -142,4 +142,4 @@ CXXFLAGS = -DmyUseCOut -DWX_PRECOMP ....
i.) For a full refresh
rm clipboard
rm *.o
make
make
4 changes: 4 additions & 0 deletions console/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ set(PROGRAMS dcm2niix)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# using Clang
add_definitions(-Wno-deprecated-register)
add_definitions(-fno-caret-diagnostics)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-dead_strip")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# using GCC
add_definitions(-Wno-unused-result)
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 4.7)
add_definitions(-fno-diagnostics-show-caret)
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# using Intel C++
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
Expand Down
3 changes: 1 addition & 2 deletions console/nii_dicom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ unsigned char * nii_loadImgCoreOpenJPEG(char* imgname, struct nifti_1_header hdr
#if OPJ_VERSION_MAJOR == 2
#if OPJ_VERSION_MINOR >= 1
#if OPJ_VERSION_BUILD > 0
warning: please make sure you custom compile your OpenJPEG library with the following:
m_nb_tile_parts_correction_checked = 0;
#pragma message "\n\nYour OpenJPEG library version > 2.1.0, please make sure it's custom compiled with: -DOPJ_DISABLE_TPSOT_FIX=ON.\n"
#endif
#endif
#endif
Expand Down

0 comments on commit e326fa8

Please sign in to comment.