Median of 200000 TH1F

Hi,

I need to store a TH1F for each of the 200000 voxels in a image 3D reconstruction program, and compute the median of the histogram for each voxel. The program slows down and nearly freezes, because the memory consumption is too much. How much memory does a TH1F allocates? Is there a clever way to store about 500k floats per voxel and compute the median without running out of memory?

Thanks a lot
Sara

Hi,

If you knew what the median was, you could simply run over all of the histogram and verify that half the entries are above the "guessed median" and half are below.  You could imagine an iterative procedure where you either:
  • Using a binary search, checked out different guesses, or

  • Using a good guess (maybe RMS ±5 percent) keep all entries in a window and keep track of the number above and below the window.

    Hope this helps. Good luck,
    Charles