diff Framework/Loaders/OrthancMultiframeVolumeLoader.h @ 1260:5a2d5380148d toa2020012701

Added outlier rejection for min max computation in multiframe volume loader
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 27 Jan 2020 14:29:02 +0100
parents 32eaf4929b08
children 2d8ab34c8c91
line wrap: on
line diff
--- a/Framework/Loaders/OrthancMultiframeVolumeLoader.h	Tue Jan 21 16:52:37 2020 +0100
+++ b/Framework/Loaders/OrthancMultiframeVolumeLoader.h	Mon Jan 27 14:29:02 2020 +0100
@@ -43,6 +43,11 @@
     std::string                          instanceId_;
     std::string                          transferSyntaxUid_;
     bool                                 pixelDataLoaded_;
+    float                                outliersHalfRejectionRate_;
+    float                                distributionRawMin_;
+    float                                distributionRawMax_;
+    float                                computedDistributionMin_;
+    float                                computedDistributionMax_;
 
     const std::string& GetInstanceId() const;
 
@@ -52,8 +57,35 @@
 
     void SetGeometry(const Orthanc::DicomMap& dicom);
 
+
+    /**
+    This method will :
+    
+    - copy the pixel values from the response to the volume image
+    - compute the maximum and minimum value while discarding the
+      outliersHalfRejectionRate_ fraction of the outliers from both the start 
+      and the end of the distribution.
+
+      In English, this means that, if the volume dataset contains a few extreme
+      values very different from the rest (outliers) that we want to get rid of,
+      this method allows to do so.
+
+      If you supply 0.005, for instance, it means 1% of the extreme values will
+      be rejected (0.5% on each side of the distribution)
+    */
     template <typename T>
-    void CopyPixelData(const std::string& pixelData);
+    void CopyPixelDataAndComputeMinMax(const std::string& pixelData);
+      
+    /** Service method for CopyPixelDataAndComputeMinMax*/
+    template <typename T>
+    void CopyPixelDataAndComputeDistribution(
+      const std::string& pixelData, 
+      std::map<T, uint64_t>& distribution);
+
+    /** Service method for CopyPixelDataAndComputeMinMax*/
+    template <typename T>
+    void ComputeMinMaxWithOutlierRejection(
+      const std::map<T, uint64_t>& distribution);
 
     void SetUncompressedPixelData(const std::string& pixelData);
 
@@ -63,7 +95,8 @@
   public:
     OrthancMultiframeVolumeLoader(boost::shared_ptr<DicomVolumeImage> volume,
                                   IOracle& oracle,
-                                  IObservable& oracleObservable);
+                                  IObservable& oracleObservable,
+                                  float outliersHalfRejectionRate = 0.0005);
     
     virtual ~OrthancMultiframeVolumeLoader();
 
@@ -72,6 +105,12 @@
       return pixelDataLoaded_;
     }
 
+    void GetDistributionMinMax
+      (float& minValue, float& maxValue) const;
+
+    void GetDistributionMinMaxWithOutliersRejection
+      (float& minValue, float& maxValue) const;
+
     void LoadInstance(const std::string& instanceId);
   };
 }