Exemple #1
0
void imProcessRegionalMaximum(const imImage* src_image, imImage* dst_image)
{
  int i, x, y, offset, offsetA, offsetB,
    width = src_image->width,
    height = src_image->height;

  float* src_data = (float*)src_image->data[0];
  imbyte* dst_data = (imbyte*)dst_image->data[0];

  for (y = 1; y < height-1; y++) 
  {
    offset = y * width + 1;
    offsetA = offset - width;
    offsetB = offset + width;

    for (x = 1; x < width-1; x++) 
    {
      if (src_data[offset]) 
        iCheckMaximum(offset, offsetA, offsetB, src_data, dst_data);

      offset++;
      offsetA++; 
      offsetB++; 
    }
  }

  // remove false maximum
  for (y = 2; y < height-2; y++) 
  {
    offset = y * width + 2;
    offsetA = offset - 2*width;
    offsetB = offset + 2*width;

    for (x = 2; x < width-2; x++) 
    {
      if (dst_data[offset] == 2)
      {
        if (iCheckFalseMaximum(offset, offsetA, offsetB, width, src_data))
          iFillValue(dst_data, x, y, width, 0);
      }

      offset++;
      offsetA++; 
      offsetB++; 
    }
  }

  // update destiny with remaining maximum
  for (i = 0; i < src_image->count; i++) 
  {
    if (dst_data[i] == 2)
      dst_data[i] = 1;
  }
}
Exemple #2
0
void imProcessRegionalMaximum(const imImage* src_image, imImage* dst_image)
{
  int width = src_image->width,
     height = src_image->height;

  float* src_data = (float*)src_image->data[0];
  imbyte* dst_data = (imbyte*)dst_image->data[0];

#ifdef _OPENMP
#pragma omp parallel for if (IM_OMP_MINHEIGHT(height))
#endif
  for (int y = 1; y < height-1; y++) 
  {
    int offset = y * width + 1;
    int offsetA = offset - width;
    int offsetB = offset + width;

    for (int x = 1; x < width-1; x++) 
    {
      if (src_data[offset]) 
        iCheckMaximum(offset, offsetA, offsetB, src_data, dst_data);

      offset++;
      offsetA++; 
      offsetB++; 
    }
  }

  // remove false maximum
#ifdef _OPENMP
#pragma omp parallel for if (IM_OMP_MINHEIGHT(height))
#endif
  for (int y = 2; y < height-2; y++) 
  {
    int offset = y * width + 2;
    int offsetA = offset - 2*width;
    int offsetB = offset + 2*width;

    for (int x = 2; x < width-2; x++) 
    {
      if (dst_data[offset] == 2)
      {
        if (iCheckFalseMaximum(offset, offsetA, offsetB, width, src_data))
          iFillValue(dst_data, x, y, width, 0);
      }

      offset++;
      offsetA++; 
      offsetB++; 
    }
  }

  // update destiny with remaining maximum
#ifdef _OPENMP
#pragma omp parallel for if (IM_OMP_MINCOUNT(src_image->count))
#endif
  for (int i = 0; i < src_image->count; i++) 
  {
    if (dst_data[i] == 2)
      dst_data[i] = 1;
  }
}