8000 Use DCMTK for all CIELab/RGB color conversions. by michaelonken · Pull Request #565 · QIICR/dcmqi · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions CMakeExternals/DCMTK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ if(NOT DEFINED DCMTK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})

ExternalProject_SetIfNotDefined(
${proj}_GIT_TAG
# DCMTK 3.7.0 ++ (May 8th, 2026).
# DCMTK 3.7.0 ++ (Sep 20th, 2026).
# This is DCMTK version with some extra fixes on segmentations and parametric maps,
# which have been released a few days after DCMTK 3.7.0, as well as performance
# optimizations for segmentation/parametric map. It also includes a simpler
# mechanism to add external modules to the DCMTK CMake build.
"5708ba6"
# as well as fixes on the RGB color conversion.
# It also includes a simpler mechanism to add external modules to the DCMTK CMake build.
"4e89d4f15512704ebf00b620082d6497f840f45a"
QUIET
)

Expand Down
103 changes: 0 additions & 103 deletions include/dcmqi/ColorUtilities.h

This file was deleted.

2 changes: 1 addition &a 8000 mp; 1 deletion include/dcmqi/ConverterBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace dcmqi {
* Must not be NULL.
* @param setCIELabValue If true, set the Recommended Display CIELab
* Value Macro on the background segment to black
* (DICOM-encoded 0, 32768, 32768). Pass false for
* (DICOM-encoded 0, 32896, 32896). Pass false for
* PALETTE color model where the per-segment
* CIELab macro must not be written; the caller
* is then responsible for ensuring the Palette
Expand Down
23 changes: 8 additions & 15 deletions libsrc/Bin2Label.cpp
8000
Original file line number Diff line numberDiff line change
Expand Up @@ -699,22 +699,13 @@
Uint16 maxRange = (m_use16Bit ? 65535 : 255);
for (size_t idx = 0; idx < m_cielabColors.m_numSegments; idx++)
{
// Scale to full 16 bit range
// Scale to the LUT range (R, G and B are already clipped to 0..1),
// rounding the same way as the 8 bit variant of dicomLab2RGB()
double R, G, B;
IODCIELabUtil::dicomLab2RGB(R, G, B, m_cielabColors.m_L[idx], m_cielabColors.m_a[idx], m_cielabColors.m_b[idx]);

R = R*maxRange;
G = G*maxRange;
B = B*maxRange;
if (R < 0) R = 0;
if (R > maxRange) R = maxRange;
if (G < 0) G = 0;
if (G > maxRange) G = maxRange;
if (B < 0) B = 0;
if (B > maxRange) B = maxRange;
m_cielabColors.m_L[idx] = OFstatic_cast(Uint16, R);
m_cielabColors.m_a[idx] = OFstatic_cast(Uint16, G);
m_cielabColors.m_b[idx] = OFstatic_cast(Uint16, B);
m_cielabColors.m_L[idx] = OFstatic_cast(Uint16, floor(R * maxRange + 0.5));
m_cielabColors.m_a[idx] = OFstatic_cast(Uint16, floor(G * maxRange + 0.5));
m_cielabColors.m_b[idx] = OFstatic_cast(Uint16, floor(B * maxRange + 0.5));
// Print RGB values
DCMSEG_DEBUG("Segment #" << (idx+1) << " uses RGB color: R=" << m_cielabColors.m_L[idx] << ", G=" << m_cielabColors.m_a[idx] << ", B=" << m_cielabColors.m_b[idx]);
}
Expand Down Expand Up @@ -806,7 +797,9 @@
// In PALETTE mode the per-segment CIELab macro must not be written,
// but the color must still be present in the palette LUT so pixel
// value 0 maps to black.
if (isPalette && !m_cielabColors.prepend(0, 32768, 32768))
Uint16 L, a, b;

Check warning on line 800 in libsrc/Bin2Label.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define each identifier in a dedicated statement.

See more on https://sonarcloud.io/project/issues?id=QIICR_dcmqi&issues=AaDVJc_nw0y-eiAteuw1&open=AaDVJc_nw0y-eiAteuw1&pullRequest=565
IODCIELabUtil::rgb2DicomLab(L, a, b, 0, 0, 0);
if (isPalette && !m_cielabColors.prepend(L, a, b))
{
DCMSEG_ERROR("Failed to prepend background color for palette LUT");
return EC_MemoryExhausted;
Expand Down
2 changes: 0 additions & 2 deletions libsrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ set(HDRS
${INCLUDE_DIR}/Itk2DicomConverter.h
${INCLUDE_DIR}/ParaMapConverter.h
${INCLUDE_DIR}/Helper.h
${INCLUDE_DIR}/ColorUtilities.h
${INCLUDE_DIR}/JSONMetaInformationHandlerBase.h
${INCLUDE_DIR}/JSONParametricMapMetaInformationHandler.h
${INCLUDE_DIR}/JSONSegmentationMetaInformationHandler.h
Expand All @@ -35,7 +34,6 @@ set(SRCS
Dicom2ItkConverterLabel.cpp
ParaMapConverter.cpp
Helper.cpp
ColorUtilities.cpp
Itk2DicomConverter.cpp
JSONMetaInformationHandlerBase.cpp
JSONParametricMapMetaInformationHandler.cpp
Expand Down
Loading
Loading
0