Moiré image generation method and device, electronic equipment and storage medium
By acquiring target moiré background images generated from grayscale images and real images, and using weighted fusion to generate moiré images, the problem of lack of moiré image training in image recognition tools is solved, realizing automatic generation and realism enhancement of moiré images, and improving recognition performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-30
- Publication Date
- 2026-04-07
AI Technical Summary
In existing technologies, image recognition tools lack sufficient images containing moiré patterns for training, resulting in unsatisfactory recognition results. Furthermore, manually collecting moiré patterns consumes a significant amount of manpower, resources, and time.
By acquiring grayscale images, original images, and target moiré background images generated based on real images, moiré images are generated using weighted fusion. Background images with real moiré patterns are used to improve the realism of the images, and grayscale images are introduced to enrich the number of images.
It enables the automatic generation of moiré patterns, saving the cost of manual collection, improving the authenticity and quantity of moiré patterns, and enhancing the recognition effect of image recognition tools.
Smart Images

Figure CN116883298B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of image processing technology, and in particular to a method, apparatus, electronic device and storage medium for generating moiré images. Background Technology
[0002] With the development of internet technology, image recognition has rapidly emerged and flourished, its applications now permeating every corner of the national economy and social life, bringing tremendous changes to people's learning, working, and even lifestyles. In many scenarios, image recognition tools process images captured by monitors (i.e., images taken directly from the monitor screen). However, images captured by monitors are often accompanied by severe moiré interference, posing a significant challenge to image recognition tools.
[0003] For deep learning-based image recognition tools, a large number of images with moiré patterns are typically needed for model training in order to obtain a high-performance model. However, collecting a large number of images with moiré patterns requires significant manpower, resources, and time, and the acquisition of moiré pattern images is quite difficult. Summary of the Invention
[0004] To solve the above-mentioned technical problems, or at least partially solve them, this disclosure provides a method, apparatus, electronic device, and storage medium for generating moiré images.
[0005] According to one aspect of this disclosure, a method for generating moiré patterns is provided, comprising:
[0006] Obtain the grayscale image and the original image to which moiré patterns are to be added;
[0007] Obtain a target moiré pattern background image, wherein the target moiré pattern background image is generated based on a real image containing moiré patterns;
[0008] Obtain a first weight corresponding to the original image, a second weight corresponding to the target moiré background image, and a third weight corresponding to the grayscale image, wherein the first weight is greater than the third weight;
[0009] Based on the first weight, the second weight, and the third weight, the original image, the target moiré background image, and the grayscale image are fused to generate a moiré image.
[0010] According to another aspect of this disclosure, a moiré image generation apparatus is provided, comprising:
[0011] The first acquisition module is used to acquire the grayscale image and the original image to which moiré patterns are to be added;
[0012] The second acquisition module is used to acquire a target moiré pattern background image, wherein the target moiré pattern background image is generated based on a real image containing moiré patterns;
[0013] The third acquisition module is used to acquire a first weight corresponding to the original image, a second weight corresponding to the target moiré background image, and a third weight corresponding to the grayscale image, wherein the first weight is greater than the third weight;
[0014] The image fusion module is used to fuse the original image, the target moiré background image, and the grayscale image according to the first weight, the second weight, and the third weight to generate a moiré image.
[0015] According to another aspect of this disclosure, an electronic device is provided, comprising:
[0016] Processor; and
[0017] Stored program memory,
[0018] The program includes instructions that, when executed by the processor, cause the processor to perform the moiré image generation method according to one aspect of the foregoing.
[0019] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to perform the moiré image generation method according to the foregoing aspect.
[0020] According to another aspect of this disclosure, a computer program product is provided, comprising a computer program, wherein the computer program, when executed by a processor, implements the moiré image generation method described in the foregoing aspect.
[0021] One or more technical solutions provided in this disclosure acquire a grayscale image and an original image to which moiré patterns are to be added, and acquire a target moiré pattern background image, wherein the target moiré pattern background image is generated based on a real image containing moiré patterns. Then, a first weight corresponding to the original image, a second weight corresponding to the target moiré pattern background image, and a third weight corresponding to the grayscale image are acquired, where the first weight is greater than the third weight. Then, based on the first weight, the second weight, and the third weight, the original image, the target moiré pattern background image, and the grayscale image are fused to generate a moiré pattern image. Using the solution of this disclosure, the automatic generation of moiré pattern images carrying real moiré patterns is achieved, eliminating the need for manual collection of moiré pattern images, saving the manpower, resources, and time required for manual collection, and improving the convenience of acquiring moiré pattern images. Furthermore, in this disclosure, using a moiré pattern background image with real moiré patterns to generate the moiré pattern image improves the realism of the moiré pattern image, and by introducing a grayscale image for image fusion to obtain the moiré pattern image, the number of generated moiré pattern images can be greatly enriched even with limited moiré pattern background images and original images. Attached Figure Description
[0022] Further details, features, and advantages of this disclosure are disclosed in the following description of exemplary embodiments in conjunction with the accompanying drawings, in which:
[0023] Figure 1 A flowchart of a moiré image generation method according to an exemplary embodiment of the present disclosure is shown;
[0024] Figure 2 A flowchart of a moiré image generation method according to another exemplary embodiment of the present disclosure is shown;
[0025] Figure 3(a) shows a schematic diagram of the row image input format for the row image recognition model;
[0026] Figure 3(b) shows a schematic diagram of the converted row image;
[0027] Figure 4 A schematic block diagram of a moiré image generation apparatus according to an exemplary embodiment of the present disclosure is shown;
[0028] Figure 5 A structural block diagram of an exemplary electronic device that can be used to implement embodiments of the present disclosure is shown. Detailed Implementation
[0029] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0030] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0031] The term "comprising" and its variations as used herein are open-ended, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below. It should be noted that the concepts of "first", "second", etc., used in this disclosure are only used to distinguish different devices, modules, or units, and are not intended to limit the order of functions performed by these devices, modules, or units or their interdependencies.
[0032] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0033] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0034] The following description, with reference to the accompanying drawings, outlines the moiré image generation method, apparatus, electronic device, and storage medium provided in this disclosure.
[0035] In some scenarios, it's common to upload images taken directly at a monitor screen to image recognition tools for processing. However, these tools often lack images containing moiré patterns during training, while images taken directly at the screen frequently contain moiré interference. This results in suboptimal recognition performance for these images, leading to a poor user experience. For example, in educational settings, students upload images of questions taken directly at the screen to a Q&A system for image recognition. The system then identifies the questions and provides solutions or answers. However, collecting moiré data is difficult in question search scenarios, making it impossible to obtain sufficient images containing moiré patterns for training the system. This results in inconsistent performance and poor accuracy in question searching.
[0036] To address the difficulty in collecting image data containing moiré patterns, the current main solution is to draw moiré patterns using mathematical principles and add them to the image. However, moiré patterns drawn using mathematical principles have poor realism and are not effective in practical applications. Therefore, this disclosure provides a moiré pattern image generation method that uses a background image with realistic moiré patterns to fuse and generate the moiré pattern image. This improves the realism of the moiré pattern image, achieves better results in practical applications, and solves the problem of consuming significant manpower, resources, and time to manually collect a large number of moiré pattern images.
[0037] Figure 1 A flowchart of a moiré image generation method according to an exemplary embodiment of the present disclosure is shown. The method can be executed by a moiré image generation device, which can be implemented in software and / or hardware and is generally integrated into an electronic device, including devices such as mobile phones, tablets, and servers.
[0038] like Figure 1 As shown, the moiré pattern image generation method may include the following steps:
[0039] Step 101: Obtain the grayscale image and the original image to which moiré patterns will be added.
[0040] Among them, grayscale images are solid grayscale images.
[0041] For example, the grayscale image can be pre-stored; a solid grayscale image can be pre-stored for acquisition and use during subsequent image fusion.
[0042] For example, the grayscale image can be randomly generated. For instance, three numbers between 0 and 255 can be randomly generated as color values for the R, G, and B channels, respectively. Then, a solid RGB color image can be generated using these three color values. Finally, the generated RGB color image is grayscaled to obtain a solid grayscale image. Additionally, to improve the realism of the image, in some embodiments, after obtaining the RGB color image, some noise can be randomly added to the RGB color image to obtain a noisy color image, which is then grayscaled to obtain the final grayscale image.
[0043] In this embodiment, the acquired original image does not contain moiré patterns. The original image can be obtained from an existing image library. The original image can be obtained from the corresponding image library based on the application scenario of the generated moiré pattern image. For example, if the generated moiré pattern image is used for a math problem search scenario, the original image can be obtained from an existing math problem image library. Similarly, if the generated moiré pattern image is used for a medical scenario, the original image can be obtained from an existing medical image library.
[0044] Step 102: Obtain the target moiré pattern background image, wherein the target moiré pattern background image is generated based on a real image containing moiré patterns.
[0045] Among them, real images can be images with moiré patterns that are taken by users while looking at a monitor screen. For example, they can be title images with moiré patterns, medical images with moiré patterns, and so on.
[0046] In this embodiment of the disclosure, a target moiré pattern background image can be obtained based on a real image containing moiré patterns. Since the target moiré pattern background image is generated based on a real image containing moiré patterns, the obtained moiré pattern background image contains real moiré pattern background data. Using it to fuse and generate a moiré pattern image can improve the realism of the moiré pattern image.
[0047] For example, when acquiring the target moiré background image, the user can take a picture of the solid-color screen and upload it, and the electronic device will use the uploaded image as the target moiré background image. Alternatively, the user can also take a video of the solid-color screen and upload it, and the electronic device will extract several video frame images of the solid-color background with moiré patterns by extracting video frames, and then randomly select one video frame image as the target moiré background image.
[0048] For example, the electronic device can also collect real images containing moiré patterns uploaded by online users, randomly select one of them and perform background filling processing to obtain a target moiré pattern background image. The specific method of generating the target moiré pattern background image based on the real image containing moiré patterns will be described in detail in subsequent embodiments, and will not be repeated here.
[0049] For example, a moiré pattern material library can be pre-built, containing multiple moiré pattern background images. These images can be real images with moiré patterns uploaded by the user and taken against a solid-color screen, or they can be generated based on real images containing moiré patterns. When a moiré pattern image needs to be generated, the electronic device randomly selects a moiré pattern background image from the moiré pattern material library as the target moiré pattern background image.
[0050] It is understood that in the embodiments of this disclosure, the execution order of steps 101 and 102 is not important. They can be executed sequentially or synchronously. This disclosure is only used as an example of step 102 being executed after step 101 to explain this disclosure, and should not be regarded as a limitation of this disclosure.
[0051] Step 103: Obtain the first weight corresponding to the original image, the second weight corresponding to the target moiré background image, and the third weight corresponding to the grayscale image, wherein the first weight is greater than the third weight.
[0052] The first weight, the second weight, and the third weight can be preset, or they can be randomly generated based on the preset range of values for the first weight, the second weight, and the third weight. This disclosure does not impose any restrictions on this. However, regardless of the method used to determine the first weight, the second weight, and the third weight, the sum of the first weight, the second weight, and the third weight should be guaranteed to be 1.
[0053] For example, the values of the first weight, the second weight, and the third weight can be stored in advance and retrieved when needed. For instance, the first weight can be set to 0.5, the second weight to 0.3, and the third weight to 0.2.
[0054] For example, a first weight value range, a second weight value range, and a third weight value range can be preset. When it is necessary to obtain the first weight, the second weight, and the third weight, the first weight, the second weight, and the third weight are generated based on the first weight value range, the second weight value range, and the third weight value range. When generating the three weights, it is necessary to ensure that the constraint condition is met: first weight + second weight + third weight = 1.
[0055] In one optional embodiment of this disclosure, the first weight ranges from [0.4, 0.7], the second weight ranges from [0.1, 0.5], and the third weight ranges from [0, 0.3]. For example, the first weight can be 0.4, the second weight can be 0.35, and the third weight can be 0.25.
[0056] In this embodiment of the disclosure, by setting the value range of the first weight to [0.4, 0.7], the value range of the second weight to [0.1, 0.5], and the value range of the third weight to [0, 0.3], the original image can be given a larger weight and the grayscale image can be given a smaller weight. This ensures that the generated moiré image retains more data from the original image, thus guaranteeing the effectiveness and usability of the moiré image.
[0057] Step 104: Based on the first weight, the second weight, and the third weight, the original image, the target moiré background image, and the grayscale image are fused to generate a moiré image.
[0058] In this embodiment of the disclosure, a first weight corresponding to the original image, a second weight corresponding to the target moiré background image, and a third weight corresponding to the grayscale image are obtained. Based on the obtained three weights, the original image, the target moiré background image, and the grayscale image can be fused to generate a moiré image.
[0059] For example, during fusion, the image data corresponding to the original image, the target moiré background image, and the grayscale image can be weighted and summed according to the first weight, the second weight, and the third weight to obtain the moiré image.
[0060] In other words, the moiré pattern can be represented as: oImg=w1*qImg+w2*mImg+w3*gImg.
[0061] Wherein, oImg represents the fused moiré pattern image, qImg represents the original image, mImg represents the target moiré pattern background image, gImg represents the grayscale image, w1 represents the first weight corresponding to the original image, w2 represents the second weight corresponding to the target moiré pattern background image, and w3 represents the third weight corresponding to the grayscale image. In this embodiment, when fusing to generate the moiré pattern image, a solid grayscale image is added, which greatly enriches the number of generated moiré pattern images. This is because, for the original image, the moiré pattern background image and the grayscale image together form a new background image. Theoretically, the number of new background images is equal to the product of the number of moiré pattern background images and the number of grayscale images, thus greatly increasing the number of new background images. The new background images are then combined with the original image to obtain a large number of moiré pattern images. In addition, adding a grayscale image can also dilute the data in the text and image regions of the moiré pattern background image, making the final synthesized moiré pattern image more harmonious and realistic. The fused moiré pattern image can be used to train an image recognition tool to improve the recognition effect of the image recognition tool on images containing moiré patterns taken from a screen.
[0062] The moiré pattern image generation method of this disclosure acquires a grayscale image and an original image to which moiré patterns are to be added, and acquires a target moiré pattern background image, wherein the target moiré pattern background image is generated based on a real image containing moiré patterns. Then, it acquires a first weight corresponding to the original image, a second weight corresponding to the target moiré pattern background image, and a third weight corresponding to the grayscale image, where the first weight is greater than the third weight. Then, based on the first weight, the second weight, and the third weight, it fuses the original image, the target moiré pattern background image, and the grayscale image to generate a moiré pattern image. Using the solution of this disclosure, the automatic generation of moiré pattern images carrying real moiré patterns is achieved, eliminating the need for manual collection of moiré pattern images, saving the manpower, resources, and time required for manual collection, and improving the convenience of acquiring moiré pattern images. Furthermore, in this embodiment, using a moiré pattern background image with real moiré patterns to generate the moiré pattern image improves the realism of the moiré pattern image, and by introducing a grayscale image for image fusion to obtain the moiré pattern image, it can greatly enrich the number of generated moiré pattern images when the moiré pattern background image and the original image are limited. Furthermore, by fusing a grayscale image with the original image and the target moiré background image to generate a moiré image, the grayscale image can soften the data in the target moiré background image, making the final synthesized moiré image more harmonious and realistic, thus improving the harmony and realism of the moiré image. In this embodiment, by setting the first weight of the original image to be greater than the third weight corresponding to the grayscale image, more data from the original image can be retained in the generated moiré image, ensuring the effectiveness and usability of the moiré image, thereby obtaining a more realistic and harmonious moiré image, providing data support for training a better image recognition tool.
[0063] In one alternative embodiment of this disclosure, such as Figure 2 As shown, in Figure 1 Based on the illustrated embodiment, step 102 may include the following sub-steps:
[0064] Step 201: Obtain a real image containing moiré patterns.
[0065] For example, an electronic device can collect real images containing moiré patterns uploaded by each user online, or it can collect real images containing moiré patterns that exist on the network. When a moiré pattern image needs to be generated, it can randomly or sequentially select one of the collected real images to generate the target moiré pattern background image.
[0066] For example, an electronic device may prompt a user to upload a real image containing moiré patterns. After receiving the prompt, the user may take a picture of the screen and upload it, or select a real image containing moiré patterns that was previously taken of the screen and uploaded from the local photo album. The electronic device receives the real image uploaded by the user to generate the target moiré pattern background image.
[0067] Step 202: Perform target detection on the real image to determine the filling region in the real image.
[0068] In this embodiment of the disclosure, after obtaining a real image containing moiré patterns, target detection can be performed on the real image to obtain target detection results.
[0069] For example, pre-trained text detection models and / or image detection models can be used to perform object detection on real images to detect text content regions and / or image regions in real images. The detected text content regions and / or image regions are the object detection results.
[0070] In this embodiment of the disclosure, after performing target detection on the real image, the filling region in the real image can be further determined based on the target detection results.
[0071] Typically, when performing object detection on an image, the identified targets are marked using detection boxes, i.e., the targets in the image are bounded out using detection boxes. Therefore, in this embodiment of the disclosure, the area within the detection box can be determined as the filling area in the real image. In some optional embodiments, the detection box can be expanded outward by several pixels. For example, for any detection box, each side of the detection box is moved outward by a distance of 3 pixels to obtain a new area that is larger than the area bounded by the original detection box, and this new area is determined as the filling area in the real image, thereby preventing the detection box from overlapping the edges of text or graphics.
[0072] It is understandable that the number of filled regions is consistent with the number of text content regions and image regions contained in the real image. There can be one or more filled regions. When there are multiple filled regions, each filled region is not connected to the others.
[0073] Step 203: Fill the filled area with pixels to generate the target moiré background image.
[0074] In this embodiment of the disclosure, after determining the filling area in the real image, the filling area can be filled with pixels to obtain the target moiré background image.
[0075] This disclosure provides various pixel filling methods for filling areas with pixels. In practical applications, one method can be selected or multiple different pixel filling methods can be used to fill the same real image area to obtain multiple target moiré background images, thereby increasing the number of moiré background images. Each pixel filling method is described in detail below.
[0076] Pixel Filling Method 1: In this method, when filling a real image with pixels, the boundary pixel value of at least one boundary in the filling area can be obtained first, and then the boundary pixel value can be used to fill the filling area with pixels.
[0077] For example, the boundary pixel values of the upper boundary of the filling region can be obtained to perform pixel filling on the filling region. Typically, the detection bounding box of object detection is a regular positive direction or rectangle. Therefore, the filling region determined based on the detection bounding box is also a regular positive direction or rectangle. During pixel filling, the pixel value of each pixel on the upper boundary can be obtained to obtain the boundary pixel value of the upper boundary. Then, the boundary pixel value of the upper boundary is used to replace the pixel values of each row of pixels in the filling region row by row to complete the pixel filling of the filling region. Similarly, the boundary pixel values of the lower boundary of the filling region can be obtained to perform pixel filling on the filling region; or, the boundary pixel values of the left boundary of the filling region can be obtained to perform pixel filling on the filling region; or, the boundary pixel values of the right boundary of the filling region can be obtained to perform pixel filling on the filling region.
[0078] For example, the boundary pixel values of the upper and lower boundaries of the filling region can be obtained simultaneously for pixel filling. For instance, the upper half of the filling region can be filled with pixels according to the boundary pixel value of the upper boundary, and the lower half of the filling region can be filled with pixels according to the boundary pixel value of the lower boundary. Similarly, the boundary pixel values of the left and right boundaries of the filling region can be obtained simultaneously for pixel filling.
[0079] Pixel Filling Method Two: In this method, when filling the filled area in a real image with pixels, the non-filled area in the real image can be determined first based on the filled area. It's understood that for a real image, the remaining portion besides the filled area is considered a non-filled area. Then, the largest preset graphic region can be determined from the non-filled area of the real image. Any vertex of this preset graphic region is aligned with the corresponding vertex of the filled area, and the size of the preset graphic region is adjusted to match the size of the filled area, resulting in the target graphic region. Finally, the pixel values of the target graphic region are used to fill the filled area with pixels.
[0080] The preset graphic area can be, but is not limited to, rectangles, squares, parallelograms, etc. The following explanation uses a rectangular preset graphic area as an example to illustrate the specific implementation process of this pixel's fill method. The fill process is similar when the preset graphic area is of other shapes, and will not be elaborated here.
[0081] For example, after determining the largest rectangular region from the non-filled region, the top-left vertex of this rectangular region can be aligned with the top-left vertex of the filled region, and the size of the rectangular region can be adjusted to match the size of the filled region to obtain the target rectangular region. Specifically, during size adjustment, if the width of the rectangular region is greater than the width of the filled region, the width of the rectangular region is cropped to the same size as the width of the filled region; if the width of the rectangular region is less than the width of the filled region, the width of the rectangular region is increased to the same size as the width of the filled region. The pixel values of the increased width portion can be used to fill the boundary pixel values of the right edge of the rectangular region. That is, the width of the rectangular region can be increased by adding pixels to the right side of the rectangular region, so that the width of the supplemented rectangular region is the same as the width of the filled region, and the pixel values of the supplemented pixels are consistent with the boundary pixel values of the right edge of the rectangular region. If the height of the rectangular region is greater than the height of the filled region, the height of the rectangular region is cropped to the same size as the height of the filled region; if the height of the rectangular region is less than the height of the filled region, the height of the rectangular region is increased to the same size as the height of the filled region, and the pixel values of the increased height portion can be used to fill the boundary pixel values of the lower edge of the rectangular region. Similarly, the top-right vertex of the rectangular region can be aligned with the top-right vertex of the filling region, or the bottom-right vertex of the rectangular region can be aligned with the bottom-right vertex of the filling region, or the bottom-left vertex of the rectangular region can be aligned with the bottom-left vertex of the filling region. Then, the size of the rectangular region can be adjusted using similar methods to obtain the target rectangular region. After obtaining the target rectangular region, the pixel values of the target rectangular region can be used to fill the filling region. For example, the filling region in the real image can be replaced with the target rectangular region to obtain the target moiré background image.
[0082] It is understandable that when there are multiple filling regions, vertex alignment and filling are performed separately for each filling region.
[0083] Pixel Filling Method 3: In this method, when filling the filled area in a real image, the non-filled areas in the real image can be determined first based on the filled area. It's understood that for a real image, the remaining parts besides the filled area are all non-filled areas. Then, following a preset traversal order, the pixel values of the non-filled areas are used to fill the filled area. During pixel filling, each pixel value of the non-filled area is traversed sequentially and filled into the filled area. If the number of pixels in the non-filled area is less than the number of pixels in the filled area, after reaching the last pixel value of the non-filled area, the traversal order is repeated to fill the filled area again, that is, each pixel value of the non-filled area is traversed again and the unfilled pixels in the filled area are filled sequentially until all pixels in the filled area are filled.
[0084] The traversal order can be, for example, but is not limited to, traversing the pixel values of each column in order from top to bottom and from left to right, traversing the pixel values of each row in order from left to right and from top to bottom, and so on.
[0085] For example, taking the traversal order as traversing the pixel values of each column in order from top to bottom and from left to right as an example, when filling the filling area, the traversal starts from the top left vertex of the non-filling area. First, the pixel values of the first row and first column of the non-filling area are filled into the pixel positions of the first row and first column of the filling area. Then, the pixel values of the second row and first column of the non-filling area are filled into the pixel positions of the second row and first column of the filling area, and so on. When the last pixel value of the first column of the non-filling area (i.e., the last row of the first column) is reached, the first pixel value of the second column of the non-filling area (i.e., the first row of the second column) is continued to be traversed. Similarly, when the last pixel value of the first column of the filling area (i.e., the last row of the first column) is reached, the first pixel value of the second column of the filling area (i.e., the first row of the second column) is continued to be traversed. Following the traversal order described above, each pixel value in the non-filled area is traversed sequentially to fill the filled area. If the number of pixels in the non-filled area is greater than or equal to the number of pixels in the filled area, then all pixels in the filled area are filled, resulting in the target moiré background image. If the number of pixels in the non-filled area is less than the number of pixels in the filled area, after all pixel values in the non-filled area have been traversed, the traversal order is repeated again, starting from the top left vertex of the non-filled area, to continue filling the remaining pixels in the filled area until all pixels in the filled area are filled, resulting in the target moiré background image.
[0086] Pixel Filling Method 4: In this method, when filling the filling area in the real image with pixels, for the text content area contained in the filling area, the foreground pixels and background pixels can be determined from the text content area first. Then, based on the background pixel value of the background pixel, the foreground pixels of the text content area can be filled with pixels.
[0087] For example, when determining foreground and background pixels from a text content area, the text content area can be binarized. Through binarization, it is possible to distinguish which pixels in the text content area are foreground pixels and which pixels are background pixels, thereby obtaining the foreground and background pixels in the text content area.
[0088] In this method, different filling methods can be used when filling the foreground pixels with the background pixel values based on the background pixels.
[0089] As an optional implementation, for any foreground pixel in the text content area, the nearest target background pixel can be determined from the background pixels, and then the target background pixel value of that target background pixel can be used to fill the foreground pixel. Following this filling method, pixel filling can be performed on every foreground pixel in the text content area.
[0090] For example, when determining the nearest background pixel for any foreground pixel, the chessboard distance (also known as Chebyshev distance) method can be used to calculate the distance between the foreground pixel and each background pixel, select the nearest background pixel as the target background pixel corresponding to the foreground pixel, and use the target background pixel value of the target background pixel to fill the foreground pixel.
[0091] As an alternative implementation, for any text content area, the average value of the background pixel values of the background pixels in that text content area can be obtained, and then the average value can be used to fill the foreground pixels in that text content area.
[0092] For example, suppose the filling area contains three text content areas, namely text content area A, text content area B, and text content area C. For each text content area, taking text content area A as an example, the background pixel values of all background pixels in text content area A can be obtained, and an average value (for example, it can be denoted as the first average value) can be calculated based on the obtained background pixel values. Then, the foreground pixel values of all foreground pixels in text content area A are replaced with this average value to achieve pixel filling of foreground pixels in text content area A.
[0093] Furthermore, in one optional embodiment of this disclosure, the filled area may also include an image area, and different pixel filling methods may be used to fill the image area.
[0094] As an optional implementation, the target text content region closest to the image region can be determined from the pixel-filled text content region, and the target text content region can be scaled to obtain a target region with the same size as the image region. Then, the target region can be overlaid on the image region to perform pixel filling on the image region.
[0095] In other words, in this embodiment of the disclosure, for each image region, the target text content region closest to the image region can be found from all text content regions in the real image that have completed pixel filling. It is understood that the foreground pixels in the target text content region have all been filled. Different methods can be used to find the target text content region closest to the image region. For example, the distance between the center point coordinates of each text content region and the center point coordinates of the image region can be calculated, and the closest text content region can be selected as the target text content region. Alternatively, for each text content region, the coordinate point closest to the image region in each text content region can be found first, and then the distances between each coordinate point and the image region can be compared to determine the closest target coordinate point. The text content region to which the target coordinate point belongs is then determined as the target text content region.
[0096] Next, after determining the target text content area, it can be scaled according to the size of the image area, adjusting its dimensions (width and height) to match those of the image area, thus obtaining the target area. Then, the target area is directly overlaid on the image area to achieve pixel filling, thereby avoiding pixel-by-pixel filling and improving efficiency.
[0097] As an alternative implementation, the average background pixel value of all background pixels in the text content area can be used to fill the image area with pixels.
[0098] For example, suppose the filling area of a real image contains three text content areas, namely text content area A, text content area B, and text content area C, and two image areas, namely image area D and image area E. When filling pixels in each image area, the background pixel values of all background pixels in the three text content areas A, B, and C can be obtained. An average value (for example, it can be denoted as the second average value) can be calculated based on all the obtained background pixel values. Then, this average value is used to replace the pixel values of all pixels in the two image areas, thus achieving pixel filling of the two image areas.
[0099] It should be noted that, in the embodiments of this disclosure, when the filled area includes both text content areas and image areas, one of the two text content area filling methods and the two image area filling methods provided in this disclosure can be selected and combined to achieve pixel filling of the text content areas and image areas in the filled area. Furthermore, other methods for pixel filling of text content areas and image areas not mentioned in this disclosure should also be considered part of this disclosure.
[0100] Pixel Filling Method 5: In this method, when filling a real image with pixels to generate a target moiré background image, the model input data can be generated based on the image data of columns (i+1) to w of a preset region and the i-th prediction result output by a pre-trained moiré prediction model. The preset region includes the target filling region or a non-filled region of a preset size on the real image. The initial value of i is 0, i is a natural number, and w is the total number of columns in the target filling region. When using image data from a non-filled region to fill the target filling region with pixels, the... The number of columns in the non-filled region can be determined based on the number of columns in the target filled region. For example, a non-filled region with the same number of columns as the target filled region can be selected as the preset region. That is, the number of columns in the preset size is the same as the number of columns in the target filled region, while the number of rows in the preset size is not limited. Next, the input data of the model is input into the moiré prediction model, and the (i+1)th prediction result output by the moiré prediction model is obtained. Then, the (i+1)th column data of the target filled region in the real image is replaced with the (i+1)th prediction result, and the value of i is incremented by 1. All the above steps are repeated until i = w, indicating that the target filled region is completely filled. After that, a new target filled region is determined and pixel filling is performed. When all the filled regions in the real image have been pixel filled, a new image is obtained in which the image data of the filled regions in the real image have been replaced, which is used as the target moiré background image.
[0101] The moiré pattern prediction model is pre-trained. Its input is a w*h*c row image, where w represents the width (total number of columns), h represents the height (total number of rows), and c represents the number of channels (e.g., 3 for an RGB color image). The model outputs c sequences of height h, denoted as 1*h*c. This sequence can be appended to the input image as a new model input. The disclosed moiré pattern prediction model can employ a CRNN+Attention network structure. In practical applications, other network structures, such as those incorporating a transform structure, can also be used. During training, several (w+1)*h*c image data points can be randomly extracted from the background pixels of real image data containing moiré patterns as training samples. The first w*h*c are the input data, and the last 1*h*c are the output label data. The moiré pattern prediction model is iteratively trained using these training samples.
[0102] Typically, the input format of a row image recognition model is shown in Figure 3(a). However, considering that the model structure is convolved in the row direction and ultimately convolved into a row of data, and this scheme needs to predict the pixel values of each column of the row image, in an optional embodiment of this disclosure, in order to obtain more accurate prediction results, the input image can be adjusted, and the row image shown in Figure 3(a) can be adjusted to the form shown in Figure 3(b) as the input format of the row image recognition model. Thus, the sequence output by the moiré prediction model each time can be used as a column of data of the row image shown in Figure 3(a).
[0103] In this embodiment of the disclosure, when filling the filling area with pixels, each text content region within the filling area is filled separately. For the image region within the filling area, the image region can be split into at least one row of images, and then pixel filling is performed according to the filling method for the text content region. Therefore, in this embodiment of the disclosure, the current target filling area can be a text content region on a real image, or it can be an image region or a part of an image region on a real image. The following uses filling a text content region as an example, i.e., the target filling area is a text content region on a real image, to explain the specific process of pixel filling based on the output result of the moiré prediction model.
[0104] Exemplarily, when filling the text content area, first, i = 0. Model input data is generated based on the image data of columns 1 to w of the text content area. If the text content area is a line text image, the w-column image data needs to be converted into model input data with w rows. Then, the obtained model input data is input into the moiré prediction model, and the first prediction result output by the moiré prediction model is obtained. Next, the data of the first column of this text content area on the real image is replaced with this first prediction result, and the value of i is incremented by 1, that is, i = 0 + 1 = 1. At this time, i < w, and the above steps are repeated. That is, based on the image data of columns 2 to w of the text content area and 1 prediction result (i.e., the first prediction result) output by the moiré prediction model, model input data is generated. Among them, the 1 prediction result can be spliced on the right side of the image data of column w to obtain new model input data. Then, the newly obtained model input data is input into the moiré prediction model again, and the second prediction result output by the moiré prediction model is obtained. Next, the data of the second column of this text content area on the real image is replaced with this second prediction result, and the value of i is incremented by 1, that is, i = 1 + 1 = 2. At this time, i < w, and the above steps are repeated. That is, based on the image data of columns 3 to w of the text content area and 2 prediction results (i.e., the first prediction result and the second prediction result) output by the moiré prediction model, model input data is generated. Among them, the first prediction result can be spliced on the right side of the image data of column w, and the second prediction result can be spliced on the right side of the first prediction result to obtain new model input data. Then, the newly obtained model input data is input into the moiré prediction model again, and the third prediction result output by the moiré prediction model is obtained. Next, the data of the third column of this text content area on the real image is replaced with this third prediction result, and the value of i is incremented by 1, that is, i = 2 + 1 = 3. At this time, i < w, and the above steps are repeated until i = w. At this time, the w-column image data of this text content area on the real image are all replaced with the prediction results of the moiré prediction model, and the pixel filling of this text content area is completed.
[0105] Exemplarily, when performing pixel filling on an image area in a filled area, the image area can be split into multiple sub-areas. Among them, the number of rows of each sub-area is the same as that of the image area, and the number of columns of each sub-area is w. Then, a non-filled area with a column number of w and an unlimited number of rows (which can be a preset number of rows) can be determined from the real image as a preset area. When performing pixel filling on each sub-area, one of the sub-areas is first taken as the target filling area. First, i = 0, and model input data is generated based on the image data of the 1st to wth columns of the preset area. If the sub-area is a line text image, the w-column image data needs to be converted into model input data with w rows. Then, the obtained model input data is input into the moiré prediction model, and the first prediction result output by the moiré prediction model is obtained. Next, the data of the 1st column of the sub-area on the real image is replaced with the first prediction result, and the value of i is incremented by 1, that is, i = 0 + 1 = 1. At this time, i < w, and the above steps are repeated, that is, based on the image data of the 2nd to wth columns of the preset area, and 1 prediction result (i.e., the first prediction result) output by the moiré prediction model, model input data is generated. Among them, 1 prediction result can be spliced on the right side of the image data of the wth column to obtain new model input data. Then, the newly obtained model input data is input into the moiré prediction model again, and the second prediction result output by the moiré prediction model is obtained. Next, the data of the 2nd column of the sub-area on the real image is replaced with the second prediction result, and the value of i is incremented by 1, that is, i = 1 + 1 = 2. At this time, i < w, and the above steps are repeated, that is, based on the image data of the 3rd to wth columns of the preset area, and 2 prediction results (i.e., the first prediction result and the second prediction result) output by the moiré prediction model, model input data is generated, and the newly obtained model input data is input into the moiré prediction model again, and the third prediction result output by the moiré prediction model is obtained. Next, the data of the 3rd column of the sub-area on the real image is replaced with the third prediction result, and the value of i is incremented by 1, that is, i = 2 + 1 = 3. At this time, i < w, and the above steps are repeated until i = w. At this time, the w-column image data of the sub-area in the image area on the real image are all replaced with the prediction results of the moiré prediction model, and the pixel filling of the sub-area is completed. After that, the next sub-area in the image area can be obtained as a new target filling area, and filling can be performed according to the above similar pixel filling process until the image area is filled up.
[0106] Similarly, according to the above pixel filling method, pixel filling is performed on the filled area on the real image. When the pixel filling of all the filled areas on the real image is completed, that is, a new image in which the image data of the filled area on the real image are all replaced is obtained, and this new image can be used as the target moiré background image.
[0107] In practical applications, to improve the operating efficiency of electronic devices, multiple moiré pattern background images can be generated offline. For example, a moiré pattern material library can be pre-built, containing multiple moiré pattern background images. These moiré pattern background images can be obtained by pixel-filling a real image containing moiré patterns using at least one of the pixel-filling methods provided above. It is understood that for the same real image, using different pixel-filling methods can yield different moiré pattern background images. Therefore, this disclosure provides multiple pixel-filling methods. By employing diverse filling methods, a rich variety of moiré pattern background images can be obtained using a limited number of real images, thereby increasing the number of moiré pattern images and helping to obtain a large number of relatively realistic moiré pattern images.
[0108] The moiré pattern image generation method of this disclosure obtains a real image containing moiré patterns, performs target detection on the real image, determines the filling area in the real image, and then fills the filling area with pixels to generate a target moiré pattern background image. Thus, a moiré pattern background image with real moiré patterns can be obtained, providing data support for obtaining a more realistic moiré pattern image.
[0109] An exemplary embodiment of this disclosure also provides a moiré image generation apparatus.
[0110] Figure 4 A schematic block diagram of a moiré image generation apparatus according to an exemplary embodiment of the present disclosure is shown, such as Figure 4 As shown, the moiré image generation device 40 includes: a first acquisition module 410, a second acquisition module 420, a third acquisition module 430, and an image fusion module 440.
[0111] The first acquisition module 410 is used to acquire the grayscale image and the original image to which moiré patterns are to be added;
[0112] The second acquisition module 420 is used to acquire a target moiré pattern background image, wherein the target moiré pattern background image is generated based on a real image containing moiré patterns;
[0113] The third acquisition module 430 is used to acquire a first weight corresponding to the original image, a second weight corresponding to the target moiré background image, and a third weight corresponding to the grayscale image, wherein the first weight is greater than the third weight.
[0114] The image fusion module 440 is used to fuse the original image, the target moiré background image, and the grayscale image according to the first weight, the second weight, and the third weight to generate a moiré image.
[0115] Optionally, the second acquisition module 420 includes:
[0116] The real image acquisition unit is used to acquire real images containing moiré patterns;
[0117] A filling region determination unit is used to perform target detection on the real image and determine the filling region in the real image;
[0118] A pixel filling unit is used to fill the filling area with pixels to generate a target moiré background image.
[0119] Optionally, the pixel filling unit is further configured to:
[0120] Obtain the boundary pixel value of at least one boundary in the filled region;
[0121] The boundary pixel values are used to fill the filling area with pixels.
[0122] Optionally, the pixel filling unit is further configured to:
[0123] The preset graphic region with the largest area is determined from the non-filled region of the real image;
[0124] Align any vertex of the preset graphic region with the corresponding vertex of the filling region, and adjust the size of the preset graphic region to be consistent with the size of the filling region to obtain the target graphic region;
[0125] The pixel values of the target rectangular region are used to fill the filling area with pixels.
[0126] Optionally, the pixel filling unit is further configured to:
[0127] According to a preset traversal order, the pixel values of the non-filled areas are used to fill the filled areas with pixels;
[0128] When the number of pixels in the non-filled area is less than the number of pixels in the filled area, after traversing to the last pixel value of the non-filled area, the pixel values of the non-filled area are used to fill the filled area again according to the traversal order until all pixels in the filled area are filled.
[0129] Optionally, the filling area includes a text content area; the pixel filling unit is further configured to:
[0130] Determine the foreground and background pixels of the text content area;
[0131] Based on the background pixel values of the background pixels, the foreground pixels of the text content area are filled with pixels.
[0132] Optionally, the pixel filling unit is further configured to:
[0133] For any foreground pixel, determine the target background pixel that is closest to the foreground pixel from the background pixels, and use the target background pixel value of the target background pixel to fill the foreground pixel;
[0134] or,
[0135] The foreground pixels in the text content area are filled with pixels using the average value of the background pixel values of the background pixels in the text content area.
[0136] Optionally, the filling region further includes an image region; the pixel filling unit is further configured to:
[0137] From the pixel-filled text content area, determine the target text content area that is closest to the image area;
[0138] The target text content region is scaled to obtain a target region with the same size as the image region.
[0139] The target region is overlaid on the image region to fill the image region with pixels;
[0140] or,
[0141] The image region is pixel-filled using the average background pixel value of all background pixels in the text content region.
[0142] Optionally, the pixel filling unit is further configured to:
[0143] Based on the image data of columns (i+1) to w of the preset region and the i-th prediction result output by the pre-trained moiré prediction model, model input data is generated. The preset region includes the target filling region currently being filled or a non-filled region of a preset size on the real image. The initial value of i is 0, i is a natural number, and w is the total number of columns of the target filling region.
[0144] Input the model input data into the moiré pattern prediction model and obtain the (i+1)th prediction result output by the moiré pattern prediction model;
[0145] Replace the (i+1)th column of data in the target filling region of the real image with the (i+1)th predicted result, and increment the value of i by 1;
[0146] Repeat all the above steps until i = w, determine the new target filling area and perform pixel filling;
[0147] In response to the completion of pixel filling in the filling areas of the real image, a target moiré background image is obtained.
[0148] Optionally, the first weight has a value range of [0.4, 0.7], the second weight has a value range of [0.1, 0.5], and the third weight has a value range of [0, 0.3].
[0149] The moiré image generation apparatus provided in this disclosure can execute any moiré image generation method applicable to electronic devices provided in this disclosure, and has the corresponding functional modules and beneficial effects for executing the method. Content not described in detail in the apparatus embodiments of this disclosure can be referred to the description in any method embodiment of this disclosure.
[0150] Exemplary embodiments of this disclosure also provide an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor. The memory stores a computer program executable by the at least one processor, the computer program, when executed by the at least one processor, causing the electronic device to perform a moiré image generation method according to embodiments of this disclosure.
[0151] Exemplary embodiments of this disclosure also provide a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a computer's processor, is used to cause the computer to perform a moiré image generation method according to embodiments of this disclosure.
[0152] Exemplary embodiments of this disclosure also provide a computer program product, including a computer program, wherein, when executed by a computer's processor, the computer program is used to cause the computer to perform a moiré image generation method according to embodiments of this disclosure.
[0153] refer to Figure 5 The present invention describes a structural block diagram of an electronic device 1100 that can serve as a server or client of the present disclosure, which is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0154] like Figure 5As shown, the electronic device 1100 includes a computing unit 1101, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1102 or a computer program loaded from a storage unit 1108 into a random access memory (RAM) 1103. The RAM 1103 may also store various programs and data required for the operation of the device 1100. The computing unit 1101, ROM 1102, and RAM 1103 are interconnected via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.
[0155] Multiple components in electronic device 1100 are connected to I / O interface 1105, including: input unit 1106, output unit 1107, storage unit 1108, and communication unit 1109. Input unit 1106 can be any type of device capable of inputting information to electronic device 1100. Input unit 1106 can receive input digital or character information and generate key signal inputs related to user settings and / or function control of electronic device. Output unit 1107 can be any type of device capable of presenting information and may include, but is not limited to, a display, speaker, video / audio output terminal, vibrator, and / or printer. Storage unit 1108 may include, but is not limited to, disk and optical disk. Communication unit 1109 allows electronic device 1100 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks, and may include, but is not limited to, modems, network cards, infrared communication devices, wireless communication transceivers, and / or chipsets, such as Bluetooth™ devices, WiFi devices, WiMax devices, cellular communication devices, and / or the like.
[0156] The computing unit 1101 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 1101 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 1101 performs the various methods and processes described above. For example, in some embodiments, the moiré image generation method can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 1108. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 1100 via ROM 1102 and / or communication unit 1109. In some embodiments, the computing unit 1101 can be configured to perform the moiré image generation method by any other suitable means (e.g., by means of firmware).
[0157] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0158] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0159] As used in this disclosure, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or apparatus (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including machine-readable media that receive machine instructions as machine-readable signals. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0160] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0161] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0162] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other.
Claims
1. A method for generating moiré patterns, wherein, The method includes: Obtain the grayscale image and the original image to which moiré patterns are to be added; Obtain a target moiré pattern background image, wherein the target moiré pattern background image is generated based on a real image containing moiré patterns; Obtain a first weight corresponding to the original image, a second weight corresponding to the target moiré background image, and a third weight corresponding to the grayscale image, wherein the first weight is greater than the third weight; Based on the first weight, the second weight, and the third weight, the original image, the target moiré background image, and the grayscale image are weighted and summed to generate a moiré image.
2. The moiré pattern image generation method as described in claim 1, wherein, The acquisition of the target moiré background image includes: Obtain a realistic image containing moiré patterns; Target detection is performed on the real image to determine the filled regions in the real image; The filled area is filled with pixels to generate the target moiré background image.
3. The moiré pattern image generation method as described in claim 2, wherein, The step of filling the filled area with pixels includes: Obtain the boundary pixel value of at least one boundary in the filled region; The boundary pixel values are used to fill the filling area with pixels.
4. The moiré pattern image generation method as described in claim 2, wherein, The step of filling the filled area with pixels includes: From the non-filled areas of the real image, determine the preset graphic region with the largest area; Align any vertex of the preset graphic region with the corresponding vertex of the filling region, and adjust the size of the preset graphic region to be consistent with the size of the filling region to obtain the target graphic region; The pixel values of the target graphic region are used to fill the filling region with pixels.
5. The moiré pattern image generation method as described in claim 2, wherein, The step of filling the filled area with pixels includes: According to a preset traversal order, the pixel values of the non-filled areas of the real image are used to fill the filled areas with pixels; When the number of pixels in the non-filled area is less than the number of pixels in the filled area, after traversing to the last pixel value of the non-filled area, the pixel values of the non-filled area are used to fill the filled area again according to the traversal order until all pixels in the filled area are filled.
6. The moiré pattern image generation method as described in claim 2, wherein, The filling area includes a text content area, and the pixel filling of the filling area includes: Determine the foreground and background pixels of the text content area; Based on the background pixel values of the background pixels, the foreground pixels of the text content area are filled with pixels.
7. The moiré pattern image generation method as described in claim 6, wherein, The step of filling the foreground pixels of the text content region with pixels based on the background pixel values of the background pixels includes: For any foreground pixel, determine the target background pixel that is closest to the foreground pixel from the background pixels, and use the target background pixel value of the target background pixel to fill the foreground pixel; or, The foreground pixels in the text content area are filled with pixels using the average value of the background pixel values of the background pixels in the text content area.
8. The moiré pattern image generation method as described in claim 6, wherein, The filling region further includes an image region, and the pixel filling of the filling region includes: From the pixel-filled text content area, determine the target text content area that is closest to the image area; The target text content region is scaled to obtain a target region with the same size as the image region. The target region is overlaid on the image region to fill the image region with pixels; or, The image region is pixel-filled using the average background pixel value of all background pixels in the text content region.
9. The moiré pattern image generation method as described in claim 2, wherein, The step of filling the filled area with pixels to generate the target moiré background image includes: Based on the image data of columns (i+1) to w of the preset region and the i-th prediction result output by the pre-trained moiré prediction model, model input data is generated. The preset region includes the target filling region currently being filled or a non-filled region of a preset size on the real image. The initial value of i is 0, i is a natural number, and w is the total number of columns of the target filling region. Input the model input data into the moiré pattern prediction model and obtain the (i+1)th prediction result output by the moiré pattern prediction model; Replace the (i+1)th column of data in the target filling region of the real image with the (i+1)th predicted result, and increment the value of i by 1; Repeat all the above steps until i = w, determine the new target filling area and perform pixel filling; In response to the completion of pixel filling in the filling areas of the real image, a target moiré background image is obtained.
10. A moiré pattern image generation device, wherein, The device includes: The first acquisition module is used to acquire the grayscale image and the original image to which moiré patterns are to be added; The second acquisition module is used to acquire a target moiré pattern background image, wherein the target moiré pattern background image is generated based on a real image containing moiré patterns; The third acquisition module is used to acquire a first weight corresponding to the original image, a second weight corresponding to the target moiré background image, and a third weight corresponding to the grayscale image, wherein the first weight is greater than the third weight; The image fusion module is used to perform a weighted summation of the original image, the target moiré background image, and the grayscale image according to the first weight, the second weight, and the third weight to generate a moiré image.
11. An electronic device, comprising: processor; as well as Stored program memory, The program includes instructions that, when executed by the processor, cause the processor to perform the moiré image generation method according to any one of claims 1-9.
12. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to execute the moiré image generation method according to any one of claims 1-9.
Citation Information
Patent Citations
Method and device for removing moire patterns of image
CN110738609A
Moire picture generation method, system, device and storage medium
CN110992244A