Skip to content
Snippets Groups Projects
Select Git revision
  • e6ea63fb8cafea64ab5d680f27a2f306431f2d62
  • master default protected
  • development
  • cpp-experiment
  • v0.3.0
5 results

variables.jl

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    NPBGSubtractor.cpp 30.42 KiB
    #include <assert.h>
    #include <math.h>
    #include <string.h>
    
    #include "NPBGSubtractor.h"
    
    //#ifdef _DEBUG
    //#undef THIS_FILE
    //static char THIS_FILE[]=__FILE__;
    //#define new DEBUG_NEW
    //#endif
    //using namespace bgslibrary::algorithms::kde;
    
    namespace bgslibrary
    {
      namespace algorithms
      {
        namespace kde
        {
          void BGR2SnGnRn(unsigned char * in_image,
            unsigned char * out_image,
            unsigned int rows,
            unsigned int cols)
          {
            unsigned int i;
            unsigned int r2, r3;
            unsigned int r, g, b;
            double s;
    
            for (i = 0; i < rows*cols * 3; i += 3)
            {
              b = in_image[i];
              g = in_image[i + 1];
              r = in_image[i + 2];
    
              // calculate color ratios
              s = (double)255 / (double)(b + g + r + 30);
    
              r2 = (unsigned int)((g + 10) * s);
              r3 = (unsigned int)((r + 10) * s);
    
              out_image[i] = (unsigned char)(((unsigned int)b + g + r) / 3);
              out_image[i + 1] = (unsigned char)(r2 > 255 ? 255 : r2);
              out_image[i + 2] = (unsigned char)(r3 > 255 ? 255 : r3);
            }
          }
    
          void UpdateDiffHist(unsigned char * image1, unsigned char * image2, DynamicMedianHistogram * pHist)
          {
            unsigned int j;
            int bin, diff;
    
            unsigned int  imagesize = pHist->imagesize;
            unsigned char histbins = pHist->histbins;
            unsigned char *pAbsDiffHist = pHist->Hist;
    
            int histbins_1 = histbins - 1;
    
            for (j = 0; j < imagesize; j++)
            {
              diff = (int)image1[j] - (int)image2[j];
              diff = abs(diff);
              // update histogram
              bin = (diff < histbins ? diff : histbins_1);
              pAbsDiffHist[j*histbins + bin]++;
            }
          }
    
          void FindHistMedians(DynamicMedianHistogram * pAbsDiffHist)
          {