Skip to content

Commit

Permalink
Simplified DcmQuantColorTable::computeHistogram().
Browse files Browse the repository at this point in the history
Simplified code to avoid bogus error reports from Cppcheck.

Thanks to Oliver Klerx <[email protected]> for the suggestion and patch.
  • Loading branch information
eichelberg committed Dec 18, 2024
1 parent 38186d3 commit 28a6e30
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions dcmimage/libsrc/diqtctab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,20 @@ OFCondition DcmQuantColorTable::computeHistogram(

// compute initial maxval
maxval = OFstatic_cast(DcmQuantComponent, -1);
DcmQuantColorHashTable *htable = NULL;

// attempt to make a histogram of the colors, unclustered.
// If at first we don't succeed, lower maxval to increase color
// coherence and try again. This will eventually terminate.
OFBool done = OFFalse;
while (! done)
do
{
htable = new DcmQuantColorHashTable();
numColors = htable->addToHashTable(image, maxval, maxcolors);
if (numColors > 0) done = OFTrue;
else
{
delete htable;
DcmQuantColorHashTable htable;
if (htable.addToHashTable(image, maxval, maxcolors) > 0)
{
numColors = htable.createHistogram(array);
return EC_Normal;
}
maxval = maxval/2;
}
}

numColors = htable->createHistogram(array);
delete htable;
return EC_Normal;
} while (OFTrue);
}


Expand Down

0 comments on commit 28a6e30

Please sign in to comment.