Example #1
0
int main(int c, char *v[])
{
	if (c != 2 && c != 1) {
		fprintf(stderr, "usage:\n\t%s [in]\n", *v);
		//                         0   1
		return EXIT_FAILURE;
	}
	char *filename_in = c > 1 ? v[1] : "-";
	int w, h, pd, nh[4];
	float *x = iio_read_image_float_vec(filename_in, &w, &h, &pd);
	float *tmp = xmalloc(w*h*sizeof*tmp);
	if (pd != 3) fail("requires a rgb image");
	long double (*his[4])[2];
	for (int l = 0; l < 4; l++)
		his[l] = xmalloc(w*h*sizeof*his[l]);
	for (int l = 0; l < 3; l++) {
		for (int i = 0; i < w*h; i++)
			tmp[i] = x[3*i+l];
		nh[l] = fill_histogram(his[l], tmp, w*h);
	}
	for (int i = 0; i < w*h; i++)
		tmp[i] = round(RRR*x[3*i]+GGG*x[3*i+1]+BBB*x[3*i+2]);
	nh[3] = fill_histogram(his[3], tmp, w*h);

	dump_histograms(his, nh);

	return EXIT_SUCCESS;
}
void thresh(const int size, const int percent) {
  
  int nmax = find_max(size);
  
  fill_histogram(size);
  
  int threshold = calc_threshold(percent, nmax, size);
  
  fill_mask(size, threshold);

}
void draw_histogram(TH1F * const h, const particle_type p,
		    const int energy_level_gev, const detector d)
{
	h->SetName(generate_histogram_name(p, energy_level_gev, d));

	TTree *const t = load_tree(generate_file_path(p, energy_level_gev, d),
				   "ntp_cluster");

	fill_histogram(h, t, 0.3);
	h->Scale(1 / h->GetEntries());
	h->GetYaxis()->SetRangeUser(0.0001, 10);
	h->SetXTitle("E_{cluster} (GeV)");
	h->SetYTitle("entries / #scale[0.5]{#sum} entries      ");

	h->Draw("SAME");
}
Example #4
0
int main(int c, char *v[])
{
	if (c != 2 && c != 1 && c != 3) {
		fprintf(stderr, "usage:\n\t%s [in [out]]\n", *v);
		//                         0   1   2
		return 1;
	}
	char *filename_in  = c > 1 ? v[1] : "-";
	char *filename_out = c > 2 ? v[2] : "-";

	int w, h;
	float *x = iio_read_image_float(filename_in, &w, &h);

	long double H[256];
	fill_histogram(H, x, w*h);
	accumulate_histogram(H);
	equalize_inplace(x, H, w*h);

	iio_write_image_float(filename_out, x, w, h);

	return 0;
}
Example #5
0
void fill_histograms(vector<TH1F *> * histograms, const vector<vector<float > > data, int bins, int layers) {
  for(int i = 0; i < histograms->size(); ++i) {
    fill_histogram((*histograms)[i], data, bins, i);
  }
}