Exemplo n.º 1
0
/**
  *
  * Function to upsample the image
  *
**/
void zoom_in(
	const float *I, // input image
	float *Iout,    // output image
	int nx,         // width of the original image
	int ny,         // height of the original image
	int nxx,        // width of the zoomed image
	int nyy         // height of the zoomed image
)
{
	// compute the zoom factor
	const float factorx = ((float)nxx / nx);
	const float factory = ((float)nyy / ny);

	// re-sample the image using bicubic interpolation
	#pragma omp parallel for
	for (int i1 = 0; i1 < nyy; i1++)
	for (int j1 = 0; j1 < nxx; j1++)
	{
		float i2 =  (float) i1 / factory;
		float j2 =  (float) j1 / factorx;

		float g = bicubic_interpolation_at(I, j2, i2, nx, ny, false);
		Iout[i1 * nxx + j1] = g;
	}
}
Exemplo n.º 2
0
/**
  *
  * Compute the bicubic interpolation of an image.
  *
**/
static void bicubic_interpolation_warp(
	const float *input,  //image to be warped
	const float *u,      //x component of the vector field
	const float *v,      //y component of the vector field
	float       *output, //warped output image with bicubic interpolation
	const int    nx,     //image width
	const int    ny,     //image height
	bool         border_out//if true, put zeros outside the region
)
{
#ifdef _OPENMP
#pragma omp parallel for
#endif
	for(int i = 0; i < ny; i++)
		for(int j = 0; j < nx; j++)
		{
			const int   p  = i * nx + j;
			const float uu = (float) (j + u[p]);
			const float vv = (float) (i + v[p]);

			//obtain the bicubic interpolation at position (uu, vv)
			output[p] = bicubic_interpolation_at(input,
					uu, vv, nx, ny, border_out);
		}
}
Exemplo n.º 3
0
/**
  *
  * Downsample an image
  *
**/
static void zoom_out(
	const float *I,          // input image
	float *Iout,             // output image
	const int nx,            // image width
	const int ny,            // image height
	const float factor       // zoom factor between 0 and 1
)
{
	// temporary working image
	float *Is = xmalloc(nx * ny * sizeof(float));
	for(int i = 0; i < nx * ny; i++)
		Is[i] = I[i];

	// compute the size of the zoomed image
	int nxx, nyy;
	zoom_size(nx, ny, &nxx, &nyy, factor);

	// compute the Gaussian sigma for smoothing
	const float sigma = ZOOM_SIGMA_ZERO * sqrt(1.0/(factor*factor) - 1.0);

	// pre-smooth the image
	gaussian_smoothing_in_place(Is, nx, ny, sigma);

	// re-sample the image using bicubic interpolation
#ifdef _OPENMP
#pragma omp parallel for
#endif
	for (int i1 = 0; i1 < nyy; i1++)
	for (int j1 = 0; j1 < nxx; j1++)
	{
		const float i2  = (float) i1 / factor;
		const float j2  = (float) j1 / factor;

		float g = bicubic_interpolation_at(Is, j2, i2, nx, ny, false);
		Iout[i1 * nxx + j1] = g;
	}

	free(Is);
}