Mercurial > hg > orthanc-stone
diff OrthancStone/Sources/Loaders/OrthancMultiframeVolumeLoader.cpp @ 1757:28979b77ce90
Suppressed one pass on the dose distribution computation
author | bgo@SHARKNADO.localdomain |
---|---|
date | Mon, 26 Apr 2021 17:37:54 +0200 |
parents | 946eb7200b82 |
children | 4ee11b8773e2 |
line wrap: on
line diff
--- 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 <typename T> void OrthancMultiframeVolumeLoader::CopyPixelDataAndComputeDistribution( - const std::string& pixelData, std::map<T,uint64_t>& distribution) + const std::string& pixelData, std::map<T, PixelCount>& 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<const uint8_t*>(pixelData.c_str()); @@ -311,6 +312,7 @@ } } } +#endif { const uint8_t* source = reinterpret_cast<const uint8_t*>(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 <typename T> void OrthancMultiframeVolumeLoader::ComputeMinMaxWithOutlierRejection( - const std::map<T, uint64_t>& distribution) + const std::map<T, PixelCount>& 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<T, uint64_t>::const_iterator it = distribution.begin(); + typename std::map<T, PixelCount>::const_iterator it = distribution.begin(); uint64_t totalCount = 0; distributionRawMin_ = static_cast<float>(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<float>(pixelValue); @@ -436,14 +437,14 @@ // then start from start and remove pixel values up to // endRejectionCount voxels rejected { - typename std::map<T, uint64_t>::const_iterator it = distribution.begin(); + typename std::map<T, PixelCount>::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<T, uint64_t>::const_reverse_iterator it = distribution.rbegin(); + typename std::map<T, PixelCount>::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<T, uint64_t> distribution; + std::map<T, PixelCount> distribution; CopyPixelDataAndComputeDistribution(pixelData, distribution); ComputeMinMaxWithOutlierRejection(distribution); }