Picture translation method, apparatus, device, storage medium and computer program product

By dividing the text area in an image into multiple sub-regions and replacing the colors according to the background color, the problem of uneven color and poor visual effect in existing image translation technologies is solved, achieving better visual consistency.

CN122244205APending Publication Date: 2026-06-19BEIJING QIHOOD TECHNOLOGY CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING QIHOOD TECHNOLOGY CO LTD
Filing Date
2024-12-17
Publication Date
2026-06-19

Smart Images

  • Figure CN122244205A_ABST
    Figure CN122244205A_ABST
Patent Text Reader

Abstract

This application relates to the field of image processing technology and discloses an image translation method, apparatus, device, storage medium, and computer program product. The method includes: in response to an image translation request, dividing the text region in the image to be translated into multiple sub-regions, replacing the color of the text to be translated in each sub-region according to the background main color of each sub-region, obtaining a processed image, translating the text to be translated, and embedding the translated text into the processed image to obtain a translated image. Because this application divides the text region in the image to be translated into multiple sub-regions for partitioning and replaces the color of the text to be translated in each sub-region according to the background main color of each sub-region, it achieves harmonious integration of font color and background main color, thereby improving the visual consistency between the font and background after image translation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to an image translation method, apparatus, device, storage medium, and computer program product. Background Technology

[0002] In existing image translation technologies, background and font colors are typically processed to achieve visual consistency after text replacement. However, existing methods suffer from uneven color distribution and poor visual effects when blending background and font colors. Summary of the Invention

[0003] The main objective of this application is to provide an image translation method, apparatus, device, storage medium, and computer program product, aiming to solve the technical problems of uneven color and poor visual effects in existing image translation technologies.

[0004] To achieve the above objectives, this application provides an image translation method, which includes:

[0005] In response to an image translation request, the text region in the image to be translated is divided into multiple sub-regions;

[0006] The text to be translated in each sub-region is replaced with its own color based on the background color of each sub-region, resulting in a processed image.

[0007] The text to be translated is translated, and the translated text is embedded into the processed image to obtain the translated image.

[0008] Optionally, in response to the image translation request, the text region in the image to be translated is divided into multiple sub-regions, including:

[0009] In response to an image translation request, the text region in the image to be translated is identified;

[0010] Determine whether the text area is a solid color background area;

[0011] If the text area is a non-solid color background area, then the text area is divided into multiple sub-areas.

[0012] Optionally, determining whether the text area is a solid color background area includes:

[0013] The pixels in the text area are traversed at preset intervals.

[0014] Determine whether the text area is a solid color background area based on the traversed pixels.

[0015] Optionally, before traversing the pixels in the text region at preset intervals, the method further includes:

[0016] Information is extracted from the image to be translated to obtain the resolution of the image;

[0017] The preset interval corresponding to the image resolution is found in the preset mapping table, wherein the preset mapping table includes the correspondence between image resolution and preset interval.

[0018] Optionally, if the text area is a non-solid color background area, then the text area is divided into multiple sub-regions, including:

[0019] If the text area is a non-solid color background area, then obtain the text information of the text area;

[0020] Calculate the grid size based on the text information, and set the grid division according to the grid size;

[0021] The text region in the image to be translated is divided into multiple sub-regions based on the grid division.

[0022] Optionally, after determining whether the text area is a solid color background area, the method further includes:

[0023] If the text area is a solid color background area, then obtain the background color of the text area;

[0024] The text area is filled with color based on the background color to obtain the processed image.

[0025] Optionally, the step of filling the text area with color based on the background color to obtain the processed image includes:

[0026] Call the property setting interface in the web page canvas to set the background color to the fill color;

[0027] Based on the fill color, the rectangle drawing interface in the web page canvas is called to draw a fill rectangle in the text area, and the processed image is obtained.

[0028] Optionally, in response to an image translation request, identifying text regions in the image to be translated includes:

[0029] In response to an image translation request, the text to be translated in the image is identified using a large model;

[0030] The text to be translated is located in the image to be translated, and the text region in the image to be translated is identified based on the text location.

[0031] Optionally, the step of replacing the text to be translated in each sub-region with its color based on the background primary color of each sub-region to obtain a processed image includes:

[0032] Get the color of each pixel in each sub-region, and calculate the background primary color of each sub-region based on the color of each pixel;

[0033] Get the font color of the text to be translated in each sub-region;

[0034] Compare the similarity between the color of each pixel and the color of the font, and obtain the target pixels with a similarity greater than a preset threshold;

[0035] The color of the target pixel is replaced with the background main color to obtain the processed image.

[0036] Optionally, before translating the text to be translated and embedding the translated text into the processed image to obtain the translated image, the method further includes:

[0037] The text regions in the processed image are blurred to obtain a blurred image;

[0038] Accordingly, the process of translating the text to be translated and embedding the translated text into the processed image to obtain the translated image includes:

[0039] The text to be translated is translated, and the translated text is embedded into the blurred image to obtain the translated image.

[0040] Optionally, blurring the text region in the processed image to obtain a blurred image includes:

[0041] Use the property settings interface in the webpage canvas to set the blur filter;

[0042] The text area in the processed image is blurred using the blur filter to obtain a blurred image.

[0043] Furthermore, to achieve the above objectives, this application also proposes an image translation device, which includes:

[0044] The region segmentation module is used to divide the text region in the image to be translated into multiple sub-regions in response to the image translation request;

[0045] The color replacement module is used to replace the text to be translated in each sub-region with the main background color of each sub-region to obtain the processed image.

[0046] The text embedding module is used to translate the text to be translated and embed the translated text into the processed image to obtain the translated image.

[0047] Optionally, the region segmentation module is further configured to, in response to an image translation request, identify text regions in the image to be translated; determine whether the text region is a solid color background region; and if the text region is a non-solid color background region, segment the text region into multiple sub-regions.

[0048] Optionally, the region segmentation module is further configured to traverse the pixels in the text region at preset intervals; and determine whether the text region is a solid color background region based on the traversed pixels.

[0049] Optionally, the region segmentation module is further configured to extract information from the image to be translated to obtain the resolution of the image to be translated; and to search for a preset interval corresponding to the image resolution in a preset mapping table, wherein the preset mapping table includes a correspondence between image resolution and preset interval.

[0050] Optionally, the region segmentation module is further configured to: if the text region is a non-solid color background region, obtain the text information of the text region; calculate the grid size based on the text information, and set the division grid based on the grid size; and divide the text region in the image to be translated into multiple sub-regions based on the division grid.

[0051] Optionally, the image translation device further includes:

[0052] The color fill module is used to obtain the background color of the text area if the text area is a solid color background area; and to fill the text area with color based on the background color to obtain the processed image.

[0053] In addition, to achieve the above objectives, this application also proposes an image translation device, which includes a memory, a processor, and an image translation program stored in the memory and executable on the processor, the image translation program being configured to implement the image translation method as described above.

[0054] In addition, to achieve the above objectives, this application also proposes a storage medium storing an image translation program, which, when executed by a processor, implements the image translation method as described above.

[0055] In addition, to achieve the above objectives, this application also provides a computer program product, which includes an image translation program. When the image translation program is executed by a processor, it implements the image translation method as described above.

[0056] One or more technical solutions proposed in this application have at least the following technical effects:

[0057] This application discloses a method for responding to an image translation request by dividing the text region of the image to be translated into multiple sub-regions, replacing the color of the text to be translated in each sub-region according to the background primary color of each sub-region, obtaining a processed image, translating the text to be translated, and embedding the translated text into the processed image to obtain a translated image. Because this application divides the text region of the image to be translated into multiple sub-regions for partitioning and replaces the color of the text to be translated in each sub-region according to the background primary color of each sub-region, it achieves a harmonious integration of the font color and the background primary color, thereby improving the visual consistency between the font and the background after image translation. Attached Figure Description

[0058] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0059] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0060] Figure 1 This is a flowchart illustrating the first embodiment of the image translation method of this application;

[0061] Figure 2 This is a flowchart illustrating the second embodiment of the image translation method of this application;

[0062] Figure 3 This is a schematic diagram of the image to be translated according to an embodiment of the image translation method of this application;

[0063] Figure 4 This is a schematic diagram of a processed image according to an embodiment of the image translation method of this application;

[0064] Figure 5 This is a schematic diagram of the translated image according to an embodiment of the image translation method of this application;

[0065] Figure 6 This is a schematic diagram of the image to be translated according to an embodiment of the image translation method of this application;

[0066] Figure 7 This is a schematic diagram of a processed image according to an embodiment of the image translation method of this application;

[0067] Figure 8 This is a schematic diagram of the translated image according to an embodiment of the image translation method of this application;

[0068] Figure 9This is a flowchart illustrating the third embodiment of the image translation method of this application;

[0069] Figure 10 This is a flowchart illustrating the fourth embodiment of the image translation method of this application;

[0070] Figure 11 This is a schematic diagram of the module structure of the image translation device according to an embodiment of this application;

[0071] Figure 12 This is a schematic diagram of the device structure of the hardware operating environment involved in the image translation method in this application embodiment.

[0072] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0073] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0074] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0075] In existing image translation technologies, background and font colors are typically processed to achieve visual consistency after text replacement. However, existing methods suffer from uneven color distribution and poor visual effects when blending background and font colors.

[0076] To overcome the aforementioned shortcomings, this application provides a solution comprising: in response to an image translation request, dividing the text region in the image to be translated into multiple sub-regions, replacing the color of the text to be translated in each sub-region according to the background primary color of each sub-region, obtaining a processed image, translating the text to be translated, and embedding the translated text into the processed image, thereby obtaining a translated image; since this application divides the text region in the image to be translated into multiple sub-regions for partitioning and replaces the color of the text to be translated in each sub-region according to the background primary color of each sub-region, a harmonious integration of the font color and the background primary color is achieved, thereby improving the visual consistency between the font and the background after image translation.

[0077] It should be noted that the executing entity in this embodiment may be an image translation device with data processing, network communication and program running functions, such as a computer, or other electronic devices that can achieve the same or similar functions. This embodiment does not impose any restrictions on this.

[0078] Based on this, this application provides an image translation method, referring to... Figure 1 , Figure 1This is a flowchart illustrating the first embodiment of the image translation method of this application.

[0079] In the first embodiment, the image translation method includes:

[0080] Step S10: In response to the image translation request, the text region in the image to be translated is divided into multiple sub-regions.

[0081] It should be understood that, in order to facilitate subsequent color replacement and text embedding operations, improve processing accuracy and efficiency, and reduce color conflicts and translation artifacts, in this embodiment, in response to an image translation request, the text region in the image to be translated is divided into multiple sub-regions. Here, a user initiates an instruction through some means (such as clicking a button, uploading an image, etc.) to translate the text information in an image into another language. The text region can refer to the area in the image to be translated that contains the text to be translated. A sub-region can refer to a smaller, more easily processed portion further subdivided from the text region.

[0082] In a practical implementation, dividing the text region in the image to be translated into multiple sub-regions can be achieved using image processing techniques (such as edge detection, connected component analysis, etc.) or large models to identify the text region in the image and then dividing it into multiple smaller sub-regions. The size and shape of these sub-regions can be configured according to actual conditions (such as a 4×2 pixel grid, etc.) to better accommodate text blocks of different sizes; this embodiment does not impose any limitations on this.

[0083] Step S20: Replace the color of the text to be translated in each sub-region according to the background color of each sub-region to obtain the processed image.

[0084] Understandably, to achieve harmonious integration of the font color and the background primary color, this embodiment replaces the text to be translated in each sub-region with its own background primary color to obtain the processed image. The background primary color refers to the main component of pixel color within a sub-region, which can be obtained by calculating the average or mode of pixel colors within that sub-region. Color replacement refers to the process of replacing pixels of a specific color in an image with another color while keeping other parts of the image unchanged. In the specific implementation, within each sub-region, the background primary color is calculated, and this background primary color is used to replace pixel colors similar to the font color to obtain the processed image.

[0085] Step S30: Translate the text to be translated and embed the translated text into the processed image to obtain the translated image.

[0086] It should be understood that translated text can refer to the text content obtained after translating the text to be translated into the target language. In specific implementation, the content of the text to be translated is identified through a large model, and then translated into the target language through a translation API or the large model. Then, based on the position, size, font, and other attributes of the text to be translated, the translated text is embedded into the processed image to obtain the translated image.

[0087] This embodiment divides the text area in the image to be translated into multiple sub-regions for partitioning. Based on the background color of each sub-region, the color of the text to be translated in each sub-region is replaced, thereby achieving a harmonious integration of the font color and the background color, and thus improving the visual consistency between the font and the background after the image is translated.

[0088] Reference Figure 2 , Figure 2 This is a flowchart illustrating the second embodiment of the image translation method of this application, based on the above. Figure 1 The first embodiment shown illustrates a second embodiment of the image translation method of this application.

[0089] In the second embodiment, step S10 includes:

[0090] Step S101: In response to the image translation request, identify the text region in the image to be translated.

[0091] It should be understood that, in order to reduce the computational overhead caused by pixel-by-pixel processing and improve processing efficiency, this embodiment will determine whether the text region in the image to be translated is a solid color background region before dividing the text region into multiple sub-regions. If the text region is a non-solid color background region, the text region will be divided into multiple sub-regions; if the text region is a solid color background region, the text region will be directly filled with color based on the background color.

[0092] In practice, identifying text regions in an image to be translated can be achieved through image processing techniques (such as image segmentation and edge detection) or by preprocessing the image using a large model to identify the text regions. Here, a text region refers to the area within the image that contains the text to be translated.

[0093] Furthermore, in order to quickly and accurately extract the text to be translated from the image and provide a foundation for subsequent text translation and embedding, step S101 includes: in response to the image translation request, identifying the text to be translated in the image using a large model; obtaining the text position of the text to be translated in the image, and identifying the text region in the image based on the text position.

[0094] Understandably, in order to quickly and accurately extract the text to be translated from an image, providing a foundation for subsequent text translation and embedding, this embodiment uses a large model to identify the text to be translated in the image, and identifies the text region in the image based on the text position of the text to be translated. Here, the large model can refer to a machine learning model with powerful processing capabilities and high generalization ability, capable of recognizing text in an image and extracting relevant information. The text to be translated can refer to the text content in the image that needs to be translated. The text position can refer to the specific coordinates or region of the text to be translated in the image.

[0095] In the implementation, when a user initiates an image translation request, a pre-trained large model is used to perform text recognition on the image. The large model can identify the text content in the image and extract it as the text to be translated. After extracting the text to be translated, the specific location of the text in the image (such as coordinate range) is further obtained. Then, the text region in the image is identified based on the text location.

[0096] Step S102: Determine whether the text area is a solid color background area.

[0097] It should be understood that after identifying the text region, it is necessary to determine whether the text region has a solid color background. This can be achieved by traversing the pixels in the text region and calculating the color value differences of the traversed pixels. If the color value differences are within a certain range (such as less than a certain threshold), the text region is considered a solid color background region; otherwise, it is a non-solid color background region. A solid color background region can refer to an area where the color values ​​of all pixels within the text region are basically the same or have very small differences.

[0098] Furthermore, to avoid pixel-by-pixel traversal and improve computational efficiency, step S102 includes: traversing the pixels in the text region at preset intervals; and determining whether the text region is a solid-color background region based on the traversed pixels. The preset interval can be a traversal interval set when traversing the pixels in the text region. For example, the preset interval can be 20 pixels, meaning the text region is traversed at intervals of 20 pixels to obtain the traversed pixels.

[0099] Furthermore, in order to set a suitable preset interval for subsequent pixel traversal, before traversing the pixels in the text region according to the preset interval, the method further includes: extracting information from the image to be translated to obtain the resolution of the image to be translated; and searching for the preset interval corresponding to the image resolution in a preset mapping table, wherein the preset mapping table includes the correspondence between image resolution and preset interval.

[0100] Understandably, in order to set a suitable preset interval for subsequent pixel traversal, this embodiment searches for the corresponding preset interval in a preset mapping table based on the resolution of the image to be translated. Here, image resolution can refer to a parameter describing the number of pixels in the image, expressed as the product of the horizontal and vertical pixel counts. The preset mapping table can be a predefined table used to store the mapping relationship between image resolutions and corresponding preset intervals.

[0101] Furthermore, in order to reduce the computational load of pixel-by-pixel processing, after step S102, the method further includes: if the text area is a solid color background area, then obtaining the background color of the text area; and filling the text area with color based on the background color to obtain the processed image.

[0102] It should be understood that in this embodiment, when the text area is a solid color background area, the background color of the text area is directly used to fill the text area, thereby reducing the computational load of pixel-by-pixel processing. Here, a solid background area can refer to an area where the color values ​​of all pixels within the text area are basically the same or have very small differences. The background color can refer to the color values ​​within the background area. In specific implementation, after obtaining the background color, it can be used to fill the text area. This can be achieved using image processing software. When filling with color, it is necessary to ensure that the fill color is completely consistent with the background color and that the filled area completely overlaps with the text area.

[0103] For ease of understanding, please refer to Figure 3 , Figure 4 as well as Figure 5 This explanation is provided, but does not limit the scope of this application. Figure 3 This is a schematic diagram of the image to be translated according to an embodiment of the image translation method of this application. Figure 4 This is a schematic diagram of a processed image according to an embodiment of the image translation method of this application. Figure 5 This is a schematic diagram of the translated image according to an embodiment of the image translation method of this application. Figure 3 In the image, the area within the red box represents the text region. Since the color values ​​of all pixels within this region, excluding the text itself, are essentially the same, the text region has a solid color background. Therefore, the text region is filled directly with its background color (blue) to obtain the processed image, as shown below. Figure 4 As shown. Figure 5 In this process, the translated text is embedded into the text area of ​​the processed image to obtain the translated image.

[0104] Furthermore, to improve the color fill effect, the step of filling the text area with color based on the background color to obtain the processed image includes: calling the attribute setting interface in the web canvas to set the background color as the fill color; and calling the rectangle drawing interface in the web canvas based on the fill color to draw a fill rectangle in the text area to obtain the processed image. Here, the web canvas can refer to the canvas element in HTML5, which provides an area for drawing graphics on a webpage and provides corresponding JavaScript APIs to manipulate this area.

[0105] In the specific implementation, for example, after obtaining the background color, the property setting interface (such as ctx.fillStyle) in the web canvas (canvas element) is called to set the background color as the fill color. Here, ctx is the canvas context, which provides methods and properties for drawing graphics on the canvas. After setting the fill color, the system needs to call the rectangle drawing interface in the web canvas (such as ctx.fillRect(x,y,width,height)) to draw a filled rectangle in the text area to obtain the processed image. Here, x and y are the coordinates of the top-left corner of the rectangle, and width and height are the width and height of the rectangle.

[0106] Step S103: If the text area is a non-solid color background area, then the text area is divided into multiple sub-areas.

[0107] Understandably, for text areas with non-solid color backgrounds, it's necessary to further divide the text area into multiple smaller sub-regions. This can be achieved by dividing the text area into several grids, with each grid serving as a sub-region. The purpose of this division is to more finely process the text and background colors within each sub-region, reducing color clashes and translation artifacts.

[0108] For ease of understanding, please refer to Figure 6 , Figure 7 as well as Figure 8 This explanation is provided, but does not limit the scope of this application. Figure 6 This is a schematic diagram of the image to be translated according to an embodiment of the image translation method of this application. Figure 7 This is a schematic diagram of a processed image according to an embodiment of the image translation method of this application. Figure 8 This is a schematic diagram of the translated image according to an embodiment of the image translation method of this application. Figure 6In the image, the area within the red box represents the text region. Because the color values ​​of pixels other than the text itself are inconsistent, the text region has a non-solid-color background. Therefore, the text region is divided into multiple sub-regions. The text to be translated in each sub-region is then color-replaced according to its dominant background color, resulting in the processed image, as shown below. Figure 7 As shown. Figure 8 In this process, the translated text is embedded into the text area of ​​the processed image to obtain the translated image.

[0109] Furthermore, to improve the accuracy of sub-region segmentation, step S103 includes: if the text region is a non-solid-color background region, then acquiring the text information of the text region; calculating the grid size based on the text information, and setting the segmentation grid according to the grid size; and segmenting the text region in the image to be translated into multiple sub-regions according to the segmentation grid. Here, the grid size can refer to the size of the small regions (grids) into which the image is divided. The segmentation grid can refer to the grid into which the image is divided into multiple small regions.

[0110] In the specific implementation, after confirming that the text area is not a solid color background, the text information of the text area can be obtained through a large model. After obtaining the text information, the grid size is calculated based on the text size and text density in the text information. Then, the grid is set according to the calculated grid size to divide the image into multiple small areas.

[0111] Before dividing the text region into multiple sub-regions, this embodiment also determines whether the text region in the image to be translated is a solid color background region. Only when the text region is a non-solid color background region will the text region be divided into multiple sub-regions; if the text region is a solid color background region, the text region will be directly filled with color based on the background color, thereby reducing the computational overhead caused by pixel-by-pixel processing and improving processing efficiency.

[0112] Reference Figure 9 , Figure 9 This is a flowchart illustrating the third embodiment of the image translation method of this application. Based on the above embodiments, the third embodiment of the image translation method of this application is proposed.

[0113] In the third embodiment, step S20 includes:

[0114] Step S201: Obtain the color of each pixel in each sub-region, and calculate the background main color of each sub-region based on the color of each pixel.

[0115] It should be understood that, in order to ensure that only pixels with a color similar to the font color are replaced with the background main color and to reduce errors and distortions in the color replacement process, in this embodiment, the color of each pixel in the sub-region is replaced based on the similarity between the color of each pixel and the font color.

[0116] In the specific implementation, obtaining the color of each pixel in each sub-region and calculating the dominant background color of each sub-region based on the color of each pixel can be achieved by the system iterating through each pixel in each sub-region and obtaining their color values. Then, color clustering algorithms (such as K-means clustering) or color histogram analysis are used to calculate the dominant background color of the sub-region. The dominant background color can refer to the color that dominates the sub-region.

[0117] Step S202: Obtain the font color of the text to be translated in each sub-region.

[0118] It is understandable that obtaining the font color of the text to be translated in each sub-region can be done by obtaining the pixel points corresponding to the text to be translated in each sub-region and determining the font color of the text to be translated based on the color of the pixel points corresponding to the text to be translated.

[0119] Step S203: Compare the similarity between the color of each pixel and the color of the font, and obtain the target pixel with a similarity greater than a preset threshold.

[0120] Understandably, comparing the similarity between the color of each pixel and the font color, and identifying target pixels with a similarity greater than a preset threshold, can be achieved by comparing the color similarity of each pixel in each sub-region with the font color. This can be done by calculating distances in the color space, such as using Euclidean distance or Manhattan distance. Then, pixels with a similarity greater than the preset threshold are selected as target pixels. The preset threshold can refer to the standard used to judge color similarity, and it can be set in advance.

[0121] Step S204: Replace the color of the target pixel with the background main color to obtain the processed image.

[0122] It should be understood that for each target pixel in a sub-region, its color is replaced with the main background color. This can be achieved by directly modifying the pixel's color value. After replacing the colors in all sub-regions, the processed image is obtained.

[0123] In this embodiment, the color of each pixel in the sub-region is replaced based on the similarity between the color of each pixel and the color of the font. This ensures that only pixels with a color similar to the font are replaced with the background main color, reducing errors and distortions in the color replacement process.

[0124] Reference Figure 10 , Figure 10 This is a flowchart illustrating the fourth embodiment of the image translation method of this application. Based on the above embodiments, the fourth embodiment of the image translation method of this application is proposed.

[0125] In the fourth embodiment, before step S30, the method further includes:

[0126] Step S21: Blur the text region in the processed image to obtain a blurred image.

[0127] It should be understood that, in order to reduce the traces of translation and further enhance the immersive effect after translation, in this embodiment, the processed image is also blurred to obtain a blurred image, and the translated text is embedded in the blurred image to obtain a translated image.

[0128] Further, step S21 includes: calling the attribute setting interface in the web page canvas to set a blur filter; blurring the text area in the processed image using the blur filter to obtain a blurred image.

[0129] In practical implementation, for example, the blurring function of canvas (such as ctx.filter = blur(...)) can be used to blur the text area in the processed image to weaken the translation traces and enhance the overall aesthetics.

[0130] Accordingly, step S30 includes:

[0131] Step S30': Translate the text to be translated and embed the translated text into the blurred image to obtain the translated image.

[0132] Understandably, after blurring, a large model identifies the content of the text to be translated, and the translation API or the large model translates the text into the target language. Then, based on the position, size, font, and other attributes of the text to be translated, the translated text is embedded into the blurred image to obtain the translated image.

[0133] This embodiment blurs the processed image to obtain a blurred image, and then embeds the translated text into the blurred image to obtain a translated image. This weakens the translation traces and further enhances the immersive effect after translation.

[0134] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the image translation method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.

[0135] This application also provides an image translation device, please refer to... Figure 11 The image translation device includes:

[0136] The region segmentation module 10 is used to segment the text region in the image to be translated into multiple sub-regions in response to the image translation request;

[0137] The color replacement module 20 is used to replace the text to be translated in each sub-region with the main background color of each sub-region to obtain the processed image.

[0138] The text embedding module 30 is used to translate the text to be translated and embed the translated text into the processed image to obtain the translated image.

[0139] The image translation device provided in this application, employing the image translation method described in the above embodiments, can solve the technical problems of uneven color and poor visual effects in existing image translation technologies. Compared with the prior art, the beneficial effects of the image translation device provided in this application are the same as those of the image translation method provided in the above embodiments, and other technical features in the image translation device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0140] This application provides an image translation device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the image translation method in Embodiment 1 above.

[0141] The following is for reference. Figure 12 The diagram illustrates a structural schematic suitable for implementing the image translation device of the embodiments of this application. The image translation device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 12 The image translation device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of this application.

[0142] like Figure 12As shown, the image translation device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in ROM (Read Only Memory) 1002 or a program loaded from storage device 1003 into RAM (Random Access Memory) 1004. RAM 1004 also stores various programs and data required for the operation of the image translation device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via bus 1005. Input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touch screens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, LCDs (Liquid Crystal Displays), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. The communication device 1009 allows the image translation device to communicate wirelessly or wiredly with other devices to exchange data. Although the figures show image translation devices with various systems, it should be understood that implementing or having all of the systems shown is not required. More or fewer systems may be implemented alternatively.

[0143] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0144] The image translation device provided in this application, employing the image translation method described in the above embodiments, can solve the technical problems of uneven color and poor visual effects in existing image translation technologies. Compared with the prior art, the beneficial effects of the image translation device provided in this application are the same as those of the image translation method provided in the above embodiments, and other technical features of this image translation device are the same as those disclosed in the previous embodiment method, and will not be repeated here.

[0145] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0146] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0147] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the image translation method in the above embodiments.

[0148] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, RAM (Random Access Memory), ROM (Read Only Memory), EPROM (Erasable Programmable Read Only Memory), or flash memory, optical fiber, CD-ROM (CD-Read Only Memory), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0149] The aforementioned computer-readable storage medium may be included in the image translation device; or it may exist independently and not be assembled into the image translation device.

[0150] The aforementioned computer-readable storage medium carries one or more programs, which, when executed by the image translation device, cause the image translation device to perform the aforementioned image translation method.

[0151] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including LAN (Local Area Network) or WAN (Wide Area Network)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0152] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0153] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0154] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described image translation method. This solves the technical problems of uneven color and poor visual effects in existing image translation technologies. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the image translation method provided in the above embodiments, and will not be repeated here.

[0155] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the image translation method described above.

[0156] The computer program product provided in this application can solve the technical problems of uneven color and poor visual effect in existing image translation technologies. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the image translation method provided in the above embodiments, and will not be repeated here.

[0157] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

[0158] This application discloses A1, an image translation method, the image translation method comprising:

[0159] In response to an image translation request, the text region in the image to be translated is divided into multiple sub-regions;

[0160] The text to be translated in each sub-region is replaced with its own color based on the background color of each sub-region, resulting in a processed image.

[0161] The text to be translated is translated, and the translated text is embedded into the processed image to obtain the translated image.

[0162] A2. The image translation method as described in A1, wherein in response to an image translation request, the text region in the image to be translated is divided into multiple sub-regions, including:

[0163] In response to an image translation request, the text region in the image to be translated is identified;

[0164] Determine whether the text area is a solid color background area;

[0165] If the text area is a non-solid color background area, then the text area is divided into multiple sub-areas.

[0166] A3. The image translation method as described in A2, wherein determining whether the text area is a solid color background area includes:

[0167] The pixels in the text area are traversed at preset intervals.

[0168] Determine whether the text area is a solid color background area based on the traversed pixels.

[0169] A4. The image translation method as described in A3, before traversing the pixels in the text region at preset intervals, further includes:

[0170] Information is extracted from the image to be translated to obtain the resolution of the image;

[0171] The preset interval corresponding to the image resolution is found in the preset mapping table, wherein the preset mapping table includes the correspondence between image resolution and preset interval.

[0172] A5. The image translation method as described in A2, wherein if the text region is a non-solid color background region, the text region is divided into multiple sub-regions, including:

[0173] If the text area is a non-solid color background area, then obtain the text information of the text area;

[0174] Calculate the grid size based on the text information, and set the grid division according to the grid size;

[0175] The text region in the image to be translated is divided into multiple sub-regions based on the grid division.

[0176] A6. The image translation method as described in A2, after determining whether the text area is a solid color background area, further includes:

[0177] If the text area is a solid color background area, then obtain the background color of the text area;

[0178] The text area is filled with color based on the background color to obtain the processed image.

[0179] A7. The image translation method as described in A6, wherein filling the text area with color based on the background color to obtain the processed image includes:

[0180] Call the property setting interface in the web page canvas to set the background color to the fill color;

[0181] Based on the fill color, the rectangle drawing interface in the web page canvas is called to draw a fill rectangle in the text area, and the processed image is obtained.

[0182] A8. The image translation method as described in A2, wherein the step of identifying the text region in the image to be translated in response to the image translation request includes:

[0183] In response to an image translation request, the system identifies the text to be translated in the image using a large model; obtains the text position of the text to be translated in the image, and identifies the text region in the image based on the text position.

[0184] A9. The image translation method as described in any one of A1 to A8, wherein the step of replacing the text to be translated in each sub-region with the color according to the background primary color of each sub-region to obtain the processed image includes:

[0185] Get the color of each pixel in each sub-region, and calculate the background primary color of each sub-region based on the color of each pixel;

[0186] Get the font color of the text to be translated in each sub-region;

[0187] Compare the similarity between the color of each pixel and the color of the font, and obtain the target pixels with a similarity greater than a preset threshold;

[0188] The color of the target pixel is replaced with the background main color to obtain the processed image.

[0189] A10. The image translation method as described in any one of A1 to A8, wherein before translating the text to be translated and embedding the translated text into the processed image to obtain the translated image, the method further includes:

[0190] The text regions in the processed image are blurred to obtain a blurred image;

[0191] Accordingly, the process of translating the text to be translated and embedding the translated text into the processed image to obtain the translated image includes:

[0192] The text to be translated is translated, and the translated text is embedded into the blurred image to obtain the translated image.

[0193] A11. The image translation method as described in A10, wherein blurring the text region in the processed image to obtain a blurred image includes:

[0194] Use the property settings interface in the webpage canvas to set the blur filter;

[0195] The text area in the processed image is blurred using the blur filter to obtain a blurred image.

[0196] This application also discloses B12, an image translation device, the image translation device comprising:

[0197] The region segmentation module is used to divide the text region in the image to be translated into multiple sub-regions in response to the image translation request;

[0198] The color replacement module is used to replace the text to be translated in each sub-region with the main background color of each sub-region to obtain the processed image.

[0199] The text embedding module is used to translate the text to be translated and embed the translated text into the processed image to obtain the translated image.

[0200] B13. In the image translation device as described in B12, the region segmentation module is further configured to, in response to an image translation request, identify a text region in the image to be translated; determine whether the text region is a solid color background region; and if the text region is a non-solid color background region, segment the text region into multiple sub-regions.

[0201] B14. In the image translation device described in B13, the region segmentation module is further configured to traverse the pixels in the text region at preset intervals; and determine whether the text region is a solid color background region based on the traversed pixels.

[0202] B15. The image translation device as described in B14, wherein the region segmentation module is further configured to extract information from the image to be translated to obtain the resolution of the image to be translated; and to search for a preset interval corresponding to the image resolution in a preset mapping relationship table, wherein the preset mapping relationship table includes a correspondence between image resolution and preset interval.

[0203] B16. The image translation device as described in B13, wherein the region segmentation module is further configured to: if the text region is a non-solid color background region, acquire the text information of the text region; calculate the grid size based on the text information, and set the division grid based on the grid size; and divide the text region in the image to be translated into multiple sub-regions based on the division grid.

[0204] B17. The image translation device as described in B13, further comprising:

[0205] The color fill module is used to obtain the background color of the text area if the text area is a solid color background area; and to fill the text area with color based on the background color to obtain the processed image.

[0206] This application also discloses C18, an image translation device, the image translation device comprising: a memory, a processor, and an image translation program stored in the memory and executable on the processor, wherein the image translation program, when executed by the processor, implements the image translation method as described above.

[0207] This application also discloses D19, a storage medium storing an image translation program, which, when executed by a processor, implements the image translation method as described above.

[0208] This application also discloses E20, a computer program product including an image translation program, which, when executed by a processor, implements the image translation method as described above.

Claims

1. A picture translation method, characterized by, The image translation method includes: In response to an image translation request, the text region in the image to be translated is divided into multiple sub-regions; The text to be translated in each sub-region is replaced with its own color based on the background color of each sub-region, resulting in a processed image. The text to be translated is translated, and the translated text is embedded into the processed image to obtain the translated image.

2. The picture translation method of claim 1, wherein, In response to the image translation request, the text region in the image to be translated is divided into multiple sub-regions, including: In response to an image translation request, the text region in the image to be translated is identified; Determine whether the text area is a solid color background area; If the text area is a non-solid color background area, then the text area is divided into multiple sub-areas.

3. The image translation method as described in claim 2, characterized in that, The step of determining whether the text area is a solid color background area includes: The pixels in the text area are traversed at preset intervals. Determine whether the text area is a solid color background area based on the traversed pixels.

4. The image translation method as described in claim 3, characterized in that, Before traversing the pixels in the text region at preset intervals, the method further includes: Information is extracted from the image to be translated to obtain the resolution of the image; The preset interval corresponding to the image resolution is found in the preset mapping table, wherein the preset mapping table includes the correspondence between image resolution and preset interval.

5. The image translation method as described in claim 2, characterized in that, If the text region is a non-solid color background region, then the text region is divided into multiple sub-regions, including: If the text area is a non-solid color background area, then obtain the text information of the text area; Calculate the grid size based on the text information, and set the grid division according to the grid size; The text region in the image to be translated is divided into multiple sub-regions based on the grid division.

6. The image translation method as described in claim 2, characterized in that, After determining whether the text area is a solid color background area, the method further includes: If the text area is a solid color background area, then obtain the background color of the text area; The text area is filled with color based on the background color to obtain the processed image.

7. An image translation device, characterized in that, The image translation device includes: The region segmentation module is used to divide the text region in the image to be translated into multiple sub-regions in response to the image translation request; The color replacement module is used to replace the text to be translated in each sub-region with the main background color of each sub-region to obtain the processed image. The text embedding module is used to translate the text to be translated and embed the translated text into the processed image to obtain the translated image.

8. An image translation device, characterized in that, The image translation device includes: a memory, a processor, and an image translation program stored in the memory and executable on the processor, wherein the image translation program, when executed by the processor, implements the image translation method as described in any one of claims 1 to 6.

9. A storage medium, characterized in that, The storage medium stores an image translation program, which, when executed by a processor, implements the image translation method as described in any one of claims 1 to 6.

10. A computer program product, characterized in that, The computer program product includes an image translation program, which, when executed by a processor, implements the image translation method as described in any one of claims 1 to 6.