Dot matrix display character recognition method based on color features
By employing a color feature-based text recognition method for dot matrix displays, and utilizing dual-strategy filtering and K-Means clustering algorithms, the problem of character recognition in complex environments on dot matrix displays is solved, generating high-contrast masks and achieving high-precision character recognition.
Patent Information
- Application Number
- CN202511311503.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-15
- Publication Date
- 2025-11-18
AI Technical Summary
Traditional OCR methods face challenges when recognizing characters on dot matrix displays, such as jagged edges on characters, uneven brightness due to changes in ambient lighting, and halo effects. These issues make character recognition difficult, and the methods also ignore color characteristics, making it difficult to effectively segment character areas in complex lighting environments.
A color feature-based text recognition method for dot matrix displays is adopted. Non-target pixels are removed through a dual-strategy filtering mechanism, color clusters are quantized using the K-Means clustering algorithm, and target colors are matched by Euclidean distance to generate a high-contrast foreground mask for use by the OCR engine.
It effectively isolates target characters, reduces background interference, and generates a high-contrast, high-fidelity foreground mask, improving the accuracy and robustness of character recognition and adapting to different devices and ambient lighting changes.
Smart Images

Figure CN120976940A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automatic distribution devices, and more particularly to a method for recognizing text on a dot matrix display based on color features. Background Technology
[0002] Dot matrix displays (such as LED, VFD, and LCD) are widely used in industrial automation, aerospace, and other fields, offering advantages such as high reliability and low cost. These devices typically display numerical or alphanumeric information on a dark background using saturated colors (red, green, amber, etc.). However, OCR faces multiple challenges when recognizing dot matrix characters: characters are composed of pixels with noticeable jagged edges; ambient lighting, equipment aging, and changes in viewing angle lead to uneven brightness and contrast, and even halo effects, severely impacting image quality and making traditional algorithms difficult to adapt.
[0003] The main problems with existing technologies are as follows: Preprocessing issues: Otsu and other grayscale methods assume that the image presents a bimodal grayscale histogram, but raster images often do not conform to this assumption, and choosing an inappropriate threshold may lead to the loss of core character information. Edge detection algorithms such as Canny or Sobel introduce a large number of pseudo-contours, noise, and breaks when processing jagged pixels, making character structures difficult to recognize.
[0004] Color characteristics are ignored: general OCR often converts to grayscale images, fundamentally losing color signals; even when trying to extract with a fixed threshold in color spaces such as HSV, it is difficult to resist misjudgments caused by changes in lighting and saturation.
[0005] Character region segmentation is prone to failure: Due to complex halos and background noise, small gaps between characters, connected regions, and projection segmentation methods, it is difficult to accurately identify character boundaries, which directly affects OCR performance.
[0006] As can be seen from the above, traditional OCR processes are difficult to meet the recognition requirements of dot matrix characters in complex lighting and noise environments, and a preprocessing strategy based on color features rather than grayscale information is urgently needed. Summary of the Invention
[0007] The technical problem to be solved by the present invention is to provide a text recognition method for dot matrix displays based on color features, which can effectively isolate target color characters, reduce background interference, and finally generate a high-contrast, high-fidelity foreground mask for subsequent use by OCR engines.
[0008] To address the aforementioned technical problems, this invention provides a text recognition method for dot matrix displays based on color features, comprising the following steps: S1, receiving the original image and region of interest as input, and removing non-target pixels from the image after background filtering; S2, sending the filtered effective pixels into a K-Means clustering algorithm for color quantization, and automatically summarizing the main color clusters in the image using the K-Means clustering algorithm; S3, in the color measurement matching stage, determining the target color representing the foreground of the character by calculating the Euclidean distance between the center of each color cluster and the preset target color in RGB space; S4, performing foreground mask reconstruction based on the matching results to generate a binary image containing only the target character pixels, and sending it into a standard OCR engine for final text recognition.
[0009] Furthermore, step S1 employs a dual-strategy filtering mechanism. First, a static threshold method is used for rapid pre-filtering to remove pure black and pure white pixels from the image. Then, a statistically based dynamic filtering method is used to continue removing non-target pixels from the image.
[0010] Furthermore, when the static thresholding method is used in step S1, for pixels in the RGB color space... Define the black filter conditions:
[0011] White filter conditions:
[0012] in and These are the low threshold and the high threshold, respectively. and .
[0013] Furthermore, when using the dynamic filtering method in step S1, the final filtering conditions are determined by combining weighted brightness and weighted chromaticity information:
[0014] For adaptive weighted brightness, the calculation is as follows:
[0015] The weighting coefficients are based on the target color. Adaptive determination: Formula for calculating weighting coefficients:
[0016]
[0017]
[0018] The weighting coefficients satisfy the following normalization constraints:
[0019] in This is a weighting enhancement factor, set for different display types; The weighted standard deviation of chromaticity is calculated as follows:
[0020] Dynamic weighting coefficient calculation:
[0021]
[0022]
[0023] in This is the chromaticity enhancement factor, with a value range of [value range missing]. It dynamically adjusts according to the color purity of the monitor; The adaptive standard deviation threshold is calculated as follows:
[0024] Based on the baseline standard deviation threshold, The weighting factor has a range of values. .
[0025] Furthermore, step S1 automatically selects the optimal weighting strategy based on the characteristics of the target color: Color purity determination:
[0026] in It is an order of magnitude The smallest positive number; The strategy logic selection is as follows: when At that time, a high-weight enhancement mode is adopted. when At that time, a medium-weighted model is adopted. ; when At that time, it will revert to the traditional equal-weighted model.
[0027] Further, step S2 includes: S21, based on the number of effective pixels Adaptively determine the number of clusters k: ;in Number of clusters; S22, the K-Means algorithm updates the cluster centers iteratively until it converges; Cluster centers In the The update formula for the next iteration is: ;in It is in the In the next iteration, the one assigned to the The set of pixels in each cluster; the cluster centers obtained after convergence. The quantized color palette that makes up the image represents the main colors in the image; S23. After completing the clustering, calculate the value of each color cluster. The proportion of pixels contained: ;in Is assigned to the first The number of pixels of the primary color, It represents the total number of pixels participating in the clustering.
[0028] Furthermore, the aforementioned The number of clusters can be either 3 or 4.
[0029] Furthermore, step S3 uses Euclidean distance in the RGB space as a metric for color similarity; the primary color... With target color The distance between them is:
[0030] Step S3 selects the target color. The primary color with the smallest distance The best match is defined as a minimum distance that is less than a preset similarity threshold. .
[0031] Furthermore, the similarity threshold The value ranges from 30 to 50.
[0032] Further, step S4 includes: defining a pixel mask. :
[0033] in It is a pixel. Category label after K-Means clustering It is the category label corresponding to the best matching color; The final processed image for:
[0034] in These are the original pixel values. This is the background fill value.
[0035] Compared with existing technologies, this invention offers the following advantages: The color feature-based text recognition method for dot matrix displays provided by this invention innovatively designs a multi-stage image preprocessing method while preserving color features. This method relies on prior color information, transforming the character recognition problem into a color-driven segmentation task, thereby effectively isolating target color characters, reducing background interference, and ultimately generating a high-contrast, high-fidelity foreground mask for subsequent OCR engine use. This invention possesses high adaptability, strong robustness, eliminates the need for manual parameter tuning for different devices, supports real-time applications, and achieves efficient execution through vectorization. Attached Figure Description
[0036] Figure 1 This is a flowchart of the text recognition process for dot matrix displays based on color features according to the present invention. Figure 2 This is a detailed flowchart of the present invention from input image and ROI region to output recognition result; Figure 3a This is a diagram illustrating the original image and the misidentification results; Figure 3b This is a schematic diagram of the identification results of the present invention; Figure 4 This is a diagram showing the overall architecture of the present invention combined with an OCR system. Detailed Implementation
[0037] The present invention will now be further described with reference to the accompanying drawings and embodiments.
[0038] Figure 1 This is a schematic diagram of the structure of the dot matrix display text recognition method based on color features according to the present invention.
[0039] Please see Figure 1 The color feature-based text recognition method for dot matrix displays provided by this invention includes the following steps: S1. Receive the original image and region of interest as input, and remove non-target pixels from the image after background filtering; S2. The filtered effective pixels are fed into the K-Means clustering algorithm for color quantization. The K-Means clustering algorithm is used to automatically summarize the main color clusters in the image. S3. In the color measurement and matching stage, the target color representing the foreground of the character is determined by calculating the Euclidean distance between the center of each color cluster and the preset target color in the RGB space. S4. Based on the matching results, perform foreground mask reconstruction to generate a binary image containing only the target character pixels, and then send it to the standard OCR engine for final text recognition.
[0040] This invention receives the original image and the region of interest (ROI) as input, and after a series of processes including background filtering, color clustering, color matching, and mask reconstruction, it finally outputs a high-precision OCR recognition result. The detailed process is as follows: Figure 2 As shown below, the various steps of this invention will be described in detail.
[0041] I. Background Pixel Filtering Algorithm The goal of this stage is to initially remove background pixels in the image that are unrelated to the target character, thereby reducing the computational burden on subsequent clustering algorithms and improving their accuracy. This invention employs a dual-strategy adaptive filtering mechanism.
[0042] 1. Static RGB threshold filtering method This method serves as a fast pre-filtering technique to remove pure black and pure white pixels from an image. For pixels in the RGB color space... Define the filtering conditions: Black filter condition (removes pixels that are close to black):
[0043] White filter condition (removes pixels that are nearly white):
[0044] in and These are the low threshold and the high threshold, respectively. Typically, the present invention sets... and This is used to define the pixel range between near-black and near-white. This method is simple to calculate and can effectively handle ideal cases where the background is pure black or pure white.
[0045] 2. Adaptive Filtering Method in Chromaticity-Luminosity Space When the static thresholding method filters out too many pixels (indicating the background is not pure black / white), the system automatically switches to this more robust filtering strategy. This method comprehensively considers the brightness and chromaticity information of pixels and innovatively introduces an adaptive weighting mechanism based on target color features. Traditional equal-weighted brightness calculation fails to reflect the differences in spectral emission characteristics of different types of dot matrix displays. This invention proposes an adaptive weighted brightness calculation method: Traditional brightness calculation:
[0046] The adaptive weighted brightness calculation of the present invention:
[0047] The weighting coefficients are based on the target color. Adaptive determination: Formula for calculating weighting coefficients:
[0048]
[0049]
[0050] Normalization constraints:
[0051] in The weighting enhancement factor is set for different display types: • Red LED display:
[0052] • Green LED display:
[0053] • Amber display:
[0054] To further improve the sensitivity to the target color channel, this invention also introduces an adaptive weighting mechanism in the calculation of the chromaticity standard deviation: Traditional colorimetric standard deviation calculation:
[0055] The weighted standard deviation of colorimetry in this invention is calculated as follows:
[0056] Dynamic weighting coefficient calculation:
[0057]
[0058]
[0059] in This is the color enhancement factor, with a typical value range of [value range missing]. It dynamically adjusts based on the color purity of the monitor.
[0060] Based on the weighted calculation results, the system also adaptively adjusts the standard deviation threshold: Adaptive standard deviation threshold:
[0061] in: • Baseline standard deviation threshold (e.g., 5) • For the weighting influence factor, a recommended value is [value].
[0062] Based on the combined weighted brightness and weighted chromaticity information, the final filtering criteria are:
[0063] Here It can be viewed as the weighted deviation of a pixel color from the target color in the RGB space, and is a chromaticity saturation measure optimized for a specific display. .
[0064] This condition not only preserves pixels that are neither extremely bright nor extremely dark but still have significant color information, but more importantly, it can intelligently enhance the features of pixels that match the target color while effectively suppressing background noise that differs significantly from the target color, thus achieving more accurate foreground-background separation.
[0065] Algorithm adaptive switching logic: The system automatically selects the optimal weighting strategy based on the characteristics of the target color: Color purity determination:
[0066] in It is a very small positive number (e.g.) Used to avoid when A division-by-zero error occurs when the value is zero. This ensures that purity calculations can be performed stably even if the target color is very dark (close to black).
[0067] Strategy selection logic: •when At that time, a high-weight enhancement mode is adopted.
[0068] •when At that time, a medium-weighted model was adopted. ) •when At that time, it will revert to the traditional equal-weighted model.
[0069] II. Unsupervised Color Quantization Based on K-Means After background filtering, the remaining pixels are fed into the K-Means clustering algorithm for color quantization, the purpose of which is to classify the colors in the image into a few representative dominant colors.
[0070] 1. Adaptive selection of the number of clusters k Number of clusters The choice of [the appropriate element] is crucial. In this invention... Based on the number of effective pixels Adaptive determination to avoid overfitting or underfitting:
[0071] in Cluster number (usually set to 3 or 4) because the color composition of the dot matrix display area is usually very simple (such as character color, background background color, anti-aliasing transition color).
[0072] 2. Iteration and convergence of cluster centers The K-Means algorithm updates cluster centers iteratively until it converges. Cluster centers In the The update formula for the next iteration is:
[0073] in It is in the In the next iteration, the one assigned to the The set of pixels in each cluster. The cluster centers are obtained after convergence. This constitutes the quantization palette of the image, representing the main colors in the image.
[0074] 3. Statistical analysis of color proportion After clustering is completed, calculate the proportion of pixels contained in each color cluster:
[0075] in Is assigned to the first The number of pixels of the primary color, This represents the total number of pixels participating in the clustering. Color proportion is an important basis for determining the dominant color.
[0076] III. Color metric matching based on Euclidean distance This stage matches the primary colors obtained from clustering with the target colors provided by the user to determine which primary color represents the foreground character.
[0077] 1. Color similarity calculation This invention uses the Euclidean distance (L2 norm) in the RGB color space as a measure of color similarity. (Main color) With target color The distance between them is:
[0078] While color spaces like CIELAB offer superior perceived uniformity, and HSV / HLS spaces excel in characterizing hue and saturation, for applications like dot-matrix displays with limited color gamut and distinct luminous characteristics, the Euclidean distance in the RGB space is sufficiently efficient and accurate, while also offering lower computational costs and greater suitability for real-time processing. This invention, through adaptive weighted brightness and chromaticity calculations, effectively incorporates considerations of color saturation and target features within the RGB space, thereby avoiding the additional computational burden of complex color space conversions.
[0079] 2. Optimal Match Determination This invention selects the target color The primary color with the smallest distance This is considered the best match. At the same time, this minimum distance must be less than a preset similarity threshold. (Considering that there may be color cast in the application scenarios, the value is 30-50, with 30 being the preferred value):
[0080] This condition ensures that the selected primary color is close enough to the target color, avoiding incorrect matching.
[0081] IV. Pixel Mask Reconstruction Algorithm This invention includes: original ROI pixels -> color clustering labels -> best matching color index -> constructing a Boolean mask -> applying the mask to the original image -> generating the processed image. The pixel mask is constructed as follows: Define pixel mask :
[0082] in It is a pixel. Category label after K-Means clustering It is the category label corresponding to the best matching color.
[0083] The final processed image It could be:
[0084] in These are the original pixel values. This is the background fill value (usually black [0,0,0]). For example... Figure 3a and Figure 3b As shown, the image has a clean background and high contrast, making it suitable for OCR engine processing. Figure 3aOriginal image and misidentification result: Due to the presence of noisy pixels in the background that are similar in color to the characters, the traditional OCR engine misidentified the correct value "111.20" as "888.20".
[0085] The comparison of images before and after processing by the method of this invention effectively removes background noise through color feature extraction and mask reconstruction. The OCR engine successfully recognizes the correct result "111.20" in the newly generated image, as shown in the figure. Figure 3b As shown.
[0086] The overall architecture of this invention combined with the OCR system is as follows: Figure 4 As shown, a three-layer architecture consisting of an input layer, a processing layer, and an output layer is adopted. The input layer acquires the original image and performs ROI extraction. The processing layer performs background filtering, color quantization, color matching, and mask reconstruction. The output layer includes a high-quality foreground image, OCR recognition, and recognition result output.
[0087] In summary, the color feature-based text recognition method for dot matrix displays provided by this invention has the following technical advantages: 1. Dual-Strategy Adaptive Filtering and Target-Oriented Weighting Mechanism: This invention uniquely combines a static thresholding method with a statistically based dynamic filtering method, automatically switching based on image content to ensure robustness under various background conditions. Furthermore, this invention introduces for the first time an adaptive weighting calculation method based on user-specified target color, allowing the algorithm to "actively learn" the color characteristics of the target display. This dual-weighted optimization architecture introduces weights into brightness and chromaticity standard deviation calculations, forming a synergistically enhanced dual-filtering effect that significantly improves target pixel recognition accuracy and enhances background noise suppression capabilities.
[0088] 2. Unsupervised Color Quantization: Through K-Means clustering, the algorithm learns the dominant colors in an image from the data itself, rather than relying on a preset color range. This allows the method to effectively adapt to color shifts caused by different devices and displays with varying degrees of aging.
[0089] 3. High-fidelity mask generation: The color recognition is transformed into a pixel-level segmentation task. The generated foreground mask retains the character shape information to the greatest extent while completely eliminating background noise, fundamentally solving the problem of traditional OCR methods in the segmentation stage.
[0090] 4. Display physical characteristic modeling and multi-level adaptation: By introducing weight enhancement factors for different LED types. This approach directly integrates the spectral emission characteristics of dot matrix displays into the algorithm design, giving the algorithm a professional edge. Furthermore, a three-level adaptive optimization system is formed, encompassing adaptive calculation of weight coefficients, dynamic adjustment of thresholds, and intelligent switching of strategies. This ensures the algorithm's stable performance under different displays, aging levels, and ambient lighting conditions.
[0091] 5. End-to-End Integration and Mathematical Theory Extension: This invention provides a complete automated solution from raw images to high-precision recognition results, achieving a tight integration of complex color analysis and OCR recognition processes. Furthermore, this invention extends the traditional Euclidean distance metric into a target-oriented weighted distance metric, providing new mathematical tools and theoretical frameworks for dot matrix display image analysis.
[0092] By combining and synergizing these innovative aspects, this invention not only has significant advantages in technical implementation, but also provides new solutions to image processing problems in specific fields at the theoretical level.
[0093] Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications and improvements without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention shall be defined by the claims.
Claims
1. A method for text recognition on a dot matrix display based on color features, characterized in that, Includes the following steps: S1. Receive the original image and region of interest as input, and remove non-target pixels from the image after background filtering; S2. The filtered effective pixels are fed into the K-Means clustering algorithm for color quantization. The K-Means clustering algorithm is used to automatically summarize the main color clusters in the image. S3. In the color measurement and matching stage, the target color representing the foreground of the character is determined by calculating the Euclidean distance between the center of each color cluster and the preset target color in the RGB space. S4. Based on the matching results, perform foreground mask reconstruction to generate a binary image containing only the target character pixels, and then send it to the standard OCR engine for final text recognition.
2. The dot matrix display text recognition method based on color features as described in claim 1, characterized in that, Step S1 employs a dual-strategy filtering mechanism. First, a static threshold method is used for rapid pre-filtering to remove pure black and pure white pixels from the image. Then, a statistically based dynamic filtering method is used to continue removing non-target pixels from the image.
3. The dot matrix display text recognition method based on color features as described in claim 2, characterized in that, When the static threshold method is used in step S1, for pixels in the RGB color space Define the black filter conditions: White filter conditions: in and These are the low threshold and the high threshold, respectively. and .
4. The dot matrix display text recognition method based on color features as described in claim 2, characterized in that, When the dynamic filtering method is used in step S1, the weighted luminance and weighted chrominance information are combined, and the final filtering conditions are: For adaptive weighted brightness, the calculation is as follows: The weighting coefficients are based on the target color. Adaptive determination: Formula for calculating weighting coefficients: The weighting coefficients satisfy the following normalization constraints: in This is a weighting enhancement factor, set for different display types; The weighted standard deviation of chromaticity is calculated as follows: Dynamic weighting coefficient calculation: in This is the chromaticity enhancement factor, with a value range of [value range missing]. It dynamically adjusts according to the color purity of the monitor; The adaptive standard deviation threshold is calculated as follows: Based on the baseline standard deviation threshold, The weighting factor has a range of values. .
5. The dot matrix display text recognition method based on color features as described in claim 2, characterized in that, Step S1 automatically selects the optimal weighting strategy based on the characteristics of the target color: Color purity determination: in It is an order of magnitude The smallest positive number; The strategy logic selection is as follows: when At that time, a high-weight enhancement mode is adopted. when At that time, a medium-weighted model is adopted. ; when At that time, it will revert to the traditional equal-weighted model.
6. The dot matrix display text recognition method based on color features as described in claim 1, characterized in that, Step S2 includes: S21. Based on the number of effective pixels Adaptively determine the number of clusters k: in Number of clusters; S22, the K-Means algorithm updates the cluster centers iteratively until it converges; Cluster centers In the The update formula for the next iteration is: in It is in the In the next iteration, the one assigned to the The set of pixels in each cluster; the cluster centers obtained after convergence. The quantized color palette that makes up the image represents the main colors in the image; S23. After completing the clustering, calculate the value of each color cluster. The proportion of pixels contained: in Is assigned to the first The number of pixels of the primary color, It represents the total number of pixels participating in the clustering.
7. The dot matrix display text recognition method based on color features as described in claim 6, characterized in that, The The number of clusters can be either 3 or 4.
8. The dot matrix display text recognition method based on color features as described in claim 1, characterized in that, Step S3 uses Euclidean distance in the RGB space as a measure of color similarity; the primary color With target color The distance between them is: Step S3 selects the target color. The primary color with the smallest distance The best match is defined as a minimum distance that is less than a preset similarity threshold. .
9. The dot matrix display text recognition method based on color features as described in claim 8, characterized in that, The similarity threshold The value ranges from 30 to 50.
10. The dot matrix display text recognition method based on color features as described in claim 1, characterized in that, Step S4 includes: Define pixel mask : in It is a pixel. Category label after K-Means clustering It is the category label corresponding to the best matching color; The final processed image for: in These are the original pixel values. It is the background fill value.