Esempio n. 1
0
void fusion_free( void* _segments ){
    segments_t *mem = _segments;

    free(mem->tmp_fullsize);
    free(mem->tmp2_fullsize);
    free(mem->tmp_halfsize);
    free(mem->tmp_quartsize);
    free(mem->tmp2_quartsize);

    free_pyramid(mem->nlev,mem->pyr,mem->pyr_r,mem->pyr_c,false);

    for (int n = 0; n < mem->nimages; n++){
        free(mem->W[n]);
        free_pyramid(mem->nlev,mem->pyrI[n],mem->pyrI_r[n],mem->pyrI_c[n], false);
        free_pyramid(mem->nlev,mem->pyrW[n],mem->pyrW_r[n],mem->pyrW_c[n], true);
    }
    free(mem->pyrI);
    free(mem->pyrI_r);
    free(mem->pyrI_c);
    free(mem->pyrW);
    free(mem->pyrW_r);
    free(mem->pyrW_c);
    free(mem->W);
    free(mem->R);
    free(_segments);
}
Esempio n. 2
0
int main_pan(int c, char *v[])
{
	// process input arguments
	if (c != 2 && c != 1) {
		fprintf(stderr, "usage:\n\t%s [image]\n", *v);
		//                          0  1
		return 1;
	}
	char *filename_in = c > 1 ? v[1] : "-";

	// read image
	struct pan_state e[1];
	e->rgb = read_image_uint8_rgb(filename_in, &e->w, &e->h);
	create_pyramid(e);

	// open window
	struct FTR f = ftr_new_window(BAD_MIN(e->w,800), BAD_MIN(e->h,600));
	f.userdata = e;
	action_reset_zoom_and_position(&f);
	ftr_set_handler(&f, "expose", pan_exposer);
	ftr_set_handler(&f, "motion", pan_motion_handler);
	ftr_set_handler(&f, "button", pan_button_handler);
	ftr_set_handler(&f, "key", pan_key_handler);
	int r = ftr_loop_run(&f);

	// cleanup and exit (optional)
	ftr_close(&f);
	free(e->rgb);
	free_pyramid(e);
	return r;
}
Esempio n. 3
0
void fusion_free( void* _segments ){
    segments_t *mem = _segments;

    free(mem->tmp_weights);
    free(mem->tmp_fullsize);
    free(mem->tmp2_fullsize);
    free(mem->tmp_halfsize);
    free(mem->tmp_quartsize);
    free(mem->tmp2_quartsize);

    for(int k = 0; k < CHANNELS; k++){
        free_pyramid(mem->nlev,mem->pyr[k],false);
    }
    free(mem->pyr_r);
    free(mem->pyr_c);

    for (int n = 0; n < mem->nimages; n++){
        free(mem->W[n]);
        free_pyramid(mem->nlev,mem->pyrW[n], true);
        for(int k = 0; k < CHANNELS; k++){
            free_pyramid(mem->nlev,mem->pyrI[k][n], false);
        }
        free(mem->pyrI_r[n]);
        free(mem->pyrI_c[n]);
    }


    free(mem->pyrI);
    free(mem->pyrI_r);
    free(mem->pyrI_c);
    free(mem->pyrW);
    free(mem->pyrW_r);
    free(mem->pyrW_c);
    free(mem->W);

    for (int n = 0; n < mem->nimages; n++){
        for(int k = 0; k < CHANNELS; k++){
            free(mem->C[n][k]);
        }
        free(mem->C[n]);
    }
    free(mem->C);
    free(mem->R);
    free(_segments);
}
Esempio n. 4
0
// API: close a fancy image
void fancy_image_close(struct fancy_image *fi)
{
	struct FI *f = (void*)fi;

	if (f->tiffo)
		tiff_octaves_free(f->t);
	else {
		if ((f->option_write && f->x_changed) || f->option_creat)
			iio_save_image_float_vec(f->x_filename, f->x,
					f->w, f->h, f->pd);
		if (f->no > 1)
			free_pyramid(f);
		else
			free(f->x);
	}
	free(f);
}
Esempio n. 5
0
// API: reload an image (works only for "small", images that can be read whole)
void fancy_image_reload(struct fancy_image *fi)
{
	struct FI *f = (void*)fi;

	if (!f->tiffo && !f->gdal)
	{
		int tmp_w, tmp_h, tmp_pd;
		float *tmp_x = iio_read_image_float_vec(f->x_filename,
				&tmp_w, &tmp_h, &tmp_pd);
		if (!tmp_x)
		{
			fprintf(stderr, "WARNING: could not reload image %s\n",
					f->x_filename);
			return;
		}
		if (tmp_w != f->w || tmp_h != f->h || tmp_pd != f->pd)
		{
			fprintf(stderr, "WARNING: image \"%s\" was resized"
					" from (%d %d %d) to (%d %d %d)\n",
					f->x_filename,
					f->w, f->h, f->pd,
					tmp_w, tmp_h, tmp_pd);
		}
		if (f->no > 1)
			free_pyramid(f);
		else
			free(f->x);
		f->x = tmp_x;
		f->w = tmp_w;
		f->h = tmp_h;
		f->pd = tmp_pd;
		f->no = build_pyramid(f, f->max_octaves);
		f->x_changed = true;

	}

	if (f->tiffo && !f->gdal)
	{
		// TODO: perform some sort of cache invalidation
		fprintf(stderr, "WARNING: tiffo reload not implemented!\n");
	}
}
Esempio n. 6
0
// API: close a fancy image
void fancy_image_close(struct fancy_image *fi)
{
	struct FI *f = (void*)fi;

	if (f->tiffo) {
#ifdef FANCY_TIFF
		tiff_octaves_free(f->t);
#else
		assert(false);
#endif
	} else {
		if ((f->option_write && f->x_changed) || f->option_creat)
			iio_write_image_float_vec(f->x_filename, f->x,
					f->w, f->h, f->pd);
		if (f->no > 1)
			free_pyramid(f);
		else
			free(f->x);
	}
	free(f);
}