An optimization procedure for spatial and density resolution in hard X-ray micro-computed tomography