Changeset 695


Ignore:
Timestamp:
03/15/06 10:22:48 (18 years ago)
Author:
bittner
Message:

pvs homegenity measure added

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Makefile

    r677 r695  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.0) on: út 14. II 10:13:02 2006 
     3# Generated by qmake (2.00a) (Qt 4.1.0) on: st 15. III 09:41:58 2006 
    44# Project:  preprocessor.pro 
    55# Template: app 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r677 r695  
    114114   
    115115 
     116  /** Compute continuous PVS difference */ 
     117  float GetPvsHomogenity(const Pvs<T> &pvs) { 
     118        float  
     119          pvsReduction, 
     120          pvsEnlargement; 
     121 
     122        ComputeContinuousPvsDifference(pvs, 
     123                                                                   pvsReduction, 
     124                                                                   pvsEnlargement); 
     125 
     126        return pvsReduction + pvsEnlargement; 
     127  } 
     128 
    116129                                           
    117130                                           
     
    122135 
    123136 
    124 /** Compute continuous PVS difference */ 
     137/** 
     138   Compute continuous PVS difference of 'b' with respect to the base PVS (*this). 
     139   Provides separatelly PVS reduction from PVS enlargement. 
     140 
     141*/ 
    125142template <typename T> 
    126143void 
    127 Pvs<T>::ComputeContinuousPvsDifference(const Pvs<T> &pvs, 
     144Pvs<T>::ComputeContinuousPvsDifference(const Pvs<T> &b, 
    128145                                                                           float &pvsReduction, 
    129146                                                                           float &pvsEnlargement) 
    130147{ 
    131    
    132  
     148  // Uses sum of log differences, which corresponds to entropy 
     149  std::map<T, PvsData<T>, LtSample<T> >::const_iterator it; 
     150   
     151  for (it = b.mEntries.begin(); it != b.mEntries.end(); ++ it) { 
     152        float bSumPdf = (*it).second.mSumPdf; 
     153        float aSumPdf = 0.0f; 
     154        PvsData<T> *data = Find((*it).first);            
     155        if (data) { 
     156          aSumPdf = data->second.mSumPdf; 
     157          // mark this entry as processed to avoid double counting 
     158          data->second.mSumPdf = -aSumPdf; 
     159        } 
     160        float diff = bSumPdf - aSumPdf; 
     161         
     162        if (diff > 0.0f) { 
     163          pvsEnlargement += diff; 
     164        } else { 
     165          pvsReduction += -diff; 
     166        } 
     167  } 
     168   
     169  for (it = mEntries.begin(); it != mEntries.end(); ++ it) { 
     170        float aSumPdf = (*it).second.mSumPdf; 
     171        float bSumPdf = 0.0f; 
     172        if (aSumPdf < 0.0f) { 
     173          // this entry was already accounted for! 
     174          // just revert it back 
     175          (*it).second.mSumPdf = -aSumPdf; 
     176        } else { 
     177          PvsData<T> *data = b.Find((*it).first); 
     178          if (data) { 
     179                bSumPdf = data->second.mSumPdf; 
     180          } 
     181          float diff = bSumPdf - aSumPdf; 
     182           
     183          if (diff > 0.0f) { 
     184                pvsEnlargement += diff; 
     185          } else { 
     186                pvsReduction += -diff; 
     187          } 
     188        } 
     189  } 
    133190} 
    134191 
Note: See TracChangeset for help on using the changeset viewer.