Ant Colony Optimization for Resistor Color Code Detection

ABSTRACT


I. Introduction
Resistors are components that are often found in electronic circuits.Resistors contain a resistance value or resistance designed to regulate voltage and electric current [1].Based on the EIA (Electronic Industries Association) rules, the resistance value is shown by a color band [2].Twelve colors have different value representations depending on the color position [3].Many combinations of color bands raise the need for technology that can automatically measure resistor values visually.
Various combinations of automatic resistor measurement methods have been proposed in previous studies.Machine learning is a popular method used.Gao et al extract characters from on-chip resistors using traditional segmentation and classify the segmentation results using artificial neural networks [4].Wu proposed gravity features and classified stroke lines using the decision tree recognition method to recognize characters on-chip resistors [5].Li et al developed a color band recognition method using the Retinex algorithm and a Back Propagation neural network on a resistor image acquired using a black-and-white industrial camera [6].Muminovic and Sokic developed a resistor color band classification using the Support Vector Machine (SVM) [7].Chen and Wang cluster the main body color and the extracted band color using K-Nearest Neighbour (K-NN) [8].
In addition, color-based segmentation approaches and statistical analysis are also popularly proposed.Yan et al refined the traditional segmentation results on PCB resistors using local gray-level distributions [9].Jadon et al proposed morphological operation using binarization and mean a shift to cluster resistor values [10].Li et al proposed a PCB recycling system using information retrieval based on the color of the resistors, capacitors, and integrated circuits (ICs) [11].Abdallah et al implement a weighting resistor matrix (WRM) to detect resistor lines [12].Li et al proposed calculating the symmetrical Kullback-Leibler distance to measure the difference in the class distribution of resistor rings [13].
The previously proposed computed all image matrix values include the non-resistor area, which is more than the resistor area.Furthermore, most of their methods work iteratively.It triggers In the early stages of learning resistors, introducing color-based values is needed.Moreover, some combinations require a resistor trip analysis to identify.Unfortunately, a resistor body color is considered a local solution, which often confuses resistor coloration.Ant Colony Optimization (ACO) is a heuristic algorithm that can recognize problems with traveling a group of ants.ACO is proposed to select commercial matrix values to be computed without preventing local solutions.In this study, each explores the matrix based on pheromones and heuristic information to generate local solutions.Global solutions are selected based on their high degree of similarity with other local solutions.The first stage of testing focuses on exploring variations of parameter values.Applying the best parameters resulted in 85% accuracy and 43 seconds for 20 resistor images.This method is expected to prevent local solutions without wasteful computation of the matrix.
computational complexity [14].Heuristic algorithms can be applied to select commercial matrix values to be computed, thus, it is expected to reduce computational complexity [15].The results of the comparison of algorithms show that the ant colony optimization performs better than other heuristic methods [16] [17].Furthermore, the use of the ant system in various segmentation cases has proven to be superior, such as mitotic cells [18], word [19], and traveling salesman problems [20].
In this study, resistor value estimation using ant colony optimization is proposed.The ant colony optimization algorithm is a metaheuristic inspired by the foraging behavior of ants [21].In this context, the ants represent individual agents that traverse the resistor rods, seeking to find the other resistor rod.As they move along the nodes of the resistor rings, the ants leave behind a pheromone trail, mimicking the pheromone deposition of real ants.The concentration of pheromone on each node serves as a measure of its attractiveness or desirability.
The proposed method leverages the power of ant colony optimization to estimate the resistor values.Each ant selects its path through the resistor rings based on a combination of pheromone trails and heuristic information.The pheromone trails guide the ants towards the nodes with higher pheromone concentration, which are likely to correspond to the locations of the resistor rods.Meanwhile, the heuristic information provides additional guidance by incorporating domain-specific knowledge or constraints into the decision-making process [22].
By iteratively applying the ant colony optimization algorithm, the pheromone trails are updated dynamically, allowing the ants to progressively refine their paths.This iterative process encourages the exploration of different paths initially and gradually favors the exploitation of the most promising paths based on the accumulated pheromone levels [23].As a result, the ants effectively converge towards the optimal paths that lead to accurate estimation of the resistor values.
One key aspect considered in this study is the selection of the node with the highest pheromone concentration in each resistor ring for distance measurement.This node is expected to be closer to the corresponding resistor rod, providing valuable information for accurate estimation.By focusing on the nodes with higher pheromone levels, the proposed method intelligently prioritizes the exploration of regions likely to contain the resistor rods, improving the efficiency and effectiveness of the estimation process.
The use of ant colony optimization in resistor value estimation offers several advantages.It is a flexible [24] and adaptive approach [25] that can handle different resistor network configurations and accommodate variations in resistor characteristics.The algorithm's ability to leverage collective intelligence and distributed decision-making enables robust estimation even in the presence of noise or uncertainties in the circuit [26].Furthermore, the method can potentially overcome the limitations of traditional techniques by providing more accurate estimations and reducing the dependency on explicit mathematical models.

II. Methods
This study employed EIA images as the training data for the proposed method.The training dataset consisted of a diverse range of EIA images, which were collected from various sources and curated for this study.A total of 20 test images were randomly selected from Google to evaluate the performance of the method on unseen data.
To provide a comprehensive understanding of the dataset, Table 1 summarizes the characteristics and properties of the training data [27], including the number of samples, their associated labels or annotations, and relevant metadata.The distribution of the training data is visualized in Figure 1 (b), where each data point represents a specific EIA image along with its corresponding label.
For the test data, Figure 1 (a) showcases a subset of the randomly chosen test images.These images were carefully selected to cover a wide range of scenarios and variations in resistor configurations.The test data is crucial for assessing the generalization capabilities of the proposed method and its ability to accurately estimate resistor values in real-world settings.In order to ensure a consistent and reliable analysis, certain preprocessing steps were applied to both the training and test data.Firstly, all resistor positions were standardized to a vertical orientation, with an allowable angle deviation of less than 10 degrees.This orientation normalization step helps in reducing potential variations caused by the rotation or tilt of the resistors in the images.
Additionally, the ends of the resistor iron were cropped to remove any irrelevant or distracting elements that could interfere with the accurate estimation of resistor values.This cropping process helps to focus solely on the essential region of interest, allowing the method to concentrate its analysis on the relevant components of the resistors.Furthermore, during the preprocessing phase, a thorough detection and removal process was implemented to eliminate any uncounted resistor body templates from the training data.Figure 1 (c) provides a visual representation of these identified templates that were excluded from the training dataset.By eliminating such templates, the method avoids potential biases or distortions in the estimation process, ensuring the accuracy and reliability of the results.
Overall, the use of EIA images as training data, supplemented with the randomly selected test images, provides a robust and diverse dataset for evaluating the proposed method's performance.The careful preprocessing steps, including orientation normalization, cropping of resistor ends, and removal of uncounted resistor body templates, contribute to the accuracy and reliability of the resistor value estimation process.
In this case, the ant colony algorithm can choose the best ring value representation based on Pheromone.The pseudocode of the Ant Colony Algorithm is shown in Pseudocode 1.The ants will alternately explore the resistor color nodes in the dimensions of the matrix until the ants reach the farthest resistor bar or color code (Ringmax).Based on resistor theory, the maximum ring reaches 5 rings.Ants leave pheromones at the nodes they pass through, as shown in (1).Based on Pseudocode 2, the pheromone is a marker of areas passed and not passed by ants, whereas heuristic information passed by ants is a temporary solution.The solutions formed in each ring are computed based on the mean function.The distance between training and testing data is calculated to get the Ring value.In addition, the position is also used to get the precision resistor value.The ring shows the tolerance value if it is in the last position.
Meanwhile, if the ring is in the last-1 position, then the ring shows 10 to the power of the ring's value.In addition, the value of the ring shows the value of the ring itself, both in tens and hundreds.Thus, an ant creates a solution set of combined color ring values.The best solution is selected based on the fitness function shown in Pseudocode 3. The pheromone update function is applied every time the ant changes to prevent local solutions.The local update pheromone is shown in (2).
where  and  0 is the parameter that is set to prevent the ant from passing through the same node as the previous ant.
We tested parameters to form the best ant colony architecture.The trial variations of initialization are shown in Table 2.
Where the accuracy (ACC) is the correct total-C against all of data-A.

III. Result and Discussion
Ant Colony Optimization is proposed to select commercial matrix values to be computed without preventing local solutions.In this study, each explores the matrix based on pheromones and heuristic information to generate local solutions.Global solutions are selected based on their high degree of similarity with other local solutions.In order to achieve a global solution, many parameters need to be initialized.For this reason, the first testing stage focuses on exploring variations of parameter values.
In the first trial we evaluated the use of a and b, shown in Table 2.The results show that heuristic information plays a major role in the classification results.Based on Equation (1), pheromones are influenced by heuristic information, thus if the heuristic information is omitted, then the Pheromone loses information to select the point that is considered a ring or not.Based on Table 3, the selected values are αand β are 0 and 1, respectively.In the second test, we evaluate the effect of  0 of the initial Pheromone and  of the additional pheromones.The best values of  and  0 are 1 and 0 respectively.Setting  =1 at (1-) in Equation 2eliminates the effect of additional pheromones, while the initialization of =0 eliminates the effect of the initial pheromones.Thus, all pheromone values change to zero, causes the ant path to be unaffected by the previous ant path.If the previous path is wrong, the next ant path does not repeat the same error.Worst results are obtained in setting values =0,  0 =1.Setting this value increases the pheromone value, allowing the ants to explore the same area.When the first ant explores the wrong way, the next ant will also fall into the wrong path.
We tested with three variations of values with five conditions, consisting of (1) an ant explored the right edge, (2) an ant explored the left edge, (3) an ant are set randomly, (4) two ants explored both edges, (4) 3 ants explored the middle and two edges of resistor (5) an ant explored the right edge.
Table 5 shows no difference in using 1 or 2 ants placed on the edge area shown at the same accuracy value.This is due to the edges being unaffected by the acquisition light.However, the middle part triggers a misrepresentation of the resistor code value caused by the light effect.Things are different when the ants are set at random.Ants are often set in locations instead of resistors, ants circle around to find the first ring.This triggers a longer computation time, even longer than 3 ants.Thus the, further research can be allocated for setting the location of ants.The set parameter values were determined in Table 6 based on the previous test.Figure 2 shows the test results with the best value parameter settings.3 errors occur in the same characteristics, namely when the resistor is white.The error result is shown in Figure 3.The third error is caused by the ring's color, which resembles the background, so the ring's value is incorrectly detected as a background.A resistor color detector could be used in the classroom as a teaching tool if it is developed.The instructor will explain the resistor color code with the help of the notes and handouts.The student will attend the teacher's demonstration, engage in question and answer sessions, and conduct analysis.The students will review the color code handouts and consult with the instructor about any questions.As a last step, students will follow the information provided by the proposed detector.This scenario may prove to be instructive for students just beginning their electrical engineering education.

IV. Conclusion
In this study, Ant Colony Optimization is proposed to select commercial matrix values to be computed without preventing local solutions.Pheromones and heuristic information in the form of RGB matrices contribute greatly to the movement of ants.Global solutions are selected based on their high degree of similarity with other local solutions.In order to prevent the local solutions, the local updated pheromones are employed.In the testing, we explored the various variations of parameter values, such as: , , ,  0 , and population.We get the best accuracy by applying  = 0,  = 1,  = 1,  0 = 0 and population = 1.Applying the best parameters resulted in 85% accuracy and 43 seconds for 20 images.It can be concluded that the proposed method prevents local solutions without exploring all the matrix values.The future implementation of the color detector at school could benefit electrical engineering students.

Fig. 3 .
Fig. 3. Error ResultMeanwhile, the path traversed by the ants is shown in Figure4.The ants explore part of the ring, both on the right edge and ants on the left edge.However, applying the best parameters resulted in 85% accuracy and 43 seconds times for 20 images.This method is expected to prevent local solutions without wasteful computation of the matrix.

Table 1 .
Training Data are influenced by heuristic information.In this case, the heuristic information-  is the RBG matrix on the resistor image. and  indicate the amount of Pheromone and heuristic information in influencing the movement of ants.The solution based on Pheromone and heuristic information is computed in the construct solution function shown in Pseudocode 2.

Table 6 .
. Testing of population The parameter setting