Macerals are the basic components of coal reservoirs. Identification of macerals in coal reservoirs is of great practical significance. In this paper, ten coal samples and six typical maceral images, including megaspores, resinite, cutinite, barkinite, microspores and alginate, from Permian coal samples of the Qingshui Basin are taken as examples for quantitative image-algorithm analysis. Combined with the functions (e.g., “bwlabel”, “ginput”, “Regionprops”, and “bwboundaries”), algorithms and the “Color Thresholder” application in MATLAB, the contents, radii and specific surface areas of different types of maceral structures are identified and calculated. Binarization of thin-section images by means of the RGB and HSV modes in the "Color Threshold" in MATLAB is the first step of automatic recognition. Various functions and algorithms are used to capture pixel distributions in binary images with maceral distributions. The contents of six representative macerals were 58.747%, 11.302%, 20.563%, 48.293%, 24.044% and 11.469%, with corresponding average radii of 150.6976 μm, 93.5590 μm, 88.3547 μm, 93.5590 μm, 114.8465 μm and 84.3030 μm, respectively; the specific surface areas of the macerals were 0.1172 m2/g, 0.6375 m2/g, 0.7646 m2/g, 0.4169 m2/g, 0.1261 m2/g and 0.7374 m2/g, respectively. To determine the accuracy of the quantitative analysis process, we compared the results of traditional recognition methods with the results of the image-function identification method. The results show that there is a good linear relationship between the two experiments for exinite, inertinite and vitrinite contents in coal, with R2 values of 0.9275, 0.9907 and 0.9930, respectively. Due to the influence of microscopy, artificial parameters in the imaging process, and the influence of impurities, inclusions or dark minerals in the original coal samples, some optical noise was present inside and outside the maceral components. We establish a noise-reduction system that is based on the "imerode" and "imdilate" functions to eliminate noisy areas in nonmaceral features and repair damaged spaces in the components caused by noise.