Exemple #1
0
/* this is similar to a difference of gaussian (DoG) filter */
void update_centre_surround(unsigned char * img,
                            int img_width, int img_height,
                            int bitsperpixel,
                            long * integral_image,
                            int patch_width,
                            unsigned char * output_img,
                            int output_img_width,
                            int output_img_height)
{
    int x, y, x0, y0, n=0, tx, ty, bx, by, c;
    int outer = patch_width/2;
    int inner = patch_width/4;
    int patch_pixels = patch_width*patch_width/2;
    long response_outer, response_inner, v;
	int bytesperpixel = bitsperpixel/8;

    /* update the integral image */
    update_integral_image(img, img_width, img_height, bitsperpixel,
                          integral_image);

    for (y = 0; y < output_img_height; y++) {
        y0 = y * img_height / output_img_height;
        ty = y0 - outer;
        by = ty + patch_width;
        if (ty < 0) ty = 0;
        if (by >= img_height) by = img_height-1;

        for (x = 0; x < output_img_width; x++) {
            n = y*output_img_width + x;

            x0 = x * img_width / output_img_width;
            tx = x0 - outer;
            bx = tx + patch_width;
            if (tx < 0) tx = 0;
            if (bx >= img_width) bx = img_width-1;

            response_outer =
                get_integral(integral_image,
                             tx, ty, bx, by, img_width);
            response_inner =
                get_integral(integral_image,
                             tx + inner, ty + inner,
                             tx + inner + outer, ty + inner + outer,
                             img_width)*4;
            v = 127 + ((response_inner - response_outer)/
                       patch_pixels);
            if (v < 0) v = 0;
            if (v > 255) v = 255;
            for (c = 0; c < bytesperpixel; c++) {
                output_img[n*bytesperpixel + c] = (unsigned char)v;
            }
        }
    }
}
Exemple #2
0
int main(void)
{
	double res, term1, term2, t1, t2, t3, t4, term;
	int l, m, l1, m1, l_max;
	
	printf("Insert l_max\n");
	scanf( "%d" , &l_max);
	printf("l_max = %i \n", l_max);

        
	res = 0.;
	for (l = 0; l <= l_max; l++){
		for (m = -l; m <= l; m++){	
			l1 = l;
			for (m1 = -l1; m1 <= l1; m1++){
				printf(" l=%d , m=%d \n", l, m);
				printf(" l1=%d , m1=%d \n", l1, m1);
				// phi part
				t1 = get_integral(0.,2.*PI, (double)l, (double)m, 1);
				t2 = get_integral(0.,2.*PI, (double)l, (double)m, 2);
				t3 = get_integral(0.,2.*PI, (double)l1, (double)m1, 1);
				t4 = get_integral(0.,2.*PI, (double)l1, (double)m1, 2);
				term1 = t1*t3 + t2*t4;
				//term1 = get_integral(0.,2.*PI, (double)l, (double)m, 4);
				//printf("term1 = %lf \n", term1);
				// integrals over theta
				term2 =  get_integral(-1., 1., l, m, 3)*get_integral(-1., 1., l1, m1, 3);
				//printf("term2 = %lf \n", term2);
				term = term1*term2;
				if (term != 0.0){
					printf(" \n term = %lf \n", term);
				}
				res = res + term;
			}
		}
	}

	printf("\n res = %lf \n", res);
	return 0;
}
int main(int argc,char* argv[]) {

   AIDA::IAnalysisFactory* af = AIDA_createAnalysisFactory();
   if(!af) return EXIT_FAILURE;

   AIDA::ITreeFactory* trf = af->createTreeFactory();
   if(!trf) return EXIT_FAILURE;
   AIDA::ITree* tree = trf->create();
   delete trf;
   if(!tree) return EXIT_FAILURE;

   AIDA::IHistogramFactory* hf = af->createHistogramFactory(*tree);
   if(!hf) return EXIT_FAILURE;
   AIDA::IHistogram1D* h1d = hf->createHistogram1D("master 1d","master 1d",50,-3,3);
   AIDA::IHistogram1D* hr = hf->createHistogram1D("random","random",50,-3,3);
   delete hf;
   if(!h1d) return EXIT_FAILURE;
   if(!hr) return EXIT_FAILURE;

   { // fill the "master" histogram with a gaussian centered at zero, and a rms of one
      for (int i=0; i<1000000; i++) {
         h1d->fill(rgauss_shoot());
      }
   }

   { // fill the "random" histogram with values sampled from the "master"
      std::vector<double> integral;
      if(!get_integral(*h1d,integral)) return EXIT_FAILURE;
      for (int i=0; i<1000000; i++) {
         hr->fill(get_random(*h1d,integral));
      }
   }

   AIDA::IPlotterFactory* pf = af->createPlotterFactory(argc,argv);
   if(pf) {
      AIDA::IPlotter* plotter = pf->create();
      delete pf;
      if(plotter) {
         plotter->createRegions(1,2,0);
         plotter->region(0)->plot(*h1d);
         plotter->region(1)->plot(*hr);
         plotter->show();
         plotter->interact();
         delete plotter;
      }
   } else {
      // Printing some statistical values of the "master" histogram
      std::cout << "Master :" << std::endl;
      std::cout << "Title  : " << h1d->title() << std::endl;
      std::cout << "Entries: " << h1d->entries() << std::endl;
      std::cout << "Mean   : " << h1d->mean() << std::endl;
      std::cout << "RMS    : " << h1d->rms() << std::endl;      
      std::cout << "========" << std::endl;
      // ... and the same for the "randomly sampled" histogram
      std::cout << "Sampled:" << std::endl;
      std::cout << "Title  : " << hr->title() << std::endl;
      std::cout << "Entries: " << hr->entries() << std::endl;
      std::cout << "Mean   : " << hr->mean() << std::endl;
      std::cout << "RMS    : " << hr->rms() << std::endl;      
   }

   delete af;

   std::cout << "That's it !" << std::endl;

   return EXIT_SUCCESS;
}