Biofilms are typically heterogeneous in morphology, structure, and composition, resulting in non-uniform mechanical properties. The distribution of mechanical properties, in turn, determines the biofilm mechanical behavior, such as deformation and detachment. Most past studies neglected heterogeneity of biofilms. In this study, an image-based modeling approach was developed to transform two-dimensional optical coherence tomography biofilm images to a pixel-scale non-Newtonian viscosity map of the biofilm. The spatial distribution of non-Newtonian viscosity was applied in an established Oldroyd-B constitutive model and implemented using the phase-field continuum approach for the deformation and stress analysis. The heterogeneous model was able to predict deformations and stresses more accurately than a homogenous one. This is the first time, to the best of our knowledge, that an image-based approach is used to map the mechanical heterogeneity of biofilms for computational studies. It provides an efficient method to characterize biofilm mechanical behavior.