示例#1
0
kkint32  OurNeighbors::LastScanLine (const ImageFeaturesList&  images)  const
{
  kkint32  lastScanLine = 0;
  ImageFeaturesList::const_iterator  idx;
  for  (idx = images.begin ();  idx != images.end ();  idx++)
  {
    const ImageFeaturesPtr image = *idx;
    if  (image->SfCentroidRow () > lastScanLine)
      lastScanLine = (kkint32)(image->SfCentroidRow () + 0.5f);
  }

  return  lastScanLine;
}  /* LastScanLine */
示例#2
0
LLoydsEntryPtr  OurNeighbors::DeriveLLoydsBins (const ImageFeaturesList&  examples,
                                                kkint32                   lloydsBinSize
                                               )
{
  double  lloydsIndex = 0.0;

  kkint32  numLLoydsBins = kkint32 (lastScanLine + lloydsBinSize - 1)  / kkint32 (lloydsBinSize);

  VectorIntPtr  lloydsBins = new VectorInt (numLLoydsBins, 0);

  ImageFeaturesList::const_iterator  idx;
  for  (idx = examples.begin ();  idx != examples.end ();  idx++)
  {
    const ImageFeaturesPtr i = *idx;
    kkint32 lloydsBin =  kkint32 (i->SfCentroidRow () / double (lloydsBinSize));
    if  (lloydsBin >= numLLoydsBins)
    {
      // This can not happen; but if it does; then I must of screwed up the programming.
      log.Level (-1) << endl << endl << endl
                     << "OurNeighbors::DeriveLLoydsBins       **** ERROR ****" << endl
                     << endl
                     << "              An invalid lloydsBin[" << lloydsBin << "] was derived." << endl
                     << "              must be in range of  [0 - " << (numLLoydsBins - 1) << "]" << endl
                     << endl;

      lloydsBin = numLLoydsBins - 1;
    }

    (*lloydsBins)[lloydsBin]++;
  }

  lloydsIndex = LLoydsIndexOfPatchiness (*lloydsBins);

  return  new LLoydsEntry (lloydsBinSize, lloydsBins, lloydsIndex);
}  /* DeriveLLoydsBins */