Exemplo n.º 1
0
void recurGraph(byte *g) {
  int res,i,j;
  byte buf[W*H];

  res=complete(g);

  if(res==-1) return;
  if(res==1) {
    if(isMin(g)) {
      outGraph(g);
      testGraph(g);
      printf("ok\n");
      return;
    }//if
  }//if
  for(i=0; i<H*W; i++) {
    for(j=0; j<4; j++) {
      if((g[i]&(1<<j))&&(g[i]&(16<<j))) {
        copy(g,buf);
        buf[i]-=(1<<j);
        recurGraph(buf);
        copy(g,buf);
        buf[i]-=(16<<j);
        recurGraph(buf);
        return;
      }//if
    }//for
  }//for
}//recurGraph
Exemplo n.º 2
0
void HessianDetector::findLevelKeypoints(float curScale, float pixelDistance)
{
   assert(par.border >= 2);
   const int rows = cur.rows;
   const int cols = cur.cols;
   for (int r = par.border; r < (rows - par.border); r++)
   {
      for (int c = par.border; c < (cols - par.border); c++) 
      {
         const float val = cur.at<float>(r,c);
         if ( (val > positiveThreshold && (isMax(val, cur, r, c) && isMax(val, low, r, c) && isMax(val, high, r, c))) ||
              (val < negativeThreshold && (isMin(val, cur, r, c) && isMin(val, low, r, c) && isMin(val, high, r, c))) )
            // either positive -> local max. or negative -> local min.
            localizeKeypoint(r, c, curScale, pixelDistance);
      }
   }
}
Exemplo n.º 3
0
Arquivo: main01.c Projeto: HalseyLee/C
int main(int argc, const char * argv[]) {
    int num[] = {34,56,67,23,567,67,98,87};
    int len = sizeof(num) / sizeof(num[0]);
    //最大值
    int res = isMax(num,len);
    printf("%d \n",res);
    //最小值
    res = isMin(num,len);
    printf("%d \n",res);
    //累加和
    res = sum(num,len);
    printf("%d \n",res);
    //平均数
    res = avg(num,len);
    printf("%d \n",res);
    //找
    int key = 23;
    res = number(num,len,key);
    printf("%d \n",res);
}
Exemplo n.º 4
0
bool Normalization::algorithm() {
  KstVectorPtr vectorIn = inputVector(VECTOR_IN);
  KstVectorPtr vectorOut = outputVector(VECTOR_OUT);
  double *arr;
  double *Yi;
  int iLength = vectorIn->length();
  int w = 1;

  arr = new double[iLength];
  Yi = new double[iLength];

  for(int i=0; i<iLength; i++)
  {
    Yi[i] = vectorIn->value()[i];
  }

  //
  // exclude peak values
  //
  for(int loop=0; loop<2; loop++)
  {
    for(int i=0; i<iLength; i++)
    {
      arr[i] = Yi[i];
    }

    for(int i=0; i<iLength; i++)
    {
      if(isMin(Yi, i, iLength) || isMax(Yi, i, iLength))
      {
        excludePts(arr, i, w, iLength);
      }
    }

    searchHighPts(arr, iLength);
    interpolate(Yi, arr, iLength);
  }

  //
  // do a piecewise linear fit
  //
  vectorOut->resize(iLength, false);

  int L = 3;
  double cof[2] = { 0.0, 0.0 };

  for(int i=0; i<iLength; i=i+L)
  {
    fit(i, L, iLength, Yi, cof, vectorOut);
  }

  //
  // normalize
  //
  for(int i=0; i<iLength; i++)
  {
    vectorOut->value()[i] = vectorIn->value()[i] / vectorOut->value()[i];
  }

  //
  // exclude off points
  //
  for(int i=0; i<iLength; i++)
  {
    if(vectorOut->value()[i] < 0.0 || vectorOut->value()[i] > 1.2)
    {
      vectorOut->value()[i] = NOPOINT;
    }
  }

  delete[] arr;
  delete[] Yi;

  return true;
}