# Combination Pattern Method Using Deep Learning for Pill Classification
## 1 Introduction  
Medication safety is a critical concern in healthcare due to its direct impact on patient health. The accurate identification of medications is essential, as errors can lead to serious adverse effects, including injuries and complications. Oral pills, widely used because of their stability and ease of administration, pose significant challenges, particularly for patients with memory problems. Reports from the Organization for Economic Co-operation and Development (OECD) indicate that medication errors contribute to 18.3% of adverse patient events [1], with a significant portion resulting from confusion over pill shapes and colors, as highlighted by studies in the British Medical Journal (BMJ) [2] and by the World Health Organization (WHO) [3]. This problem is exacerbated during the medication cycle--prescribing, dispensing, and administration--where physical characteristics of pills often lead to errors [4, 5]. The variability in pill shapes, sizes, and colors, which may change over time due to factors like wear and discoloration, complicates reliable identification. Traditional machine learning models used for pill detection struggle to keep pace with the rapid introduction of new drugs, often failing to adapt to these changes, as evidenced by studies showing that nearly 25% of medications go unidentified in university hospitals [6,7]. Pentagonal pills present unique challenges among the various pill shapes due to their complex geometry, including pointed edges and a mix of curves and straight lines, as illustrated in Figure 1.  
These identification challenges are compounded by rotation invariance and perspective distortion, where a pill's orientation in an image can drastically alter its perceived shape. Variable lighting conditions that distort visual features further exacerbate such issues, underscoring the need for more sophisticated algorithms that can effectively navigate these complexities. To address these issues, numerous studies have explored the potential of computer vision technology in pill detection. A widely used analytical technique involves comparing similarities between input and reference images based on shape, color, and imprinting features. These methods are broadly categorized into pixel-based and shape-based matching. Pixel-based methods calculate differences between corresponding pixels and compute similarity metrics such as the sum of squared differences or normalized cross-correlation [8,9]. Although effective against image distortion, they cannot detect changes in size or rotation. In contrast, shape-based matching extracts the subject's region of interest (ROI) from a reference image, better accommodating object size and orientation variations, and excels in variable illumination settings [10, 11, 12]. Recent advancements in deep learning-based object-detection algorithms have been pivotal in developing self-learning and decision-making capabilities for pill-recognition solutions [13]. These neural networks excel in tasks such as object detection, biomedical diagnosis, and variant detection thanks to their ability to process and learn from large datasets [14, 15, 16, 17]. Popular methods include You Only Look Once (YOLO), convolutional neural networks (CNNs), and recurrent neural networks (RNNs). Achieving high detection performance, however, necessitates extensive data due to the nuanced variability in pill shapes, textures, and colors. This variability demands a comprehensive approach that accounts for these subtle differences, making pill identification a complex visual classification challenge that requires precise differentiation between pill fragments. To address these challenges, we propose the Multi-Combination Pattern Labeling (MCPL) method, a novel approach designed to enhance the accuracy and reliability of pill classification in challenging image conditions. The MCPL method extracts unique and representative features from pill images, providing a rich representation of the pill's characteristics to improve classification performance.