A color changing method for electronic magnifiers containing images of various font colors
By separating and classifying ROI regions in images, and utilizing k-means clustering and YUV color-changing processing, the problem of text segmentation and color-changing in electronic visual aids when processing images with various font colors was solved, thus improving the reading experience for people with low vision.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG UNIV OF TECH
- Filing Date
- 2023-06-18
- Publication Date
- 2026-06-16
AI Technical Summary
Existing electronic vision aids cannot effectively distinguish between text and background when processing images containing multiple font colors, resulting in poor readability and recognition of text after color-changing processing, which affects the reading experience of people with low vision.
By acquiring the original image, separating the ROI and non-ROI regions, using the k-means clustering algorithm to distinguish text and background colors, classifying and merging each region, and finally performing color transformation processing in the YUV color space to generate the color-transformed image.
It achieves effective segmentation and color transformation of images with various font colors, improving text recognizability and reading experience, and is especially suitable for information acquisition by people with low vision.
Smart Images

Figure CN116934876B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of image communication, and specifically relates to a color-changing method for images containing multiple font colors suitable for electronic visual aids, which is applicable to the field of image processing technology. Background Technology
[0002] Improving vision for people with low vision is a common concern. Currently, research on assistive devices for people with low vision has gradually become a hot topic both domestically and internationally. With the advancement of technology, electronic assistive devices can better help people with low vision improve their reading experience.
[0003] Currently, common electronic visual aids, in order to help low-vision patients improve their visual abilities, generally process images by changing their colors, taking into account the impact of different font and image colors on reading. However, this color-changing process is usually applied to the entire image. When dealing with a text image containing multiple font colors, the image often contains various colored fonts, including dark text on a light background and light text on a dark background. If the entire image is color-changed, the readability and recognizability of the text are not ideal, which will greatly affect the reading experience and information acquisition efficiency of low-vision individuals.
[0004] Regarding the problem of character region segmentation, a pictographic character segmentation method based on hierarchical contour extraction, disclosed in patent CN112686265A, removes noise through filtering and then layers the extracted contours by judging whether the rectangular regions contained within the contours contain outer rectangles, thereby suppressing the output of internal contours of the characters. Next, a threshold is set by calculating the area of the rectangular regions contained within the contours; only rectangles larger than the threshold contain the characters to be output, thus achieving character segmentation. The limitation of this method is that it can only handle specific types of pictographic character segmentation problems and may not be applicable to other types of character segmentation problems. For example, it may not be effective in segmenting continuous handwritten letters. Furthermore, this method may be affected by changes in character shape, such as italics or thickness, which may lead to segmentation errors. Segmentation accuracy may be affected by factors such as image preprocessing and threshold setting. For example, improper settings of Gaussian or bilateral filter parameters in the preprocessing step may lead to the loss or distortion of image information. At the same time, the threshold setting also needs to consider factors such as character size and spacing; otherwise, it may result in incorrect or missed character segmentation. Therefore, the application scenarios of this method are somewhat limited.
[0005] Regarding color-changing issues, a patent for a 2D color-changing method based on a fixed hue, published in CN109166162A, involves converting the image's color space from RGB color code to HSV color values, traversing the pixels in the image, and performing color-changing processing on each pixel to convert it to the target color. The limitation of this method is that when processing edge pixels, due to the discreteness between pixels, the processed image edges may exhibit jagged, discontinuous changes; the color-changing effect may also appear unnatural because this method simply replaces color values, and the color-changing effect is based on a fixed hue transformation, potentially leading to unnatural colors in the resulting image.
[0006] Besides the text segmentation issues mentioned above, current electronic visual aids cannot change the color of images containing multiple font colors. For such images, the text colors are numerous and complex. If the entire image is directly color-changed, it may affect the recognizability and readability of the text. Therefore, some special algorithms are needed to distinguish the text in the image and change the color of different types of text separately, thereby achieving color transformation of images with multiple font colors. Summary of the Invention
[0007] To address the problems existing in the prior art, this invention proposes a color-changing method for images containing multiple font colors suitable for electronic visual aids.
[0008] The technical solution adopted by the present invention to solve its technical problem is a color-changing method for images containing multiple font colors suitable for electronic visual aids. The method involves acquiring an original image, separating ROI regions and non-ROI regions in the original image, distinguishing text and background colors for each ROI region and non-ROI region, classifying each ROI region and non-ROI region, merging the classified ROI regions, and performing color-changing processing to obtain the color-changed image.
[0009] Preferably, separating the ROI region and non-ROI region in the original image includes the following steps:
[0010] Step 1.1: Perform grayscale processing on the original image to obtain a grayscale image;
[0011] Step 1.2: Perform edge detection on the grayscale image using the Canny operator to obtain the contour map;
[0012] Step 1.3: Filter the outline image where the area is within [Area]. min Area max Within the region ], obtain the bounding rectangle of each region, resulting in M ROI regions;
[0013] Step 1.4: Separate M ROI regions from the original image, record the size and corner coordinates of each ROI region, and use the original image after removing the ROI regions as the non-ROI regions.
[0014] Preferably, distinguishing text and background in each ROI region and non-ROI region includes the following steps:
[0015] Step 2.1: In the RGB color space, cluster each ROI region and non-ROI region into 2 clusters using the k-means clustering algorithm;
[0016] Step 2.2: Convert the clustering results of ROI and non-ROI regions into corresponding region shapes, visualize the clustering results, and obtain clustering result diagrams for ROI and non-ROI regions respectively;
[0017] Step 2.3: Calculate the width of the strokes in the two clustering result images respectively, and generate the corresponding two stroke width images;
[0018] Step 2.4: Normalize and binarize the stroke width image sequentially to generate a stroke width binary image. Binarize the corresponding clustering result image to obtain a cluster binary image. Traverse the stroke width binary image and the cluster binary image, count the number of different pixels, and divide the number of different pixels by the total number of pixels to obtain the proportion of different pixels. Compare the proportions of different pixels in the two clusters. The cluster with the larger proportion of different pixels is the text cluster, and the other cluster is the background cluster.
[0019] Step 2.5: Repeat the above steps to distinguish between text and background in each ROI and non-ROI region, and obtain the text color and background color in each ROI and non-ROI region; classify the regions according to the text color and background color in the ROI region.
[0020] Preferably, step 2.3 includes the following steps:
[0021] Step 2.3.1: Perform edge detection using the Canny operator on the two clustering result images of each ROI region and non-ROI region to obtain the contour binary image of the ROI region, and process the contour binary image of the ROI region;
[0022] Step 2.3.2: Based on the aforementioned contour binary image, calculate the gradient of each edge pixel p;
[0023] Step 2.3.3: Search for the corresponding edge pixel q along the gradient direction of edge pixel p, and calculate the gradient direction of q;
[0024] Step 2.3.4: If the absolute value of the difference between the gradient direction of q and the gradient direction of p is less than or equal to Gd maxIf the pixel through which the line connecting p and q passes does not store the stroke width or the stored stroke width is greater than the current |pq| value, then the pixel through which the line connecting p and q passes is assigned the value |pq|.
[0025] If the absolute value of the difference between the gradient direction of q and the gradient direction of p is greater than Gd max If the current point q is not an edge pixel corresponding to point p, then discard point q.
[0026] Step 2.3.5: Repeat steps 2.3.2 to 2.3.4 until all edge pixels of the ROI region's contour binary map have been traversed, and store the stroke widths obtained after traversal in the stroke width map;
[0027] Step 2.3.6: Traverse the binary outline map of the ROI region obtained in Step 2.3.1 again, search for the corresponding edge pixel q along the gradient direction of the edge pixel p, take the median value of the stroke width stored in the pixels through which the line connecting p and q passes, and assign it to the pixels through which the line connecting p and q passes.
[0028] Step 2.3.7: Store the median stroke width in the stroke width map for subsequent differentiation of text and background within the ROI area.
[0029] Preferably, classifying each ROI region and non-ROI region includes the following steps:
[0030] Step 3.1: Calculate the color vector lengths of text and background clusters for each ROI and non-ROI region; here, the color vector length is calculated by obtaining the average pixel value of each cluster and then calculating the vector length of the average pixel value. get;
[0031] Step 3.2: If the color vector length of the text cluster is greater than that of the corresponding background cluster, then classify the region as a light-colored text with a dark background region; otherwise, classify the region as a dark-colored text with a light background region.
[0032] Preferably, merging the classified ROI regions includes the following steps:
[0033] Step 4.1.1: If a non-ROI area is classified as a dark text light background area, then merge the non-ROI area with the ROI area that is also a dark text light background area to obtain a dark text light background image. Merge the ROI areas that are light text dark background areas into one image, and fill the other areas with black to obtain a light text dark background image.
[0034] Step 4.1.2: If a non-ROI area is classified as a light-text dark-background area, then merge the non-ROI area with the ROI area that is also a light-text dark-background area to obtain a light-text dark-background image. Merge the ROI areas that are dark-text light-background areas into one image, and fill the other areas with white to obtain a dark-text light-background image.
[0035] Preferably, the color-changing treatment includes the following steps:
[0036] Step 4.2: Convert the dark text light background image and the light text dark background image to the YUV color space, and generate the corresponding YUV mapping table according to the target color of the color change. The YUV components of the dark text light background image and the light text dark background image correspond to three different mapping tables respectively.
[0037] Step 4.3: Extract the YUV component information of the dark text light background image and the light text dark background image. Generate the Y, U, and V components of the target image by using the target color mapping table for each image. Combine the Y component and the U and V components of the target image after color change to generate two color-changing images, namely the dark text light background color-changing image and the light text dark background color-changing image.
[0038] Preferably, based on the size and corner coordinates of each ROI region, the dark text light background color-changing image and the light text dark background color-changing image are merged to obtain the final color-changing image.
[0039] This invention relates to a color-changing method for images containing multiple font colors suitable for electronic visual aids. The method involves acquiring an original image, separating ROI regions and non-ROI regions from the original image, distinguishing text and background colors for each ROI region and non-ROI region, classifying each ROI region and non-ROI region, merging the classified ROI regions, and performing color-changing processing to obtain the color-changed image.
[0040] The beneficial effect of this invention is that, through a special image processing strategy, it achieves the segmentation and color enhancement processing of images containing multiple font colors. The color-changed text is easy to recognize. Using an electronic visual aid as a carrier, it solves the problem that people with low vision cannot obtain important information in a short time when faced with complex images containing multiple font colors. Attached Figure Description
[0041] Figure 1 This is a flowchart of the method of the present invention;
[0042] Figure 2 This is a flowchart of the algorithm for extracting stroke width maps from different regions in an embodiment of the present invention;
[0043] Figure 3 This is a flowchart of the algorithm for color-changing classified images in an embodiment of the present invention;
[0044] Figure 4 This is a diagram showing the segmentation effect of different background regions in the original image in an embodiment of the present invention;
[0045] Figure 5 This is a clustering effect diagram of a ROI region in an embodiment of the present invention;
[0046] Figure 6 This is an illustration of the effect of merging dark text with light background areas in an embodiment of the present invention;
[0047] Figure 7 This is an illustration of the effect of merging light-colored text with a dark background in an embodiment of the present invention.
[0048] Figure 8 This is the final effect image of changing the color of the image from black background to yellow text in an embodiment of the present invention. Detailed Implementation
[0049] The present invention will be further described in detail below with reference to embodiments, but the scope of protection of the present invention is not limited thereto.
[0050] This invention relates to a color-changing method for images containing multiple font colors suitable for electronic visual aids. The method includes acquiring an original image, separating ROI regions and non-ROI regions from the original image, distinguishing text and background colors within each ROI region and non-ROI region, classifying each ROI region and non-ROI region, merging the classified ROI regions, and performing color-changing processing to obtain a color-changed image, such as... Figure 1 As shown; the method is generally applied to electronic visual aids, which acquire raw images using a camera or the Internet and then color-change them.
[0051] Step 1: Acquire the original image of the two-dimensional digit using the camera of the electronic assistive device or the Internet, and separate the ROI region and non-ROI region from the acquired original image of the two-dimensional digit. Specifically, this includes the following steps.
[0052] Step 1.1: Perform grayscale processing on the original image of the two-dimensional digit to obtain a grayscale image.
[0053] Step 1.2: Use the Canny operator to perform edge detection on the grayscale image to obtain a contour map; weak edges can be suppressed by adjusting the first and second gradient thresholds, thereby more accurately representing the actual edges of the image object contour.
[0054] Step 1.3, filter the outline map where the area is within [Area]. min Area maxWithin the range of [Area], find the bounding rectangle of each region to obtain M ROI regions; obviously, 0 < Area min <Area max The range of area values can be set and adjusted by those skilled in the art based on the screen size of the electronic visual aid.
[0055] Step 1.4: Separate M ROI regions from the original image, record the size and corner coordinates of each ROI region, and use the original image after removing the ROI regions as the non-ROI regions to facilitate subsequent region merging.
[0056] like Figure 4 The image shown is a diagram illustrating the ROI region segmentation effect in the original image according to an embodiment of the present invention.
[0057] Step 2: For the ROI and non-ROI regions obtained in Step 1, use clustering and stroke width maps to distinguish between text and background, including the following steps.
[0058] Step 2.1: In the RGB color space, cluster each ROI region and non-ROI regions into two clusters using the k-means clustering algorithm. The specific clustering steps are as follows:
[0059] Randomly select k pixels as the initial cluster centers (k is 2 when clustering each ROI region, representing the number of clusters);
[0060] For each sample in the dataset, calculate its distance to the k cluster centers and assign it to the class corresponding to the cluster center with the smallest distance;
[0061] For each cluster, recalculate its cluster center position;
[0062] Repeat the above two steps iteratively until the set termination condition is met (the error (eps) found through iteration is less than EPS). min When or when the maximum number of iterations is reached (Itera) max ).
[0063] Step 2.2: Convert the clustering results of the ROI region and the non-ROI region into the corresponding region shapes and visualize the clustering results. Specifically, to create an image with the same size as the corresponding region, mark the pixels belonging to the clustering results as black and the remaining pixels as white, and obtain the clustering result images for the ROI region and the non-ROI region respectively.
[0064] like Figure 5 The image shown is a clustering effect diagram of a certain ROI region in an embodiment of the present invention. The black pixels are the clustering result clusters, and the white pixels are the background.
[0065] Step 2.3: For the two clustering result images generated in Step 2.2 above, calculate the stroke width of the two clustering result images (black area) respectively, and generate the corresponding stroke width image. The two stroke width images can be generated according to the two clustering result images of the ROI area and the non-ROI area.
[0066] Specifically, the method for extracting the stroke width image is as follows:
[0067] Step 2.3.1: Perform edge detection on the two clustering result images of each ROI region and non-ROI region using the Canny operator to obtain the contour binary image of the ROI region. In the contour binary image, the pixel value of the object contour is 0 (black), and the value of the other pixels is 1 (white). Process the contour binary image of the ROI region, including Gaussian filtering, to remove high-frequency noise and smooth the image.
[0068] Step 2.3.2: Calculate the gradient of each edge pixel p for the contour binary image obtained in the above steps.
[0069] Step 2.3.3: Search for the corresponding edge pixel q along the gradient direction of the edge pixel p, and calculate the gradient direction of q.
[0070] Step 2.3.4, if the absolute value of the difference between the gradient direction of q and the gradient direction of p is less than or equal to Gd max If the pixel through which the line connecting p and q passes does not store the stroke width or the stored stroke width is greater than the current |pq| value, then the pixel through which the line connecting p and q passes is assigned the value |pq|.
[0071] If the absolute value of the difference between the gradient direction of q and the gradient direction of p is greater than Gd max If the current point q is not an edge pixel corresponding to point p, then point q should be discarded.
[0072] Step 2.3.5: Repeat steps 2.3.2 to 2.3.4 until all edge pixels of the ROI region contour binary map have been traversed. This is the first traversal. The stroke width obtained after the traversal is stored in the stroke width map, and the initial stroke width is obtained based on the gradient direction difference of the edge pixels.
[0073] Step 2.3.6: Iterate through the binary contour map of the ROI region obtained in Step 2.3.1 again, search for the corresponding edge pixel q along the gradient direction of the edge pixel p, and assign the median stroke width of the pixel through which the line connecting p and q passes to the pixel through which the line connecting p and q passes. Step 2.3.6 is a second iteration of the binary contour map of the ROI region, assigning the median stroke width to the pixels through which the line connecting the edge pixels passes, thus obtaining the stroke width map.
[0074] Step 2.3.7: Store the median stroke width in the stroke width map for easy similarity analysis later.
[0075] Step 2.4: Normalize the stroke width image to 0-255, then binarize it to generate a stroke width binary image. Binarize the corresponding clustering result image to obtain a cluster binary image. Traverse the stroke width binary image and the cluster binary image, count the number of different pixels (Diff_count), divide the number of different pixels by the total number of pixels to obtain the proportion of different pixels (Diff_percent), compare the proportions of different pixels between the two clusters (Diff_count0 and Diff_count1), and the cluster with the highest similarity (smallest proportion of different pixels) is considered the text cluster; otherwise, it is the background cluster.
[0076] Step 2.5: Repeat the above steps until the text and background are distinguished in M ROI regions, and obtain the text color and background color in each ROI region; perform the above corresponding processing on the non-ROI regions after removing the ROI regions from the original image to obtain the text and background colors; subsequently, according to the type of region (light text with dark background or dark text with light background), merge all ROI regions and non-ROI regions.
[0077] like Figure 2 The diagram shown is a flowchart of the algorithm for extracting stroke width maps from different regions in an embodiment of the present invention.
[0078] Step 3: Classify each ROI and non-ROI region based on the intensity of text and background colors between the ROI and non-ROI regions. This includes the following sub-steps:
[0079] Step 3.1: Calculate the color vector lengths of the text cluster and background cluster for each ROI region and non-ROI region;
[0080] Step 3.2: Determine which color is darker by comparing the color vector lengths of the text cluster and the background cluster. If the color vector length of the text cluster is greater than that of the corresponding background cluster, the area is classified as a light-colored text with a dark background area. If the color vector length of the text cluster is less than that of the background cluster, the area is classified as a dark-colored text with a light background area.
[0081] like Figure 6 , Figure 7 The image shown is an example of merging two types of areas: dark text on a light background and light text on a dark background.
[0082] Step 4: Merge the two types of regions obtained in Step 3 and perform color-changing processing to obtain the final color-changing image. Specifically, this step includes the following steps.
[0083] Step 4.1.1: If a non-ROI area is classified as a dark text light background area, then merge the non-ROI area with the ROI area that is also a dark text light background area to obtain a dark text light background image. Merge the ROI areas that are light text dark background areas into one image, and fill the other areas with black to obtain a light text dark background image.
[0084] Step 4.1.2: If a non-ROI area is classified as a light-text dark-background area, then merge the non-ROI area with the ROI area that is also a light-text dark-background area to obtain a light-text dark-background image. Merge the ROI areas that are dark-text light-background areas into one image, and fill the other areas with white to obtain a dark-text light-background image.
[0085] After merging, a color change process is required.
[0086] Step 4.2: Convert the dark text light background image and the light text dark background image to the YUV color space. Generate the corresponding YUV mapping table according to the target color of the color change. The YUV components of the dark text light background image correspond to three mapping tables: DTableY, DTableCb, and DTableCr. The YUV components of the light text dark background image correspond to three mapping tables: LTTableY, LTTableCb, and LTTableCr.
[0087] Step 4.3: Extract the YUV component information of the two images. Generate the Y component of the target image from the Y component of each image using the target color TableY mapping table. Generate the U and V components of the target image from the U and V components using the target color TableCb and TableCr mapping tables. Combine the Y component, U and V components of the color-changed target image according to the YUV420sp format to generate two color-changed images: a color-changed image of dark text on a light background and a color-changed image of light text on a dark background.
[0088] Furthermore, based on the size and corner coordinates of each ROI region recorded in step 1, the dark text light background color-changing image and the light text dark background color-changing image are merged to obtain the final color-changing image.
[0089] like Figure 3 The diagram shown is a flowchart of the algorithm for color-changing classified images in an embodiment of the present invention.
[0090] like Figure 8The image shown is the final effect of changing the color of an image from black background to yellow text in an embodiment of the present invention. Here, the YUV space easily separates luminance and chrominance information. The Y component represents the luminance information of the image, and the U and V components represent the chrominance information of the image. Therefore, the luminance and chrominance information of the image can be easily separated. This allows the chrominance information to be transformed only when changing the color of the image, without affecting the luminance information, thereby maintaining the brightness relationship of the image.
[0091] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0092] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0093] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0094] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0095] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0096] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A color-changing method for images containing multiple font colors suitable for electronic visual aids, characterized in that: Obtain the original image and separate the ROI and non-ROI regions from the original image; Differentiate text and background colors for each ROI and non-ROI area, including the following steps: Step 2.1: In the RGB color space, cluster each ROI region and non-ROI region into 2 clusters using the k-means clustering algorithm; Step 2.2: Convert the clustering results of ROI and non-ROI regions into corresponding region shapes, visualize the clustering results, and obtain clustering result diagrams for ROI and non-ROI regions respectively; Step 2.3: Calculate the width of the strokes in the two clustering result images respectively, and generate the corresponding two stroke width images; Step 2.4: Normalize and binarize the stroke width image sequentially to generate a stroke width binary image. Binarize the corresponding clustering result image to obtain a cluster binary image. Traverse the stroke width binary image and the cluster binary image, count the number of different pixels, and divide the number of different pixels by the total number of pixels to obtain the proportion of different pixels. Compare the proportions of different pixels in the two clusters. The cluster with the larger proportion of different pixels is the text cluster, and the other cluster is the background cluster. Step 2.5: Repeat the above steps to distinguish between text and background in each ROI and non-ROI area, and obtain the text color and background color in each ROI and non-ROI area; The process of categorizing each ROI region and non-ROI region includes the following steps: Step 3.1: Calculate the color vector lengths of the text cluster and background cluster for each ROI region and non-ROI region; Step 3.2: If the color vector length of the text cluster is greater than that of the corresponding background cluster, then classify the region as a light-colored text with a dark background region; otherwise, classify the region as a dark-colored text with a light background region. The classified ROI regions are merged and recolored, including the following steps: Step 4.1.1: If a non-ROI area is classified as a dark text light background area, then merge the non-ROI area with the ROI area that is also a dark text light background area to obtain a dark text light background image. Merge the ROI areas that are light text dark background areas into one image, and fill the other areas with black to obtain a light text dark background image. Step 4.1.2: If a non-ROI area is classified as a light-text dark-background area, then merge the non-ROI area with the ROI area that is also a light-text dark-background area to obtain a light-text dark-background image. Merge the ROI areas that are dark-text light-background areas into one image, and fill the other areas with white to obtain a dark-text light-background image. Step 4.2: Convert the dark text light background image and the light text dark background image to the YUV color space, and generate the corresponding YUV mapping table according to the target color of the color change. The YUV components of the dark text light background image and the light text dark background image correspond to three different mapping tables respectively. Step 4.3: Extract the YUV component information of the dark text light background image and the light text dark background image. Generate the Y, U, and V components of the target image by using the target color mapping table for each image. Combine the Y component and U and V components of the target image after color change to generate two color-changing images, namely the dark text light background color-changing image and the light text dark background color-changing image. Based on the size and corner coordinates of each ROI region, the dark text on a light background color-changing image and the light text on a dark background color-changing image are merged to obtain the final color-changing image.
2. The color-changing method for an image containing multiple font colors suitable for electronic visual aids according to claim 1, characterized in that: Separating the ROI and non-ROI regions from the original image involves the following steps: Step 1.1: Perform grayscale processing on the original image to obtain a grayscale image; Step 1.2: Perform edge detection on the grayscale image using the Canny operator to obtain the contour map; Step 1.3: Filter the area in the outline map that is within the range of... Within the region, obtain the bounding rectangle of each region, resulting in M ROI regions; Step 1.4: Separate M ROI regions from the original image, record the size and corner coordinates of each ROI region, and use the original image after removing the ROI regions as the non-ROI regions.
3. The color-changing method for an image containing multiple font colors suitable for electronic visual aids according to claim 1, characterized in that: Step 2.3 includes the following steps: Step 2.3.1: Perform edge detection using the Canny operator on the two clustering result images of each ROI region and non-ROI region to obtain the contour binary image of the ROI region, and process the contour binary image of the ROI region; Step 2.3.2: Based on the aforementioned contour binary image, calculate the gradient of each edge pixel p; Step 2.3.3: Search for the corresponding edge pixel q along the gradient direction of edge pixel p, and calculate the gradient direction of q; Step 2.3.4: If the absolute value of the difference between the gradient direction of q and the gradient direction of p is less than or equal to... If the pixel through which the line connecting p and q passes does not store the stroke width or the stored stroke width is greater than the current |pq| value, then the pixel through which the line connecting p and q passes is assigned the value |pq|. If the absolute value of the difference between the gradient direction of q and the gradient direction of p is greater than If the current point q is not an edge pixel corresponding to point p, then discard point q. Step 2.3.5: Repeat steps 2.3.2 to 2.3.4 until all edge pixels of the ROI region's contour binary map have been traversed, and store the stroke widths obtained after traversal in the stroke width map; Step 2.3.6: Traverse the binary outline map of the ROI region obtained in Step 2.3.1 again, search for the corresponding edge pixel q along the gradient direction of the edge pixel p, take the median value of the stroke width stored in the pixels through which the line connecting p and q passes, and assign it to the pixels through which the line connecting p and q passes. Step 2.3.7: Store the median stroke width in the stroke width map.