Пример #1
0
int main_times(int c, char *v[])
{
	// process input arguments
	if (c != 3) {
		fprintf(stderr, "usage:\n\t%s file.tiff factor\n", *v);
		//                          0 1         2
		return 1;
	}
	char *filename = v[1];
	double factor = atof(v[2]);

	// open image
	struct fancy_image *f = fancy_image_open(filename, "rw,megabytes=33");

	// process data
	for (int j = 0; j < f->h; j++)
	for (int i = 0; i < f->w; i++)
	for (int l = 0; l < f->pd; l++)
	{
		double x = fancy_image_getsample(f, i, j, l);
		x = x * factor;
		fancy_image_setsample(f, i, j, l, x);
	}

	// close image (and save remaining updated tiles)
	fancy_image_close(f);

	// exit
	return 0;
}
Пример #2
0
int main_setsample(int c, char *v[])
{
	if (c != 7) {
		fprintf(stderr, "usage:\n\t"
				"%s inout.tiff opts i j l v\n",*v);
		//                0 1          2    3 4 5 6
		return 1;
	}
	char *filename = v[1];
	char *opts = v[2];
	int arg_i = atoi(v[3]);
	int arg_j = atoi(v[4]);
	int arg_l = atoi(v[5]);
	float arg_v = atof(v[6]);

	struct fancy_image *f = fancy_image_open(filename, opts);
	fancy_image_setsample(f, arg_i, arg_j, arg_l, arg_v);
	fancy_image_close(f);

	return 0;
}
Пример #3
0
static void fancy_zoom_out_by_factor_two(char *fname_out, char *fname_in, int m)
{
	// open input image
	struct fancy_image *a = fancy_image_open(fname_in, "r");

	// read information from input image
	int tw = 0, th = 0, fmt = 0, bps = 0;
	int tiffo = fancy_image_leak_tiff_info(&tw, &th, &fmt, &bps, a);

	// create output image of the appropriate size and options
	int pw = ceil(a->w / 2.0);
	int ph = ceil(a->h / 2.0);
	struct fancy_image *b = fancy_image_create(fname_out,
			"w=%d,h=%d,pd=%d,bps=%d,fmt=%d,tw=%d,th=%d",
			pw, ph, a->pd, bps, fmt, tw, th);

	// fill-in the zoomed-out image
	for (int j = 0; j < b->h; j++)
	for (int i = 0; i < b->w; i++)
	for (int l = 0; l < b->pd; l++)
	{
		int ii = 2 * i;
		int jj = 2 * j;
		double v[4] = {
			fancy_image_getsample(a, ii + 0, jj + 0, l),
			fancy_image_getsample(a, ii + 1, jj + 0, l),
			fancy_image_getsample(a, ii + 0, jj + 1, l),
			fancy_image_getsample(a, ii + 1, jj + 1, l)
		};
		double r = combine_4doubles(v, m);
		fancy_image_setsample(b, i, j, l, r);
	}

	// close both images
	fancy_image_close(b);
	fancy_image_close(a);
}