Precise quantification of myocardial infarction is crucial for evaluating the therapeutic strategies. We developed a robust, color-based semi-automatic algorithm capable of infarct region detection, isolation and quantification with four different histological staining techniques, and the isolation and quantification of diffuse fibrosis in the heart. Our method is developed based on the color difference in the infarct and non-infarct regions after histological staining. Mouse cardiac tissues stained with Masson trichrome (MTS), hematoxylin and eosin (H&E), 2,3,5-Triphenyltetrazolium chloride and picrosirius red were included to demonstrate the performance of our method. We demonstrate that our algorithm can effectively identify and produce a clear visualization of infarct tissue for the four staining techniques. Notably, the infarct region on a H&E-stained tissue section can be clearly visualized after processing. The MATLAB-based program we developed holds promise in the infarct quantification. Additionally, our program can isolate and quantify the diffuse fibrotic elements from an MTS-stained cardiac section, which suggested the algorithm potential for evaluating pathological cardiac fibrosis in diseased cardiac tissues. In conclusion, we demonstrate that this color-based algorithm is capable of accurately identifying, isolating and quantifying cardiac infarct regions with different staining techniques, as well as the diffuse and patchy fibrosis in MTS-stained cardiac tissues.