A high granularity imaging calorimeter for cosmic-ray physics