Use Imglib algorithms' Histogram1d class