A method, device, equipment and storage medium for constructing an image with moiré patterns
By drawing periodic lines on two images to generate images with moiré patterns, the problem of collecting moiré patterns that consumes a lot of resources is solved, and an efficient training data construction and annotation process is achieved.
Patent Information
- Application Number
- CN202011410069.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-03
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-12-03
AI Technical Summary
Collecting a large number of monitor images with moiré pattern requires a lot of manpower, material resources and time costs, which brings huge challenges to image understanding tools based on deep learning.
By creating two images with the same size as the target image and drawing periodic lines in them, an image with moiré patterns is generated. The image acquisition module, image creation module, line drawing module and image generation module are used to realize the construction of the image.
The training data set can be constructed without spending a lot of manpower, material resources and time. It provides a method to construct images with moiré patterns, reduces the cost of data collection and labeling, and improves the efficiency of training data.
Smart Images

Figure CN112562028B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method, device, equipment and storage medium for constructing an image with moiré patterns. Background Art
[0002] Moiré, also known as Moiré ripples, is an optical phenomenon first discovered by French researcher More in the 18th century. When an opaque periodic texture with transparent gaps is overlaid on another similar pattern, a large-scale spatial interference effect will occur, forming moiré. Moiré is a manifestation of the beat phenomenon. Mathematically speaking, when two equal-amplitude sine waves with similar frequencies are superimposed, the amplitude of the composite signal will change according to the difference between the two frequencies. Similarly, the beat principle also applies to spatial ripples. The superposition of stripes with slightly different spatial frequencies will also form a beat due to the difference in stripe spacing and the gradual shift of the overlapping positions.
[0003] With the development of Internet technology, image understanding has rapidly emerged and flourished. Its application has spread to every corner of the national economy and social life, and is bringing about tremendous changes in human production methods, working methods and even lifestyles. In many scenarios, the processing objects of image understanding tools are display camera images (images taken of the display screen). However, display camera images are often accompanied by serious moiré interference, which poses a huge challenge to image understanding tools.
[0004] For deep learning-based image understanding tools, in order to obtain a model with better performance, it is usually necessary to collect a large number of display images with moiré patterns. However, collecting a large number of display images with moiré patterns requires a lot of manpower, material resources and time costs. Summary of the invention
[0005] In view of this, the present application provides a method, device, equipment and storage medium for constructing images with moiré patterns, so as to solve the problem that collecting a large number of display camera images with moiré patterns requires a lot of manpower, material resources and time costs. The technical solution is as follows:
[0006] A method for constructing an image with moiré patterns, comprising:
[0007] Create two images of the same size as the target image;
[0008] Draw periodic lines on the two created images respectively to obtain two images with lines, wherein the two images with lines contain lines of the same type but different periods, and the absolute value of the period difference of the lines of the same type in the two images with lines is less than a preset value;
[0009] An image with moiré patterns is generated according to the two images with lines and the target image.
[0010] Optionally, the method for constructing an image with moiré patterns further includes:
[0011] The image to be added with moiré is enlarged by a preset multiple, and the enlarged image is used as the target image.
[0012] Optionally, the creating two images having the same size as the target image includes:
[0013] Create two solid-color images of the same size as the destination image.
[0014] Optionally, the creating two pure color images having the same size as the target image includes:
[0015] Create two pure black images of the same size as the destination image.
[0016] Optionally, drawing periodic lines on the two created images respectively includes:
[0017] Drawing the first type of lines at a first cycle on one of the created images; or, drawing the first type of lines at a first cycle and drawing other types of lines on one of the created images;
[0018] On another created image, drawing the first type of lines according to the second cycle; or, on another created image, drawing the first type of lines according to the second cycle and drawing other types of lines;
[0019] The first period is different from the second period, and an absolute value of a difference between the first period and the second period is smaller than a preset value.
[0020] Optionally, generating a target image with moiré patterns according to the two images with lines and the target image includes:
[0021] generating a moiré image based on the two images having lines;
[0022] An image with moiré patterns is generated according to the moiré pattern image and the target image.
[0023] Optionally, generating a moiré image according to the two images having lines includes:
[0024] Performing perspective transformation on one of the images with lines to obtain a transformed image with lines;
[0025] Merging another image with lines with the transformed image with lines to obtain a moiré image;
[0026] or,
[0027] Perform perspective transformation on two images with lines according to different transformation parameters to obtain two transformed images with lines;
[0028] The two transformed line images are fused to obtain a moiré image.
[0029] Optionally, generating an image with moiré patterns according to the moiré pattern image and the target image includes:
[0030] Performing perspective transformation on the target image according to target transformation parameters to obtain a transformed image of the target image, wherein the target transformation parameters are transformation parameters used when performing perspective transformation on one of the two images with lines;
[0031] An image with moiré is generated according to the moiré image and the transformed image of the target image.
[0032] Optionally, generating an image with moiré patterns according to the moiré pattern image and the transformed image of the target image includes:
[0033] Processing the background in the moiré image to white to obtain a processed image;
[0034] An image with moiré patterns is generated according to the processed image and the transformed image of the target image.
[0035] A device for constructing a moiré image comprises: an image acquisition module, an image creation module, a line drawing module and an image generation module;
[0036] The image acquisition module is used to acquire the image to which moiré patterns are to be added as a target image;
[0037] The image creation module is used to create two images with the same size as the target image;
[0038] The line drawing module is used to draw periodic lines on the two created images respectively to obtain two images with lines, wherein the two images with lines contain lines of the same type but different periods, and the absolute value of the period difference of the lines of the same type in the two images with lines is less than a preset value;
[0039] The image generation module is used to generate an image with moiré patterns according to the two images with lines and the target image.
[0040] Optionally, the apparatus for constructing an image with moiré patterns further includes: an image magnification module;
[0041] The image enlargement module is used to enlarge the image to be added with moiré by a preset multiple and use the enlarged image as the target image.
[0042] Optionally, the image generation module includes: a moiré image generation module and a moiré-banded image generation module;
[0043] The moiré image generation module is used to generate a moiré image according to the two images with lines;
[0044] The moiré-patterned image generation module is used to generate an image with moiré patterns according to the moiré-patterned image and the target image.
[0045] A device for constructing an image with moiré patterns, comprising: a memory and a processor;
[0046] The memory is used to store programs;
[0047] The processor is used to execute the program to implement each step of any one of the above-mentioned methods for constructing an image with moiré patterns.
[0048] A readable storage medium stores a computer program, and when the computer program is executed by a processor, each step of the method for constructing an image with moiré patterns described in any one of the above items is implemented.
[0049] Through the above scheme, it can be known that the method, device, equipment and storage medium for constructing an image with moiré provided by the present application first obtains the image to be added with moiré as the target image, then creates two images of the same size as the target image, then draws periodic lines on the two created images respectively, and finally generates an image with moiré based on the two images with lines and the target image. The method for constructing an image with moiré provided by the present application can construct an image with moiré based on an ordinary image, which makes it no longer necessary to spend a lot of manpower, material resources and time costs to collect training data when constructing a training data set. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0051] Figure 1 A schematic diagram of a process of constructing a moiré image provided by an embodiment of the present application;
[0052] Figure 2A schematic diagram of the moiré pattern produced by the mutual interference of two groups of lines of the same type with slightly different periods;
[0053] Figure 3 A partial enlarged view of an image with lines obtained by drawing vertical lines on a completely black image provided by an embodiment of the present application;
[0054] Figure 4 A partial enlarged view of an image with lines obtained by drawing horizontal and vertical lines on a completely black image provided by an embodiment of the present application;
[0055] Figure 5 Another schematic diagram of a process of constructing a moiré image provided by an embodiment of the present application;
[0056] Figure 6 A schematic diagram of a process for generating an image with moiré patterns based on two images with lines and a target image provided in an embodiment of the present application;
[0057] Figure 7 A partial enlarged image of an image obtained by perspective transformation of an image having lines (horizontal and vertical lines) provided in an embodiment of the present application;
[0058] Figure 8 An example of a moiré image obtained by performing perspective transformation on an image with lines and fusing it with another image with lines provided in an embodiment of the present application;
[0059] Fig. 9 An example of an image with moiré patterns constructed by using the method for constructing an image with moiré patterns provided in an embodiment of the present application;
[0060] Fig.10 A schematic diagram of the structure of a device for constructing a moiré image provided in an embodiment of the present application;
[0061] Fig.11 A schematic diagram of the structure of a device for constructing a moiré image provided in an embodiment of the present application. DETAILED DESCRIPTION
[0062] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0063] In view of the fact that collecting images with moiré patterns requires a lot of manpower, material resources and time costs, the inventor of this case thought that an image with moiré patterns could be forged using an ordinary image. However, how to use an ordinary image to forge an image with moiré patterns is the key. To this end, the inventor of this case conducted research and experiments, and finally proposed a method for constructing an image with moiré patterns through research and experiments.
[0064] The method for constructing an image with moiré proposed by the inventor of this case can be applied to devices with image acquisition and image processing functions, such as voice recorders, translators, scanners, smart phones, etc. The device with image acquisition and image processing functions acquires images through an image acquisition module, and constructs an image with moiré from the images acquired by the image processing module and the image acquisition module. The method can also be applied to a device that does not have an image acquisition function but has an image processing function. The device can establish a communication connection with a device with an image acquisition function, obtain an image acquired by the device with an image acquisition function, and construct an image with moiré based on the acquired image. Next, the method for constructing an image with moiré provided by this application is introduced through the following embodiments.
[0065] First embodiment
[0066] See also Figure 1 , shows a schematic flow chart of a method for constructing an image with moiré patterns provided in an embodiment of the present application, the method may include:
[0067] Step S101: obtaining an image to which moiré patterns are to be added as a target image.
[0068] The image to be added with moiré patterns may be any type of image obtained by any means, for example, it may be an image obtained by scanning, photographing, etc., and may be a color image, a grayscale image, a black and white image, etc.
[0069] Step S102: Create two images with the same size as the target image.
[0070] In order to simplify the image processing process, this embodiment preferably creates two pure color images of the same size as the target image. More preferably, two pure black images of the same size as the target image can be created. The fully black image is an image in which the pixel value of each pixel is 0.
[0071] Step S103: Draw periodic lines on the two created images respectively to obtain two images with lines.
[0072] It should be noted that periodic lines refer to a number of lines with equal intervals, and the period refers to the interval between two lines.
[0073] The two images with lines contain lines of the same type but different periods, and the absolute value of the period difference between the lines of the same type in the two images with lines is smaller than a preset value.
[0074] Moiré patterns are produced by the mutual interference of two sets of similar lines with slightly different periods, such as Figure 2 As shown, therefore, this embodiment draws the same type of lines with different and close periods on two images (such as two completely black images), so that a moiré image can be generated based on the two images with lines later.
[0075] There are many ways to draw periodic lines on two images respectively. This embodiment provides the following four optional ways:
[0076] Implementation method 1: On one of the created images, lines of the first type are drawn according to a first cycle, and on another created image, lines of the first type are drawn according to a second cycle.
[0077] For example, a vertical line may be drawn on one of the created images according to a first cycle, and a vertical line may be drawn on another created image according to a second cycle. Figure 3 A partial enlarged view of an image with lines obtained by drawing a vertical line on a completely black image is shown.
[0078] Implementation method 2: On one of the created images, draw lines of the first type according to the first period, on another created image, draw lines of the first type according to the second period, and draw lines of other types, where the lines of other types can be periodic lines or non-periodic lines.
[0079] For example, horizontal lines may be drawn on one of the created images according to a first cycle, and horizontal lines and vertical lines (ie, a grid) may be drawn on another created image according to a second cycle. Figure 4 A partial enlarged view of an image with lines obtained by drawing horizontal and vertical lines on a completely black image is shown.
[0080] Implementation method three: on one of the created images, draw the first type of lines according to the first period, and draw other types of lines; on the other created image, draw the first type of lines according to the second period. The other types of lines can be periodic lines or non-periodic lines.
[0081] For example, horizontal and vertical lines may be drawn on one of the created images according to a first cycle, and horizontal lines may be drawn on another created image according to a second cycle.
[0082] Implementation method 4: On one of the created images, draw lines of the first type according to the first period and draw lines of other types, and on another created image, draw lines of the first type according to the second period and draw lines of other types. The lines of other types may be periodic lines or non-periodic lines.
[0083] For example, horizontal and vertical lines may be drawn on one of the created completely black images according to a first cycle, and horizontal and vertical lines may be drawn on another created image according to a second cycle.
[0084] In the above four methods, the first period is different from the second period, and the absolute value of the difference between the first period and the second period is less than or equal to the preset value. Assuming that the first period is T1 and the second period is T2, optionally, the preset value can be 4, T2 can be equal to T1+1, T2 can also be equal to T1+1, T2 can also be equal to T1+4, and T1 can be 16 pixels.
[0085] It should be noted that no matter which method is used to draw the lines on the two created images, it is sufficient as long as the two images after drawing contain at least one line of the same type and with a similar period.
[0086] Step S104: Generate an image with moiré patterns according to the two images with lines and the target image.
[0087] The method for constructing an image with moiré provided in an embodiment of the present application first obtains an image to which moiré is to be added as a target image, then creates two images of the same size as the target image, then draws periodic lines on the two created images respectively, and finally generates an image with moiré according to the two images with lines and the target image. The method for constructing an image with moiré provided in an embodiment of the present application can construct an image with moiré based on an ordinary image, which makes it unnecessary to spend a lot of manpower, material resources and time costs to collect training data when constructing a training data set.
[0088] Second embodiment
[0089] It can be seen from the above embodiments that the method for constructing an image with moiré provided in the above embodiments directly fuses the moiré onto the image to which the moiré is to be added, that is, the image to which the moiré is to be added is used as the target image for subsequent processing. However, considering that the moiré is directly fused onto the image to which the moiré is to be added, the size ratio of the camera's photosensitive unit and the pixel array gap of the display cannot be simulated, resulting in the final constructed image with moiré not being realistic enough. In order to make the final constructed image with moiré more realistic, this embodiment provides another implementation method of the method for constructing an image with moiré.
[0090] See also Figure 5, another schematic flow chart of a method for constructing a moiré image is shown, which may include:
[0091] Step S501: obtaining an image to which moiré patterns are to be added.
[0092] The image to be added with moiré patterns may be any type of image obtained by any means, for example, it may be an image obtained by scanning, photographing, etc., and may be a color image, a grayscale image, a black and white image, etc.
[0093] Step S502: Enlarging the image to be added with moiré by a preset multiple to obtain an enlarged image as a target image.
[0094] The magnification factor of the image to be added with moiré can be determined according to the size ratio of the camera photosensitive unit and the pixel array gap of the display. For example, if the size ratio of the camera photosensitive unit and the pixel array gap of the display is close to 4:1, the image to be added with moiré can be magnified 4 times.
[0095] Step S503: Create two images with the same size as the target image.
[0096] Preferably, two pure color images with the same size as the target image may be created, and more preferably, two pure black images with the same size as the target image may be created.
[0097] Step S504: Draw periodic lines on the two drawn images respectively to obtain two images with lines.
[0098] The specific implementation process and related explanations of this step can be found in the specific implementation process and related explanations of step S103 in the above embodiment, which will not be described in detail in this embodiment.
[0099] Step S505: Generate an image with moiré patterns according to the two images with lines and the target image.
[0100] The method for constructing an image with moiré provided in an embodiment of the present application first obtains an image to which moiré is to be added, then enlarges the image to which moiré is to be added by a preset multiple, uses the enlarged image as a target image, then creates two images of the same size as the target image, then draws periodic lines on the two created images respectively, and finally generates an image with moiré according to the two images with lines and the target image. The method for constructing an image with moiré provided in an embodiment of the present application can construct a more realistic image with moiré based on an ordinary image, which makes it no longer necessary to spend a lot of manpower, material resources and time costs to collect training data when constructing a training data set.
[0101] Third embodiment
[0102] This embodiment introduces the implementation process of “generating an image with moiré patterns according to two images with lines and a target image” in the above embodiment.
[0103] See also Figure 6 , shows a schematic flow chart of generating an image with moiré patterns according to two images with lines and a target image, which may include:
[0104] Step S601: generating a moiré image according to two images having lines.
[0105] There are many implementation methods for generating a moiré image based on two images with lines. This embodiment provides the following three optional implementation methods:
[0106] The first implementation method:
[0107] The weighted sum of two images with lines is the moiré image.
[0108] Considering that the moiré image obtained based on the first implementation manner may not be realistic enough, this embodiment provides the following second and third implementation manners:
[0109] The second implementation method:
[0110] Step S601 - a1 , performing perspective transformation on one of the images with lines to obtain a transformed image with lines.
[0111] See also Figure 7 , shows a partially enlarged view of an image obtained after perspective transformation of an image with lines (horizontal and vertical lines).
[0112] Step S601 - a2: Fusing another image with lines with the transformed image with lines to obtain a moiré image.
[0113] Specifically, the weighted sum of the other image with lines and the transformed image with lines can be used to obtain the moiré image. Optionally, the weight corresponding to the other image with lines and the weight corresponding to the transformed image with lines can be the same, for example, both are 0.5. Of course, the weight corresponding to the other image with lines and the weight corresponding to the transformed image with lines can also be different. Figure 8 , which shows a schematic diagram of a moiré image obtained by weighted summing another image with lines and the transformed image with lines based on the same weights.
[0114] The second implementation method:
[0115] Step S601-b1, performing perspective transformation on the two images with lines according to different transformation parameters, to obtain two transformed images with lines.
[0116] Step S601 - b2: merge the two transformed line images to obtain a moiré image.
[0117] Specifically, the weighted sum of the two transformed line images is a moiré image, wherein the weights corresponding to the two transformed line images can be the same, or can be different, and can be set according to actual conditions.
[0118] Step S602: Generate a target image with moiré patterns according to the moiré pattern image and the target image.
[0119] There are multiple ways to generate a target image with moiré patterns according to the moiré pattern image and the target image. In one possible implementation, the following method is used:
[0120] The moiré image can be directly fused with the target image to obtain a fused image. If the target image is an image to be added with moiré, the fused image is the final constructed image with moiré. If the target image is an image to be added with moiré after being magnified by a preset multiple, the fused image is reduced by a preset multiple, and the reduced image is the final constructed image with moiré. The moiré image and the target image can be fused by weighted summing of the moiré image and the target image, and the weights corresponding to the moiré image and the target image can be set according to actual conditions.
[0121] Considering that in real scenes, when a camera is used to shoot an object, the object has perspective deformation. In order to simulate the relationship between such deformation and moiré, this embodiment provides another implementation method for generating a target image with moiré according to a moiré image and a target image:
[0122] Step S6021: Perform perspective transformation on the target image according to the target transformation parameters to obtain a transformed image of the target image.
[0123] It should be noted that performing perspective transformation on the target image can simulate the projection relationship of the display screen on the camera's photosensitive unit.
[0124] The target transformation parameters based on which the perspective transformation of the target image is performed are transformation parameters used when the perspective transformation of one of the two images with lines is performed.
[0125] Assume that two images with lines are I pattern1 and I pattern2, as mentioned above, when generating a moiré image, one of the two images with lines can be transformed into a perspective, for example, pattern1 Based on the transformation parameter 1, the perspective transformation can also be performed on two images with lines based on different transformation parameters. For example, pattern1 Based on the transformation parameter 1, a perspective transformation is performed on I pattern2 Based on the perspective transformation parameter 2, if only I pattern1 The target transformation parameter in step S5021 is transformation parameter 1. pattern1 and I pattern2 If perspective transformation is performed on both, the target transformation parameter can be transformation parameter 1 or transformation parameter 2.
[0126] Step S6022: Generate an image with moiré patterns according to the moiré pattern image and the transformed image of the target image.
[0127] Specifically, the process of generating an image with moiré patterns according to the moiré pattern image and the transformed image of the target image includes:
[0128] Step S6022-1: Process the background in the moiré image to white to obtain a processed image.
[0129] Assuming that the two images created are completely black images, the moiré image can be inverted to obtain a processed image. The moiré image is inverted, that is, for each pixel in the moiré image, the pixel value of the pixel is subtracted from 255.
[0130] Step S6022-2: Generate an image with moiré patterns based on the processed image and the transformed image of the target image.
[0131] Specifically, the processed image is fused with the transformed image of the target image to obtain a fused image; if the target image is an image to which moiré is to be added, the fused image is the final constructed image with moiré; if the target image is an image obtained by magnifying the image to which moiré is to be added by a preset multiple, the fused image is reduced by a preset multiple, and the reduced image is the final constructed image with moiré; the final constructed image with moiré has the same size as the image to which moiré is to be added. Fig. 9 A schematic diagram showing a constructed target image with moiré patterns is shown.
[0132] The processed image and the transformed image of the target image may be fused by weighted summing the processed image and the transformed image of the target image, and the weighted summed image is the fused image. Optionally, the weight corresponding to the processed image is the same as the weight corresponding to the transformed image of the target image. Of course, the weight corresponding to the processed image may be different from the weight corresponding to the transformed image of the target image, and the weights corresponding to the two may be set according to specific circumstances.
[0133] For any type of image acquired through any means, an image with moiré patterns can be constructed through the method for constructing an image with moiré patterns provided by the above embodiment. This makes it unnecessary to collect a large number of images with moiré patterns in a time-consuming and laborious manner. In addition, if the target image used to construct the image with moiré patterns is an image with a label, the constructed image with moiré patterns can directly use the label of the target image. In this way, the process of manually labeling the image with moiré patterns is avoided, thereby reducing the labeling time and labeling cost.
[0134] Fourth embodiment
[0135] An embodiment of the present application also provides a device for constructing an image with moiré patterns. The device for constructing an image with moiré patterns provided in the embodiment of the present application is described below. The device for constructing an image with moiré patterns described below and the method for constructing an image with moiré patterns described above can refer to each other.
[0136] See also Fig.10 , shows a schematic diagram of the structure of a device for constructing a moiré image provided in an embodiment of the present application, which may include: an image acquisition module 1001, an image creation module 1002, a line drawing module 1003 and an image generation module 1004.
[0137] The image acquisition module 1001 is used to acquire an image to which moiré patterns are to be added as a target image.
[0138] The image creation module 1002 is used to create two images with the same size as the target image.
[0139] The line drawing module 1003 is used to draw periodic lines on the two created images respectively to obtain two images with lines.
[0140] The two images with lines contain lines of the same type but different periods, and the absolute value of the period difference between the lines of the same type in the two images with lines is smaller than a preset value.
[0141] The image generation module 1004 is configured to generate an image with moiré patterns according to the two images with lines and the target image.
[0142] Optionally, the apparatus for constructing an image with moiré patterns provided in the embodiment of the present application may further include: an image magnification module.
[0143] The image enlargement module is used to enlarge the image to be added with moiré by a preset multiple and use the enlarged image as the target image.
[0144] Optionally, the image creation module 1002 is specifically configured to create two pure color images of the same size as the target image.
[0145] Optionally, the image creation module 1002 is specifically configured to create two pure black images of the same size as the target image.
[0146] Optionally, the line drawing module 1003 is specifically used to draw the first type of lines according to the first cycle on one of the created images, or to draw the first type of lines according to the first cycle on one of the created images and draw other types of lines; to draw the first type of lines according to the second cycle on another created image, or to draw the first type of lines according to the second cycle on another created image and draw other types of lines.
[0147] The first period is different from the second period, and an absolute value of a difference between the first period and the second period is smaller than a preset value.
[0148] Optionally, the image generation module 1004 includes: a moiré image generation module and a moiré-banded image generation module.
[0149] The moiré image generation module is used to generate a moiré image according to the two images with lines.
[0150] The moiré-patterned image generation module is used to generate an image with moiré patterns according to the moiré-patterned image and the target image.
[0151] Optionally, the moiré image generation module is specifically used to perform perspective transformation on one of the images with lines to obtain a transformed image with lines, and fuse the other image with lines with the transformed image with lines to obtain a moiré image; or, perform perspective transformation on two images with lines according to different transformation parameters to obtain two transformed images with lines, and fuse the two transformed images with lines to obtain a moiré image.
[0152] Optionally, a moiré image generation module is specifically used to perform a perspective transformation on the target image according to a target transformation parameter to obtain a transformed image of the target image, and to generate an image with moiré based on the moiré image and the transformed image of the target image.
[0153] The target transformation parameter is a transformation parameter used when performing perspective transformation on one of the two images with lines.
[0154] Optionally, when the moiré image generation module generates the moiré image based on the moiré image and the transformed image of the target image, the module is specifically used to process the background in the moiré image into white to obtain a processed image, and generate the moiré image based on the processed image and the transformed image of the target image.
[0155] The apparatus for constructing an image with moiré provided in the embodiment of the present application can construct an image with moiré based on an ordinary image, which eliminates the need to spend a lot of manpower, material resources and time to collect training data when constructing a training data set.
[0156] Fifth embodiment
[0157] The present application also provides a device for constructing a moiré image. Fig.11 , shows a schematic diagram of the structure of the device for constructing a moiré image, the device may include: at least one processor 1101, at least one communication interface 1102, at least one memory 1103 and at least one communication bus 1104;
[0158] In the embodiment of the present application, the number of the processor 1101, the communication interface 1102, the memory 1103, and the communication bus 1104 is at least one, and the processor 1101, the communication interface 1102, and the memory 1103 communicate with each other through the communication bus 1104;
[0159] The processor 1101 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention;
[0160] The memory 1103 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory;
[0161] The memory stores a program, and the processor can call the program stored in the memory, wherein the program is used to:
[0162] Obtain an image to which moiré patterns are to be added as a target image;
[0163] Create two images of the same size as the target image;
[0164] Draw periodic lines on the two created images respectively to obtain two images with lines, wherein the two images with lines contain lines of the same type but different periods, and the absolute value of the period difference of the lines of the same type in the two images with lines is less than a preset value;
[0165] An image with moiré patterns is generated according to the two images with lines and the target image.
[0166] Optionally, the detailed functions and extended functions of the program may refer to the above description.
[0167] Sixth embodiment
[0168] The embodiment of the present application further provides a readable storage medium, which may store a program suitable for execution by a processor, wherein the program is used to:
[0169] Obtain an image to which moiré patterns are to be added as a target image;
[0170] Create two images of the same size as the target image;
[0171] Draw periodic lines on the two created images respectively to obtain two images with lines, wherein the two images with lines contain lines of the same type but different periods, and the absolute value of the period difference of the lines of the same type in the two images with lines is less than a preset value;
[0172] An image with moiré patterns is generated according to the two images with lines and the target image.
[0173] Optionally, the detailed functions and extended functions of the program may refer to the above description.
[0174] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0175] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0176] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for constructing an image with moiré patterns, characterized in that: include: Acquire an image to which moiré patterns are to be added, and magnify the image to which moiré patterns are to be added by a preset multiple, and use the magnified image as a target image; wherein the magnification multiple of the image to which moiré patterns are to be added is determined according to the size ratio of the camera photosensitive unit and the pixel array gap of the display; Create two images of the same size as the target image; Draw periodic lines on the two created images respectively to obtain two images with lines, wherein the two images with lines contain lines of the same type but different periods, and the absolute value of the period difference of the lines of the same type in the two images with lines is less than a preset value, so as to ensure that the two images after drawing contain at least one line of the same type and close period; An image with moiré patterns is generated according to the two images with lines and the target image.
2. The method for constructing an image with moiré patterns according to claim 1, characterized in that: The step of creating two images having the same size as the target image comprises: Create two solid-color images of the same size as the destination image.
3. The method for constructing an image with moiré patterns according to claim 2, characterized in that: The step of creating two pure color images having the same size as the target image comprises: Create two pure black images of the same size as the destination image.
4. The method for constructing an image with moiré patterns according to claim 1, characterized in that: The step of drawing periodic lines on the two created images respectively includes: Drawing the first type of lines at a first cycle on one of the created images; or, drawing the first type of lines at a first cycle and drawing other types of lines on one of the created images; On another created image, drawing the first type of lines according to the second cycle; or, on another created image, drawing the first type of lines according to the second cycle and drawing other types of lines; The first period is different from the second period, and an absolute value of a difference between the first period and the second period is smaller than a preset value.
5. The method for constructing an image with moiré patterns according to claim 1, characterized in that: The step of generating a target image with moiré patterns according to the two images with lines and the target image comprises: generating a moiré image based on the two images having lines; An image with moiré patterns is generated according to the moiré pattern image and the target image.
6. The method for constructing an image with moiré patterns according to claim 5, characterized in that: The step of generating a moiré image according to the two images having lines comprises: Performing perspective transformation on one of the images with lines to obtain a transformed image with lines; Merging another image with lines with the transformed image with lines to obtain a moiré image; or, Perform perspective transformation on two images with lines according to different transformation parameters to obtain two transformed images with lines; The two transformed line images are fused to obtain a moiré image.
7. The method for constructing an image with moiré patterns according to claim 6, characterized in that: The step of generating an image with moiré patterns according to the moiré pattern image and the target image includes: Performing perspective transformation on the target image according to target transformation parameters to obtain a transformed image of the target image, wherein the target transformation parameters are transformation parameters used when performing perspective transformation on one of the two images with lines; An image with moiré is generated according to the moiré image and the transformed image of the target image.
8. The method for constructing an image with moiré patterns according to claim 7, characterized in that: The step of generating an image with moiré patterns according to the moiré pattern image and the transformed image of the target image comprises: Processing the background in the moiré image to white to obtain a processed image; An image with moiré patterns is generated according to the processed image and the transformed image of the target image.
9. A device for constructing a moiré image, characterized in that: include: An image acquisition module, an image magnification module, an image creation module, a line drawing module and an image generation module; The image acquisition module is used to acquire the image to which moiré patterns are to be added; The image magnification module is used to magnify the image to be added with moiré by a preset multiple and use the magnified image as the target image; wherein the magnification multiple of the image to be added with moiré is determined according to the size ratio of the camera photosensitive unit and the pixel array gap of the display; The image creation module is used to create two images with the same size as the target image; The line drawing module is used to draw periodic lines on the two created images respectively to obtain two images with lines, wherein the two images with lines contain lines of the same type but different periods, and the absolute value of the period difference of the lines of the same type in the two images with lines is less than a preset value, so as to ensure that the two images after drawing contain at least one line of the same type and close period; The image generation module is used to generate an image with moiré patterns according to the two images with lines and the target image.
10. The device for constructing a moiré image according to claim 9, characterized in that: The image generation module includes: a moiré image generation module and a moiré-banded image generation module; The moiré image generation module is used to generate a moiré image according to the two images with lines; The moiré-patterned image generation module is used to generate an image with moiré patterns according to the moiré-patterned image and the target image.
11. A device for constructing a moiré image, characterized in that: include: Memory and processor; The memory is used to store programs; The processor is used to execute the program to implement each step of the method for constructing an image with moiré patterns according to any one of claims 1 to 8.
12. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the method for constructing an image with moiré patterns as claimed in any one of claims 1 to 8 is implemented.
