コード例 #1
0
/* Same as ConvHorizontal, but apply to vertical columns of image.
*/
void ConvVertical(vector<float>& image, int width, int height, float *kernel, int ksize)
{
  int rows, cols, r, c, i, halfsize;
  float buffer[4000];
  vector<float> pixels(width*height);

  rows = height;
  cols = width;

  halfsize = ksize / 2;
  pixels = image;
  assert(rows + ksize < 4000);

  for (c = 0; c < cols; c++) {
    for (i = 0; i < halfsize; i++)
      buffer[i] = pixels[c];
    for (i = 0; i < rows; i++)
      buffer[halfsize + i] = pixels[i*cols+c];
    for (i = 0; i < halfsize; i++)
      buffer[halfsize + rows + i] = pixels[(rows - 1)*cols+c];

    ConvBufferFast(buffer, kernel, rows, ksize);
    for (r = 0; r < rows; r++)
      pixels[r*cols+c] = buffer[r];
  }

  image = pixels;	 
}
コード例 #2
0
/* Convolve image with the 1-D kernel vector along image rows.  This
is designed to be as efficient as possible.  Pixels outside the
image are set to the value of the closest image pixel.
*/
void ConvHorizontal(vector<float>& image, int width, int height, float *kernel, int ksize)
{
  int rows, cols, r, c, i, halfsize;
  float buffer[4000];
  vector<float> pixels(width*height);


  rows = height;
  cols = width;

  halfsize = ksize / 2;
  pixels = image;
  assert(cols + ksize < 4000);

  for (r = 0; r < rows; r++) {
    /* Copy the row into buffer with pixels at ends replicated for
    half the mask size.  This avoids need to check for ends
    within inner loop. */
    for (i = 0; i < halfsize; i++)
      buffer[i] = pixels[r*cols];
    for (i = 0; i < cols; i++)
      buffer[halfsize + i] = pixels[r*cols+i];
    for (i = 0; i < halfsize; i++)
      buffer[halfsize + cols + i] = pixels[r*cols+cols-1];

    ConvBufferFast(buffer, kernel, cols, ksize);
    for (c = 0; c < cols; c++)
      pixels[r*cols+c] = buffer[c];
  }
  image = pixels;	 
}
コード例 #3
0
ファイル: sift_util.cpp プロジェクト: oakfr/omni3d
/* Convolve image with the 1-D kernel vector along image rows.  This
   is designed to be as efficient as possible.  Pixels outside the
   image are set to the value of the closest image pixel.
*/
void ConvHorizontal(SiftImage image, double *kernel, int ksize)
{
    int rows, cols, r, c, i, halfsize;
    double **pixels, buffer[4000];

    rows = image->rows;
    cols = image->cols;
    halfsize = ksize / 2;
    pixels = image->pixels;
    assert(cols + ksize < 4000);

    for (r = 0; r < rows; r++) {
	/* Copy the row into buffer with pixels at ends replicated for
	   half the mask size.  This avoids need to check for ends
	   within inner loop. */
	for (i = 0; i < halfsize; i++)
	    buffer[i] = pixels[r][0];
	for (i = 0; i < cols; i++)
	    buffer[halfsize + i] = pixels[r][i];
	for (i = 0; i < halfsize; i++)
	    buffer[halfsize + cols + i] = pixels[r][cols - 1];

	ConvBufferFast(buffer, kernel, cols, ksize);
	for (c = 0; c < cols; c++)
	  pixels[r][c] = buffer[c];
    }
}
コード例 #4
0
ファイル: gauss_convol.cpp プロジェクト: UIKit0/MissStereo
/* Same as ConvHorizontal, but apply to vertical columns of image.
*/
static void ConvVertical(LWImage<flnum>& image, flnum *kernel, int ksize)
{
    flnum buffer[8000];

    const int rows = image.h;
    const int cols = image.w;
    const int halfsize = ksize / 2;
    assert(rows + ksize < 8000);  /*TANG: this will give a limit of image size*/

    for(int comp = 0; comp < image.comps; comp++) {
        const int deltaComp = comp*image.stepComp();
        for (int c = 0; c < cols; c++) {
            for (int i = 0; i < halfsize; i++)
                buffer[i] = image.pixel(c,0)[deltaComp];
            for (int i = 0; i < rows; i++)
                buffer[halfsize + i] = image.pixel(c,i)[deltaComp];
            for (int i = 0; i < halfsize; i++)
                buffer[halfsize + rows + i] = image.pixel(c,rows-1)[deltaComp];

            ConvBufferFast(buffer, kernel, rows, ksize);
            for (int r = 0; r < rows; r++)
                image.pixel(c,r)[deltaComp] = buffer[r];
        }
    }
}
コード例 #5
0
ファイル: gauss_convol.cpp プロジェクト: UIKit0/MissStereo
/* Convolve image with the 1-D kernel vector along image rows.  This
   is designed to be as efficient as possible.  Pixels outside the
   image are set to the value of the closest image pixel.
*/
static void ConvHorizontal(LWImage<flnum>& image, flnum *kernel, int ksize)
{
    flnum buffer[8000];
    
    const int rows = image.h;
    const int cols = image.w;
    const int halfsize = ksize / 2;
    assert(cols + ksize < 8000); /*TANG: this will give a limit of image size*/

    for(int comp = 0; comp < image.comps; comp++) {
        const int deltaComp = comp*image.stepComp();
        for (int r = 0; r < rows; r++) {
            /* Copy the row into buffer with pixels at ends replicated for
            half the mask size.  This avoids need to check for ends
            within inner loop. */
            for (int i = 0; i < halfsize; i++)
                buffer[i] = image.pixel(0,r)[deltaComp];
            for (int i = 0; i < cols; i++)
                buffer[halfsize + i] = image.pixel(i,r)[deltaComp]; 
            for (int i = 0; i < halfsize; i++)
                buffer[halfsize + cols + i] = image.pixel(cols-1,r)[deltaComp];

            ConvBufferFast(buffer, kernel, cols, ksize);
            for (int c = 0; c < cols; c++)
                image.pixel(c,r)[deltaComp] = buffer[c];
        }
    }
}
コード例 #6
0
ファイル: sift_util.cpp プロジェクト: oakfr/omni3d
/* Same as ConvHorizontal, but apply to vertical columns of image.
*/
void ConvVertical(SiftImage image, double *kernel, int ksize)
{
    int rows, cols, r, c, i, halfsize;
    double **pixels, buffer[4000];

    rows = image->rows;
    cols = image->cols;
    halfsize = ksize / 2;
    pixels = image->pixels;
    assert(rows + ksize < 4000);

    for (c = 0; c < cols; c++) {
	for (i = 0; i < halfsize; i++)
	    buffer[i] = pixels[0][c];
	for (i = 0; i < rows; i++)
	    buffer[halfsize + i] = pixels[i][c];
	for (i = 0; i < halfsize; i++)
	    buffer[halfsize + rows + i] = pixels[rows - 1][c];

	ConvBufferFast(buffer, kernel, rows, ksize);
	for (r = 0; r < rows; r++)
	  pixels[r][c] = buffer[r];
    }
}