From images to mathematical models: intravoxel micromechanics for ceramics and polymers