Exemplo n.º 1
0
int main()
{
    image_height=4;
    image_width=3;
    image = (char*)malloc(sizeof(char)*image_height*image_width);
    construct_image();

    meet=(ConsensusGrid*)malloc(sizeof(ConsensusGrid)*image_height*image_width);
    basis = (int*)malloc(sizeof(int)*image_height*image_width);

    FILE *fp = fopen("image2.txt","w+");
    for(int i=0; i<image_height; i++)
    {
        for(int j = 0; j<image_width; j++)
        {
            meet[i*image_width+j]=consensus_parallel(i, j, image,image_height,image_width);
            meet[i*image_width+j].occurance = new tuple[image_height*image_width];
        }
    }
    assert_meet();
    calculate_list_parallel();
    assert_occurance();
    calculate_basis_parallel();
    assert_basis();
}
Exemplo n.º 2
0
int main(int argc, char** argv) {

	struct image_t* image;
	struct image_t* new_image;
	struct palette_coeff_t* palette;
	unsigned int k;
	COLOR_TYPE* new_coeff;
	unsigned int new_coeff_size;
	unsigned int i;

	if(argc != 4) {
		print_command_line();
        return EXIT_FAILURE;
	}
	else {
		image = read_image(argv[1]);
		k = atoi(argv[2]);
	}

	fflush(stdout);
	palette = create_palette(image);

	printf("reduce palette : %d\n", reduce_palette(palette, 0, k));

	new_coeff = backtrace_palette_index(palette->model->size, 0, k, &new_coeff_size, palette);

	printf("New color : ");
	for(i = 0; i<new_coeff_size; i++) {
		printf("%d ", new_coeff[i]);
	}
	printf("\n");

	new_image = construct_image(new_coeff, new_coeff_size, image, palette->model);

	save_image(argv[3], new_image);


	free(new_image->pixels);
	free(new_image);


	free(new_coeff);

	free(image->pixels);
	free(image);

	free(palette->model->data);
	free(palette->model);
	free(palette->coeff);
	free(palette);

	return EXIT_SUCCESS;
}
Exemplo n.º 3
0
    image_base<ImageType, PixelType>::image_base(
                cl::Context const& context,
                std::array<std::size_t, N> const& dims,
                cl_mem_flags mem_flags
            )
        : image_(
            construct_image(
                    context,
                    dims,
                    mem_flags,
                    pixel_image_format<PixelType>()
            )
        )
        , dims_(dims)
    {

    }