Picture material processing method, device and equipment
By generating and merging a mask set of image materials, and using an image inpainting algorithm to process text areas, the problem of recognition error in graphic tools is solved, and efficient and accurate text mark erasure is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- RAJAX NETWORK &TECHNOLOGY (SHANGHAI) CO LTD
- Filing Date
- 2023-04-20
- Publication Date
- 2026-05-05
AI Technical Summary
In existing technologies, when using graphic tools to erase text marks, there is an error in recognizing the specified text area, resulting in unsatisfactory image processing results.
By receiving image materials, obtaining text regions, generating masks and dividing them into bright and dark areas, identifying their correspondence, merging the masks, using image restoration algorithms to process the image materials, generating a mask set, and performing image restoration.
Accurately erase text marks in image materials to improve processing results and avoid errors caused by large-scale image restoration.
Smart Images

Figure CN116486412B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a method, apparatus and device for processing image materials. Background Technology
[0002] With the continuous development of the internet industry, more and more users are choosing to interact with resources on online platforms. In many online resource interaction scenarios, service providers need to upload a large number of image materials around the resources. For service providers, the quality of image materials greatly affects the click-through rate of users.
[0003] Typically, the quality of image materials provided by service providers varies greatly. Whether it's enhancing the image materials themselves or applying them to other resource slots, text-related markings in the images always require a series of processing steps before they can be used in production. In related technologies, image material processing mainly relies on manual methods. Graphical tools can be used to erase text-related markings from image materials to obtain images that meet platform requirements. However, erasing text-related markings using graphic tools requires identifying specific text areas. Due to the influence of edge pixels in the image material, there will be some errors in the identification process of these designated text areas, thus affecting the accuracy of text erasure and resulting in unsatisfactory image material processing results. Summary of the Invention
[0004] In view of this, this application provides a method, apparatus, and device for processing image materials. The main purpose is to solve the problem that the existing method of using drawing tools to erase text marks has certain errors in the recognition process of a specified text area, which affects the accuracy of text mark erasure and leads to unsatisfactory image material processing results.
[0005] According to the first aspect of this application, a method for processing image materials is provided, applied to a service platform, the method comprising:
[0006] Receive image material and extract the text region from the image material;
[0007] A mask is generated for the text area in the image material. The average gray value of the text area is used to divide the text area into a bright area and a dark area. The bright area and the dark area correspond to the text part and the background part, respectively.
[0008] Identify the correspondence between the bright and dark areas in the text region and the text and background regions, respectively, and use the correspondence to merge the masks of all text regions in the image material to generate a mask set for the image material;
[0009] Based on the mask set of the image material, an image restoration algorithm is used to process the text portion of the image material to obtain the restored image material.
[0010] Further, receiving image material and obtaining text regions from the image material includes:
[0011] Receive image materials and preprocess the image materials, the preprocessing including at least image channel conversion processing and grayscale processing;
[0012] The vertex coordinates of the original text region are determined from the preprocessed image material using text recognition technology. The boundary of the original text region is then expanded based on the vertex coordinates to obtain the text region in the image material.
[0013] Furthermore, the step of generating a mask for the text region in the image material, and dividing the text region into bright and dark regions using the average grayscale value of the text region, includes:
[0014] For the text area in the image material, a mask is generated using a rectangle so that the inside of the rectangle and the outside of the rectangle have different fill values;
[0015] Based on the mask and the grayscale value corresponding to the image material, the average grayscale value of the text area is calculated. The average grayscale value is used to divide the text area into a bright area and a dark area, which correspond to the text part and the background part, respectively.
[0016] Further, the step of calculating the average grayscale value of the text region based on the grayscale value corresponding to the mask and the image material, and using the average grayscale value to divide the text region into bright and dark regions, includes:
[0017] Multiply the mask by the grayscale value corresponding to the image material to obtain the grayscale value corresponding to the text area in the image material. Calculate the average grayscale value of the text area based on the grayscale value corresponding to the text area in the image material.
[0018] Using the average gray value of the text region as the division threshold, the brightness value of each pixel in the image material is compared with the brightness value to divide the text region into bright and dark regions.
[0019] Wherein, if the brightness value corresponding to the pixel is greater than the average gray value of the text area, then the pixels in the text area are divided into bright areas;
[0020] If the brightness value corresponding to the pixel is less than or equal to the average gray value of the text area, then the pixel in the text area is divided into a dark area.
[0021] The bright area corresponds to one of the text portion and the background portion, and the dark area corresponds to the other of the text portion and the background portion.
[0022] Further, the step of identifying the correspondence between the bright and dark areas in the text region and the text portion and background portion, respectively, and using the correspondence to merge the masks of all text regions in the image material to generate a mask set for the image material, includes:
[0023] An erosion operation is performed on the text region. Based on the average gray value of the text region after the erosion operation, the correspondence between the bright and dark areas in the text region and the text part and the background part is identified respectively.
[0024] The masks of all text regions in the image material are merged using the correspondence to obtain a mask set that covers all text regions;
[0025] The mask set covering all text regions is expanded at least once according to a pre-set expansion kernel, and a mask set for the image material is generated based on the expanded mask set of the text regions.
[0026] Further, the step of performing an erosion operation on the text region, and identifying the correspondence between the bright and dark areas of the text region and the text portion and background portion respectively based on the average grayscale value of the text region after the erosion operation, includes:
[0027] The text area is etched according to the pre-set etch kernel, and the average gray value of the text area after the etch operation is calculated.
[0028] If the average gray value of the text area after the erosion operation is greater than the average gray value of the text area before the erosion operation, then the background part corresponding to the bright area in the text area and the text part corresponding to the dark area in the text area are identified.
[0029] If the average grayscale value of the text region after the erosion operation is less than or equal to the average grayscale value of the text region before the erosion operation, then the bright areas in the text region corresponding to the text portion and the dark areas in the text region corresponding to the background portion are identified.
[0030] Further, the step of processing the text portion of the image material using an image inpainting algorithm based on the mask set of the image material to obtain the repaired image material includes:
[0031] Based on the mask set of the image material, an image inpainting algorithm is used to determine the text region to be repaired in the text portion of the image material, and the text region to be repaired in the image material is erased.
[0032] The fill color value is calculated based on the color values around the text area to be repaired after erasure. The fill color value is then used to fill the text area to be repaired according to the preset repair radius, resulting in the repaired image material.
[0033] According to a second aspect of this application, a method for processing image materials is provided, applied to a service provider's client, the method comprising:
[0034] The image material is acquired and uploaded to a service platform. The service platform generates a mask for the text area in the image material. The masks of all text areas in the image material are merged using the correspondence between the bright and dark areas in the text area and the text and background areas, respectively, to generate a mask set for the image material. Based on the mask set of the image material, an image restoration algorithm is used to process the text part of the image material to obtain the restored image material.
[0035] Receive the repaired image materials;
[0036] If the repaired image material meets the resource deployment conditions, then the repaired image material will be deployed to resource slots in different service scenarios.
[0037] According to a third aspect of this application, an apparatus for processing image materials is provided, the apparatus comprising:
[0038] The acquisition unit is used to receive image materials and acquire text regions from the image materials;
[0039] A segmentation unit is used to generate a mask for the text region in the image material, and to divide the text region into a bright region and a dark region using the average gray value of the text region. The bright region and the dark region correspond to the text part and the background part, respectively.
[0040] The recognition unit is used to recognize the correspondence between the bright and dark areas in the text region and the text part and the background part, respectively, and to merge the masks of all text regions in the image material using the correspondence to generate a mask set of the image material.
[0041] The processing unit is used to process the text portion of the image material using an image restoration algorithm based on the mask set of the image material, to obtain the restored image material.
[0042] Furthermore, the acquisition unit is specifically used to receive image materials, preprocess the image materials, and the preprocessing includes at least image channel conversion processing and grayscale processing; using text recognition technology to determine the vertex coordinates of the original text region from the preprocessed image materials, and expanding the boundary of the original text region according to the vertex coordinates of the original text region to obtain the text region in the image materials.
[0043] Furthermore, the partitioning unit includes:
[0044] The generation module is used to generate a mask for the text area in the image material using a rectangular frame, so that the inside of the rectangular frame and the outside of the rectangular frame have different fill values;
[0045] The segmentation module is used to calculate the average gray value of the text region based on the gray value corresponding to the mask and the image material. The segmentation module is used to divide the text region into a bright region and a dark region using the average gray value. The bright region and the dark region correspond to the text part and the background part, respectively.
[0046] Further, the segmentation module is specifically used to multiply the mask by the grayscale value corresponding to the image material to obtain the grayscale value corresponding to the text region in the image material; calculate the average grayscale value of the text region based on the grayscale value corresponding to the text region in the image material; use the average grayscale value of the text region as a segmentation threshold, iterate through and compare the brightness value with each pixel in the image material, and divide the text region into bright regions and dark regions;
[0047] Wherein, if the brightness value corresponding to the pixel is greater than the average gray value of the text area, the pixel in the text area is divided into a bright area; if the brightness value corresponding to the pixel is less than or equal to the average gray value of the text area, the pixel in the text area is divided into a dark area; the bright area corresponds to one of the text part and the background part, and the dark area corresponds to the other of the text part and the background part.
[0048] Furthermore, the identification unit includes:
[0049] The recognition module is used to perform an erosion operation on the text region, and based on the average gray value of the text region after the erosion operation, to identify the correspondence between the bright and dark areas in the text region and the text part and the background part, respectively.
[0050] The merging module is used to merge the masks of all text regions in the image material using the correspondence relationship, so as to obtain a mask set that covers all text regions;
[0051] The expansion module is used to perform at least one round of expansion operation on the mask set covering all text regions according to a pre-set expansion kernel, and generate a mask set for image materials based on the expanded mask set of text regions.
[0052] Furthermore, the recognition module is specifically used to perform an erosion operation on the text region according to a pre-set erosion kernel, and to calculate the average gray value of the text region after the erosion operation; if the average gray value of the text region after the erosion operation is greater than the average gray value of the text region before the erosion operation, then the bright area in the text region corresponds to the background part and the dark area in the text region corresponds to the text part; if the average gray value of the text region after the erosion operation is less than or equal to the average gray value of the text region before the erosion operation, then the bright area in the text region corresponds to the text part and the dark area in the text region corresponds to the background part.
[0053] Furthermore, the processing unit is specifically used to determine the text region to be repaired in the text portion of the image material using an image inpainting algorithm based on the mask set of the image material, and to erase the text region to be repaired in the image material; to calculate the fill color value based on the color value around the text region to be repaired after erasing, and to fill the text region to be repaired with the fill color value according to a preset repair radius, thereby obtaining the repaired image material.
[0054] According to a fourth aspect of this application, an apparatus for processing image materials is provided, the apparatus comprising:
[0055] An uploading unit is used to acquire image materials and upload them to a service platform. The service platform generates masks for the text areas in the image materials, merges the masks of all text areas in the image materials using the correspondence between bright and dark areas in the text areas and the text and background areas respectively, and generates a mask set for the image materials. Based on the mask set of the image materials, an image restoration algorithm is used to process the text parts of the image materials to obtain the restored image materials.
[0056] The receiving unit is used to receive the repaired image materials;
[0057] The delivery unit is used to deliver the repaired image material to resource slots in different service scenarios if the repaired image material meets the resource delivery conditions.
[0058] According to a fifth aspect of this application, a storage medium is provided that stores a computer program thereon, which, when executed by a processor, implements the above-described method for processing image materials.
[0059] According to a sixth aspect of this application, an image material processing apparatus is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor executes the program to implement the image material processing method described above.
[0060] By utilizing the above technical solution, this application provides a method, apparatus, and device for processing image materials. Compared with existing technologies that use tools to erase text marks when processing image materials, this application receives image materials, obtains text regions from the image materials, generates masks for the text regions, divides the text regions into bright and dark regions using the average grayscale value of the text regions, with the bright and dark regions corresponding to the text and background parts, respectively, identifies the correspondence between the bright and dark regions and the text and background parts, and merges the masks of all text regions in the image material using the correspondence to generate a mask set for the image material. Based on the mask set of the image material, an image inpainting algorithm is used to process the image material to obtain the repaired image material. This process, by creating a mask for each text region, can finely divide the text and background parts of the image material, avoiding processing errors caused by large-scale image inpainting. Furthermore, by merging the masks of the text regions, text marks in the image material can be accurately erased, improving the processing effect of the image material.
[0061] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0062] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0063] Figure 1 A flowchart illustrating a method for processing image materials according to an embodiment of this application is shown;
[0064] Figure 2 This illustration shows a flowchart of another image material processing method provided in an embodiment of this application;
[0065] Figure 3 A flowchart is shown corresponding to the processing procedure of the image materials provided in the embodiments of this application;
[0066] Figure 4This diagram illustrates the interaction chain formed by the processing of image materials provided in the embodiments of this application.
[0067] Figure 5 A schematic diagram of the structure of an image material processing apparatus provided in an embodiment of this application is shown;
[0068] Figure 6 This illustration shows a schematic diagram of another image material processing apparatus provided in an embodiment of this application. Detailed Implementation
[0069] The present application will be described in detail below with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in the embodiments of the present application can be combined with each other.
[0070] In related technologies, image processing primarily relies on manual methods. Text-like markings in images can be erased using graphic design tools to obtain images that meet platform requirements. However, erasing text-like markings using graphic design tools requires identifying specific text regions. Due to the influence of edge pixels in the image material, there will be some errors in the identification process, affecting the accuracy of text-like marking erasure and resulting in unsatisfactory image processing results.
[0071] To address this issue, this embodiment provides an image material processing system, including a service platform and a service client. The service platform receives image materials, obtains text regions from these materials, generates masks for the text regions, and divides the text regions into bright and dark areas using the average grayscale value of the text regions. These bright and dark areas correspond to the text and background, respectively. The system identifies the correspondence between the bright and dark areas and the text and background, and uses this correspondence to merge the masks of all text regions in the image material, generating a mask set for the image material. Based on this mask set, an image inpainting algorithm is used to process the image material, resulting in a repaired image material. In practical applications, the client obtains image materials and uploads them to the service platform. The service platform then generates masks for the text areas in the image materials. By using the correspondence between bright and dark areas in the text areas and the text and background parts respectively, the masks of all text areas in the image materials are merged to generate a mask set for the image materials. Based on the mask set, an image inpainting algorithm is used to process the image materials to obtain the repaired image materials. The repaired image materials do not contain text areas, which can accurately erase text marks in the image materials and improve the processing effect of the image materials.
[0072] Specifically, this embodiment provides a method for processing image materials, applied to a service platform, such as... Figure 1 As shown, it includes the following steps:
[0073] 101. Receive image material and obtain the text area in the image material.
[0074] Typically, online platforms provide various services to service providers. This process often requires uploading resource images, which the platform then uses to create service provider resources. These resources might include links to the service provider's website, website videos, and website pages. The image materials are essentially the resource images uploaded by the service provider to the platform. These images can encompass different service types. For example, depending on the service type the service provider is offering on the platform, images of the service provider's store and eligibility can be provided, such as actual store photos and service provider qualification photos. For the service type of resources the service provider is listing, actual photos and detailed images of the resources within the store can be provided, such as images of items from different angles and item specifications.
[0075] Understandably, when acquiring image materials, service providers often prioritize attracting more users to browse the content, without considering whether the images are suitable for their own use. If the resources contain textual markings such as watermarks, graphics, or color blocks, it will affect the online platform's production of the resources and the overall presentation, making it difficult for users to find them. Therefore, textual markings in image materials are usually processed before production to ensure the optimal presentation of the resources on the online platform.
[0076] Considering that image materials usually do not contain any text resources, text recognition technology can be used to obtain the text regions in the image materials. Once the text regions are identified, further text erasure processing can be performed on the text regions to process the image materials into resource images that meet the presentation requirements. For example, OCR recognition algorithms are used to obtain the text regions in the image materials. Specifically, the image materials containing text are preprocessed to reduce useless information in the image materials. This step mainly includes operations such as grayscale conversion, noise reduction, and binarization. Then, feature extraction and dimensionality reduction are performed on the preprocessed image materials to obtain text images. Features are the key information used to identify text. Each different character can be distinguished from other characters through features. After determining the features, feature dimensionality reduction is performed, while retaining sufficient information in the text images. Finally, each text image is classified, and the features are recognized as text, thereby obtaining the bounding box information and text information corresponding to each text image in the image materials. The bounding box information includes the vertex coordinates of the quadrilateral corresponding to the bounding box, the size of the bounding box, etc., and the text information includes character type and character information.
[0077] The execution subject of this invention can be an image material processing device, which can be applied to a service platform. Typically, the quality of image materials greatly affects the user's click-through rate. However, the image materials provided by service providers often have quality differences, affecting the browsing of image content. Here, by obtaining the text area in the image material and erasing the text area, the image material is free of watermarks, text, splicing, shadows, etc., thereby ensuring that the image material meets the review requirements of the service scenario and can be accurately connected to resource positions in various service scenarios.
[0078] 102. Generate a mask for the text area in the image material, and divide the text area into a bright area and a dark area using the average gray value of the text area.
[0079] Understandably, text regions in image materials are typically obtained using text recognition algorithms, which have a coarse granularity. Directly applying image inpainting algorithms to these text regions can create abrupt changes, and the pixels at the region edges have a significant impact on the inpainting result. Furthermore, some text regions are too large to be directly processed by image inpainting algorithms. Therefore, a fine-grained approach is needed to segment the text within these regions.
[0080] Specifically, a mask can be generated for each text region in the image material. The mask size is the same as the image material size, meaning the mask contains the same number of pixels as the image material. To improve computational efficiency, the mask definition can set the fill value of pixels in this region to 1, and the fill value of pixels in other regions to 0. Multiplying the mask by the grayscale value of the original image yields the grayscale value of the text region. The average grayscale value of the text region is then used as a segmentation threshold to divide the text region into two areas. The bright and dark areas are then determined based on brightness contrast. These two areas correspond to the text region and the background region, respectively. Here, design specifications recommend maintaining a contrast ratio of at least 4.5:1 (based on brightness value calculations) between the text and background to ensure text clarity; the optimal contrast ratio is 7:1. For example, with an average grayscale value of 186, pixels in the text region with a value greater than 186 are classified as bright areas, and pixels with a value less than 186 are classified as dark areas.
[0081] 103. Identify the correspondence between the bright and dark areas in the text region and the text portion and background portion, respectively. Use the correspondence to merge the masks of all text regions in the image material to generate a mask set for the image material.
[0082] Considering the deterministic brightness difference between text and background in a text region, pixels with higher brightness values may represent text, and vice versa. This can be addressed by performing expansion or erosion operations on the text region. Based on the trend of the average grayscale value change after these operations, the correspondence between bright and dark areas and the text and background regions can be identified. Since expansion or erosion operations enlarge or shrink the background area within the text region, if the average grayscale value of the text region increases after expansion, the enlarged background area is considered a bright area, and the bright area is then... The text area is assigned to the background area, and the dark area is assigned to the text area. If the average gray value of the text area increases after the erosion operation, the eroded background area is determined to be a dark area, and the dark area is assigned to the background area, while the bright area is assigned to the text area. If the average gray value of the text area decreases after the expansion operation, the expanded background area is determined to be a dark area, and the bright area is assigned to the text area, while the dark area is assigned to the background area. If the average gray value of the text area decreases after the erosion operation, the eroded background area is determined to be a bright area, and the dark area is assigned to the text area, while the bright area is assigned to the background area.
[0083] Furthermore, after determining the text and background portions in each text region, the masks for the text and background portions are different. By merging all text regions, a mask set for the image material can be obtained. This mask set for the image material covers the masks of all text regions, and the text and background portions can be clearly distinguished within the mask set. It should be noted that, to ensure that the entire text portion is surrounded by the background portion, at least one round of dilation operation can be performed on the mask of the text region in the image material after generating the mask set for the image material. Each dilation operation will expand the background portion at the edge of the text, thereby eliminating the transition color between the text and background portions after the dilation operation and improving the restoration effect of the image material.
[0084] 104. Based on the mask set of the image material, use an image restoration algorithm to process the text portion of the image material to obtain the restored image material.
[0085] Understandably, the mask set of the image material can clearly distinguish the text and background parts in the text area, enabling a finer-grained division of the text and background in the image material. Further, an image restoration algorithm is used to erase the text parts in the image material, resulting in a restored image material. Here, the image restoration algorithm can use inpainting technology, which is equivalent to object deletion technology. It can remove specified areas in the image material through background filling / replacement methods, achieving image restoration that is imperceptible to the user and has a natural effect.
[0086] Specifically, based on the mask set of the image material, the text portion of the image material can be used as the area to be repaired. The most matching background portion in the image material is then selected as the sampling area. The sampled pixels are copied and filled into the area to be repaired. After this process, the image material is updated to obtain the repaired image material. During the copying and filling of sampled pixels, any one of the following three filling methods can be used: pixel-by-pixel filling, region-by-region filling, and deep learning-based filling. For pixel-by-pixel filling, the process starts from the boundary of the area to be repaired and gradually fills all pixels in the area from the boundary to the center. The pixel to be filled is obtained by the weighted sum of all known pixels in its neighborhood. The choice of weights is crucial; pixels close to the point to be filled, close to the boundary normal, and located on the boundary contour are given higher weights. For region-by-region filling, the redundancy of the image material itself can be utilized. Information from the known parts of the image material is used to fill in the unknown parts. This process is similar to pixel-by-pixel filling, but pixel-by-pixel filling is performed on a pixel-by-pixel basis, while region-by-region filling is performed on a block-by-block basis. Compared to pixel-by-pixel filling, it can repair a larger area, and the filling effect is more natural. However, the computational complexity is high because it requires searching for similar patches across the entire image. For the deep learning-based infilling process, the texture of known parts of the image material can be utilized, treating the infilling process as an image generation process. This generates the area to be repaired in the image material. The entire process uses an encoder-decoder structure and an adversarial model. The encoder-decoder stage is used to learn image features and generate a predicted image corresponding to the area to be repaired in the image material. The training process of the adversarial model involves determining whether the predicted image is generated by the model or comes from the background of the real image material. When the generated predicted image and the background of the real image material are consistent in image content, and the discriminator of the adversarial model cannot distinguish them, it is determined that the network model parameters have reached the optimal state.
[0087] The image processing method provided in this application, compared with the existing technology of using tools to erase text marks, involves receiving image material, obtaining text regions from the image material, generating masks for the text regions, dividing the text regions into bright and dark regions using the average grayscale value of the text regions, with the bright and dark regions corresponding to the text and background parts respectively, identifying the correspondence between the bright and dark regions and the text and background parts respectively, and merging the masks of all text regions in the image material using the correspondence to generate a mask set for the image material. Based on the mask set of the image material, an image inpainting algorithm is used to process the image material to obtain the repaired image material. This process, by creating a mask for each text region, can finely divide the text and background parts of the image material, avoiding processing errors caused by large-scale image inpainting. Furthermore, by merging the masks of the text regions, text marks in the image material can be accurately erased, improving the processing effect of the image material.
[0088] In practical applications, considering the accuracy of text region recognition in image materials, preprocessing can be performed on the received image materials. This preprocessing includes at least image channel conversion and grayscale processing. Image channel conversion can convert a four-channel image material into a three-channel image with a specified background color, such as a white background, thus avoiding the loss of image information. Grayscale processing sets the pixel values in the image material to grayscale values to facilitate image processing. Then, text recognition technology is used to determine the vertex coordinates of the original text region from the preprocessed image material. Here, OCR text recognition methods can be used to obtain the boundary of the original text region in the image material, which is a rectangular bounding box. Given more precise quadrilateral vertex coordinates, the OCR text recognition result will simultaneously output the text content and confidence score. The confidence score can be set with a threshold to determine the accuracy of whether it is text. Based on historical experience, the confidence score can be set to 0, meaning that as long as the text content is recognized, it will be retained. Finally, since the quadrilateral corresponding to the text region in the image material sometimes cannot completely contain the text itself, and also to avoid subsequent erosion operations from eroding the text part, the boundary of the original text region is expanded based on the vertex coordinates of the original text region to obtain the text region in the image material. Here, the expansion process involves expanding all four vertices of the original text region outward. For example, based on experience, each edge corresponding to the initial text region can be expanded by 6 pixels.
[0089] Understandably, the restoration process here mainly focuses on image restoration of the text content within the text region. If the entire text region is subjected to image restoration, the processing granularity will be too coarse, resulting in an abrupt restoration effect. Moreover, edge pixels have too much influence on the restoration effect. Some text regions are too large to be directly processed by image restoration. Therefore, this method identifies the text portion and the background portion within the text region and performs image restoration on the text portion of the text region to achieve the desired image restoration effect.
[0090] Furthermore, to accurately identify the text portion within the text area, during the division of the text area into bright and dark regions, a mask can be generated for the text area in the image material using a rectangular bounding box. This ensures that the pixels inside and outside the rectangle have different fill values; for example, pixels inside the rectangle are filled with 1s, and pixels outside the rectangle are filled with 0s. Then, based on the mask and the corresponding grayscale value of the image material, the average grayscale value of the text area is calculated. This average grayscale value is used to divide the text area into bright and dark regions, corresponding to the text portion and the background portion, respectively. Specifically, the mask can be multiplied by the corresponding grayscale value of the image material to obtain the image pixel value. The grayscale value corresponding to the text area in the image material is calculated. Then, based on the grayscale value of the text area in the image material, the average grayscale value of the text area is calculated. Using the average grayscale value of the text area as a division threshold, the brightness value of each pixel in the image material is compared to the average grayscale value to divide the text area into bright and dark areas. If the brightness value of a pixel is greater than the average grayscale value of the text area, the pixel in the text area is classified as a bright area. If the brightness value of a pixel is less than or equal to the average grayscale value of the text area, the pixel in the text area is classified as a dark area. Here, the bright area corresponds to one of the text part and the background part, and the dark area corresponds to the other of the text part and the background part.
[0091] In the specific implementation process, the bright and dark areas in the text region correspond to the text part and the background part, respectively. Since the text region has been expanded before, and the pixel value of the expanded part after the expansion process must be the background part, in the process of identifying the correspondence between the bright and dark areas in the text region and the text part and the background part, respectively, an erosion operation can be performed on the text region. Based on the average gray value of the text region after the erosion operation, the correspondence between the bright and dark areas in the text region and the text part and the background part can be identified. Further, the masks of all text regions in the image material are merged using the correspondence to obtain a mask set covering all text regions. Then, at least one round of expansion operation is performed on the mask set covering all text regions according to the pre-set expansion kernel. Based on the expanded mask set of text regions, the mask set of the image material is generated. Considering that the erosion operation does not affect the text area but only reduces the pixel format of the Beijing part, the average gray value of the text area after the erosion operation is counted again. If it becomes brighter, it means that the background part is a dark area and the text part is a bright area. If it becomes darker, it means that the background part is a bright area and the text part is a dark area. Specifically, the text area can be eroded according to the pre-set erosion kernel, and the average gray value of the text area after the erosion operation is counted. If the average gray value of the text area after the erosion operation is greater than the average gray value of the text area before the erosion operation, the bright area in the text area corresponds to the background part and the dark area in the text area corresponds to the text part. If the average gray value of the text area after the erosion operation is less than or equal to the average gray value of the text area before the erosion operation, the bright area in the text area corresponds to the text part and the dark area in the text area corresponds to the background part.
[0092] In practical applications, after obtaining the masks of each text region, they are merged to obtain a mask set covering all text regions. To expand the text edges and ensure that the area around the text is the background, a pre-set dilation kernel can be used to perform two rounds of dilation operations on the mask set of all text regions. This ensures that there is no transition color between the text and the background, avoiding errors in the image restoration process.
[0093] Specifically, when processing the text portion of an image using an image inpainting algorithm, the algorithm identifies the text area to be repaired based on the image's mask set. This area is then erased. The fill color value is calculated based on the color values surrounding the erased area. Finally, using a pre-set repair radius, the fill color is applied to the text area, resulting in the repaired image. The image inpainting algorithm can accept both an image and a mask set as input. Since the mask set accurately records the text and background, the algorithm erases the text area and infers the fill color value based on the color values of the surrounding pixels. A pre-set repair radius is then used as the fill unit to fill the text area, ensuring that no text marks remain after image inpainting.
[0094] It should be noted that, considering the ease of image manipulation, the dilation and erosion kernels can be pre-set during the image material preprocessing stage, preferably using a 3x3 morphological kernel. Taking dilation as an example, if a 3x3 morphological kernel is used to dilate a text area, the kernel will use the largest pixel in the original image area corresponding to the kernel area as the anchor point (usually the kernel center point) during its traversal of the text area. Conversely, for erosion, the smallest pixel value in the text area corresponding to the kernel area is used as the anchor point. Similarly, the mask container table can also be pre-set during the image material preprocessing stage, so that it can be merged after all text area masks are generated.
[0095] Specifically, this embodiment provides a method for processing image materials, applied to a service platform, such as... Figure 2 As shown, it includes the following steps:
[0096] 201. Obtain image materials and upload them to the service platform.
[0097] It's understandable that service providers don't consider whether the uploaded image materials are suitable for their resource usage. The service platform can set different requirements for different service scenarios based on the image material's intended use. If the image material is intended for use as a detail image, it should not contain any text, and the image resolution should meet the set threshold. If the image material is intended for use as a thumbnail, it should be free of text while still meeting the set resolution. The specific resolution can be set according to the actual service scenario.
[0098] Alternatively, the service platform can match image modification processes to the text regions of the image material according to the needs of different service scenarios. Specifically, in the processing flow, the service platform generates a mask for the text regions in the image material, and merges the masks of all text regions in the image material using the correspondence between the bright and dark areas in the text region and the text and background parts, respectively, to generate a mask set for the image material. Based on the mask set of the image material, an image restoration algorithm is used to process the text part of the image material to obtain the restored image material.
[0099] 202. Receive the repaired image materials.
[0100] The restored image material contains no text marks, meaning it can meet the needs of different service scenarios and can be applied to resource locations in various service scenarios.
[0101] 203. If the repaired image material meets the resource deployment conditions, the repaired image material will be deployed to resource slots in different service scenarios.
[0102] Furthermore, to make flexible use of the repaired image materials, the service scenarios can be adapted based on the image attributes contained in the repaired image materials, so that the image materials can be applied to a wider range of service scenarios. For example, the detailed images of the repaired items can also be applied to the resource slots of the product main image, as well as to the resource slots of the product video.
[0103] The image processing method provided in this invention, compared to the existing technology of using tools to erase text marks, involves acquiring the image material, uploading it to a service platform, and having the platform generate masks for the text areas. The masks for all text areas in the image material are then merged using the correspondence between bright and dark areas in the text areas and the text and background areas, respectively, to generate a mask set for the image material. Based on this mask set, an image inpainting algorithm is used to process the image material, resulting in a repaired image material. The repaired image material does not contain any text areas. This process, by creating masks for each text area, allows for fine-grained segmentation of the text and background parts of the image material, avoiding processing errors caused by large-scale image inpainting. Furthermore, by merging the masks for the text areas, text marks in the image material can be accurately erased, improving the processing effect.
[0104] In practical application scenarios, Figure 3This diagram illustrates a flowchart of the image material processing procedure provided in this embodiment of the invention. After obtaining the image material, the service platform preprocesses it, then uses an OCR algorithm to identify the text regions in the image material. The text regions are then binarized using a mask generated from the text regions, clearly separating the text and background parts. After merging the text region masks and performing other post-processing operations, a mask set for the image material is obtained. Based on the mask set, an image restoration algorithm is used to restore the text parts in the image material, and the restored image material is output.
[0105] In practical application scenarios, Figure 4 The diagram illustrates the interaction chain formed during the processing of image materials provided in this embodiment of the invention. First, the service client obtains the image material and uploads it to the service platform. The service platform generates a mask for the text regions in the image material, dividing the text regions into bright and dark regions using the average grayscale value of the text regions. These bright and dark regions correspond to the text and background parts, respectively. Then, the correspondence between the bright and dark regions in the text regions and the text and background parts is identified. Using this correspondence, the masks of all text regions in the image material are merged to generate a mask set for the image material. Based on the mask set of the image material, an image restoration algorithm is used to process the image material to obtain the restored image material, which is then returned to the service client. The service client receives the restored image material, and if the restored image material meets the resource deployment conditions, it is deployed to resource slots in different service scenarios.
[0106] Furthermore, as Figure 1 In terms of specific implementation, this application provides a processing device for image materials that can be applied to the server-side of a service platform, such as... Figure 5 As shown, the device includes: an acquisition unit 51, a division unit 52, an identification unit 53, and a processing unit 54.
[0107] Acquisition unit 51 is used to receive image material and acquire the text region in the image material;
[0108] The segmentation unit 52 is used to generate a mask for the text area in the image material, and to divide the text area into a bright area and a dark area using the average gray value of the text area. The bright area and the dark area correspond to the text part and the background part, respectively.
[0109] The recognition unit 53 is used to recognize the correspondence between the bright and dark areas in the text region and the text part and the background part, respectively, and to use the correspondence to merge the masks of all text regions in the image material to generate a mask set of the image material.
[0110] The processing unit 54 is used to process the text portion of the image material using an image restoration algorithm based on the mask set of the image material, to obtain the restored image material.
[0111] The image processing apparatus provided in this invention, compared to the existing technology that uses tools to erase text marks when processing image materials, receives image materials, obtains text regions from the image materials, generates masks for the text regions, divides the text regions into bright and dark regions using the average grayscale value of the text regions, with the bright and dark regions corresponding to the text and background parts respectively, identifies the correspondence between the bright and dark regions in the text regions and the text and background parts respectively, and merges the masks of all text regions in the image materials using the correspondence to generate a mask set for the image materials. Based on the mask set of the image materials, an image restoration algorithm is used to process the image materials to obtain restored image materials. This process, by creating a mask for each text region, can finely divide the text and background parts of the image materials, avoiding processing errors caused by large-scale image restoration. Furthermore, by merging the masks of the text regions, text marks in the image materials can be accurately erased, improving the processing effect of the image materials.
[0112] In practical application scenarios, the acquisition unit 51 is specifically used to receive image materials, preprocess the image materials, and the preprocessing includes at least image channel conversion processing and grayscale processing; using text recognition technology to determine the vertex coordinates of the original text region from the preprocessed image materials, and expanding the boundary of the original text region according to the vertex coordinates of the original text region to obtain the text region in the image materials.
[0113] In practical applications, the partitioning unit 52 includes:
[0114] The generation module is used to generate a mask for the text area in the image material using a rectangular frame, so that the inside of the rectangular frame and the outside of the rectangular frame have different fill values;
[0115] The segmentation module is used to calculate the average gray value of the text region based on the gray value corresponding to the mask and the image material. The segmentation module is used to divide the text region into a bright region and a dark region using the average gray value. The bright region and the dark region correspond to the text part and the background part, respectively.
[0116] In practical applications, the segmentation module is specifically used to multiply the mask by the grayscale value corresponding to the image material to obtain the grayscale value corresponding to the text region in the image material; calculate the average grayscale value of the text region based on the grayscale value corresponding to the text region in the image material; use the average grayscale value of the text region as a segmentation threshold, iterate through and compare the brightness value with each pixel in the image material, and divide the text region into bright regions and dark regions.
[0117] Wherein, if the brightness value corresponding to the pixel is greater than the average gray value of the text area, the pixel in the text area is divided into a bright area; if the brightness value corresponding to the pixel is less than or equal to the average gray value of the text area, the pixel in the text area is divided into a dark area; the bright area corresponds to one of the text part and the background part, and the dark area corresponds to the other of the text part and the background part.
[0118] In practical applications, the identification unit 53 includes:
[0119] The recognition module is used to perform an erosion operation on the text region, and based on the average gray value of the text region after the erosion operation, to identify the correspondence between the bright and dark areas in the text region and the text part and the background part, respectively.
[0120] The merging module is used to merge the masks of all text regions in the image material using the correspondence relationship, so as to obtain a mask set that covers all text regions;
[0121] The expansion module is used to perform at least one round of expansion operation on the mask set covering all text regions according to a pre-set expansion kernel, and generate a mask set for image materials based on the expanded mask set of text regions.
[0122] In practical applications, the recognition module is specifically used to perform an erosion operation on the text region according to a pre-set erosion kernel, and to calculate the average gray value of the text region after the erosion operation. If the average gray value of the text region after the erosion operation is greater than the average gray value of the text region before the erosion operation, then the bright areas in the text region corresponding to the background and the dark areas in the text region corresponding to the text are identified. If the average gray value of the text region after the erosion operation is less than or equal to the average gray value of the text region before the erosion operation, then the bright areas in the text region corresponding to the text and the dark areas in the text region corresponding to the background are identified.
[0123] In practical applications, the processing unit 54 is specifically used to determine the text region to be repaired in the text portion of the image material using an image inpainting algorithm based on the mask set of the image material, and to erase the text region to be repaired in the image material; to calculate the fill color value based on the color value around the text region to be repaired after erasing, and to fill the text region to be repaired with the fill color value according to a preset repair radius, thereby obtaining the repaired image material.
[0124] It should be noted that for other corresponding descriptions of the functional units involved in the image material processing device applicable to the service platform side provided in this embodiment, please refer to... Figure 1 The corresponding descriptions in [the document] will not be repeated here.
[0125] Furthermore, as Figure 2 In its specific implementation, this application provides a processing device for image materials applied to a contract service provider's client, such as... Figure 6 As shown, the device includes: an uploading unit 61, a receiving unit 62, and an delivery unit 63.
[0126] Upload unit 61 is used to acquire image materials and upload the image materials to the service platform, so that the service platform generates a mask for the text areas in the image materials, merges the masks of all text areas in the image materials using the correspondence between the bright and dark areas in the text areas and the text and background areas respectively, and generates a mask set for the image materials. Based on the mask set of the image materials, an image restoration algorithm is used to process the text parts of the image materials to obtain the restored image materials.
[0127] Receiving unit 62 is used to receive the repaired image material;
[0128] The delivery unit 63 is used to deliver the repaired image material to resource slots in different service scenarios if the repaired image material meets the resource delivery conditions.
[0129] The image processing apparatus provided in this invention, compared to the existing technology that uses tools to erase text marks when processing image materials, obtains the image material, uploads it to a service platform, and allows the service platform to generate masks for the text areas in the image material. The masks for all text areas in the image material are merged using the correspondence between bright and dark areas in the text areas and the text and background areas, respectively, to generate a mask set for the image material. Based on the mask set, an image restoration algorithm is used to process the image material to obtain a restored image material. The restored image material is then received and no longer contains text areas. This process, by creating a mask for each text area, can finely divide the text and background parts of the image material, avoiding processing errors caused by large-scale image restoration. Furthermore, by merging the masks of the text areas, text marks in the image material can be accurately erased, improving the processing effect of the image material.
[0130] In practical application scenarios, the display unit is used to provide a switch authentication button to the contract service provider's client before the client inputs authentication information using the signing authentication method applicable to the contract service provider. In response to the triggering instruction of the switch authentication button, the signing authentication method to be switched is displayed on the service page, and the client inputs authentication information using the selected signing authentication method.
[0131] It should be noted that for other corresponding descriptions of the functional units involved in the image material processing device applicable to contract service provider clients provided in this embodiment, please refer to... Figure 2 The corresponding descriptions in [the document] will not be repeated here.
[0132] Based on the above, Figure 1 Accordingly, this application embodiment also provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the above-described method. Figure 1 The image processing method shown above; based on the above... Figure 2 Correspondingly, this application embodiment also provides another storage medium on which a computer program is stored, which, when executed by a processor, implements the above-described method. Figure 2 The image processing method shown.
[0133] Based on this understanding, the technical solution of this application can be embodied in the form of a software product. The software product can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, or portable hard drive), and includes several instructions to cause a computer device (such as a personal computer, server, or network device) to execute the methods described in the various implementation scenarios of this application.
[0134] Based on the above, Figure 1 The method shown, and Figure 5 To achieve the above objectives, the present application also provides a client physical device, which can be a computer, smartphone, tablet, smartwatch, or network device, etc. This physical device includes a storage medium and a processor; the storage medium stores a computer program; the processor executes the computer program to achieve the above-described objectives. Figure 1 The image processing method shown.
[0135] Based on the above, Figure 2 The method shown, and Figure 6 To achieve the above objectives, the present application also provides a physical device for a server, specifically a computer, smartphone, tablet, smartwatch, server, or network device, etc. This physical device includes a storage medium and a processor; the storage medium stores a computer program; the processor executes the computer program to achieve the above-described objectives. Figure 1 The image processing method shown.
[0136] Optionally, both types of physical devices may also include a user interface, a network interface, a camera, radio frequency (RF) circuitry, sensors, audio circuitry, a Wi-Fi module, etc. The user interface may include a display screen, input units such as a keyboard, etc., and optional user interfaces may also include USB interfaces, card reader interfaces, etc. The network interface may optionally include standard wired interfaces, wireless interfaces (such as Wi-Fi interfaces), etc.
[0137] Those skilled in the art will understand that the physical device structure for processing image materials provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or combine certain components, or have different component arrangements.
[0138] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the physical device for processing store search information, supporting the operation of the information processing program and other software and / or programs. The network communication module is used to enable communication between the various components within the storage medium, as well as communication with other hardware and software within the information processing physical device.
[0139] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented using software plus necessary general-purpose hardware platforms, or it can be implemented in hardware. By applying the technical solution of this application, compared with the existing methods, this application can finely divide the text and background parts of the image material by creating a mask for each text region, avoiding processing errors caused by large-scale image restoration. Furthermore, by merging the masks of the text regions, text marks in the image material can be accurately erased, improving the processing effect of the image material.
[0140] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of a preferred embodiment, and the modules or processes shown in the drawings are not necessarily essential for implementing this application. Those skilled in the art will understand that the modules in the apparatus of the embodiment can be distributed within the apparatus of the embodiment as described, or can be modified to be located in one or more apparatuses different from this embodiment. The modules of the above-described embodiment can be combined into one module, or further divided into multiple sub-modules.
[0141] The serial numbers in this application are for descriptive purposes only and do not represent the superiority or inferiority of any particular implementation scenario. The above disclosures are merely a few specific implementation scenarios of this application; however, this application is not limited thereto, and any variations conceived by those skilled in the art should fall within the protection scope of this application.
Claims
1. A method for processing image materials, characterized in that, include: Receive image material and extract the text region from the image material; A mask is generated for the text area in the image material. The average gray value of the text area is used to divide the text area into a bright area and a dark area. The bright area and the dark area correspond to the text part and the background part, respectively. By performing expansion or erosion operations on the text region, and based on the changing trend of the average gray value of the text region obtained after the expansion or erosion operations, the correspondence between the bright and dark areas in the text region and the text part and the background part is identified respectively. The masks of all text regions in the image material are merged using the correspondence to generate a mask set of the image material. If the average gray value of the text area increases after the expansion operation, the expanded background area is determined to be a bright area, and the bright area is assigned to the background area, and the dark area is assigned to the text area. If the average gray value of the text area increases after the erosion operation, the eroded background area is determined to be a dark area, and the dark area is assigned to the background area, while the bright area is assigned to the text area. If the average gray value of the text area decreases after the expansion operation, the expanded background area is determined to be a dark area, and the bright area is assigned to the text area, and the dark area is assigned to the background area. If the average gray value of the text area decreases after the erosion operation, the eroded background area is determined to be the bright area, the dark area is assigned to the text area, and the bright area is assigned to the background area. Based on the mask set of the image material, an image inpainting algorithm is used to process the text portion of the image material to obtain the repaired image material.
2. The method according to claim 1, characterized in that, The step of receiving image material and obtaining the text region in the image material includes: Receive image materials and preprocess the image materials, the preprocessing including at least image channel conversion processing and grayscale processing; The vertex coordinates of the original text region are determined from the preprocessed image material using text recognition technology. The boundary of the original text region is then expanded based on the vertex coordinates to obtain the text region in the image material.
3. The method according to claim 1, characterized in that, The step of generating a mask for the text region in the image material, and dividing the text region into bright and dark regions using the average grayscale value of the text region, includes: For the text area in the image material, a mask is generated using a rectangle so that the inside of the rectangle and the outside of the rectangle have different fill values; Based on the mask and the grayscale value corresponding to the image material, the average grayscale value of the text area is calculated. The average grayscale value is used to divide the text area into a bright area and a dark area, which correspond to the text part and the background part, respectively.
4. The method according to claim 3, characterized in that, The step of calculating the average grayscale value of the text region based on the grayscale value corresponding to the mask and the image material, and using the average grayscale value to divide the text region into bright and dark regions, includes: Multiply the mask by the grayscale value corresponding to the image material to obtain the grayscale value corresponding to the text area in the image material. Calculate the average grayscale value of the text area based on the grayscale value corresponding to the text area in the image material. Using the average gray value of the text region as the division threshold, the brightness value of each pixel in the image material is compared with the brightness value to divide the text region into bright and dark regions. Wherein, if the brightness value corresponding to the pixel is greater than the average gray value of the text area, the pixel in the text area is divided into a bright area; If the brightness value corresponding to the pixel is less than or equal to the average gray value of the text area, then the pixel in the text area is divided into a dark area. The bright area corresponds to one of the text portion and the background portion, and the dark area corresponds to the other of the text portion and the background portion.
5. The method according to claim 1, characterized in that, The process involves identifying the correspondence between bright and dark areas in the text region and the text and background regions, respectively. Using this correspondence, the masks of all text regions in the image material are merged to generate a mask set for the image material, including: An erosion operation is performed on the text region. Based on the average gray value of the text region after the erosion operation, the correspondence between the bright and dark areas in the text region and the text part and the background part is identified respectively. The masks of all text regions in the image material are merged using the correspondence to obtain a mask set that covers all text regions; The mask set covering all text regions is expanded at least once according to a pre-set expansion kernel, and a mask set for the image material is generated based on the expanded mask set of the text regions.
6. The method according to claim 5, characterized in that, The step of performing an erosion operation on the text region, and identifying the correspondence between the bright and dark areas of the text region and the text portion and background portion, respectively, based on the average grayscale value of the text region after the erosion operation, includes: The text area is etched according to the pre-set etch kernel, and the average gray value of the text area after the etch operation is calculated. If the average gray value of the text area after the erosion operation is greater than the average gray value of the text area before the erosion operation, then the background part corresponding to the bright area in the text area and the text part corresponding to the dark area in the text area are identified. If the average grayscale value of the text region after the erosion operation is less than or equal to the average grayscale value of the text region before the erosion operation, then the bright areas in the text region corresponding to the text portion and the dark areas in the text region corresponding to the background portion are identified.
7. The method according to any one of claims 1-6, characterized in that, The step of processing the text portion of the image material using an image inpainting algorithm based on the mask set of the image material to obtain the inpainted image material includes: Based on the mask set of the image material, an image inpainting algorithm is used to determine the text region to be repaired in the text portion of the image material, and the text region to be repaired in the image material is erased. The fill color value is calculated based on the color values around the text area to be repaired after erasure. The fill color value is then used to fill the text area to be repaired according to the preset repair radius, resulting in the repaired image material.
8. A method for processing image materials, characterized in that, include: The process involves acquiring image materials and uploading them to a service platform. The service platform then generates masks for the text regions within the image materials. By performing expansion or erosion operations on the text regions, and based on the changing trends of the average grayscale values of the text regions after the expansion or erosion operations, the platform identifies the correspondence between bright and dark areas in the text regions and the text and background parts, respectively. These correspondences are then used to merge the masks of all text regions in the image materials, generating a mask set for the image materials. Finally, an image restoration algorithm is used to process the text parts of the image materials based on this mask set, resulting in restored image materials. If the average gray value of the text area increases after the expansion operation, the expanded background area is determined to be a bright area, and the bright area is assigned to the background area, and the dark area is assigned to the text area. If the average gray value of the text area increases after the erosion operation, the eroded background area is determined to be a dark area, and the dark area is assigned to the background area, while the bright area is assigned to the text area. If the average gray value of the text area decreases after the expansion operation, the expanded background area is determined to be a dark area, and the bright area is assigned to the text area, and the dark area is assigned to the background area. If the average gray value of the text area decreases after the erosion operation, the eroded background area is determined to be the bright area, the dark area is assigned to the text area, and the bright area is assigned to the background area. Receive the repaired image materials; If the repaired image material meets the resource deployment conditions, then the repaired image material will be deployed to resource slots in different service scenarios.
9. An apparatus for processing image materials, characterized in that, include: The acquisition unit is used to receive image materials and acquire text regions from the image materials; A segmentation unit is used to generate a mask for the text region in the image material, and to divide the text region into a bright region and a dark region using the average gray value of the text region. The bright region and the dark region correspond to the text part and the background part, respectively. The recognition unit is used to perform an expansion or erosion operation on the text region, and based on the changing trend of the average gray value of the text region obtained after the expansion or erosion operation, identify the correspondence between the bright and dark areas in the text region and the text part and the background part, respectively, and use the correspondence to merge the masks of all text regions in the image material to generate a mask set of the image material. If the average gray value of the text area increases after the expansion operation, the expanded background area is determined to be a bright area, and the bright area is assigned to the background area, and the dark area is assigned to the text area. If the average gray value of the text area increases after the erosion operation, the eroded background area is determined to be a dark area, and the dark area is assigned to the background area, while the bright area is assigned to the text area. If the average gray value of the text area decreases after the expansion operation, the expanded background area is determined to be a dark area, and the bright area is assigned to the text area, and the dark area is assigned to the background area. If the average gray value of the text area decreases after the erosion operation, the eroded background area is determined to be the bright area, the dark area is assigned to the text area, and the bright area is assigned to the background area. The processing unit is used to process the text portion of the image material using an image restoration algorithm based on the mask set of the image material, to obtain the restored image material.
10. An apparatus for processing image materials, characterized in that, include: An uploading unit is used to acquire image materials and upload them to a service platform. The service platform generates masks for the text regions in the image materials. By performing expansion or erosion operations on the text regions, and based on the changing trend of the average grayscale value of the text regions after the expansion or erosion operations, it identifies the correspondence between bright and dark areas in the text regions and the text and background parts, respectively. Using these correspondences, it merges the masks of all text regions in the image materials to generate a mask set for the image materials. Based on the mask set, it uses an image restoration algorithm to process the text parts of the image materials to obtain the restored image materials. If the average gray value of the text area increases after the expansion operation, the expanded background area is determined to be a bright area, and the bright area is assigned to the background area, and the dark area is assigned to the text area. If the average gray value of the text area increases after the erosion operation, the eroded background area is determined to be a dark area, and the dark area is assigned to the background area, while the bright area is assigned to the text area. If the average gray value of the text area decreases after the expansion operation, the expanded background area is determined to be a dark area, and the bright area is assigned to the text area, and the dark area is assigned to the background area. If the average gray value of the text area decreases after the erosion operation, the eroded background area is determined to be the bright area, the dark area is assigned to the text area, and the bright area is assigned to the background area. The receiving unit is used to receive the repaired image materials; The delivery unit is used to deliver the repaired image material to resource slots in different service scenarios if the repaired image material meets the resource delivery conditions.
Citation Information
Patent Citations
Picture character fidelity editing method and device and computer readable storage medium
CN114298925A