int main(int argc, char* argv[])
{
  if (argc < 5) {
        std::cout << "Usage:" << std::endl;
	std::cout << "   " << argv[0] << " <input_file> <output_file> <number of runs> <number of threads>" << std::endl;
        return 0;
  }


  struct timeval start, end;
  int iter = atoi(argv[3]), i, j, k;
  int n_threads = atoi(argv[4]);
  double usec = 0;
  std::vector<std::thread> threads;

  load_image_file(argv[1]);       	/* Input of image1 */

  for(i = 0; i < iter; i++)
  {
      barrier1 = barrier2 = 0;  /* Init barriers on every iteration */
      gettimeofday(&start, NULL);
      /* Calculation of histogram */
      for (j = 0; j < GRAYLEVEL; j++) {
        histogram[j] = 0;
      }
      max_frequency = -1;
      for (j = 0; j < IMAGESIZE ; j++) {
        for (k = 0; k < IMAGESIZE; k++) {
          image2[j][k] = 0;
        }
      }

      for (j = 0; j < n_threads; j++) {
        threads.push_back(std::thread(make_histogram_image, j, n_threads));
      }

      for (j = 0; j < n_threads; j++) {
        threads[j].join();
      }

      gettimeofday(&end, NULL); 
      usec += end.tv_usec + 1000000*(end.tv_sec - start.tv_sec) - start.tv_usec;

      threads.clear();
  }

  save_image_file(argv[2]);       	/* Output of image2 */

  std::cout << "histogram takes: " << (double)usec / 1000000 << "sec    mean: " << (double)usec / 1000000 / iter <<"sec    image size: " << y_size1*x_size1 << std::endl;
  return 0;
}
Ejemplo n.º 2
0
int
main()
{
  typedef agg::pixfmt_bgr24 pixel_type;
  
  const unsigned w = 60, h = 50;
  
  unsigned row_size = pixel_type::pix_width * w;
  unsigned buf_size = row_size * h;
  agg::pod_array<unsigned char> img_buf(buf_size);
  
  agg::rendering_buffer rbuf(img_buf.data(), w, h, app_flip_y ? -row_size : row_size);
  pixel_type pixf(rbuf);
  
  typedef agg::renderer_base<pixel_type> renderer_base;
  typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;

  renderer_base rb(pixf);
  renderer_solid rs(rb);
  
  agg::rasterizer_scanline_aa<> ras;
  agg::scanline_p8 sl;

  agg::rgba8 white(255, 255, 255);
  rb.clear(white);

  agg::rgba8 color(160, 0, 0);

  agg::ellipse shape(30.0, 25.0, 12.0, 12.0);
  
  ras.add_path(shape);
  rs.color(color);
  agg::render_scanlines(ras, sl, rs);
  
  save_image_file(rbuf, "output.ppm");
  
  return 0;
}
Ejemplo n.º 3
0
int main(int argc, char* argv[])
{

  char *pgmInputFileName, *pgmOutputFileName;
  if(argc < 2 || argc > 3) {
      printf("Usage: %s InputFile.pgm <Output.pgm>\n", argv[0]);
      exit(1);
  }
  else if(argc == 2) {
    pgmInputFileName  = argv[1];
    pgmOutputFileName = "default_output.pgm";
  }
  else if(argc == 3) {
    pgmInputFileName  = argv[1];
    pgmOutputFileName = argv[2];
  }
  
  load_image_file( pgmInputFileName  );   /* Input of image1 */ 
  sobel_filtering( );                     /* Sobel filter is applied to image1 */
  save_image_file( pgmOutputFileName );   /* Output of image2 */
  printf("Output saved...OK\n");
  return 0;

}