Skip to content

Commit

Permalink
Fixed issue with rendering MONOCHROME1 images.
Browse files Browse the repository at this point in the history
Fixed issue when rendering certain MONOCHROME1 images without specifying
a VOI transformation, e.g. an image with 13 bits per pixel. Due to an
incorrect calculation, the rendered output value sometimes deviated by 1
from the expected value.

Thanks to Giulio Simonetti <[email protected]> for the
report and sample file.
  • Loading branch information
jriesmeier committed Oct 30, 2024
1 parent d1fb197 commit 3ff1f83
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions dcmimgle/include/dcmtk/dcmimgle/dimoopxt.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 1996-2021, OFFIS e.V.
* Copyright (C) 1996-2024, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
Expand Down Expand Up @@ -643,9 +643,9 @@ class DiMonoOutputPixelTemplate
const double absmin = inter->getAbsMinimum();
const double absmax = inter->getAbsMaximum();
const double lowvalue = OFstatic_cast(double, low);
const double outrange = OFstatic_cast(double, high) - lowvalue + 1; // output range
const unsigned long ocnt = determineOptimizationCount(inter->getAbsMaxRange()); // number of LUT entries
DCMIMGLE_TRACE("intermediate pixel data - absmin: " << absmin << ", absmax: " << absmax);
const double outrange = OFstatic_cast(double, high) - lowvalue; // output range
const unsigned long ocnt = determineOptimizationCount(inter->getAbsMaxRange()); // number of LUT entries
DCMIMGLE_TRACE("intermediate pixel data - absmin: " << absmin << ", absmax: " << absmax << ", absrange: " << inter->getAbsMaxRange());
const T1 *p = pixel + start;
T3 *q = Data;
unsigned long i;
Expand All @@ -656,7 +656,7 @@ class DiMonoOutputPixelTemplate
createDisplayLUT(dlut, disp, plut->getBits());
Uint32 value; // presentation LUT is always unsigned
const double gradient1 = OFstatic_cast(double, plut->getCount()) / inter->getAbsMaxRange();
const double gradient2 = outrange / OFstatic_cast(double, plut->getAbsMaxRange());
const double gradient2 = outrange / OFstatic_cast(double, plut->getAbsMaxRange() - 1);
if (initOptimizationLUT(lut, ocnt))
{ // use LUT for optimization
q = lut;
Expand Down Expand Up @@ -722,7 +722,7 @@ class DiMonoOutputPixelTemplate
}
} else { // has no presentation LUT
createDisplayLUT(dlut, disp, inter->getBits());
const double gradient = outrange / (inter->getAbsMaxRange());
const double gradient = outrange / (inter->getAbsMaxRange() - 1);
if (initOptimizationLUT(lut, ocnt))
{ // use LUT for optimization
q = lut;
Expand Down

0 comments on commit 3ff1f83

Please sign in to comment.