Esempio n. 1
0
int main(int c, char *v[])
{
	char *filename_m = pick_option(&c, &v, "m", "");
	bool old_boundary = pick_option(&c, &v, "o", NULL);
	bool fan_boundary = pick_option(&c, &v, "f", NULL);
	bool Fan_boundary = pick_option(&c, &v, "F", NULL);
	global_parameter_p = atof(pick_option(&c, &v, "p", "NAN"));
	if ((c != 1 && c != 2 && c != 3) || (c>1 && !strcmp(v[1], "-h"))) {
		fprintf(stderr, "usage:\n\t%s [in [out]]\n", *v);
		//                          0  1   2
		return 1;
	}
	char *filename_i = c > 1 ? v[1] : "-";
	char *filename_o = c > 2 ? v[2] : "-";
	if (old_boundary && !fan_boundary)
	{
		fprintf(stderr, "using old boundary\n");
		global_boundary_function = construct_symmetric_boundary_old;
	}
	if (fan_boundary)
	{
		fprintf(stderr, "using fancy boundary\n");
		global_boundary_function = construct_symmetric_boundary_fancy;
	}
	if (Fan_boundary)
	{
		fprintf(stderr, "using Fancy boundary\n");
		global_boundary_function = construct_symmetric_boundary_Fancy;
	}
	if (isfinite(global_parameter_p))
	{
		fprintf(stderr, "using fancier boundary (p=%g)\n",
				global_parameter_p);
		global_boundary_function = construct_symmetric_boundary_fancier;
	}

	int w, h, pd;
	float *x = iio_read_image_float_split(filename_i, &w, &h, &pd);
	float *y = malloc(w*h*pd*sizeof*y);

	ppsmooth_split(y, x, w, h, pd);

	iio_save_image_float_split(filename_o, y, w, h, pd);

	if (*filename_m) {
		for (int i = 0; i < w*h*pd; i++)
			y[i] = x[i] - y[i];
		iio_save_image_float_split(filename_m, y, w, h, pd);
	}

	return 0;
}
Esempio n. 2
0
static void ppsmooth_vec(float *y, float *x, int w, int h, int pd)
{
	float *x_split = xmalloc(w*h*pd*sizeof*x);
	float *y_split = xmalloc(w*h*pd*sizeof*x);

	for (int j = 0; j < h; j++)
	for (int i = 0; i < w; i++)
	for (int l = 0; l < pd; l++)
		x_split[l*w*h+(j*w+i)] = x[pd*(j*w+i)+l];

	ppsmooth_split(y_split, x_split, w, h, pd);

	for (int j = 0; j < h; j++)
	for (int i = 0; i < w; i++)
	for (int l = 0; l < pd; l++)
		y[pd*(j*w+i)+l] = y_split[l*w*h+(j*w+i)];

	free(x_split);
	free(y_split);
}