コード例 #1
0
ファイル: lsd.c プロジェクト: kunle12/darknet
void inter_dcgan(char *cfgfile, char *weightfile)
{
    network *net = load_network(cfgfile, weightfile, 0);
    set_batch_network(net, 1);
    srand(2222222);

    clock_t time;
    char buff[256];
    char *input = buff;
    int i, imlayer = 0;

    for (i = 0; i < net->n; ++i) {
        if (net->layers[i].out_c == 3) {
            imlayer = i;
            printf("%d\n", i);
            break;
        }
    }
    image start = random_unit_vector_image(net->w, net->h, net->c);
    image end = random_unit_vector_image(net->w, net->h, net->c);
        image im = make_image(net->w, net->h, net->c);
        image orig = copy_image(start);

    int c = 0;
    int count = 0;
    int max_count = 15;
    while(1){
        ++c;

        if(count == max_count){
            count = 0;
            free_image(start);
            start = end;
            end = random_unit_vector_image(net->w, net->h, net->c);
            if(c > 300){
                end = orig;
            }
            if(c>300 + max_count) return;
        }
        ++count;

        slerp(start.data, end.data, (float)count / max_count, im.w*im.h*im.c, im.data);

        float *X = im.data;
        time=clock();
        network_predict(net, X);
        image out = get_network_image_layer(net, imlayer);
        //yuv_to_rgb(out);
        normalize_image(out);
        printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time));
        //char buff[256];
        sprintf(buff, "out%05d", c);
        save_image(out, "out");
        save_image(out, buff);
        show_image(out, "out", 0);
    }
}
コード例 #2
0
ファイル: image.c プロジェクト: Nerei/darknet
void show_images(image *ims, int n, char *window)
{
    image m = collapse_images_vert(ims, n);
    save_image(m, window);
    show_image(m, window);
    free_image(m);
}
コード例 #3
0
int main(int args, char ** argv) {
    misc::process_args(args, argv);
    load_image(file_name[0], left_layer.rgb, left_layer.H, left_layer.W);
    load_image(file_name[1], right_layer.rgb, right_layer.H, right_layer.W);
  timer.reset();
    left.init(left_layer); right.init(right_layer);

    //misc::median_filter_rgb(left.rgb, left.H, left.W, 1);
    //misc::median_filter_rgb(right.rgb, right.H, right.W, 1);
    if (use_lab) {
      left_layer.computeLab();
      // misc::median_filter_rgb(left.lab, left.H, left.W, 1);
    }
    left.buildTree(use_lab);	
    left_layer.computeGradient();
    right_layer.computeGradient();
    // next part : compute disparity
    left.initDisparity();
    updateTable(255 * 0.1);
// timer.check("build forest");
    left.stereoMatch(right, 1, max_disparity, use_lab);    
    misc::median_filter(left.disparity, left.H, left.W); //TODO: why radius = 2, not 3 as dp

timer.check("all");
	//save
    save_image(file_name[2], left.disparity, left.H, left.W, scale);
    //save_image(file_name[3], right.disparity, right.H, right.W, scale);
    return 0;
}
コード例 #4
0
ファイル: image.c プロジェクト: c-aries/swc
void
image_get()
{
  int i, t, index;
  char *filename;

  for (t = 0; t < IMAGE_QUERY_TURN; t++) {
    printf("%d .. ", IMAGE_QUERY_TURN - t);
    fflush(stdout);
    for (i = 0; i < video.buffer.req.count; i++) {
      buffer_dequeue(i);
      buffer_enqueue(i);
    }
  }
  printf("%d ..\n", IMAGE_QUERY_TURN - t);
  fflush(stdout);
  index = 0;
  buffer_dequeue(index);
  update_image_pixels(index);
  filename = get_file_name("swc", "jpeg");
  save_image(filename);
  printf("%s saved.\n", filename);
  free(filename);
  buffer_enqueue(index);
}
コード例 #5
0
int main(int args, char ** argv) {
    misc::process_args(args, argv);
    load_image(file_name[0], left_pyramid[0].rgb, left_pyramid[0].H, left_pyramid[0].W);
    load_image(file_name[1], right_pyramid[0].rgb, right_pyramid[0].H, right_pyramid[0].W);
    if (left_pyramid[0].H != right_pyramid[0].H || left_pyramid[0].W != right_pyramid[0].W) {
        printf("The size of two pictures differ!! quit....");
        return 0;
    }
    if (left_pyramid[0].H >= MAX_HEIGHT || right_pyramid[0].W >= MAX_WIDTH) {
        printf("Input : %d x %d, program : %d %d\n", left_pyramid[0].H, left[0].W, MAX_HEIGHT, MAX_WIDTH);
        puts("Image too big. change settings.hpp and re-compile.");
        return 0;
    }

timer.reset();
    if (use_lab) {
      left_pyramid[0].computeLab();
      right_pyramid[0].computeLab();
    }
    for (int i = 0; i + 1 < levels; ++i) {
      left_pyramid[i+1].shrinkPicture(left_pyramid[i+1].rgb, left_pyramid[i].rgb, left_pyramid[i].H, left_pyramid[i].W);
      right_pyramid[i+1].shrinkPicture(right_pyramid[i+1].rgb, right_pyramid[i].rgb, right_pyramid[i].H, right_pyramid[i].W);
      if (use_lab) {
        left_pyramid[i+1].shrinkPicture(left_pyramid[i+1].lab, left_pyramid[i].lab, left_pyramid[i].H, left_pyramid[i].W);
        right_pyramid[i+1].shrinkPicture(right_pyramid[i+1].lab, right_pyramid[i].lab, right_pyramid[i].H, right_pyramid[i].W);
      }
    }

    for (int lvl = levels - 1; lvl >= 0; -- lvl) {
        int idx = lvl % OBJ_NUM;
        left[idx].init(left_pyramid[lvl]);
        right[idx].init(right_pyramid[lvl]);
        if (lvl == levels - 1) {
            left[idx].noPrediction(max_disparity / (1 << lvl));
        } else {
            DP::getSupportProb(left[idx].rgb, right[idx].rgb, 
                                left[idx].H, left[idx].W, max_disparity / (1 << lvl));
            DP::getProbMatrix(lvl, max_disparity / (1 << (lvl + 1)), max_disparity / (1 << lvl), dataset);
            DP::getInterval(pixel_intv_threshold * (1 << lvl)/*, tot_threshold*/);
            left[idx].readPrediction(left[(lvl + 1)%OBJ_NUM].disparity);
            // left[idx].intersectInterval(left[(lvl + 1) % OBJ_NUM]);
        } 
        // Now use the INTERVAL to find the new disparities.
        left_pyramid[lvl].computeGradient();
        right_pyramid[lvl].computeGradient();
        left[idx].buildForest(tree_intv_threshold, use_lab);
        left[idx].noPrediction(max_disparity / (1 << lvl));
        left[idx].initDisparity();
        updateTable(255 * 0.1);
        left[idx].stereoMatch(right[idx], 1, use_lab);
        misc::median_filter(left[idx].disparity, left[idx].H, left[idx].W, 3);
        // save_image(layername[lvl][0], left[idx].disparity, left[idx].H, left[idx].W, scale * (1 << lvl));
    } // end of layer iteration.

timer.check("all");

    save_image(file_name[2], left[0].disparity, left[0].H, left[0].W, scale);

    return 0;
}
コード例 #6
0
ファイル: darknet.cpp プロジェクト: yca/VideoAI
void Darknet::yoloImage(const QString &filename, float thresh)
{
	const Mat ori = OpenCV::loadImage(getAbs(filename), -1);
	Mat img;
	cv::resize(ori, img, cv::Size(priv->net.w, priv->net.h));
	image im = toDarkImage(img);
	//image im = load_image_color((char *)qPrintable(getAbs(filename)), 0, 0);

	//image sized = resize_image(im, priv->net.w, priv->net.h);
	//float *X = sized.data;
	float *X = im.data;
	float *predictions = network_predict(priv->net, X);

	float nms=.5;
	const detection_layer l = priv->l;
	convert_yolo_detections(predictions, l.classes, l.n, l.sqrt, l.side, 1, 1, thresh, priv->probs, priv->boxes, 0);
	if (nms) do_nms_sort(priv->boxes, priv->probs, l.side*l.side*l.n, l.classes, nms);
	draw_detections(im, l.side*l.side*l.n, thresh, priv->boxes, priv->probs, voc_names, 0, 20);
	show_image(im, "predictions");
	save_image(im, "predictions");

	//show_image(sized, "resized");
	free_image(im);
	//free_image(sized);
}
コード例 #7
0
ファイル: jpeg-save.c プロジェクト: frne/gimp
static void
make_preview (void)
{
  destroy_preview ();

  if (jsvals.preview)
    {
      gchar *tn = gimp_temp_name ("jpeg");

      if (! undo_touched)
        {
          /* we freeze undo saving so that we can avoid sucking up
           * tile cache with our unneeded preview steps. */
          gimp_image_undo_freeze (preview_image_ID);

          undo_touched = TRUE;
        }

      save_image (tn,
                  preview_image_ID,
                  drawable_ID_global,
                  orig_image_ID_global,
                  TRUE, NULL);

      if (display_ID == -1)
        display_ID = gimp_display_new (preview_image_ID);
    }
  else
    {
      gtk_label_set_text (GTK_LABEL (preview_size), _("File size: unknown"));

      gimp_displays_flush ();
    }
}
コード例 #8
0
ファイル: main.c プロジェクト: scottellis/shapegen
void draw_loop(const char *dir, int start_image_num, int num_images)
{
	int key, i;
	IplImage *img;
	CvSize size = { IMAGE_WIDTH, IMAGE_HEIGHT };

	img = cvCreateImage(size, IPL_DEPTH_8U, 1); //3);
	if (!img)
		return;

	for (i = start_image_num; i < start_image_num + num_images; i++) {
		draw_shapes(img);
		cvShowImage("shapegen", img);
		save_image(dir, img, i);

 		if (dir)
			key = 0xff & cvWaitKey(500);
		else
			key = 0xff & cvWaitKey(0);

		if (key == ESCAPE_KEY)
			break;
	}

	cvReleaseImage(&img);
}
コード例 #9
0
ファイル: create_images.cpp プロジェクト: Martin9295/wesnoth
static surface
create_image_base(const std::string& filename)
{
	surface result = SDL_CreateRGBSurface(
			  SDL_SWSURFACE
			, 1024
			, 1024
			, 32
			, 0xFF0000
			, 0xFF00
			, 0xFF
			, 0);

	surface_lock lock(result);

	Uint32 *pixels = lock.pixels();

	for(Uint32 r = 0; r < 256; r += 4) {
		for(Uint32 g = 0; g < 256; g += 2) {
			for(Uint32 b = 0; b < 256; b += 2, ++pixels) {

				*pixels = (0xFF << 24) | (r << 16) | (g << 8) | b;

			}
		}
	}

	save_image(result, filename);

	return result;
}
コード例 #10
0
ファイル: darknet.c プロジェクト: kunle12/darknet
void mkimg(char *cfgfile, char *weightfile, int h, int w, int num, char *prefix)
{
    network *net = load_network(cfgfile, weightfile, 0);
    image *ims = get_weights(net->layers[0]);
    int n = net->layers[0].n;
    int z;
    for(z = 0; z < num; ++z){
        image im = make_image(h, w, 3);
        fill_image(im, .5);
        int i;
        for(i = 0; i < 100; ++i){
            image r = copy_image(ims[rand()%n]);
            rotate_image_cw(r, rand()%4);
            random_distort_image(r, 1, 1.5, 1.5);
            int dx = rand()%(w-r.w);
            int dy = rand()%(h-r.h);
            ghost_image(r, im, dx, dy);
            free_image(r);
        }
        char buff[256];
        sprintf(buff, "%s/gen_%d", prefix, z);
        save_image(im, buff);
        free_image(im);
    }
    free_network(net);
}
コード例 #11
0
ファイル: detector.c プロジェクト: apollos/eyes
void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filename, float thresh, float hier_thresh)
{
	int show_flag = 1;
    list *options = read_data_cfg(datacfg);
    char *name_list = option_find_str(options, "names", "data/names.list");
    char **names = get_labels(name_list);

    image **alphabet = load_alphabet();
    network net = parse_network_cfg(cfgfile);
    if(weightfile){
        load_weights(&net, weightfile);
    }
    set_batch_network(&net, 1);
    srand(2222222);
    clock_t time;
    char buff[256];
    char *input = buff;
    int j;
    float nms=.4;
    while(1){
        if(filename){
            strncpy(input, filename, 256);
        } else {
            printf("Enter Image Path: ");
            fflush(stdout);
            input = fgets(input, 256, stdin);
            if(!input) return;
            strtok(input, "\n");
        }
        image im = load_image_color(input,0,0);
        image sized = resize_image(im, net.w, net.h);
        layer l = net.layers[net.n-1];

        box *boxes = calloc(l.w*l.h*l.n, sizeof(box));
        float **probs = calloc(l.w*l.h*l.n, sizeof(float *));
        for(j = 0; j < l.w*l.h*l.n; ++j) probs[j] = calloc(l.classes + 1, sizeof(float *));

        float *X = sized.data;
        time=clock();
        network_predict(net, X);
        printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time));
        get_region_boxes(l, 1, 1, thresh, probs, boxes, 0, 0, hier_thresh);
        if (l.softmax_tree && nms) do_nms_obj(boxes, probs, l.w*l.h*l.n, l.classes, nms);
        else if (nms) do_nms_sort(boxes, probs, l.w*l.h*l.n, l.classes, nms);
        draw_detections(im, l.w*l.h*l.n, thresh, boxes, probs, names, alphabet, l.classes, show_flag);
        save_image(im, "predictions");
        show_image(im, "predictions");

        free_image(im);
        free_image(sized);
        free(boxes);
        free_ptrs((void **)probs, l.w*l.h*l.n);
#ifdef OPENCV
        cvWaitKey(0);
        cvDestroyAllWindows();
#endif
        if (filename) break;
    }
}
コード例 #12
0
ファイル: imageio.cpp プロジェクト: kspangsege/archon
void save_image(Image::ConstRefArg image,
                std::string file_path, std::string format_name,
                Logger* logger, FileFormat::ProgressTracker* tracker,
                FileFormat::Registry::ConstRefArg r)
{
    save_image(image, *make_file_output_stream(file_path),
               file_path, format_name, logger, tracker, r);
}
コード例 #13
0
ファイル: GFitsImage.cpp プロジェクト: gammalib/gammalib
/***********************************************************************//**
 * @brief Save FITS image
 *
 * Saves the image into the FITS file.
 ***************************************************************************/
void GFitsImage::data_save(void)
{
    // Save image
    save_image(type(), pixels());

    // Return
    return;
}
コード例 #14
0
ファイル: mandelbrot.c プロジェクト: AndrewWUw/cs9021
int main(void) {
    Image image;
    image.width = DIM;
    image.height = DIM;
    mandel(-1.25, -2, 1.25, 0.5, &image);
    save_image("mandelbrot.pnm", &image);
    return EXIT_SUCCESS;
}
コード例 #15
0
ファイル: funset.cpp プロジェクト: fengbingchun/CUDA_Test
int test_layer_reverse()
{
	// Blog: http://blog.csdn.net/fengbingchun/article/details/77160872
#ifdef __linux__
	std::string image_name{ "test_data/images/lena.png" };
#else
	std::string image_name{ "E:/GitCode/CUDA_Test/test_data/images/lena.png" };
#endif
	cv::Mat matSrc = cv::imread(image_name);
	CHECK(matSrc.data);

	cv::cvtColor(matSrc, matSrc, CV_BGR2GRAY);
	const int width{ 1511 }, height{ 1473 };
	const auto length = width * height;
	cv::resize(matSrc, matSrc, cv::Size(width, height));
	cv::Mat matTmp1;
	matSrc.convertTo(matTmp1, CV_32FC1);

	float elapsed_time1{ 0.f }, elapsed_time2{ 0.f }; // milliseconds
	const std::vector<int> vec{ 5, 7};
	std::unique_ptr<float[]> dst1(new float[length]), dst2(new float[length]);
	std::for_each(dst1.get(), dst1.get() + length, [](float& n) {n = 0.f; });
	std::for_each(dst2.get(), dst2.get() + length, [](float& n) {n = 0.f; });

	int ret = layer_reverse_cpu((float*)matTmp1.data, dst1.get(), length, vec, &elapsed_time1);
	if (ret != 0) PRINT_ERROR_INFO(image_reverse_cpu);

	ret = layer_reverse_gpu((float*)matTmp1.data, dst2.get(), length, vec, &elapsed_time2);
	if (ret != 0) PRINT_ERROR_INFO(image_reverse_gpu);

	compare_result(dst1.get(), dst2.get(), length);

	cv::Mat matTmp2(height, width, CV_32FC1, dst2.get()), matDst;
	matTmp2.convertTo(matDst, CV_8UC1);

#ifdef __linux__
	save_image(matSrc, matDst, 400, 200, "test_data/images/image_reverse.png");
#else
	save_image(matSrc, matDst, 400, 200, "E:/GitCode/CUDA_Test/test_data/images/image_reverse.png");
#endif

	fprintf(stderr, "test layer reverse: cpu run time: %f ms, gpu run time: %f ms\n", elapsed_time1, elapsed_time2);

	return 0;
}
コード例 #16
0
ファイル: image.c プロジェクト: renmengye/darknet
void show_image(image p, char *name)
{
#ifdef OPENCV
    show_image_cv(p, name);
#else
    fprintf(stderr, "Not compiled with OpenCV, saving to %s.png instead\n", name);
    save_image(p, name);
#endif
}
コード例 #17
0
ファイル: image.cpp プロジェクト: harold/factor
void factor_vm::primitive_save_image()
{
	/* do a full GC to push everything into tenured space */
	gc();

	gc_root<byte_array> path(dpop(),this);
	path.untag_check(this);
	save_image((vm_char *)(path.untagged() + 1));
}
コード例 #18
0
ファイル: lsd.c プロジェクト: vaiv/OpenANPR
void test_lsd(char *cfgfile, char *weightfile, char *filename)
{
    network net = parse_network_cfg(cfgfile);
    if(weightfile){
        load_weights(&net, weightfile);
    }
    set_batch_network(&net, 1);
    srand(2222222);

    clock_t time;
    char buff[256];
    char *input = buff;
    int i, imlayer = 0;

    for (i = 0; i < net.n; ++i) {
        if (net.layers[i].out_c == 3) {
            imlayer = i;
            printf("%d\n", i);
            break;
        }
    }

    while(1){
        if(filename){
            strncpy(input, filename, 256);
        }else{
            printf("Enter Image Path: ");
            fflush(stdout);
            input = fgets(input, 256, stdin);
            if(!input) return;
            strtok(input, "\n");
        }
        image im = load_image_color(input, 0, 0);
        image resized = resize_min(im, net.w);
        image crop = crop_image(resized, (resized.w - net.w)/2, (resized.h - net.h)/2, net.w, net.h);
        //grayscale_image_3c(crop);

        float *X = crop.data;
        time=clock();
        network_predict(net, X);
        image out = get_network_image_layer(net, imlayer);
        //yuv_to_rgb(out);
        constrain_image(out);
        printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time));
        show_image(out, "out");
        show_image(crop, "crop");
        save_image(out, "out");
#ifdef OPENCV
        cvWaitKey(0);
#endif

        free_image(im);
        free_image(resized);
        free_image(crop);
        if (filename) break;
    }
}
コード例 #19
0
ファイル: wesmage.cpp プロジェクト: Martin9295/wesnoth
int
main(int argc, char* argv[])
{
	try {
		const toptions& options = toptions::parse(argc, argv);

		surface surf(make_neutral_surface(
				IMG_Load(options.input_filename.c_str())));

		if(!surf) {
			std::cerr << "Error: Failed to load input file »"
					<< options.input_filename
					<< "«.\n";

			return EXIT_FAILURE;
		}

		std::vector<surface> surfaces;
		if(options.count != 1) {
			for(int i = 1; i < options.count; ++i) {
				// make_neutral_surface make a deep-copy of the image.
				surfaces.push_back(make_neutral_surface(surf));
			}
		}
		surfaces.push_back(surf);

		const clock_t begin = options.time ? get_begin_time() : 0;

		for(int i = 0; i < options.count; ++i) {
			BOOST_FOREACH(const std::string& filter, options.filters) {
				filter_apply(surfaces[i], filter);
			}
		}

		if(options.time) {
			const clock_t end = std::clock();
			std::cout << "Applying the filters took "
					<<  end - begin
					<< " ticks, "
					<< static_cast<double>(end - begin) / CLOCKS_PER_SEC
					<< " seconds.\n";
		}

		if(!options.output_filename.empty()) {
			save_image(surfaces[0], options.output_filename);
		}

	} catch(const texit& exit) {
		return exit.status;
	} catch(exploder_failure& err) {
		std::cerr << "Error: Failed with error »" << err.message << "«.\n";
		return EXIT_FAILURE;
	}

	return EXIT_SUCCESS;
}
コード例 #20
0
ファイル: funset.cpp プロジェクト: fengbingchun/CUDA_Test
int test_image_process_laplacian()
{
	// Blog: http://blog.csdn.net/fengbingchun/article/details/79321200
#ifdef __linux__
	cv::Mat src = cv::imread("test_data/images/lena.png", 0);
#else
	cv::Mat src = cv::imread("E:/GitCode/CUDA_Test/test_data/images/lena.png", 0);
#endif
	if (!src.data || src.channels() != 1) {
		fprintf(stderr, "read image fail\n");
		return -1;
	}
	int width{ 400 }, height{ 400 };
	cv::resize(src, src, cv::Size(width, height));

	std::unique_ptr<unsigned char[]> data1(new unsigned char[width * height]), data2(new unsigned char[width * height]);
	float elapsed_time1{ 0.f }, elapsed_time2{ 0.f }; // milliseconds
	int ksize{ 1 };

	CHECK(laplacian_cpu(src.data, width, height, ksize, data1.get(), &elapsed_time1) == 0);
	//CHECK(laplacian_gpu(src.data, width, height, data2.get(), &elapsed_time2) == 0);

	//fprintf(stdout, "gray image edge detection: laplacian: cpu run time: %f ms, gpu run time: %f ms\n", elapsed_time1, elapsed_time2);

	cv::Mat dst;
	cv::Laplacian(src, dst, src.depth(), ksize);
#ifdef __linux__
	cv::imwrite("test_data/images/laplacian.png", dst);
#else
	cv::imwrite("E:/GitCode/CUDA_Test/test_data/images/laplacian.png", dst);
#endif

	CHECK(compare_result(data1.get(), dst.data, width*height) == 0);
	//CHECK(compare_result(data1.get(), data2.get(), width*height) == 0);

#ifdef __linux__
	save_image(src, dst, width, height / 2, "test_data/images/laplacian_result.png");
#else
	save_image(src, dst, width, height / 2, "E:/GitCode/CUDA_Test/test_data/images/laplacian_result.png");
#endif

	return 0;
}
コード例 #21
0
ファイル: tests_images.c プロジェクト: Ballada/libdeep
static void test_load_training_images()
{
	char filename[256];
	unsigned char ** images=NULL;
	char ** classifications=NULL;
	int * numbers;
	int im;
	int no_of_images = 3;
	int no_of_images2;
	int width=40,height=40;
	char commandstr[256],str[256];

	printf("test_load_training_images...");

	/* create a directory for the images */
	sprintf(commandstr,"mkdir %sdeeplearn_test_images",
			DEEPLEARN_TEMP_DIRECTORY);
	system(commandstr);

	/* save a tests images */
	for (im = 0; im < no_of_images; im++) {
		sprintf(filename,"%sdeeplearn_test_images/img%d.%d.png",
				DEEPLEARN_TEMP_DIRECTORY, im%2, im);
		save_image(filename);
	}

	sprintf(str,"%sdeeplearn_test_images",
			DEEPLEARN_TEMP_DIRECTORY);

	/* load the images */
	no_of_images2 =
		deeplearn_load_training_images(str,
									   &images,
									   &classifications,
									   &numbers,
									   width, height);
	assert(no_of_images == no_of_images2);
	assert(images!=NULL);
	
	/* free memory */
	for (im = 0; im < no_of_images; im++) {
		free(images[im]);
		free(classifications[im]);
	}
	free(images);
	free(classifications);
	free(numbers);

	/* remove the images */
	sprintf(commandstr,"rm -rf %sdeeplearn_test_images",
			DEEPLEARN_TEMP_DIRECTORY);
	system(commandstr);

	printf("Ok\n");
}
コード例 #22
0
ファイル: lsc.c プロジェクト: wcheswick/ex
void
kbd_hit(char key) {
	set_active();
	switch (key) {
	case 'd':
		dump_screen(0);
		break;
	case 'w':
	case 'W':
		save_image();
		break;
	case 'q':
	case 'Q':
	case 'x':
	case 'X':	/* exit the program */
		end_display();
		exit(0);
	case 'v':
		show_video_settings = !show_video_settings;
		refresh_screen = 1;
		break;
	case 'h':
		set_hue(get_hue() - 1);
		refresh_screen = 1;
		break;
	case 'H':
		set_hue(get_hue() + 1);
		refresh_screen = 1;
		break;
	case 's':
		set_saturation(get_saturation() - 1);
		refresh_screen = 1;
		break;
	case 'S':
		set_saturation(get_saturation() + 1);
		refresh_screen = 1;
		break;
	case 'b':
		set_brightness(get_brightness() - 1);
		refresh_screen = 1;
		break;
	case 'B':
		set_brightness(get_brightness() + 1);
		refresh_screen = 1;
		break;
	case 'c':
		set_contrast(get_contrast() - 1);
		refresh_screen = 1;
		break;
	case 'C':
		set_contrast(get_contrast() + 1);
		refresh_screen = 1;
		break;
	}
}
コード例 #23
0
ファイル: gtk-reftest.c プロジェクト: fatman2021/gtk
static void
test_ui_file (GFile *file)
{
  char *ui_file, *reference_file;
  cairo_surface_t *ui_image, *reference_image, *diff_image;
  GtkStyleProvider *provider;

  ui_file = g_file_get_path (file);

  provider = add_extra_css (ui_file, ".css");

  ui_image = reftest_snapshot_ui_file (ui_file);
  
  reference_file = get_test_file (ui_file, ".ref.ui", TRUE);
  if (reference_file)
    reference_image = reftest_snapshot_ui_file (reference_file);
  else
    {
      reference_image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
      g_test_message ("No reference image.");
      g_test_fail ();
    }
  g_free (reference_file);

  diff_image = reftest_compare_surfaces (ui_image, reference_image);

  save_image (ui_image, ui_file, ".out.png");
  save_image (reference_image, ui_file, ".ref.png");
  if (diff_image)
    {
      save_image (diff_image, ui_file, ".diff.png");
      if (known_fail(ui_file))
        {
          printf("KNOWN FAILURE - %s\n", ui_file);
          g_test_message ("KNOWN FAIL: %s", ui_file);
        }
      else
        g_test_fail ();
    }

  remove_extra_css (provider);
}
コード例 #24
0
ファイル: anim.cpp プロジェクト: llevar/uoft
void display(void) {
  
  glLoadIdentity();
  glClearColor(0.0f,0.0f,0.0f,1.0f);   //set the background colour 
  // OK, now clear the screen with the background colour 
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
  
	
	/* Place the camera in various positions in the secene */
	
	if(curTime >= 0 && curTime <= 3){ 
		gluLookAt(-12,5,30,0,5,0,0,1,0);
	}
	else if(curTime > 3 && curTime <= 6){
		gluLookAt(-12,5, 10, 0, 7, 0, 0, 1, 0);
	}
	else if(curTime > 6 && curTime <= 10.75){
		gluLookAt(0, 5, 30, 0, 5, 0, 0, 1, 0);
	}
	else if(curTime > 10.75 && curTime <= 11.5){
		gluLookAt(-12, 7, -8, 0, 4, -2, 0, 1, 0);
	
	}
	else if(curTime > 11.5 && curTime <= 12){
	
		gluLookAt(11, 25, -30, -2,5, 0, 0, 1, 0);
	}
	else {
		gluLookAt(-12,5, 10, 0, 7, 0, 0, 1, 0);
	}	
	
	drawWalls();
	drawColumnSet();
	drawStairs();
	drawCube();
	drawSphere();
	drawPlatform();
	drawPyramid();
 	
	glPushMatrix();
	drawMan();
 	glPopMatrix();
	
	
	drawHammer();
	glFlush();

  glutSwapBuffers();

  if (recording) {
    int frame = (int)(curTime / tStep + 0.5);
    save_image(frame);
  }      
}
コード例 #25
0
ファイル: create_images.cpp プロジェクト: Martin9295/wesnoth
static void
create_image_blend_functor(
		  const surface& dst
		, const std::string root
		, const Uint8 amount
		, const Uint32 color)
{
	const std::string filename = blend_get_filename(root, amount, color);

	save_image(dst, filename);
}
コード例 #26
0
ファイル: geometry_spin.cpp プロジェクト: Dukeke/DIP_UI
void image_bmp::geometry_spin()
{
	int i,j,new_Height,new_Width;
	double rad,old_x,old_y,angle,x[4],y[4],min_x,max_x,min_y,max_y;


	angle=30;
	rad=angle/180*pi;
	
	x[0]=0;y[0]=0;
	x[1]=0-Width*sin(rad);y[1]=0+Width*cos(rad);
	x[2]=Height*cos(rad)-0;y[2]=Height*sin(rad)+0;
	x[3]=Height*cos(rad)-Width*sin(rad);y[3]=Height*sin(rad)+Width*cos(rad);

	min_x=x[0];max_x=x[0];min_y=y[0];max_y=y[0];
	for(i=0;i<3;i++)
	{
		min_x=x[i+1]<min_x?x[i+1]:min_x;
		max_x=x[i+1]>max_x?x[i+1]:max_x;
		min_y=y[i+1]<min_y?y[i+1]:min_y;
		max_y=y[i+1]>max_y?y[i+1]:max_y;

	}
	
	new_Height=ceil(max_x-min_x);
	new_Width=ceil(max_y-min_y);

	datatemp=new imagedata *[new_Height];
   	for(i=0;i<new_Height;i++)
		datatemp[i]=new imagedata [new_Width];

	for(i=0;i<new_Height;i++)
	{
		for(j=0;j<new_Width;j++)
		{
			old_x=(i+min_x)*cos(-rad)-(j+min_y)*sin(-rad);
			old_y=(i+min_x)*sin(-rad)+(j+min_y)*cos(-rad);
		    Biliner(i,j,old_x,old_y,Height,Width,data,datatemp);


		}
	}


	infoHeader_temp.biHeight=new_Height;
	infoHeader_temp.biWidth=new_Width;

	path="±£´æµÄͼƬ\\geometry_spin.bmp";
	save_image();

	for(i=0;i<new_Height;i++)
		delete[] datatemp[i];
	delete[] datatemp;
}
コード例 #27
0
ファイル: image.cpp プロジェクト: littledan/Factor
void factor_vm::primitive_save_image()
{
	/* do a full GC to push everything into tenured space */
	primitive_compact_gc();

	data_root<byte_array> path2(ctx->pop(),this);
	path2.untag_check(this);
	data_root<byte_array> path1(ctx->pop(),this);
	path1.untag_check(this);
	save_image((vm_char *)(path1.untagged() + 1 ),(vm_char *)(path2.untagged() + 1));
}
コード例 #28
0
ファイル: resource_saver_png.cpp プロジェクト: FEDE0D/godot
Error ResourceSaverPNG::save(const String &p_path,const RES& p_resource,uint32_t p_flags) {

	Ref<ImageTexture> texture=p_resource;

	ERR_FAIL_COND_V(!texture.is_valid(),ERR_INVALID_PARAMETER);
	ERR_EXPLAIN("Can't save empty texture as PNG");
	ERR_FAIL_COND_V(!texture->get_width() || !texture->get_height(),ERR_INVALID_PARAMETER);


	Image img = texture->get_data();

	Error err = save_image(p_path, img);

	if (err == OK) {

		bool global_filter = Globals::get_singleton()->get("image_loader/filter");
		bool global_mipmaps = Globals::get_singleton()->get("image_loader/gen_mipmaps");
		bool global_repeat = Globals::get_singleton()->get("image_loader/repeat");

		String text;

		if (global_filter!=bool(texture->get_flags()&Texture::FLAG_FILTER)) {
			text+=bool(texture->get_flags()&Texture::FLAG_FILTER)?"filter=true\n":"filter=false\n";
		}
		if (global_mipmaps!=bool(texture->get_flags()&Texture::FLAG_MIPMAPS)) {
			text+=bool(texture->get_flags()&Texture::FLAG_MIPMAPS)?"gen_mipmaps=true\n":"gen_mipmaps=false\n";
		}
		if (global_repeat!=bool(texture->get_flags()&Texture::FLAG_REPEAT)) {
			text+=bool(texture->get_flags()&Texture::FLAG_REPEAT)?"repeat=true\n":"repeat=false\n";
		}
		if (bool(texture->get_flags()&Texture::FLAG_ANISOTROPIC_FILTER)) {
			text+="anisotropic=true\n";
		}
		if (bool(texture->get_flags()&Texture::FLAG_CONVERT_TO_LINEAR)) {
			text+="tolinear=true\n";
		}
		if (bool(texture->get_flags()&Texture::FLAG_MIRRORED_REPEAT)) {
			text+="mirroredrepeat=true\n";
		}

		if (text!="" || FileAccess::exists(p_path+".flags")) {

			FileAccess* f = FileAccess::open(p_path+".flags",FileAccess::WRITE);
			if (f) {

				f->store_string(text);
				memdelete(f);
			}
		}
	}


	return err;
};
コード例 #29
0
ファイル: main.cpp プロジェクト: Chinmay-at-git/M1UPS
/**
 * \callgraph
 */
int main () {

        //make_platon_scene (LARGEUR, HAUTEUR);
        make_default_scene(LARGEUR, HAUTEUR);

	compute_image();
	
	save_image ("monimage.exr");

	return 0;
}
コード例 #30
0
ファイル: funset.cpp プロジェクト: fengbingchun/CUDA_Test
int test_image_process_histogram_equalization()
{
	// Blog: http://blog.csdn.net/fengbingchun/article/details/79188021
#ifdef __linux__
	const std::string image_name{ "test_data/images/lena.png" };
#else
	const std::string image_name{ "E:/GitCode/CUDA_Test/test_data/images/lena.png" };
#endif
	cv::Mat mat = cv::imread(image_name, 0);
	CHECK(mat.data);

	const int width{ mat.cols/*1513*/ }, height{ mat.rows/*1473*/ };
	cv::resize(mat, mat, cv::Size(width, height));

	std::unique_ptr<unsigned char[]> data1(new unsigned char[width * height]), data2(new unsigned char[width * height]);
	float elapsed_time1{ 0.f }, elapsed_time2{ 0.f }; // milliseconds

	CHECK(histogram_equalization_cpu(mat.data, width, height, data1.get(), &elapsed_time1) == 0);
	//CHECK(histogram_equalization_gpu(mat.data, width, height, data2.get(), &elapsed_time2) == 0);

	//fprintf(stdout, "image histogram equalization: cpu run time: %f ms, gpu run time: %f ms\n", elapsed_time1, elapsed_time2);

	cv::Mat dst;
	cv::equalizeHist(mat, dst);
#ifdef __linux__
	cv::imwrite("test_data/images/histogram_equalization.png", dst);
#else
	cv::imwrite("E:/GitCode/CUDA_Test/test_data/images/histogram_equalization.png", dst);
#endif

	CHECK(compare_result(data1.get(), dst.data, width*height) == 0);
	//CHECK(compare_result(data1.get(), data2.get(), width*height) == 0);

#ifdef __linux__
	save_image(mat, dst, width, height/2, "test_data/images/histogram_equalization_result.png");
#else
	save_image(mat, dst, width, height/2, "E:/GitCode/CUDA_Test/test_data/images/histogram_equalization_result.png");
#endif

	return 0;
}