Determination of dislocation density from hardness measurements in metals