37 m_histogram (histogram),
74 if (!inTile || !inTile->
getBuf())
106 for (ipt.
y=tileRect.
ul().
y; ipt.
y<=tileRect.
lr().
y; ++ipt.
y)
108 for (ipt.
x=tileRect.
ul().
x; ipt.
x<=tileRect.
lr().
x; ++ipt.
x)
110 pixel = inTile->
getPix(ipt, band);
111 if (pixel != null_pixel)
129 if ((pixel >= (cluster->
min-delta)) && (pixel <= (cluster->
max+delta)))
205 xmsg<<
"ossimKMeansFilter:"<<__LINE__<<
" Could not establish a histogram. Cannot " 228 xmsg<<
"ossimKMeansFilter:"<<__LINE__<<
" Number of groups has not been initialized!";
239 if (!band_histo.
valid())
241 xmsg<<
"ossimKMeansFilter:"<<__LINE__<<
" Null band histogram returned!";
252 cout<<
"ossimKMeansFilter:"<<__LINE__<<
" No K-means clustering data available."<<endl;
259 double mean0 = classifier->
getMean(0);
260 double mean1 = classifier->
getMean(1);
261 double sigma0 = classifier->
getSigma(0);
262 double sigma1 = classifier->
getSigma(1);
263 double threshold = 0;
267 threshold = (mean0 + mean1)/2.0;
270 threshold = (sigma1*mean0 + sigma0*mean1)/(sigma0 + sigma1);
273 threshold = (sigma1*sigma1*mean0 + sigma0*sigma0*mean1)/(sigma0*sigma0 + sigma1*sigma1);
279 cout<<
"ossimKMeansFilter:"<<__LINE__<<
" Using threshold = "<<threshold<<endl;
303 xmsg <<
"ossimKMeansFilter:"<<__LINE__<<
" Requested K="<<K<<
" but only max 255 supported!";
344 kwl.
add(prefix,
"num_bands", numBands);
365 keybase2 +=
"cluster";
368 key = keybase2 +
".mean";
370 key = keybase2 +
".sigma";
372 key = keybase2 +
".min";
374 key = keybase2 +
".max";
385 bool return_state =
true;
float GetRangeMin() const
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &origin, ossim_uint32 resLevel=0)
virtual void setDescription(const ossimString &description)
virtual ossim_uint32 getNumberOfInputBands() const
void setVerbose(bool v=true) const
RTTI_DEF1(ossimKMeansFilter, "ossimKMeansFilter", ossimImageSourceFilter)
void setThresholdMode(ThresholdMode mode)
Special use case is to use K-means for thresholding an image into two values based on the histogram's...
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
void setComputationMode(ossimHistogramMode mode)
virtual void setImageRectangle(const ossimIrect &rect)
virtual double getMinPixelValue(ossim_uint32 band=0) const
Returns the min pixel of the band.
Represents serializable keyword/value map.
float GetRangeMax() const
const ossimKMeansClustering * getBandClassifier(ossim_uint32 band=0) const
Callers may be interested in reporting the cluster statistics computed by this class.
ossim_uint32 m_numClusters
static ossimString toString(bool aValue)
Numeric to string methods.
const ossimIpt & ul() const
virtual ossimDataObjectStatus getDataObjectStatus() const
void setInputHistogram(ossimMultiBandHistogram *histo)
Sets the input source's histogram for quicker K-means analysis.
virtual ossim_float64 getPix(const ossimIpt &position, ossim_uint32 band=0) const
Will return the pixel at location position.
std::vector< double > m_thresholds
virtual void initialize()
Initialize the data buffer.
void setSamples(T *samples, ossim_uint32 num_entries)
const ossimKMeansClustering::Cluster * getCluster(ossim_uint32 i) const
virtual void initialize()
std::vector< ossimRefPtr< ossimKMeansClustering > > m_classifiers
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
static ossimImageDataFactory * instance()
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
virtual ossimDataObjectStatus validate() const
void setClusterPixelValues(const ossim_uint32 *dns, ossim_uint32 K)
Optionally define the output digital numbers for each cluster to be used for remapping the input pixe...
virtual ossimRefPtr< ossimMultiResLevelHistogram > getHistogram(const ossimIrect &rect)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=NULL)
Method to the load (recreate) the state of an object from a keyword list.
void setNumClusters(ossim_uint32 K)
ossimImageSource * theInputConnection
unsigned int ossim_uint32
ossimRefPtr< ossimMultiBandHistogram > m_histogram
Have num_bands entries.
const char * chars() const
For backward compatibility.
ossimRefPtr< ossimHistogram > getHistogram(ossim_int32 band)
std::vector< double > m_minPixelValue
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=NULL) const
Method to save the state of an object to a keyword list.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
const ossimIpt & lr() const
std::vector< double > m_maxPixelValue
virtual void initialize()
ThresholdMode m_thresholdMode
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
ossim_uint32 getNumClusters() const
virtual void makeBlank()
Initializes data to null pixel values.
void allocate()
Called on first getTile, will initialize all data needed.
virtual void setMaxPix(ossim_float64 max_pix)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
ossimRefPtr< ossimImageData > m_tile
virtual const void * getBuf() const
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
std::vector< ossim_uint32 > m_pixelValues
virtual void setMaxNumberOfRLevels(ossim_uint32 number)
void setPopulations(T *populations, ossim_uint32 num_entries)
double getSigma(ossim_uint32 groupId) const
ossimRefPtr< ossimMultiBandHistogram > getMultiBandHistogram(ossim_uint32 resLevel) const
double getMean(ossim_uint32 groupId) const
void setNumClusters(ossim_uint32 K)
Defines how many classification clusters will be resolved.
virtual void setMinPix(ossim_float64 min_pix)
unsigned char ossim_uint8
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)