# HG changeset patch # User bgo@SHARKNADO.localdomain # Date 1619451474 -7200 # Node ID 28979b77ce909164b4d1e3e2f74451c0678b0c37 # Parent 1a775f4ee67258377a3cb852889a0a55c3972b57 Suppressed one pass on the dose distribution computation diff -r 1a775f4ee672 -r 28979b77ce90 OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp --- a/OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp Mon Apr 26 12:05:40 2021 +0200 +++ b/OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp Mon Apr 26 17:37:54 2021 +0200 @@ -269,7 +269,7 @@ template void OrthancMultiframeVolumeLoader::CopyPixelDataAndComputeDistribution( - const std::string& pixelData, std::map& distribution) + const std::string& pixelData, std::map& distribution) { #if STONE_TIME_BLOCKING_OPS boost::posix_time::ptime timerStart = boost::posix_time::microsec_clock::universal_time(); @@ -294,6 +294,7 @@ } // first pass to initialize map +#if 0 { const uint8_t* source = reinterpret_cast(pixelData.c_str()); @@ -311,6 +312,7 @@ } } } +#endif { const uint8_t* source = reinterpret_cast(pixelData.c_str()); @@ -351,7 +353,7 @@ { CopyPixel(*targetAddrPix, source); - distribution[*targetAddrPix] += 1; + distribution[*targetAddrPix].count_ += 1; targetAddrPix++; source += bpp; @@ -372,7 +374,7 @@ template void OrthancMultiframeVolumeLoader::ComputeMinMaxWithOutlierRejection( - const std::map& distribution) + const std::map& distribution) { if (distribution.size() == 0) { @@ -391,15 +393,14 @@ // compute number of values and check (assertion) that it is equal to // width * height * depth { - typename std::map::const_iterator it = distribution.begin(); + typename std::map::const_iterator it = distribution.begin(); uint64_t totalCount = 0; distributionRawMin_ = static_cast(it->first); while (it != distribution.end()) { T pixelValue = it->first; - uint64_t count = it->second; - totalCount += count; + totalCount += it->second.count_; ++it; if (it == distribution.end()) distributionRawMax_ = static_cast(pixelValue); @@ -436,14 +437,14 @@ // then start from start and remove pixel values up to // endRejectionCount voxels rejected { - typename std::map::const_iterator it = distribution.begin(); + typename std::map::const_iterator it = distribution.begin(); uint64_t currentCount = 0; while (it != distribution.end()) { T pixelValue = it->first; - uint64_t count = it->second; + uint64_t count = it->second.count_; // if this pixelValue crosses the rejection threshold, let's set it // and exit the loop @@ -468,14 +469,14 @@ // now start from END and remove pixel values up to // endRejectionCount voxels rejected { - typename std::map::const_reverse_iterator it = distribution.rbegin(); + typename std::map::const_reverse_iterator it = distribution.rbegin(); uint64_t currentCount = 0; while (it != distribution.rend()) { T pixelValue = it->first; - uint64_t count = it->second; + uint64_t count = it->second.count_; if ((currentCount <= endRejectionCount) && (currentCount + count > endRejectionCount)) @@ -506,7 +507,7 @@ void OrthancMultiframeVolumeLoader::CopyPixelDataAndComputeMinMax( const std::string& pixelData) { - std::map distribution; + std::map distribution; CopyPixelDataAndComputeDistribution(pixelData, distribution); ComputeMinMaxWithOutlierRejection(distribution); } diff -r 1a775f4ee672 -r 28979b77ce90 OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.h --- a/OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.h Mon Apr 26 12:05:40 2021 +0200 +++ b/OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.h Mon Apr 26 17:37:54 2021 +0200 @@ -41,6 +41,12 @@ class LoadTransferSyntax; class LoadUncompressedPixelData; + struct PixelCount + { + uint64_t count_; + PixelCount() { count_ = 0; } + }; + boost::shared_ptr volume_; std::string instanceId_; std::string transferSyntaxUid_; @@ -81,11 +87,11 @@ /** Service method for CopyPixelDataAndComputeMinMax*/ template void CopyPixelDataAndComputeDistribution(const std::string& pixelData, - std::map& distribution); + std::map& distribution); /** Service method for CopyPixelDataAndComputeMinMax*/ template - void ComputeMinMaxWithOutlierRejection(const std::map& distribution); + void ComputeMinMaxWithOutlierRejection(const std::map& distribution); void SetUncompressedPixelData(const std::string& pixelData);