Image processing method and apparatus, and electronic device
By acquiring and analyzing image configuration information, determining element categories and building a layout tree, the problem of different display media having different requirements for image sizes is solved, and efficient image processing and user experience improvement is achieved.
Patent Information
- Application Number
- PCT/CN2025/075364
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-02-05
- Filing Date
- 2025-01-26
- Publication Date
- 2025-08-14
AI Technical Summary
In the prior art, due to different display media's different size and proportion requirements for promotional images, designers need to manually adjust the images, resulting in waste of manual resources and inefficient processing.
By obtaining the configuration information of the original image and the target size of the target image, determining the categories of multiple elements, including subject elements and non-subject elements, building a layout tree, rearranging elements based on the original layout information and target size, and generating a target image that meets the target size.
It avoids the waste of artificial resources, improves the efficiency and effect of image processing, and improves the user experience.
Smart Images

Figure CN2025075364_14082025_PF_FP_ABST
Abstract
Description
Image processing method, device and electronic equipment
[0001] This application claims priority to the Chinese invention patent application entitled “Image processing method, device and electronic device” filed on February 5, 2024, with application number 202410163408.4, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present disclosure relates to the field of image processing technology, and in particular to an image processing method, device, and electronic device. Background Art
[0003] There are many application scenarios for processing promotional images. For example, posters, product brochures, e-commerce promotional images, etc. can all be promotional images. Promotional images can be visual media tools used to promote and convey information. They are usually flat images. Promotional images can include patterns, pictures, text, colors and other types of content. Promotional images can be used to display advertising content to the public, to promote warning information, and to carry out cultural communication. However, promotional images can be used in different usage scenarios and display media. Since different usage scenarios and display media have different requirements for the size and proportion of promotional images, a method is needed to generate images of different sizes and proportions based on the original image content. Summary of the Invention
[0004] The present disclosure provides an image processing method, apparatus, and electronic device. According to a first aspect, an image processing method is provided, comprising: obtaining configuration information of an original image and a target size of a target image; the configuration information including the size of the original image, multiple elements in the original image, and information about the regions of the multiple elements in the original image; determining categories of the multiple elements based on the configuration information; the categories including subject elements and non-subject elements; determining original layout information of the subject elements in the original image; and arranging the multiple elements based on the original layout information and the target size to obtain the target image.
[0005] According to a second aspect, an image processing device is provided, which includes: an acquisition module for acquiring configuration information of an original image and a target size of a target image; the configuration information includes the size of the original image, multiple elements in the original image, and area information of the multiple elements in the original image; a classification module for determining categories of the multiple elements according to the configuration information; the categories include main elements and non-main elements; a determination module for determining original layout information of the main elements in the original image; and an arrangement module for arranging the multiple elements based on the original layout information and the target size to obtain the target image.
[0006] According to a third aspect, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of the first aspects is implemented.
[0007] According to a fourth aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any one of the methods described in the first aspect when executing the program.
[0008] According to a fifth aspect, a computer program product is provided, which is tangibly stored in a computer storage medium and includes computer executable instructions, which implement any one of the methods of the first aspect when executed by a device.
[0009] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0011] FIG1A is a schematic diagram of an image processing scenario according to an exemplary embodiment of the present disclosure;
[0012] FIG1B is a schematic diagram of another image processing scenario according to an exemplary embodiment of the present disclosure;
[0013] FIG2 is a flowchart of an image processing method according to an exemplary embodiment of the present disclosure;
[0014] FIG3 is a schematic diagram of a scenario of constructing a layout tree according to an exemplary embodiment of the present disclosure;
[0015] FIG4 is a schematic diagram of another image processing scenario according to an exemplary embodiment of the present disclosure;
[0016] FIG5 is a block diagram of an image processing apparatus according to an exemplary embodiment of the present disclosure;
[0017] FIG6 is a schematic block diagram of an electronic device provided by some embodiments of the present disclosure;
[0018] FIG7 is a schematic block diagram of another electronic device provided by some embodiments of the present disclosure;
[0019] FIG8 is a schematic diagram of a storage medium provided by some embodiments of the present disclosure. DETAILED DESCRIPTION
[0020] To help those skilled in the art better understand the technical solutions in this specification, the following will provide a clear and complete description of the technical solutions in the embodiments of this specification, in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. All other embodiments derived by those skilled in the art based on the embodiments in this specification without creative effort shall fall within the scope of protection of this specification.
[0021] In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
[0022] The terms used in this disclosure are for the purpose of describing specific embodiments only and are not intended to limit the disclosure. The singular forms "a," "the," and "the" used in this disclosure are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0023] It should be understood that although the terms first, second, third, etc. may be used in this disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of this disclosure, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining."
[0024] A promotional image is a visual media tool that can be used for publicity and communication of information. It is usually a flat image. Promotional images may include patterns, pictures, text, colors and other types of content. Promotional images can be used to display advertising content to the public, to publicize warning information, and to carry out cultural communication. However, promotional images can be used in different usage scenarios and display media (such as outdoor billboards, TV screens, social media, etc.). Since different usage scenarios and display media have different requirements for the size and proportion of promotional images, it is necessary to generate promotional images suitable for different scenarios and different sizes based on the same promotional image content. In related technologies, designers usually manually perform typeset work for each display medium to obtain promotional images of different sizes and proportions. However, this will result in a huge waste of human resources.
[0025] This disclosure provides an image processing method that uses pre-generated configuration information for an original image and a target size for a target image to determine the categories of multiple elements included in the original image, which may include both subject elements and non-subject elements. The method then determines the original layout information of the subject elements within the multiple elements in the original image. Finally, the method arranges the multiple elements based on the original layout information and the target size to obtain a target image that meets the target size. This method avoids waste of manual resources, improves image processing efficiency and effectiveness, and enhances the user experience.
[0026] The following uses a poster image as an example to exemplify a processing scenario of a promotional image. Referring to FIG. 1A-FIG . 1B , they are schematic diagrams of a processing scenario of a poster image according to an exemplary embodiment.
[0027] As shown in Figure 1A, first, the configuration information of the original poster 101 can be obtained as a reference, and the target size information of the target poster 102 can be obtained. The configuration information of the original poster 101 may include the size of the original poster 101, multiple elements in the original poster 101, and the area occupied by each of the multiple elements in the original poster 101. Based on the configuration information of the original poster 101, the category of each element in the original poster 101 is determined. For example, element 103 in the original poster 101 may be a background element, element 104 may be a border element, element 105 may be a decorative element, and elements 106 through 114 may be main elements.
[0028] Next, as shown in FIG1B , all the subject elements can be treated as a whole and split layer by layer to construct a layout tree 115 of the original poster 101. The layout tree 115 is mainly composed of subject elements. The layout tree 115 includes multiple layout nodes, each of which includes one or more subject elements. Among them, layout node 116 is the root node of the layout tree 115, including all subject elements. Layout node 117 is the intermediate node of the layout tree 115, each of which includes multiple subject elements. Layout node 118 is the leaf node of the layout tree 115, each of which includes one subject element.
[0029] Then, the main elements can be rearranged based on the layout tree 115 and the target size. Specifically, the main elements of one or more target nodes among the multiple layout nodes can be rearranged, where the target nodes are non-leaf nodes. For any target node, the main elements included in the child nodes of the target node are rearranged as a unit (i.e., the main elements included in each child node of the target node are arranged and moved as a whole).
[0030] Furthermore, for non-subjective elements, such as background elements, appropriate scaling and translation can be performed based on the target size. For footer elements, a target position for the footer elements can be determined from the footer region of the target poster based on the target size, and the footer elements can be placed at the target position. For decorative elements, the decorative elements can be arranged and moved in the same manner as the nearest main element. Finally, the rearranged target poster 102 can be obtained.
[0031] The present disclosure will be described in detail below with reference to specific embodiments.
[0032] FIG2 is a flow chart of an image processing method according to an exemplary embodiment, which can be applied to a target device. The target device can be implemented as any device, platform, server, or backup cluster with computing and processing capabilities. The method includes the following steps:
[0033] As shown in FIG2 , in step 201 , configuration information of the original image and a target size of the target image are obtained.
[0034] In this embodiment, the images involved may be promotional images. For example, promotional images may include but are not limited to posters, product brochures, e-commerce promotional images, etc. The original image may be an initial promotional image designed and generated in advance. For example, the scenario involved in this embodiment may be that the user needs to generate promotional images with the same content but different sizes for display media such as outdoor billboards, TV screens, computer screens, and mobile social media pages. The designer of the promotional image can first design the promotional image elements and layout the promotional image elements according to the size of a display medium to obtain a promotional image for that display medium as the original image.
[0035] In this embodiment, after the original image is generated, the configuration information of the original image can be obtained, and the configuration information may include the size of the original image, multiple elements in the original image, and the area information occupied by each of the multiple elements in the original image. Among them, the size of the original image may include the length and width of the original image. The multiple elements in the original image may be pre-designed promotional image elements, and the promotional image elements may include but are not limited to the following types of content: patterns, pictures, text, and background colors, etc. Each element in the original image occupies an element area (for example, it may be a rectangular area), and the area information of the element area occupied by each element may be obtained. The area information occupied by any element may be, for example, the center coordinates and size of the element area occupied by the element, or the coordinates of each vertex of the element area occupied by the element, etc.
[0036] In this embodiment, the target image can be a promotional image that needs to be generated and meets the display conditions of another display medium. For example, if the original image is a promotional image pre-generated for a computer screen, then any promotional image for an outdoor billboard, a TV screen, or a mobile phone social media page can be the target image.
[0037] In step 202, categories of the multiple elements are determined according to the configuration information.
[0038] In this embodiment, the elements of the promotional image can be categorized into at least subject elements and non-subject elements. The category of each of the multiple elements can be determined based on the configuration information. In one implementation, the center position of each element in the original image can be determined based on the configuration information, and the category of the element can be determined based on the center position. For example, if the center of the element is within a preset range from the center of the original image, the element can be determined to be a subject element. If the center of the element is outside the preset range from the center of the original image, the element can be determined to be a non-subject element.
[0039] In another implementation, the above configuration information can also be input into a pre-trained machine learning model, and the machine learning model can be used to classify the multiple elements to determine the category of each element.
[0040] In yet another implementation, the area ratios occupied by each of the multiple elements in the original image may be determined based on the size of the original image in the configuration information and the area information occupied by each of the multiple elements in the original image. Furthermore, the categories of each of the multiple elements may be determined based on the area information occupied by each of the multiple elements in the original image and the area ratios occupied by each of the multiple elements in the original image.
[0041] For example, non-main elements may further include background elements, side elements, and decorative elements. For any element, if the area ratio of the element in the original image is greater than or equal to a first ratio, the element can be determined as a background element. If the ratio of the overlapping area of the element with the central preset area of the original image to the element's own area is less than or equal to a second ratio, the element can be determined as a side element. If the area ratio of the element in the original image is less than or equal to a third ratio, the element can be determined as a decorative element.
[0042] For example, 90% is pre-set as the first ratio, 22% is pre-set as the second ratio, and 10% is pre-set as the third ratio. Each element in the original image is traversed. For any element A, first determine whether the ratio of element A to the image area is greater than or equal to 90%. If the ratio of element A to the image area is greater than or equal to 90% (for example, 96%), it can be determined that element A is a background element, and the next element B traversed can be classified. If element A occupies less than 90% of the image area (for example, 20%), it can be determined that element A is not a background element. The area ratio of the overlapping area of element A and a preset area (for example, a rectangular area with preset length and width dimensions with the center of the original image as the midpoint) to the area of element A itself can be calculated, and it can be determined whether the area ratio is less than or equal to the second ratio. If the ratio of the overlapping area of element A and the preset area to the area of element A itself is less than or equal to 22% (for example, 12%), it can be determined that element A is a side element, and the next element B traversed can be classified. If the overlap between element A and the preset area accounts for more than 22% (e.g., 100%) of element A's own area, it can be determined that element A is not a footer element, and the proportion of the image area occupied by element A can be determined to be less than or equal to 10%. If the proportion of the image area occupied by element A is less than or equal to 10% (e.g., 6%), it can be determined that element A is a decorative element, and the next element B traversed can be classified. If element A occupies more than 10% (e.g., 20%) of the image area, it can be determined that element A is not a decorative element. Since element A does not belong to any non-main element, it can be determined that element A is a main element.
[0043] In step 203, the original layout information of the main elements in the original image is determined.
[0044] In this embodiment, the main elements among the multiple elements of the original image can be obtained, and the original layout information of the main elements in the original image can be determined. Specifically, the layout tree of the original image can be determined based on the main elements among the multiple elements, and the layout tree can be used as the original layout information. The layout tree can include multiple layout nodes in the original image, and each layout node includes at least one main element. Among them, the root node of the layout tree includes all the main elements, each intermediate node of the layout tree includes multiple main elements, and each leaf node of the layout tree can include one main element or multiple main elements. In one implementation method, the main elements can be input as a whole into a pre-trained model, and the model can be used to hierarchically classify the main elements to obtain the above-mentioned layout tree.
[0045] In another implementation method, all the main elements can be taken as a whole to construct the root node of the layout tree, and then the main elements included in the root node can be split to construct multiple child nodes of the root node. The main elements included in each child node can be split separately to construct the child nodes of each child node...so as to finally obtain the layout tree.
[0046] For example, the above layout tree can be obtained by repeatedly executing a target operation on any layout node. The target operation may include: first, selecting any leaf node containing multiple main elements from the current layout node as the layout node to be divided. When the target operation is first executed, all the main elements can be treated as a whole to form a layout node, and the layout node is used as the root node of the layout tree, and the root node is used as the layout node to be divided when the target operation is first executed.
[0047] Then, at least one splitting line is determined for the layout node to be split. The splitting direction of the at least one splitting line is consistent, for example, the splitting directions are all vertical or horizontal, and the splitting line can be used to split the multiple main elements. The multiple main elements included in the layout node to be split are then split into multiple groups along the splitting line to generate multiple child nodes of the layout node to be split, each child node including a group of main elements.
[0048] It should be noted that when determining at least one splitting line for the layout node to be divided, all splitting lines corresponding to the layout node to be divided can be found first. If the layout node to be divided has no splitting lines, it means that the layout node to be divided cannot be divided any further. If the layout node to be divided has only vertical splitting lines in the vertical direction, or only horizontal splitting lines in the horizontal direction, the vertical splitting lines or the horizontal splitting lines can be directly used as the at least one splitting line for the layout node to be divided. If the layout node to be divided includes both vertical splitting lines in the vertical direction and horizontal splitting lines in the horizontal direction, the number of vertical splitting lines and the number of horizontal splitting lines can be determined separately. The splitting line with the largest number can be selected as the at least one splitting line for the layout node to be divided. For example, if the number of vertical splitting lines is greater than the number of horizontal splitting lines, the vertical splitting lines can be used as the splitting lines for the layout node to be divided. If the number of horizontal splitting lines is greater than the number of vertical splitting lines, the horizontal splitting lines can be used as the splitting lines for the layout node to be divided.
[0049] Figure 3 is a schematic diagram of a layout tree construction scenario. The following uses Figure 3 as an example to illustrate the process of constructing a layout tree. As shown in Figure 3, all elements of the original image can be treated as a whole to construct the root node 301 of the layout tree. Then, for root node 301, the split direction and split line are determined. Specifically, it can be determined whether root node 301 has a vertical split line and a horizontal split line. The vertical split line is a vertical line that can divide root node 301 into left and right parts, and the horizontal split line is a horizontal line that can divide root node 301 into upper and lower parts. As shown in Figure 3, root node 301 has a vertical split line 302 but no horizontal split line. Therefore, vertical split line 302 can be used as the split line for root node 301. The main elements included in root node 301 are split along the split lines, resulting in two child nodes of root node 301, namely node 303 and node 304. It can be determined that node 303 is indivisible.
[0050] Next, for node 304, it can be determined that node 304 has both vertical and horizontal split lines, including vertical split line 305, horizontal split line 306, and horizontal split line 307. Therefore, the number of horizontal split lines is greater than the number of vertical split lines, and horizontal split lines 306 and 307 can be used as split lines for node 304. The main element of node 304 is split along these split lines, resulting in three child nodes of node 304: node 308, node 309, and node 310. Nodes 308, 309, and 310 can be further split to obtain a layout tree.
[0051] In step 204 , the plurality of elements are arranged based on the original layout information and the target size to obtain a target image.
[0052] In this embodiment, multiple elements included in the original image can be rearranged based on the original layout information of the original image and the target size of the target image to obtain the target image. In one implementation, the positions of at least some of the elements can be adjusted based on the original layout information and the target size. Various different arrangements can be traversed, and some of these arrangements can be displayed to the user, who can then select a target image from among them.
[0053] In another implementation, the main elements and non-main elements can also be arranged separately. For the main elements, for example, starting from the root node of the above-mentioned layout tree, the non-leaf nodes in the layout node can be traversed in the order from the parent node to the child node, and the rearrangement operation can be performed or no adjustment operation can be performed. For any traversed layout node, the main elements included in the child nodes of the layout node can be rearranged as units (that is, the main elements included in each child node of the layout node are arranged and moved as a whole), or no adjustment operation can be performed on the layout node. Among them, the rearrangement can be to change the original vertical arrangement mode to a horizontal arrangement mode, or to change the original horizontal arrangement mode to a vertical arrangement mode. For example, as shown in Figure 4, layout node 401 includes child nodes 402 and child nodes 403. The original arrangement mode of child nodes 402 and child nodes 403 is horizontal arrangement. After traversing to layout node 401, the arrangement mode of its child nodes 402 and child nodes 403 can be changed from horizontal arrangement to vertical arrangement.
[0054] For non-main elements, such as background elements, you can scale and translate them appropriately based on the target size. For side elements, you can determine the target position of the side elements from the side area of the target image based on the target size and place them at the target position. For decorative elements, you can arrange and move them in the same manner as the nearest main element.
[0055] After arranging the main elements and non-main elements of the multiple elements included in the original image, multiple different arrangement results can be obtained. Each arrangement result corresponds to a new image, and the new image can be used as a candidate image, thereby obtaining multiple candidate images. Each candidate image can be scored to obtain a score corresponding to each candidate image. The score of any candidate image is positively correlated with the ratio of the area of the multiple elements in the candidate image to the total area of the candidate image. For example, the ratio of the area of the multiple elements in the candidate image to the total area of the candidate image can be directly used as the score of the candidate image. Finally, the candidate image with the highest score can be used as the target image, or the candidate images can be sorted in order from high to low scores, and a preset number of candidate images arranged at the front are displayed to the user, and the user selects the target image from them.
[0056] This disclosure provides an image processing method that uses pre-generated configuration information for an original image and a target size for a target image to determine the categories of multiple elements within the original image, which may include both subject elements and non-subject elements. The method then determines the original layout information for the subject elements within the original image. Finally, the method arranges the multiple elements based on the original layout information and the target size to obtain a target image that meets the target size. This method avoids waste of manual labor, improves image processing efficiency and effectiveness, and enhances the user experience.
[0057] It should be noted that although the operations of the methods of the embodiments of the present disclosure are described in a specific order in the above embodiments, this does not require or imply that these operations must be performed in this specific order, or that all of the operations shown must be performed to achieve the desired results. On the contrary, the steps depicted in the flowcharts can be performed in a different order. Additionally or alternatively, certain steps can be omitted, multiple steps can be combined into one step, and / or one step can be decomposed into multiple steps.
[0058] Corresponding to the aforementioned image processing method embodiment, the present disclosure also provides an embodiment of an image processing device.
[0059] As shown in FIG5 , FIG5 is a block diagram of an image processing device according to an exemplary embodiment of the present disclosure. The device may include: an acquisition module 501 , a classification module 502 , a determination module 503 and an arrangement module 504 .
[0060] The acquisition module 501 is used to acquire configuration information of the original image and target size of the target image. The configuration information includes the size of the original image, multiple elements in the original image, and area information of the multiple elements in the original image.
[0061] The classification module 502 is configured to determine categories of the plurality of elements according to the configuration information, where the categories include main elements and non-main elements.
[0062] The determination module 503 is configured to determine the original layout information of the main elements in the original image.
[0063] The arrangement module 504 is configured to arrange multiple elements based on the original layout information and the target size to obtain a target image.
[0064] In other implementations, the classification module 502 may include: a first determination submodule and a second determination submodule (not shown in the figure).
[0065] The first determining submodule is configured to determine the area ratios occupied by the multiple elements in the original image based on the size of the original image and the area information of the multiple elements in the original image included in the configuration information.
[0066] The second determining submodule is configured to determine categories of the multiple elements based on region information and area ratios occupied by the multiple elements in the original image.
[0067] In other embodiments, non-main elements include background elements, side elements, and decorative elements, wherein the second determination submodule is configured to: determine elements whose area ratio in the original image is greater than or equal to a first ratio as background elements, determine elements whose ratio of the overlapping area with the central preset area of the original image to their own area is less than or equal to a second ratio as side elements, determine elements whose area ratio in the original image is less than or equal to a third ratio as decorative elements, and determine elements other than the main elements among multiple elements as main elements.
[0068] In other implementations, the determination module 503 may include: a layout submodule (not shown in the figure).
[0069] The layout submodule is used to determine a layout tree of the original image based on the main elements as original layout information. The layout tree includes multiple layout nodes in the original image, and each layout node includes at least one main element.
[0070] In other embodiments, the layout submodule performs the following operations multiple times: selecting any leaf node including multiple main elements from the current layout node as the layout node to be divided, determining at least one splitting line with a consistent splitting direction for the layout node to be divided, the splitting line being used to split the multiple main elements included in the layout node to be divided, the splitting direction including a vertical direction and a horizontal direction, splitting the multiple main elements included in the layout node to be divided into multiple groups along the splitting line, and generating multiple child nodes of the layout node to be divided, each child node including a group of main elements.
[0071] In other embodiments, the arrangement module 504 is configured to arrange the main elements of one or more target nodes among the multiple layout nodes based on the target size, and for any target node, arrange the main elements included in the child nodes of the target node as a unit. Where the target node is a non-leaf node, the non-main elements among the multiple elements are arranged based on the target size, and the target image is obtained based on the result of arranging the main elements and non-main elements among the multiple elements.
[0072] In other embodiments, the arrangement module 504 may obtain a target image based on the results of arranging the main elements and non-main elements in the plurality of elements in the following manner: after arranging the main elements and non-main elements in the plurality of elements, determine a plurality of different arrangement results, each arrangement result corresponding to a candidate image, thereby obtaining a plurality of candidate images, and score each candidate image to obtain a score for the candidate image. The score of any candidate image is positively correlated with the ratio of the area of the plurality of elements in the candidate image to the total area of the candidate image, and the target image is determined based on the score of the candidate image.
[0073] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the partial description of the method embodiments. The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the embodiment scheme of the present disclosure. A person of ordinary skill in the art can understand and implement it without paying any creative work.
[0074] The technical solutions provided by the embodiments of the present disclosure may include the following beneficial effects: The embodiments of the present disclosure provide an image processing method and apparatus, which determines multiple element categories included in the original image through pre-generated configuration information of the original image and the target size of the target image. The categories may include main elements and non-main elements. Then, the original layout information of the main elements among the multiple elements in the original image is determined. Finally, based on the original layout information and the target size, the multiple elements are rearranged to obtain a target image that meets the target size. This avoids the waste of manual resources, improves the efficiency and effect of image processing, and enhances the user experience.
[0075] Figure 6 is a schematic block diagram of an electronic device provided by some embodiments of the present disclosure. As shown in Figure 6, the electronic device 910 includes a processor 911 and a memory 912, which can be used to implement a client or a server. The memory 912 is used to store computer-executable instructions (such as one or more computer program modules) non-transiently. The processor 911 is used to run the computer-executable instructions, and when the computer-executable instructions are run by the processor 911, one or more steps in the image processing method described above can be executed, thereby implementing the image processing method described above. The memory 912 and the processor 911 can be interconnected through a bus system and / or other forms of connection mechanisms (not shown).
[0076] For example, the processor 911 may be a central processing unit (CPU), a graphics processing unit (GPU), or other processing units with data processing capabilities and / or program execution capabilities. For example, the central processing unit (CPU) may be an X86 or ARM architecture. The processor 911 may be a general-purpose processor or a dedicated processor, and may control other components in the electronic device 910 to perform desired functions.
[0077] For example, the memory 912 may include any combination of one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory. Non-volatile memory may include, for example, read-only memory (ROM), a hard disk, an erasable programmable read-only memory (EPROM), a portable compact disk read-only memory (CD-ROM), a USB memory, a flash memory, etc. One or more computer program modules may be stored on the computer-readable storage medium, and the processor 911 may execute one or more computer program modules to implement various functions of the electronic device 910. Various applications and various data, as well as various data used and / or generated by the applications, may also be stored in the computer-readable storage medium.
[0078] It should be noted that, in the embodiment of the present disclosure, the specific functions and technical effects of the electronic device 910 can be referred to the description of the image processing method above, and will not be repeated here.
[0079] Figure 7 is a schematic block diagram of another electronic device provided by some embodiments of the present disclosure. The electronic device 920 is suitable for implementing the image processing method provided by the embodiment of the present disclosure, for example. The electronic device 920 can be a terminal device, etc., which can be used to implement a client or a server. The electronic device 920 can include but is not limited to mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), wearable electronic devices, etc., and fixed terminals such as digital TVs, desktop computers, smart home devices, etc. It should be noted that the electronic device 920 shown in Figure 7 is only an example and does not impose any restrictions on the functions and scope of use of the embodiments of the present disclosure.
[0080] As shown in FIG7 , the electronic device 920 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 921, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 922 or a program loaded from a storage device 928 into a random access memory (RAM) 923. Various programs and data required for the operation of the electronic device 920 are also stored in the RAM 923. The processing device 921, the ROM 922, and the RAM 923 are connected to each other via a bus 924. An input / output (I / O) interface 925 is also connected to the bus 924.
[0081] Typically, the following devices may be connected to the I / O interface 925: an input device 926 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 927 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 928 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 929. The communication device 929 may allow the electronic device 920 to communicate with other electronic devices wirelessly or by wire to exchange data. Although FIG. 7 shows the electronic device 920 having various devices, it should be understood that it is not required to implement or have all of the devices shown, and the electronic device 920 may alternatively implement or have more or fewer devices.
[0082] For example, according to an embodiment of the present disclosure, the image processing method described above can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program including program code for executing the image processing method described above. In such an embodiment, the computer program can be downloaded and installed from a network via the communication device 929, or installed from the storage device 928, or installed from the ROM 922. When the computer program is executed by the processing device 921, the functions defined in the image processing method provided by the embodiment of the present disclosure can be implemented.
[0083] Figure 8 is a schematic diagram of a storage medium provided in some embodiments of the present disclosure. For example, as shown in Figure 8, storage medium 930 may be a non-transitory computer-readable storage medium for storing non-transitory computer-executable instructions 931. When non-transitory computer-executable instructions 931 are executed by a processor, the image processing method described in the embodiments of the present disclosure may be implemented. For example, when non-transitory computer-executable instructions 931 are executed by a processor, one or more steps of the image processing method described above may be performed.
[0084] For example, the storage medium 930 may be applied to the above-mentioned electronic device. For example, the storage medium 930 may include a memory in the electronic device.
[0085] For example, the storage medium may include a memory card of a smart phone, a storage component of a tablet computer, a hard disk of a personal computer, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable compact disk read-only memory (CD-ROM), a flash memory, or any combination of the above storage media, or other applicable storage media.
[0086] For example, the description of the storage medium 930 can refer to the description of the memory in the embodiment of the electronic device, and the repeated parts are not repeated. The specific functions and technical effects of the storage medium 930 can refer to the description of the image processing method above, and are not repeated here.
[0087] It should be noted that in the context of the present disclosure, a computer-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0088] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the claims.
[0089] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for processing an image, comprising: Acquire configuration information of an original image and a target size of a target image, wherein the configuration information includes the size of the original image, multiple elements in the original image, and region information of the multiple elements in the original image; Determining categories of the plurality of elements according to the configuration information, the categories including subject elements and non-subject elements; Determining original layout information of the subject element in the original image; as well as The multiple elements are arranged based on the original layout information and the target size to obtain the target image.
2. The method according to claim 1, wherein determining the categories of the plurality of elements according to the configuration information comprises: determining, based on the size of the original image and information about the areas occupied by the multiple elements in the original image included in the configuration information, area ratios occupied by the multiple elements in the original image; as well as Based on the region information and the occupied area ratios of the multiple elements in the original image, the categories of the multiple elements are determined.
3. The method according to claim 2, wherein the non-subjective elements include background elements, side elements, and decorative elements, and wherein determining the categories of the plurality of elements based on information about regions occupied by the plurality of elements in the original image and proportions of the occupied areas comprises: Determine an element in the original image whose area ratio is greater than or equal to a first ratio as the background element; Determine an element whose ratio of the overlapping area with the central preset area of the original image to its own area is less than or equal to a second ratio as the footer element; determining an element whose area ratio in the original image is less than or equal to a third ratio as the decorative element; as well as The elements other than the non-main elements among the plurality of elements are determined as the main elements.
4. The method according to claim 1, wherein determining original layout information of the subject element in the original image comprises: Based on the main elements, determining a layout tree of the original image as the original layout information; The layout tree includes a plurality of layout nodes in the original image, and the layout nodes include at least one subject element.
5. The method according to claim 4, wherein determining the layout tree of the original image based on the main element comprises performing the following operations multiple times: Select any leaf node including multiple main elements from the current layout node as the layout node to be divided; Determine at least one dividing line with a consistent dividing direction for the layout node to be divided; the dividing line is used to divide a plurality of main elements included in the layout node to be divided; the dividing direction includes a vertical direction and a horizontal direction; as well as The multiple main elements included in the layout node to be divided are divided into multiple groups along the dividing line to generate multiple child nodes of the layout node to be divided, each child node including a group of main elements.
6. The method according to claim 4, wherein arranging the plurality of elements based on the original layout information and the target size to obtain the target image comprises: Arranging the main elements of one or more target nodes among the multiple layout nodes based on the target size; for any target node, arranging the main elements included in the child nodes of the target node as a unit; wherein the target node is a non-leaf node; Arranging non-main elements among the plurality of elements based on the target size; and A target image is obtained based on a result of arranging the main elements and the non-main elements in the plurality of elements.
7. The method according to claim 6, wherein obtaining the target image based on the result of arranging the main elements and the non-main elements in the plurality of elements comprises: After arranging the main elements and the non-main elements in the plurality of elements, a plurality of to-be-selected images are obtained by determining a plurality of different arrangement results, wherein each arrangement result corresponds to a to-be-selected image; Scoring the candidate images to obtain scores of the candidate images, wherein the score of any candidate image is positively correlated with the ratio of the areas of the multiple elements in the candidate image to the total area of the candidate image; A target image is determined based on the scores of the candidate images.
8. An image processing device, comprising: An acquisition module, used to obtain configuration information of the original image and a target size of the target image; The configuration information includes the size of the original image, a plurality of elements in the original image, and area information of the plurality of elements in the original image; A classification module, configured to determine categories of the plurality of elements according to the configuration information, the categories including main elements and non-main elements; A determination module, configured to determine original layout information of the subject element in the original image; An arrangement module is configured to arrange the plurality of elements based on the original layout information and the target size to obtain the target image.
9. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 7.
10. An electronic device comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method according to any one of claims 1 to 7 is implemented.
11. A computer program product tangibly stored in a computer storage medium and comprising computer executable instructions which, when executed by a device, cause the device to perform the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and apparatus for providing an image for display
CN102498499A
Image processing method and device, electronic equipment and storage medium
CN114157867A
Image processing method and device and storage medium
CN114677432A
Image processing method and device, medium and equipment
CN115564976A
Interface layout method and device, vehicle and storage medium
CN116126450A