As a substitute for metal, carbon foam is vital in the electromagnetic shielding industry. Nevertheless, the diameter and density of carbon foam cells are still mostly assessed manually. This research offers a Deep-Res-MixAttention segmentation method to effectively minimize manual labor and increase measurement efficiency. Moreover, the method consists of two modules: the MixAttention module is intended to improve feature extraction skills, and we use the multiscale deep residual module to collect edge information. In addition to enhancing the segmentation capability of incomplete carbon foam, the loss function is adjusted to address the dataset imbalance issue. Additionally, we propose the bidirectional selection rotation calipers algorithm to intelligently determine the density and diameter. The results reveal that the optimized network’s IoU and acc carbon reach 91.05% and 88.31%. Finally, the calculation errors of the average diameter and density are under control at 1.79% and 7.09%, respectively. The approach has a high application value for assessing the electromagnetic shielding effectiveness of carbon foam.