This file is indexed.

/usr/include/ossim/base/ossimKMeansClustering.h is in libossim-dev 2.2.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//**************************************************************************************************
//
//     OSSIM Open Source Geospatial Data Processing Library
//     See top level LICENSE.txt file for license information
//
//**************************************************************************************************
#ifndef ossimKmeansClassifier_HEADER
#define ossimKmeansClassifier_HEADER

#include <ossim/base/ossimConstants.h>
#include <ossim/base/ossimCommon.h>
#include <ossim/base/ossimReferenced.h>
#include <vector>

/***************************************************************************************************
 *
 * This class provides a sample set clustering capability using the traditional K-means scheme for
 * partitioning datasets into K distinct groups according to sample value.
 *
 * The samples can be provided as a simple array of samples, or as a histogram when the
 * populations of the corresponding samples are provided as well. The latter scheme is used by the
 * ossimKMeansFilter for clustering pixel values given the image histogram.
 *
 **************************************************************************************************/
class OSSIM_DLL ossimKMeansClustering : public ossimReferenced
{
public:
   class Cluster
   {
   public:
      Cluster() :
         min(0), max(0), mean(0), sigma(0), new_mean(0), n(0) {}

      double min;      // samples in group are => this, used for detecting convergence
      double max;      // samples in group are < this, used for detecting convergence
      double mean;
      double sigma;
      double new_mean;
      double n;        // number of samples collected for running mean
   };

   ossimKMeansClustering();
   ~ossimKMeansClustering();

   void setNumClusters(ossim_uint32 K);
   template<class T> void setSamples(T* samples, ossim_uint32 num_entries);
   template<class T> void setPopulations(T* populations, ossim_uint32 num_entries);
   bool computeKmeans();

   ossim_uint32 getNumClusters() const { return m_clusters.size(); }
   double getMean(ossim_uint32 groupId) const;
   double getSigma(ossim_uint32 groupId) const;
   double getMinValue(ossim_uint32 groupId) const;
   double getMaxValue(ossim_uint32 groupId) const;

   const ossimKMeansClustering::Cluster* getCluster(ossim_uint32 i) const;

   void setVerbose(bool v=true) const  { m_verbose = v; }

private:
   ossim_uint32 m_numEntries;
   double* m_samples;
   double* m_populations; // use double to handle arbitrarily large datasets
   std::vector<Cluster> m_clusters;
   bool m_clustersValid;
   mutable bool m_verbose;
};

template<class T> void ossimKMeansClustering::setSamples(T* samples, ossim_uint32 num_entries)
{
   if ((num_entries == 0) || (samples == 0))
      return;

   m_clustersValid = false;
   m_numEntries = num_entries;
   m_samples = new double[num_entries];
   for (ossim_uint32 i=0; i<num_entries; i++)
      m_samples[i] = (double) samples[i];
}

template<class T> void ossimKMeansClustering::setPopulations(T* populations,
                                                             ossim_uint32 num_entries)
{
   if ((num_entries == 0) || (populations == 0))
      return;

   m_clustersValid = false;
   m_populations = new double[num_entries];
   for (ossim_uint32 i=0; i<num_entries; i++)
      m_populations[i] = (double) populations[i];
}



#endif /* ossimKMeansClassifier_HEADER */