An image processing method, apparatus, device and storage medium
Patent Information
- Application Number
- CN202510155299.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-12
- Publication Date
- 2026-11-03
- Estimated Expiration
- 2045-02-12
AI Technical Summary
In existing technologies, the generation efficiency of game level images is low, relying on the personal experience of designers and the efficiency of manual verification is low, resulting in the need for repeated debugging in the image generation process.
By acquiring image configuration information, including generation and verification strategies, an initial image is automatically generated and verified until the verification requirements are met, at which point it is used as the target image.
It automatically generates and verifies images without relying on designers' experience, significantly improving image generation efficiency, reducing manual intervention, and accurately obtaining the images expected by designers.
Smart Images

Figure CN120079104B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to an image processing method, apparatus, device, and storage medium. Background Technology
[0002] Currently, in the field of game design, images used to represent game levels are created by combining different elements. As game levels increase, the game difficulty generally increases as well; therefore, the images corresponding to game levels become more complex and diverse.
[0003] In practical applications, images are typically generated by designers based on their personal experience. However, this method demands a high level of skill from the designers. If errors occur, the image generation process requires repeated verification and debugging to obtain the desired image. Manual verification, however, is inefficient, resulting in low overall image generation efficiency. Summary of the Invention
[0004] This application provides an image processing method, apparatus, device, and storage medium to improve image generation efficiency.
[0005] In a first aspect, embodiments of this application provide an image processing method, including:
[0006] Obtain image configuration information, which includes a generation strategy and a verification strategy for the target image, wherein the generation strategy is used to satisfy the verification strategy;
[0007] An initial image is generated based on the aforementioned generation strategy;
[0008] Based on the verification strategy and the initial image, the generation strategy is verified to obtain the verification result;
[0009] If the verification result indicates that the generation strategy has passed the verification, the initial image is used as the target image.
[0010] Optionally, the generation strategy is used to indicate that the target image includes multiple layers, the number of first elements, the colors of multiple second elements, the number of second elements of different colors, the colors of multiple third elements, and the number of third elements of different colors in each layer, the multiple second elements and the multiple third elements are respectively located in the multiple first elements, the number of multiple second elements and the multiple third elements are equal, and the multiple third elements are used to fill the multiple second elements one by one;
[0011] The generation of the initial image based on the generation strategy includes:
[0012] For the first layer among the multiple layers, start traversing from the second element of the first element under the first layer, and fill the second element with the third elements of the first color among the multiple third elements, until all the third elements of the first color are filled into the second element;
[0013] Continue to fill the second elements with the third elements that belong to the second color among the plurality of third elements until all the plurality of second elements are filled with third elements, and a first initial image is obtained.
[0014] Optionally, for a target third element among the plurality of third elements, after obtaining the first initial image, the method further includes:
[0015] Based on the first enclosing polygon corresponding to the target third element and the second enclosing polygon corresponding to the target first element where the target third element is located, the separation axis algorithm is used to determine whether the target third element satisfies the intersection condition. The intersection condition is used to indicate that the first enclosing polygon and the second enclosing polygon intersect.
[0016] If the target third element satisfies the intersection condition, any third element with a different color from the target third element is determined from the first element in the layer above the layer where the target first element is located as the candidate third element corresponding to the target third element.
[0017] The candidate third element corresponding to the target third element is swapped with the target third element until all the third elements that satisfy the intersection condition are swapped with the candidate third element corresponding to the third element that satisfies the intersection condition, thus obtaining the second initial image.
[0018] Optionally, the method further includes:
[0019] Determine the quantity of the third element corresponding to different colors in each layer;
[0020] Based on the number of third elements of different colors in each layer, a fourth element of the same color is assigned to the third elements of the same color in each layer. Each of the multiple fourth elements is used to be filled by a preset number of third elements of the same color when it is allowed to be used.
[0021] Based on the color arrangement order of the multiple third elements in the multiple layers, the multiple fourth elements are arranged to obtain a third initial image.
[0022] Optionally, the verification strategy includes the difficulty coefficients corresponding to the plurality of third elements and the first and second difficulty coefficients corresponding to the plurality of fourth elements;
[0023] The step of verifying the generation strategy based on the verification strategy and the initial image to obtain the verification result includes:
[0024] Based on the layer number of each third element and the difficulty coefficient corresponding to each third element, the difficulty weight corresponding to each third element is determined;
[0025] In the case where the plurality of fourth elements includes both allowed and disallowed fourth elements, the first difficulty coefficient is used as the difficulty weight corresponding to the allowed fourth element, and the difficulty weight corresponding to the disallowed fourth element is determined based on the order of the disallowed fourth elements among the plurality of fourth elements, the first difficulty coefficient, and the second difficulty coefficient.
[0026] Based on the difficulty weight corresponding to each of the third elements, the difficulty weight corresponding to each of the fourth elements, and the initial image, the generation strategy is validated to obtain the validation result.
[0027] Optionally, the step of using the initial image as the target image when the verification result indicates that the generation strategy has passed verification includes:
[0028] If the verification result indicates that the generation strategy has failed the verification, the generation strategy is adjusted to obtain the adjusted generation strategy.
[0029] A new initial image is generated based on the adjusted generation strategy, and the new initial image is continuously verified to obtain a new verification result. When the new verification result indicates that the adjusted generation strategy has passed the verification, the new initial image is used as the target image.
[0030] Secondly, embodiments of this application provide an image processing apparatus, including:
[0031] An information acquisition module is used to acquire image configuration information, which includes a generation strategy and a verification strategy for a target image, wherein the generation strategy is used to satisfy the verification strategy.
[0032] The image generation module is used to generate an initial image based on the generation strategy;
[0033] The image verification module is used to verify the generation strategy based on the verification strategy and the initial image, and obtain the verification result.
[0034] An image determination module is used to use the initial image as the target image if the verification result indicates that the generation strategy has passed verification.
[0035] Optionally, the generation strategy is used to indicate that the target image includes multiple layers, the number of first elements, the colors of multiple second elements, the number of second elements of different colors, the colors of multiple third elements, and the number of third elements of different colors in each layer, the multiple second elements and the multiple third elements are respectively located in the multiple first elements, the number of multiple second elements and the multiple third elements are equal, and the multiple third elements are used to fill the multiple second elements one by one;
[0036] The image generation module is specifically used for:
[0037] For the first layer among the multiple layers, start traversing from the second element of the first element under the first layer, and fill the second element with the third elements of the first color among the multiple third elements, until all the third elements of the first color are filled into the second element;
[0038] Continue to fill the second elements with the third elements that belong to the second color among the plurality of third elements until all the plurality of second elements are filled with third elements, and a first initial image is obtained.
[0039] Optionally, for a target third element among the plurality of third elements, the image generation module is further configured to:
[0040] Based on the first enclosing polygon corresponding to the target third element and the second enclosing polygon corresponding to the target first element where the target third element is located, the separation axis algorithm is used to determine whether the target third element satisfies the intersection condition. The intersection condition is used to indicate that the first enclosing polygon and the second enclosing polygon intersect.
[0041] If the target third element satisfies the intersection condition, any third element with a different color from the target third element is determined from the first element in the layer above the layer where the target first element is located as the candidate third element corresponding to the target third element.
[0042] The candidate third element corresponding to the target third element is swapped with the target third element until all the third elements that satisfy the intersection condition are swapped with the candidate third element corresponding to the third element that satisfies the intersection condition, thus obtaining the second initial image.
[0043] Optionally, the image generation module is further configured to:
[0044] Determine the quantity of the third element corresponding to different colors in each layer;
[0045] Based on the number of third elements of different colors in each layer, a fourth element of the same color is assigned to the third elements of the same color in each layer. Each of the multiple fourth elements is used to be filled by a preset number of third elements of the same color when it is allowed to be used.
[0046] Based on the color arrangement order of the multiple third elements in the multiple layers, the multiple fourth elements are arranged to obtain a third initial image.
[0047] Optionally, the verification strategy includes the difficulty coefficients corresponding to the plurality of third elements and the first and second difficulty coefficients corresponding to the plurality of fourth elements;
[0048] The image verification module is specifically used for:
[0049] Based on the layer number of each third element and the difficulty coefficient corresponding to each third element, the difficulty weight corresponding to each third element is determined;
[0050] In the case where the plurality of fourth elements includes both allowed and disallowed fourth elements, the first difficulty coefficient is used as the difficulty weight corresponding to the allowed fourth element, and the difficulty weight corresponding to the disallowed fourth element is determined based on the order of the disallowed fourth elements among the plurality of fourth elements, the first difficulty coefficient, and the second difficulty coefficient.
[0051] Based on the difficulty weight corresponding to each of the third elements, the difficulty weight corresponding to each of the fourth elements, and the initial image, the generation strategy is validated to obtain the validation result.
[0052] Optionally, the image determination module is specifically used for:
[0053] If the verification result indicates that the generation strategy has failed the verification, the generation strategy is adjusted to obtain the adjusted generation strategy.
[0054] A new initial image is generated based on the adjusted generation strategy, and the new initial image is continuously verified to obtain a new verification result. When the new verification result indicates that the adjusted generation strategy has passed the verification, the new initial image is used as the target image.
[0055] Thirdly, embodiments of this application provide an electronic device, the device including: a processor, a memory, and a system bus;
[0056] The processor and the memory are connected via the system bus;
[0057] The memory is used to store a program, the program including instructions that, when executed by the processor, cause the processor to perform any of the implementation steps of the image processing method described above.
[0058] Fourthly, embodiments of this application provide a computer-readable storage medium storing instructions that, when executed on an electronic device, cause the electronic device to perform any of the implementation steps of the above-described image processing method.
[0059] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:
[0060] In this embodiment, image configuration information can first be obtained. This image configuration information may include a generation strategy and a verification strategy for the target image, whereby the generation strategy satisfies the verification strategy. Accordingly, an initial image can be generated based on the generation strategy, and the generation strategy is verified based on the verification strategy and the initial image to obtain a verification result. If the verification result indicates that the generation strategy has passed verification, the initial image can be used as the target image. In this way, after obtaining the image configuration information, the initial image can be automatically generated without relying on the designer's personal experience. Furthermore, the generated initial image can be automatically verified without manual debugging by the designer, thereby reducing human intervention and accurately obtaining the image desired by the designer in an automated and intelligent manner, significantly improving image generation efficiency. Attached Figure Description
[0061] Figure 1 A flowchart illustrating an image processing method provided in an embodiment of this application;
[0062] Figure 2 A schematic diagram of a target image provided in an embodiment of this application;
[0063] Figure 3 This is a schematic diagram of the structure of an image processing device provided in an embodiment of this application. Detailed Implementation
[0064] As mentioned earlier, in practical applications, images are usually generated by designers based on their personal experience. However, this method requires a high level of skill from the designers. If errors occur, the image generation process requires repeated verification and debugging to obtain the desired image. Manual verification is inefficient, resulting in low overall image generation efficiency.
[0065] To address the aforementioned problems, this application provides an image processing method that includes: firstly, acquiring image configuration information, wherein the image configuration information may include a generation strategy and a verification strategy for a target image, the generation strategy being used to satisfy the verification strategy. Accordingly, an initial image is generated based on the generation strategy, and the generation strategy is verified based on the verification strategy and the initial image to obtain a verification result. Thus, if the verification result indicates that the generation strategy has passed verification, the initial image can be used as the target image.
[0066] In this way, after obtaining the image configuration information, the initial image can be automatically generated without relying on the designer's personal experience. Then, the generated initial image can be automatically verified without the need for manual debugging by the designer. This reduces human intervention and obtains the image expected by the designer in an automated and intelligent way, significantly improving the efficiency of image generation.
[0067] It should be noted that the embodiments of this application do not limit the executing entity of the image processing method. For example, the image processing method of the embodiments of this application can be applied to image processing devices such as terminal devices or servers. The terminal device can be an electronic device such as a smartphone, computer, personal digital assistant (PDA), or tablet computer. The server can be a standalone server, a cluster server, or a cloud server.
[0068] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0069] Figure 1 This is a flowchart illustrating an image processing method provided in an embodiment of this application. (In conjunction with...) Figure 1 As shown, the image processing method provided in this application embodiment uses a corresponding image processing device as the execution subject to describe the specific implementation of the scheme. The image processing method may include the following steps S101-S104.
[0070] S101: Obtain image configuration information, which includes a generation strategy and a verification strategy for the target image. The generation strategy is used to satisfy the verification strategy.
[0071] In this embodiment, the generation strategy refers to a strategy used to generate an image, the ultimate goal of which is to generate the desired target image. The verification strategy is used to verify the generation strategy, the ultimate goal of which is to ensure that the final generated target image meets the generation requirements indicated by the generation strategy. Taking a game design scenario as an example, these generation requirements might be, for example, the game difficulty or game duration indicated by the image.
[0072] Based on this, as an example, the above generation strategy can indicate that the final desired target image includes multiple layers, the number of first elements under each of the multiple layers, the colors of multiple second elements, the number of second elements of different colors, the colors of multiple third elements, and the number of third elements of different colors. Furthermore, the multiple second elements and the multiple third elements are respectively located within the multiple first elements, the number of multiple second elements and the number of multiple third elements are equal, and the multiple third elements are used to fill the multiple second elements in a one-to-one correspondence. Wherein, with... Figure 2 Taking the final generated target image as an example, the first element is a disk-shaped structure including the second element, and the second element is a hole (since the second element in the target image has been filled by the third element, therefore...). Figure 2 The second element is not shown in the diagram, and the third element is a thumbtack. Therefore, the third element can be filled into the second element one by one.
[0073] Furthermore, the aforementioned verification strategy may include a difficulty coefficient corresponding to each of the third elements and a first difficulty coefficient and a second difficulty coefficient corresponding to multiple fourth elements. Taking a game design scenario as an example, the difficulty coefficient corresponding to the third element refers to the game difficulty coefficient corresponding to the image generated based on that difficulty coefficient; the first difficulty coefficient and the second difficulty coefficient corresponding to the fourth element are the game difficulty coefficients corresponding to the images generated based on that first difficulty coefficient or the second difficulty coefficient. For ease of understanding, please refer to the description below for details regarding the verification strategy; it will not be elaborated upon here.
[0074] S102: Generate an initial image based on the generation strategy.
[0075] As one possible implementation, in the process of generating the initial image based on the generation strategy, for the first layer among multiple layers, one can start by traversing from the second element of the first element under the first layer, and fill the second element with the third elements of the first color among multiple third elements, until all the third elements of the first color are filled into the second element. Then, one can continue to fill the second element with the third elements of the second color among multiple third elements, until all the second elements are filled with third elements, thus obtaining the first initial image.
[0076] For example, still using Figure 2 For example, we can start by traversing the holes of the top-level pegboard across multiple layers, filling the holes with pegs of the same color sequentially until all pegs of that color are used up. Then, we fill the holes with pegs of other colors sequentially until all pegs are filled. Since the total number of holes is the same as the total number of pegs, all holes are now filled, resulting in the first initial image. Furthermore, after obtaining this first initial image, for any target third element among the multiple third elements (i.e., any third element among the multiple third elements), we can further determine whether the target third element satisfies the intersection condition using a separating axis algorithm, based on the first enclosing polygon corresponding to the target third element and the second enclosing polygon corresponding to the target first element containing the target third element. The intersection condition indicates whether the first and second enclosing polygons intersect.
[0077] The separating axis algorithm is used to determine whether two convex polygons intersect. Its core principle is that if two convex polygons have no overlapping parts, then there must exist at least one straight line (called the separating axis) such that the projections of the two polygons onto this line do not overlap. Conversely, if no such line can be found, then the two polygons must intersect.
[0078] Therefore, in this embodiment of the application, the first enclosing polygon refers to the polygon used to enclose the third element, and the second enclosing polygon refers to the polygon used to enclose the first element. Figure 2 For example, the first enclosing polygon is the polygon corresponding to each thumbtack, and the second enclosing polygon is the polygon corresponding to each disc-shaped structure. In this way, the separation axis algorithm can effectively detect whether the first and second enclosing polygons intersect, that is, determine whether the target third element satisfies the intersection condition.
[0079] Accordingly, if the target third element satisfies the intersection condition, from the first element in the layer above the target first element, any third element with a different color from the target third element is identified as a candidate third element corresponding to the target third element, and their positions are swapped with the target third element. Furthermore, if the target third element does not satisfy the intersection condition, another pin can be selected from among the multiple third elements as the target third pin. This process is repeated until all third elements satisfying the intersection condition have been swapped with their corresponding candidate third elements, resulting in the second initial image.
[0080] For example, still using Figure 2For example, if the target third element, i.e. the target pin, satisfies the intersection condition, then a candidate pin with a different color from the target pin can be selected from the layer above the layer where the target pin is located, and the target pin and the candidate pins are swapped, until all pins that satisfy the above intersection condition have been swapped.
[0081] Furthermore, after obtaining the second initial image, the quantity of third elements of different colors in each layer can be further determined. Next, based on the quantity of third elements of different colors in each layer, fourth elements of the same color can be assigned to third elements of the same color in each layer. Each of the multiple fourth elements is used to fill the space with a preset quantity of third elements of the same color when allowed. Then, based on the color arrangement of the multiple third elements across multiple layers, the multiple fourth elements can be arranged to obtain the third initial image.
[0082] For example, still using Figure 2 For example, the fourth element could be a box for holding thumbtacks. Based on this, we can start with the plate structure in the first layer of multiple layers and first calculate the number of thumbtacks of different colors in each layer. Then, assuming the preset number is 3, we can assign a box to every 3 thumbtacks of the same color, and sort the boxes of the corresponding colors according to the order of the thumbtack colors in the multiple layers. For example, if the first layer includes blue and yellow thumbtacks, and the second layer includes purple and yellow thumbtacks, we can arrange the blue and yellow boxes first, and then arrange the purple boxes.
[0083] S103: Based on the verification strategy and the initial image, the generation strategy is verified to obtain the verification result.
[0084] As mentioned earlier, the verification strategy can include the difficulty coefficients corresponding to multiple third elements and the first and second difficulty coefficients corresponding to multiple fourth elements. Based on this, in the application embodiment, during the verification of the generation strategy, firstly, the difficulty weight corresponding to each third element can be determined based on the layer number of the layer where each third element is located and the difficulty coefficient corresponding to each third element. For example, the difficulty weight corresponding to each third element can be obtained through the following formula (1):
[0085] Q1=L1×q1 (1)
[0086] Where Q1 is the difficulty weight of each third element, L1 is the layer number of each third element, and q1 is the difficulty coefficient of each third element.
[0087] Next, as mentioned earlier, each fourth element is used to fill a preset number of third elements of the same color when it is allowed to be used. Therefore, in practical applications, the above-mentioned multiple fourth elements may include allowed fourth elements and disallowed fourth elements. Whether a fourth element is allowed to be used refers to whether the fourth element is allowed to be filled by a third element. Based on this, when multiple fourth elements include allowed and disallowed fourth elements, the first difficulty coefficient can be used as the difficulty weight corresponding to the allowed fourth element. Furthermore, based on the order of the disallowed fourth elements among the multiple fourth elements, the first difficulty coefficient, and the second difficulty coefficient, the difficulty weight corresponding to the disallowed fourth element is determined. For example, the difficulty weight corresponding to each disallowed fourth element can be obtained through the following formula (2):
[0088] Q2=(L2-3)×q2×q3 (2)
[0089] Where Q1 is the difficulty weight corresponding to each unusable fourth element, L2 is the order of each unusable fourth element among multiple fourth elements, q2 is the first difficulty coefficient, and q3 is the second difficulty coefficient.
[0090] Then, the generation strategy can be verified based on the difficulty weight corresponding to each third element, the difficulty weight corresponding to each fourth element, and the initial image, and the verification result can be obtained.
[0091] In practice, the difficulty weights corresponding to each third element and each fourth element can be summed first to obtain the sum, which serves as the difficulty index for the initial image. Taking a game design scenario as an example, this difficulty index represents the difficulty of the game level corresponding to the initial image (i.e., the first, second, and third initial images mentioned above). Next, it is determined whether this difficulty index matches the generation requirements indicated by the generation strategy, such as a pre-designed difficulty index, thus obtaining the verification result.
[0092] S104: If the verification result indicates that the generation strategy has passed the verification, the initial image will be used as the target image.
[0093] For example, if the verification result indicates that the generation strategy has passed the verification, it means that the difficulty index corresponding to the initial image matches the pre-designed difficulty index, that is, the initial image meets the generation requirements, and the initial image can be used as the target image to complete the image processing process.
[0094] Furthermore, if the verification result indicates that the generation strategy has failed, the generation strategy can be adjusted. For example, the number of first elements in each layer, the colors of multiple second elements, the number of second elements of different colors, the colors of multiple third elements, and the number of third elements of different colors can be adjusted to obtain an adjusted generation strategy. Next, a new initial image is generated based on the adjusted generation strategy, and the new initial image is verified again to obtain a new verification result. This process continues until a new verification result indicates that the adjusted generation strategy has passed verification, at which point the new initial image is used as the target image.
[0095] As can be seen from the above steps S101-S104, in this embodiment, image configuration information can first be obtained. This image configuration information may include a generation strategy and a verification strategy for the target image, whereby the generation strategy satisfies the verification strategy. Accordingly, an initial image can be generated based on the generation strategy, and the generation strategy is verified based on the verification strategy and the initial image to obtain a verification result. Thus, if the verification result indicates that the generation strategy has passed verification, the initial image can be used as the target image. In this way, after obtaining the image configuration information, the initial image can be automatically generated without relying on the designer's personal experience. Furthermore, the generated initial image can be automatically verified without manual debugging by the designer, thereby reducing human intervention and accurately obtaining the image desired by the designer in an automated and intelligent manner, significantly improving image generation efficiency.
[0096] Furthermore, based on the image processing method provided in the above embodiments, this application embodiment can also provide an image processing apparatus. The image processing apparatus will now be described in conjunction with the embodiments and accompanying drawings.
[0097] Figure 3 This is a schematic diagram of the structure of an image processing apparatus provided in an embodiment of this application. (In conjunction with...) Figure 3 As shown, the image processing apparatus 300 provided in this application embodiment may include:
[0098] The information acquisition module 301 is used to acquire image configuration information, the image configuration information including a generation strategy and a verification strategy for the target image, the generation strategy being used to satisfy the verification strategy;
[0099] Image generation module 302 is used to generate an initial image based on the generation strategy;
[0100] Image verification module 303 is used to verify the generation strategy based on the verification strategy and the initial image, and obtain a verification result;
[0101] The image determination module 304 is used to use the initial image as the target image when the verification result indicates that the generation strategy has passed the verification.
[0102] Optionally, the generation strategy is used to indicate that the target image includes multiple layers, the number of first elements, the colors of multiple second elements, the number of second elements of different colors, the colors of multiple third elements, and the number of third elements of different colors in each layer, the multiple second elements and the multiple third elements are respectively located in the multiple first elements, the number of multiple second elements and the multiple third elements are equal, and the multiple third elements are used to fill the multiple second elements one by one;
[0103] The image generation module 302 is specifically used for:
[0104] For the first layer among the multiple layers, start traversing from the second element of the first element under the first layer, and fill the second element with the third elements of the first color among the multiple third elements, until all the third elements of the first color are filled into the second element;
[0105] Continue to fill the second elements with the third elements that belong to the second color among the plurality of third elements until all the plurality of second elements are filled with third elements, and a first initial image is obtained.
[0106] Optionally, for a target third element among the plurality of third elements, the image generation module 302 is further configured to:
[0107] Based on the first enclosing polygon corresponding to the target third element and the second enclosing polygon corresponding to the target first element where the target third element is located, the separation axis algorithm is used to determine whether the target third element satisfies the intersection condition. The intersection condition is used to indicate that the first enclosing polygon and the second enclosing polygon intersect.
[0108] If the target third element satisfies the intersection condition, any third element with a different color from the target third element is determined from the first element in the layer above the layer where the target first element is located as the candidate third element corresponding to the target third element.
[0109] The candidate third element corresponding to the target third element is swapped with the target third element until all the third elements that satisfy the intersection condition are swapped with the candidate third element corresponding to the third element that satisfies the intersection condition, thus obtaining the second initial image.
[0110] Optionally, the image generation module 302 is further configured to:
[0111] Determine the quantity of the third element corresponding to different colors in each layer;
[0112] Based on the number of third elements of different colors in each layer, a fourth element of the same color is assigned to the third elements of the same color in each layer. Each of the multiple fourth elements is used to be filled by a preset number of third elements of the same color when it is allowed to be used.
[0113] Based on the color arrangement order of the multiple third elements in the multiple layers, the multiple fourth elements are arranged to obtain a third initial image.
[0114] Optionally, the verification strategy includes the difficulty coefficients corresponding to the plurality of third elements and the first and second difficulty coefficients corresponding to the plurality of fourth elements;
[0115] The image verification module 303 is specifically used for:
[0116] Based on the layer number of each third element and the difficulty coefficient corresponding to each third element, the difficulty weight corresponding to each third element is determined;
[0117] In the case where the plurality of fourth elements includes both allowed and disallowed fourth elements, the first difficulty coefficient is used as the difficulty weight corresponding to the allowed fourth element, and the difficulty weight corresponding to the disallowed fourth element is determined based on the order of the disallowed fourth elements among the plurality of fourth elements, the first difficulty coefficient, and the second difficulty coefficient.
[0118] Based on the difficulty weight corresponding to each of the third elements, the difficulty weight corresponding to each of the fourth elements, and the initial image, the generation strategy is validated to obtain the validation result.
[0119] Optionally, the image determination module 304 is specifically used for:
[0120] If the verification result indicates that the generation strategy has failed the verification, the generation strategy is adjusted to obtain the adjusted generation strategy.
[0121] A new initial image is generated based on the adjusted generation strategy, and the new initial image is continuously verified to obtain a new verification result. When the new verification result indicates that the adjusted generation strategy has passed the verification, the new initial image is used as the target image.
[0122] Furthermore, embodiments of this application also provide an electronic device, including: a processor, a memory, and a system bus;
[0123] The processor and the memory are connected via the system bus;
[0124] The memory is used to store one or more programs, the one or more programs including instructions that, when executed by the processor, cause the processor to perform any of the implementation steps of the image processing method described above.
[0125] Furthermore, embodiments of this application also provide a computer-readable storage medium storing instructions that, when executed on an electronic device, cause any of the above-described image processing method steps to be implemented.
[0126] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that all or part of the steps in the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network communication device such as a media gateway, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this application. It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on describing the differences from other embodiments. The same or similar parts between the various embodiments can be referred to mutually.
[0127] The system disclosed in the embodiments is described in a relatively simple manner because it corresponds to the method disclosed in the embodiments. For relevant details, please refer to the method section.
[0128] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0129] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An image processing method, characterized in that, include: Obtain image configuration information, which includes a generation strategy and a verification strategy for the target image, wherein the generation strategy is used to satisfy the verification strategy; An initial image is generated based on the aforementioned generation strategy; Based on the verification strategy and the initial image, the generation strategy is verified to obtain the verification result; If the verification result indicates that the generation strategy has passed the verification, the initial image is used as the target image; The generation strategy is used to indicate that the target image includes multiple layers, the number of first elements, the colors of multiple second elements, the number of second elements of different colors, the colors of multiple third elements, and the number of third elements of different colors in each layer, the multiple second elements and the multiple third elements are respectively located in the multiple first elements, the number of multiple second elements and the multiple third elements are equal, and the multiple third elements are used to fill the multiple second elements one by one; The generation of the initial image based on the generation strategy includes: For the first layer among the multiple layers, start traversing from the second element of the first element under the first layer, and fill the second element with the third elements of the first color among the multiple third elements, until all the third elements of the first color are filled into the second element; Continue to fill the second elements with the third elements that belong to the second color among the plurality of third elements until all the plurality of second elements are filled with third elements, and a first initial image is obtained; The method further includes: Determine the quantity of the third element corresponding to different colors in each layer; Based on the number of third elements of different colors in each layer, a fourth element of the same color is assigned to the third elements of the same color in each layer. Each of the multiple fourth elements is used to be filled by a preset number of third elements of the same color when it is allowed to be used. Based on the color arrangement order of the multiple third elements in the multiple layers, the multiple fourth elements are arranged to obtain a third initial image; The verification strategy includes the difficulty coefficients corresponding to the plurality of third elements and the first and second difficulty coefficients corresponding to the plurality of fourth elements. The step of verifying the generation strategy based on the verification strategy and the initial image to obtain the verification result includes: Based on the layer number of each third element and the difficulty coefficient corresponding to each third element, the difficulty weight corresponding to each third element is determined; In the case where the plurality of fourth elements includes both allowed and disallowed fourth elements, the first difficulty coefficient is used as the difficulty weight corresponding to the allowed fourth element, and the difficulty weight corresponding to the disallowed fourth element is determined based on the order of the disallowed fourth elements among the plurality of fourth elements, the first difficulty coefficient, and the second difficulty coefficient. Based on the difficulty weight corresponding to each of the third elements, the difficulty weight corresponding to each of the fourth elements, and the initial image, the generation strategy is validated to obtain the validation result.
2. The image processing method according to claim 1, characterized in that, After obtaining the first initial image, the method further includes, for the target third element among the plurality of third elements: Based on the first enclosing polygon corresponding to the target third element and the second enclosing polygon corresponding to the target first element where the target third element is located, the separation axis algorithm is used to determine whether the target third element satisfies the intersection condition. The intersection condition is used to indicate that the first enclosing polygon and the second enclosing polygon intersect. If the target third element satisfies the intersection condition, any third element with a different color from the target third element is determined from the first element in the layer above the layer where the target first element is located as the candidate third element corresponding to the target third element. The candidate third element corresponding to the target third element is swapped with the target third element until all the third elements that satisfy the intersection condition are swapped with the candidate third element corresponding to the third element that satisfies the intersection condition, thus obtaining the second initial image.
3. The image processing method according to claim 1 or 2, characterized in that, The step of using the initial image as the target image when the verification result indicates that the generation strategy has passed verification includes: If the verification result indicates that the generation strategy has failed the verification, the generation strategy is adjusted to obtain the adjusted generation strategy. A new initial image is generated based on the adjusted generation strategy, and the new initial image is continuously verified to obtain a new verification result. When the new verification result indicates that the adjusted generation strategy has passed the verification, the new initial image is used as the target image.
4. An image processing apparatus, characterized in that, include: An information acquisition module is used to acquire image configuration information, which includes a generation strategy and a verification strategy for a target image, wherein the generation strategy is used to satisfy the verification strategy. The image generation module is used to generate an initial image based on the generation strategy; An image verification module is used to verify the generation strategy based on the verification strategy and the initial image, and obtain a verification result. An image determination module is used to use the initial image as the target image if the verification result indicates that the generation strategy has passed the verification. The generation strategy is used to indicate that the target image includes multiple layers, the number of first elements, the colors of multiple second elements, the number of second elements of different colors, the colors of multiple third elements, and the number of third elements of different colors in each layer, the multiple second elements and the multiple third elements are respectively located in the multiple first elements, the number of multiple second elements and the multiple third elements are equal, and the multiple third elements are used to fill the multiple second elements one by one; The image generation module is specifically used for: For the first layer among the multiple layers, start traversing from the second element of the first element under the first layer, and fill the second element with the third elements of the first color among the multiple third elements, until all the third elements of the first color are filled into the second element; Continue to fill the second elements with the third elements that belong to the second color among the plurality of third elements until all the plurality of second elements are filled with third elements, and a first initial image is obtained; The image generation module is also used for: Determine the quantity of the third element corresponding to different colors in each layer; Based on the number of third elements of different colors in each layer, a fourth element of the same color is assigned to the third elements of the same color in each layer. Each of the multiple fourth elements is used to be filled by a preset number of third elements of the same color when it is allowed to be used. Based on the color arrangement order of the multiple third elements in the multiple layers, the multiple fourth elements are arranged to obtain a third initial image; The verification strategy includes the difficulty coefficients corresponding to the plurality of third elements and the first and second difficulty coefficients corresponding to the plurality of fourth elements. The image verification module is specifically used for: Based on the layer number of each third element and the difficulty coefficient corresponding to each third element, the difficulty weight corresponding to each third element is determined; In the case where the plurality of fourth elements includes both allowed and disallowed fourth elements, the first difficulty coefficient is used as the difficulty weight corresponding to the allowed fourth element, and the difficulty weight corresponding to the disallowed fourth element is determined based on the order of the disallowed fourth elements among the plurality of fourth elements, the first difficulty coefficient, and the second difficulty coefficient. Based on the difficulty weight corresponding to each of the third elements, the difficulty weight corresponding to each of the fourth elements, and the initial image, the generation strategy is validated to obtain the validation result.
5. An electronic device, characterized in that, The device includes: a processor, a memory, and a system bus; The processor and the memory are connected via the system bus; The memory is used to store a program, the program including instructions that, when executed by the processor, cause the processor to perform the steps of the image processing method according to any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program, which, when executed by a terminal device, implements the steps of the image processing method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Inspection code generation method and system, electronic equipment and storage medium
CN119376705A
