Radiologists have used margin characteristics based on routine visual analysis; however, the attenuation changes at the margin of the lesion on CT images have not been quantitatively assessed. We established a CT-based margin analysis method by comparing a target lesion with normal lung attenuation, drawing a slope to represent the attenuation changes. This approach was applied to patients with invasive mucinous adenocarcinoma (n = 40) or bacterial pneumonia (n = 30). Correlations among multiple regions of interest (ROIs) were obtained using intraclass correlation coefficient (ICC) values. CT visual assessment, margin and texture parameters were compared for differentiating the two disease entities. The attenuation and margin parameters in multiple ROIs showed excellent ICC values. Attenuation slopes obtained at the margins revealed a difference between invasive mucinous adenocarcinoma and pneumonia (P<0.001), and mucinous adenocarcinoma produced a sharply declining attenuation slope. On multivariable logistic regression analysis, pneumonia had an ill-defined margin (odds ratio (OR), 4.84; 95% confidence interval (CI), 1.26–18.52; P = 0.02), ground-glass opacity (OR, 8.55; 95% CI, 2.09–34.95; P = 0.003), and gradually declining attenuation at the margin (OR, 12.63; 95% CI, 2.77–57.51, P = 0.001). CT-based margin analysis method has a potential to act as an imaging parameter for differentiating invasive mucinous adenocarcinoma and bacterial pneumonia.