Picture layer classification method and related apparatus
By calculating the proportion, overlap, and offset of image layers and combining them with judgment criteria, the image layer types in posters are automatically identified, solving the problem of low recognition accuracy in existing technologies and achieving efficient image layer type recognition and automatic adjustment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CTRIP TRAVEL NETWORK TECH SHANGHAI0
- Filing Date
- 2026-03-19
- Publication Date
- 2026-06-05
AI Technical Summary
Existing technologies are not very accurate in identifying the image layer types in promotional posters, resulting in high manual adjustment costs and low poster design efficiency.
By calculating the percentage of image layers, the overlap between text and image layers, and the positional offset in the poster, and combining these with preset judgment criteria, the system automatically identifies the image layer type, including canvas background layers, text background layers, and decorative layers.
It achieves highly accurate image layer type recognition, reduces the need for manual labeling, and improves the efficiency of poster design and the accuracy of automatic adjustment.
Smart Images

Figure CN122156781A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to an image layer classification method and related apparatus. Background Technology
[0002] In the design and production of promotional posters (such as travel posters), it is generally desirable for image layers to automatically adjust in response to changes in text, etc., in order to save on manual adjustment costs and improve poster design efficiency. Image layers in a poster can include canvas background layers, text background layers, and decorative layers. Different types of image layers differ significantly in layout logic and interactive behavior, requiring different types of image layers to automatically adjust their layout behavior when text changes. For example, when the text content changes, the text background layer needs to automatically expand / crop, and decorative layers related to the text content need to automatically adjust their positions.
[0003] Therefore, accurate type labels for image layers are crucial for achieving intelligent adjustment of image layers. Currently, image layer types can be identified using preset layer naming rules, but the limitations of naming standardization make the image layer types identified using this method inaccurate. Summary of the Invention
[0004] In view of the above problems, this application provides an image layer classification method and related apparatus to achieve high-accuracy image layer type recognition. The specific solution is as follows:
[0005] The first aspect of this application provides an image layer classification method, including:
[0006] Obtain the canvas size information of the target poster, as well as the position information of the text layer and the image layer to be classified in the target poster;
[0007] Based on the canvas size information, the position information of the text layer and the position information of the image layer to be classified, an index value is calculated. The index value includes: a first index value for representing the proportion of the image layer in the poster relative to the entire poster canvas, a second index value for representing the overlap of the text layer in the poster relative to the image layer in the poster, and a third index value for representing the positional offset of the text layer in the poster relative to the image layer in the poster.
[0008] From the judgment conditions corresponding to the canvas background layer, text background layer, and decoration layer, the judgment conditions satisfied by the image layer to be classified are determined based on the index value of the image layer to be classified, and the image layer type corresponding to the satisfied judgment conditions is determined as the image layer type of the image layer to be classified; wherein, the judgment conditions corresponding to any type of image layer are set according to the index range of that type of image layer.
[0009] A second aspect of this application provides an image layer classification apparatus, comprising:
[0010] The input unit is used to obtain the canvas size information of the target poster, as well as the position information of the text layer and the image layer to be classified in the target poster;
[0011] The calculation unit is used to calculate index values based on the canvas size information, the position information of the text layer and the position information of the image layer to be classified. The index values include: a first index value for characterizing the proportion of the image layer in the poster relative to the entire poster canvas, a second index value for characterizing the overlap of the text layer in the poster relative to the image layer in the poster, and a third index value for characterizing the positional offset of the text layer in the poster relative to the image layer in the poster.
[0012] The classification unit is used to determine the judgment conditions satisfied by the image layer to be classified from the judgment conditions corresponding to the canvas background layer, text background layer and decoration layer, based on the index value of the image layer to be classified, and to determine the image layer type corresponding to the satisfied judgment conditions as the image layer type of the image layer to be classified; wherein, the judgment conditions corresponding to any type of image layer are set according to the index range of that type of image layer.
[0013] A third aspect of this application provides an image layer classification device, comprising at least one processor and a memory connected to the processor, wherein:
[0014] The memory is used to store computer programs;
[0015] The processor is used to execute the computer program so that the image layer classification device can implement the image layer classification method of the first aspect described above.
[0016] A fourth aspect of this application provides a computer storage medium carrying one or more computer programs, which, when executed by an electronic device, enable the electronic device to implement the image layer classification method of the first aspect described above.
[0017] By employing the aforementioned technical solution, this application first calculates a first indicator value reflecting the proportion of the image layer, and second and third indicator values reflecting the spatial relationship between the text layer and the image layer. The calculated indicator values are then compared with pre-set judgment conditions to determine the type of the image layer. This ultimately achieves automatic image layer type recognition in posters, supporting tasks such as automatic canvas background cropping / expansion and automatic image layer adjustment to adapt to text layer layouts. Since the indicator values used are a quantitative representation of the image layer's function at the visual level, they can reflect the differences in functional positioning and design logic among different types of image layers, enabling high-precision image layer type recognition based on these indicator values. Furthermore, this application eliminates the need for manual labeling of image layer types, saving labor costs. Attached Figure Description
[0018] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings.
[0019] Figure 1 A schematic diagram of an implementation system architecture for the image layer classification scheme provided in this application;
[0020] Figure 2 A flowchart illustrating an image layer classification method provided in this application;
[0021] Figure 3 This application provides a schematic diagram of the structure of an image layer classification device;
[0022] Figure 4 This is a schematic diagram of the structure of an image layer classification device provided in this application. Detailed Implementation
[0023] 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 skilled in the art without creative effort are within the scope of protection of this application.
[0024] This application provides an image layer classification method and related apparatus. By using multiple indicators reflecting the characteristics and functional differences of different image layers, it identifies the image layer types in posters, ultimately achieving high-accuracy image layer classification. Specifically, this application's solution is applicable to image layer classification tasks in tourism posters, and is equally applicable to other types of promotional posters.
[0025] The image layer classification method provided in this application can be applied to, for example... Figure 1 The system architecture shown may include a terminal 100 and a server 200. The server 200 may include one or more servers (…). Figure 1 (This example uses a server as an illustration).
[0026] Either terminal 100 or server 200 can be used independently to execute the image layer classification method provided in this application. Alternatively, terminal 100 and server 200 can also be used collaboratively to execute the image layer classification method provided in this application. Terminal 100 can be a mobile phone, computer, etc., and this application embodiment does not impose any restrictions on the specific terminal type.
[0027] This application provides an image layer classification method, illustrated by applying the method to a computer device. Specifically, the computer device may be... Figure 1 The system consists of terminal 100 or a combination of terminal 100 and server 200. (Refer to...) Figure 2 The image layer classification method specifically includes the following steps:
[0028] Step S101: Obtain the canvas size information of the target poster, as well as the position information of the text layer and the image layer to be classified in the target poster.
[0029] The canvas size information can be represented as the width Wc and height Hc of the entire target poster. The position information of the text layer / image layer to be classified indicates the pixel position occupied by the text layer / image layer in the poster. For example, the position information of the text layer can be represented as the center coordinates (xt, yt), width Wt, and height Ht of the text layer. In this case, the boundary coordinates of the text layer in the four directions (up, down, left, right) can be represented as {yt + Ht / 2, yt − Ht / 2, xt − Wt / 2, xt + Wt / 2}, respectively. Similarly, the position information of the image layer to be classified can be represented as the center coordinates (xi, yi), width Wi, and height Hi of the image layer to be classified. In this case, the boundary coordinates of the image layer in the four directions (up, down, left, right) can be represented as {yi + Hi / 2, yi − Hi / 2, xi − Wi / 2, xi + Wi / 2}, respectively. It should be noted that regardless of whether the text layer / image layer to be classified is tilted, the position information of the text layer / image layer to be classified can be represented as in the above example to simplify the calculation.
[0030] Step S102: Calculate the index value based on the canvas size information, the position information of the text layer, and the position information of the image layer to be classified.
[0031] Specifically, the index values may include: a first index value representing the proportion of the image layer in the poster relative to the entire poster canvas; a second index value representing the overlap of the text layer in the poster relative to the image layer in the poster; and a third index value representing the positional offset of the text layer in the poster relative to the image layer in the poster.
[0032] Since the canvas background layer typically occupies the largest canvas area in a poster—meaning its proportion is much larger than other image layers—it can be distinguished from other image layers based on the first indicator value. The text background layer exists alongside the text; therefore, based on the spatial relationship between the text layer and image layers reflected by the second and third indicator values, the text background layer can be distinguished from other image layers.
[0033] Step S103: From the judgment conditions corresponding to the canvas background layer, text background layer and decoration layer, determine the judgment conditions that the image layer to be classified meets based on the index value of the image layer to be classified, and determine the image layer type corresponding to the judgment conditions met as the image layer type of the image layer to be classified.
[0034] The judgment criteria for any type of image layer are set according to the index range of that type of image layer.
[0035] It should be noted that when performing the classification task of the image layer to be classified, if the target poster contains multiple text layers, the steps of this embodiment can be performed on each text layer. If it is determined that the image layer to be classified does not belong to the text background layer based on each text layer, then it is finally determined that the image layer to be classified does not belong to the text background layer. If it is determined that the image layer to be classified belongs to the text background layer based on a certain text layer, then it is finally determined that the image layer to be classified belongs to the text background layer.
[0036] This embodiment first calculates a first indicator value reflecting the proportion of image layers, and second and third indicator values reflecting the spatial relationship between text and image layers. The calculated indicator values are then compared with pre-set judgment conditions to determine the type of image layer. This ultimately achieves automatic image layer type identification in posters, supporting tasks such as automatic canvas background cropping / expansion and automatic image layer adjustment to adapt to text layer layouts, thus improving poster production efficiency. Since the indicator values used are a quantitative representation of image layer functionality at the visual level, they can reflect the differences in functional positioning and design logic among different types of image layers, enabling high-precision image layer type identification based on these indicator values. Furthermore, this embodiment eliminates the need for manual labeling of image layer types, saving labor costs.
[0037] In one or more embodiments provided in this application, the first index value may include the width Rw of the image layer in the poster relative to the width of the entire poster canvas.
[0038] The width ratio of the image layer to be classified can be expressed as Rw = Wi / Wc.
[0039] Based on the above, the determination condition corresponding to the canvas background layer may include: Rw>T1.
[0040] T1 represents the preset background ratio threshold. The specific value of T1 can be set according to the relevant standards of the poster design industry. It can also take into account the size adaptation requirements of the poster in different display scenarios to avoid poor visual effects such as excessive white space in the poster due to an overly narrow canvas background or the core visual elements being cut off due to an overly wide canvas background.
[0041] For example, based on the consensus in the tourism poster design industry, the canvas background, as the visual base, needs to cover more than 70% of the horizontal space of the canvas; image layers with a lower proportion cannot form a complete base effect. Optionally, T1 can be 70%.
[0042] In addition, the T1 value can be determined based on statistical data or test data of the sample posters. For example, the misclassification rate and accuracy corresponding to different T1 values can be tested on the sample poster set, and the T1 value with the lowest misclassification rate and the highest accuracy can be set as the background proportion threshold.
[0043] It should be noted that, regardless of whether the poster is horizontal or vertical, the layout of text and images is generally predominantly horizontal. Therefore, this embodiment uses width features to reflect the proportion of image layers, which matches the visual flow of the horizontally dominated poster. Furthermore, compared to area proportion, this embodiment has lower computational complexity, helping to improve the efficiency of image layer classification.
[0044] In one or more embodiments provided in this application, the second indicator value may include the pixel overlap rate of the text layer in the poster relative to the image layer in the poster, and the third indicator value may include the center offset distance D of the text layer in the poster relative to the image layer in the poster.
[0045] The pixel overlap rate of the image layer to be classified can be expressed as overlap=S 重叠区域 / S 文字层 S 重叠区域 S represents the area occupied by the overlapping region between the text layer and the image to be classified. 文字层This represents the area occupied by the text layer. The center offset distance of the image layer to be classified can be expressed as D = sqrt((xi - xt)^2 + (yi - yt)^2), which is the Euclidean distance between the center point of the image layer to be classified and the center point of the text layer.
[0046] In one possible implementation, the positional information of the text layer and the image layer to be classified in the target poster includes: the center coordinates, height, and width of the text layer and the image layer to be classified; based on this, the calculation process of the pixel overlap rate of the text layer relative to the image layer to be classified may include:
[0047] Step S201: Based on the center coordinates, height, and width of the text layer and the image layer to be classified, calculate the coordinates of the four boundaries of the text layer and the image layer to be classified, which can be expressed as {yi+Hi / 2, yi−Hi / 2, xi−Wi / 2, xi+Wi / 2}.
[0048] Step S202: Based on the coordinates of the four boundaries of the text layer and the image layer to be classified, calculate the width and height of the overlapping area of the text layer and the image layer to be classified. The width of the overlapping area can be expressed as overlap_width = max(0, overlap_max − overlap_min), where overlap_min = max(xt − Wt / 2, xi − Wi / 2), overlap_max = min(xt + Wt / 2, xi + Wi / 2); the height of the overlapping area can be expressed as overlap_height = max(0, overlap_maxy − overlap_miny), where overlap_miny = max(yt − Ht / 2, yi − Hi / 2), overlap_maxy = min(yt + Ht / 2, yi + Hi / 2).
[0049] Step S203: Based on the overlapping area and the width and height of the text layer, calculate the pixel overlap rate of the text layer relative to the image layer to be classified, which can be expressed as Overlap = (overlap_width × overlap_height) / (Wt × Ht).
[0050] This embodiment calculates the pixel overlap rate of the text layer relative to the image layer to be classified using a rectangular collision detection algorithm, which simplifies the area calculation method and provides a foundation for improving classification efficiency.
[0051] Based on the above, the determination conditions corresponding to the text background layer may include: Rw≤T1, overlap>T2, and D <r。
[0052] Where T2 represents the preset overlap rate threshold, and r is the radius of the text layer in the poster.
[0053] It should be noted that the core function of the text background layer is to highlight the text and ensure its readability. Based on this, the value of T2 can be set by combining the poster design requirements with the accuracy test results. Optionally, T2 can be 60%.
[0054] This embodiment determines whether an image layer to be classified is a text background layer based on index values reflecting the proportion of the image layer, the pixel overlap with the text layer, and the offset. Since the second and third index values can be adapted to the characteristics of text background layers—adapting to text, strong overlap, and low offset—accurate recognition of text background layers can be achieved based on the aforementioned indexes.
[0055] Based on the above, the determination conditions corresponding to the decorative layer may include: overlap ≤ T2 and Rw ≤ T3; or, D ≥ r and Rw ≤ T3.
[0056] T3 represents the preset threshold for the proportion of decoration.
[0057] It should be noted that the decorative layer aims to create a specific visual atmosphere and is not constrained by the core information conveyed; compared to the canvas background layer and text background layer, the decorative layer is more flexible and free. Based on this, the value of T3 can be set by combining the poster design requirements and the results of the accuracy test. Optionally, T3 can be 30%.
[0058] This embodiment determines whether an image layer to be classified is a decorative layer based on index values reflecting the proportion of the image layer and the pixel overlap / offset with the text layer. Since the first index value can be adapted to the flexible and free characteristics of decorative layers, and the second index value can be adapted to the weak overlap / high offset characteristics of decorative layers, the task of accurately identifying decorative layers can be achieved based on the aforementioned indexes.
[0059] In one or more embodiments provided in this application, the aforementioned background proportion threshold / overlap rate threshold / decoration proportion threshold can be a dynamic threshold that can be adjusted according to the poster style.
[0060] For example, T1 = 0.7 can be set as a general background proportion threshold. Based on this, for minimalist posters, T1 = 0.65 can be set, and for full-screen immersive posters, T1 = 0.75 can be set to achieve image layer classification tasks adapted to the poster style. In one possible implementation, a style-threshold mapping library can be pre-established, recording the T1 / T2 / T3 thresholds corresponding to each style. Optionally, after the style-threshold mapping library is established, the thresholds in the library can be adjusted based on experimental errors. For example, for a certain style, a general threshold or the threshold corresponding to that style obtained from the style-threshold mapping library can be used as the initial threshold. Classification tests are performed based on the initial threshold, and the classification error corresponding to the initial threshold is calculated. If the error exceeds a preset error range, the initial threshold is fine-tuned. For example, the adjustment range can be ±0.02. Classification tests are then performed again based on the adjusted threshold, and the classification error is calculated again until the error is within the preset error range.
[0061] Based on the above, we can first determine whether the conditions for the canvas background layer are met. If not, we can then determine whether the conditions for the text background layer are met. If still not met, we can then determine whether the conditions for the decoration layer are met.
[0062] In one or more embodiments provided in this application, the method may further include:
[0063] If the image layer to be classified does not meet the judgment conditions corresponding to each type of image layer, the pre-trained model is invoked to identify the image layer type to which the image layer to be classified belongs.
[0064] The pre-trained model is trained using sample data labeled with image layer type tags, and the sample data is generated based on sample posters.
[0065] In one possible implementation, sample posters can be used as sample data, with image layer type labels annotated on them.
[0066] In another possible implementation, the parameter values calculated based on the sample poster can be used as sample data.
[0067] The aforementioned pre-trained model can be a general CNN model (such as ResNet, VGG, etc.), which can be used to achieve massive type recognition tasks for complex images.
[0068] This embodiment adopts an image layer type recognition method that first makes logical judgments and then calls the model, which saves system computing power. Since only a few ambiguous cases usually need to be processed by calling the model, the overall time consumption when using this embodiment to process a large number of image layer classification tasks is short. In addition, this embodiment uses a pre-trained model to solve the shortcomings of the logical judgment method in handling ambiguous cases, ensuring the overall accuracy of image layer classification. Furthermore, it can also avoid the hard threshold defect of logical judgment to a certain extent.
[0069] Since this solution only requires classifying and recognizing the canvas background layer, text background layer, and decoration layer, the difficulty is relatively low, allowing it to be implemented based on a lightweight CNN model. Therefore, in one or more embodiments provided in this application, the pre-trained model can be a lightweight CNN model.
[0070] Optionally, the pre-trained model can adopt a lightweight structure consisting of 3 convolutional layers and 2 fully connected layers, specifically including: input layer, convolutional layer, pooling layer, fully connected layer and Softmax output layer.
[0071] Correspondingly, input features can be adaptively simplified. Optionally, the configuration process of the sample data may include:
[0072] Based on the canvas size information of the sample poster, as well as the position information of the text layer and the specified image layer in the sample poster, the index value of the specified image layer is calculated to generate sample data.
[0073] The sample data may include the index values of the specified image layer, and the sample data is labeled with the type label of the specified image layer. For example, 0 / 1 / 2 can be used as the type label, where 0 represents the canvas background layer, 1 represents the text background layer, and 2 represents the decoration layer.
[0074] Based on this, the sample data can also include other indicators that reflect spatial relationships, such as the aspect ratio of a specified image layer, the relative angle between the text layer and the specified image layer in the sample poster, and color similarity. Color similarity can be calculated using the HSV color space with weights based on hue, saturation, and brightness. By utilizing the aforementioned input features, the CNN can learn the spatial patterns of image layers in the poster and thereby determine the image layer type label.
[0075] The input features used in this embodiment are compatible with the spatial relationship analysis logic required by this solution, enabling high-precision image layer classification tasks to be achieved based on low-dimensional input features and a lightweight pre-trained model. Furthermore, the model structure used in this embodiment is relatively simple, with the input feature dimension being much smaller than the pixel-level image feature dimension, which can significantly reduce inference time.
[0076] In addition, the aforementioned lightweight network structure has advantages such as low computational complexity, low deployment cost, and easy maintenance. Even if the pre-trained model is embedded into the poster production system and run in real time, it will not have a significant impact on the overall response speed of the system.
[0077] The image layer classification apparatus provided in the embodiments of this application is described below. The image layer classification apparatus described below can be referred to in correspondence with the image layer classification method described above.
[0078] See Figure 3 , Figure 3 This is a schematic diagram of the structure of an image layer classification device disclosed in an embodiment of this application.
[0079] like Figure 3 As shown, the device may include:
[0080] Input unit 11 is used to obtain the canvas size information of the target poster, as well as the position information of the text layer and the image layer to be classified in the target poster;
[0081] The calculation unit 12 is used to calculate index values based on the canvas size information, the position information of the text layer and the position information of the image layer to be classified. The index values include: a first index value representing the proportion of the image layer in the poster relative to the entire poster canvas, a second index value representing the overlap of the text layer in the poster relative to the image layer in the poster, and a third index value representing the positional offset of the text layer in the poster relative to the image layer in the poster.
[0082] The classification unit 13 is used to determine the judgment conditions satisfied by the image layer to be classified from the judgment conditions corresponding to the canvas background layer, text background layer and decoration layer, based on the index value of the image layer to be classified, and to determine the image layer type corresponding to the satisfied judgment conditions as the image layer type of the image layer to be classified; wherein, the judgment conditions corresponding to any type of image layer are set according to the index range of that type of image layer.
[0083] In one or more embodiments provided in this application, the first index value may include the width ratio Rw of the image layer in the poster relative to the entire poster canvas; the determination condition corresponding to the canvas background layer may include: Rw>T1; where T1 represents a preset background ratio threshold.
[0084] In one or more embodiments provided by the present application, the second index value may include the pixel overlap rate overlap of the text layer in the poster relative to the picture layer in the poster, and the third index value may include the central offset distance D of the text layer in the poster relative to the picture layer in the poster; the determination condition corresponding to the text background layer may include: Rw ≤ T1, overlap > T2, and D < r; where T2 represents a preset overlap rate threshold, and r is the radius of the text layer in the poster.
[0085] In one or more embodiments provided by the present application, the determination condition corresponding to the decoration layer may include: overlap ≤ T2 and Rw ≤ T3; or, D ≥ r and Rw ≤ T3; where T3 represents a preset decoration ratio threshold.
[0086] In one or more embodiments provided by the present application, the position information of the text layer and the to-be-classified picture layer in the target poster may include: the central coordinates, height, and width of the text layer and the to-be-classified picture layer.
[0087] On this basis, the process by which the calculation unit 12 calculates the pixel overlap rate of the text layer relative to the to-be-classified picture layer may include:
[0088] According to the central coordinates, height, and width of the text layer and the to-be-classified picture layer, calculate the four-side boundary coordinates of the text layer and the to-be-classified picture layer respectively.
[0089] According to the four-side boundary coordinates of the text layer and the to-be-classified picture layer, calculate the width and height of the overlapping area of the text layer and the to-be-classified picture layer.
[0090] According to the overlapping area and the width and height of the text layer, calculate the pixel overlap rate of the text layer relative to the to-be-classified picture layer.
[0091] In one or more embodiments provided by the present application, the classification unit 13 is further configured to:
[0092] In the case where the to-be-classified picture layer does not meet the determination conditions corresponding to each type of picture layer, call a pre-trained model to identify the type of the to-be-classified picture layer; where the pre-trained model is trained using sample data labeled with picture layer type labels, and the sample data is generated based on sample posters.
[0093] In one or more embodiments provided by the present application, the pre-trained model is a lightweight CNN model.
[0094] On this basis, the configuration process of the sample data may include:
[0095] Based on the canvas size information of the sample poster, and the position information of the text layer and the specified image layer in the sample poster, calculate the index value of the specified image layer;
[0096] Generate sample data, which includes the index values of the specified image layer and is labeled with the type label of the specified image layer.
[0097] It should be noted that each unit in the image layer classification device can be implemented entirely or partially through software, hardware, or a combination thereof. These units can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each unit.
[0098] This application also provides an image layer classification device in its embodiments. (See reference...) Figure 4 The diagram illustrates a structural schematic of an image layer classification device suitable for implementing embodiments of this application. The image layer classification device described in this application may include, but is not limited to, fixed terminals such as mobile phones and tablet computers. Figure 4 The image layer classification device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0099] like Figure 4 As shown, the image layer classification device may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 1, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 2 or a program loaded from a storage device 8 into a random access memory (RAM) 3, to implement the image layer classification method of the foregoing embodiments of this application. When the image layer classification device is powered on, the RAM 3 also stores various programs and data required for the operation of the image layer classification device. The processing unit 1, ROM 2, and RAM 3 are interconnected via a bus 4. An input / output (I / O) interface 5 is also connected to the bus 4.
[0100] Typically, the following devices can be connected to I / O interface 5: input devices 6 including, for example, touchscreens, touchpads, keyboards, mice, etc.; output devices 7 including, for example, liquid crystal displays (LCDs); storage devices 8 including, for example, memory cards, hard drives, etc.; and communication devices 9. Communication device 9 allows the image layer classification device to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 4 A picture layer classification device with various means is shown; however, it should be understood that it is not required to implement or have all the means shown. More or fewer means may be implemented alternatively.
[0101] This application also provides a computer program product including computer-readable instructions, which, when executed on an electronic device, cause the electronic device to implement any of the image layer classification methods provided in this application.
[0102] This application also provides a computer-readable storage medium that carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any of the image layer classification methods provided in this application.
[0103] Finally, it should 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.
[0104] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.
[0105] 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 layer classification method, characterized in that, Including: Obtaining the canvas size information of the target poster, as well as the position information of the text layer and the to-be-classified image layer in the target poster; Calculating an index value based on the canvas size information, the position information of the text layer, and the position information of the to-be-classified image layer, where the index value includes: a first index value for characterizing the proportion of the image layer in the poster relative to the entire poster canvas, a second index value for characterizing the overlapping situation of the text layer in the poster relative to the image layer in the poster, and a third index value for characterizing the position offset situation of the text layer in the poster relative to the image layer in the poster; Determining the determination condition satisfied by the to-be-classified image layer from the determination conditions corresponding to the canvas background layer, the text background layer, and the decoration layer respectively according to the index value of the to-be-classified image layer, and determining the image layer type corresponding to the satisfied determination condition as the image layer type of the to-be-classified image layer; wherein, the determination condition corresponding to any type of image layer is set according to the index range of this type of image layer.
2. The image layer classification method according to claim 1, characterized in that, The first index value includes the width proportion Rw of the image layer in the poster relative to the entire poster canvas; The determination condition corresponding to the canvas background layer includes: Rw > T1; where T1 represents a preset background proportion threshold.
3. The image layer classification method according to claim 2, characterized in that, The second index value includes the pixel overlap rate overlap of the text layer in the poster relative to the image layer in the poster, and the third index value includes the center offset distance D of the text layer in the poster relative to the image layer in the poster; The determination condition corresponding to the text background layer includes: Rw ≤ T1, overlap > T2, and D < r; where T2 represents a preset overlap rate threshold, and r is the radius of the text layer in the poster.
4. The image layer classification method according to claim 3, characterized in that, The determination condition corresponding to the decoration layer includes: overlap ≤ T2 and Rw ≤ T3; or, D ≥ r and Rw ≤ T3; where T3 represents a preset decoration proportion threshold.
5. The image layer classification method according to claim 3 or 4, characterized in that, The position information of the text layer and the to-be-classified image layer in the target poster includes: the center coordinates, height, and width of the text layer and the to-be-classified image layer; The calculation process of the pixel overlap rate of the text layer relative to the to-be-classified image layer includes: Respectively calculating the four-side boundary coordinates of the text layer and the to-be-classified image layer according to the center coordinates, height, and width of the text layer and the to-be-classified image layer; Calculating the width and height of the overlapping area of the text layer and the to-be-classified image layer according to the four-side boundary coordinates of the text layer and the to-be-classified image layer; Calculating the pixel overlap rate of the text layer relative to the to-be-classified image layer according to the overlapping area and the width and height of the text layer.
6. The image layer classification method according to any one of claims 1-4, characterized in that, This method further includes: In the case that the to-be-classified image layer does not satisfy the determination conditions corresponding to each type of image layer, calling a pre-trained model to identify the image layer type to which the to-be-classified image layer belongs; Wherein, the pre-trained model is trained using sample data labeled with image layer type labels, and the sample data is generated based on sample posters.
7. The image layer classification method according to claim 6, characterized in that, The pre-trained model is a lightweight CNN model; The configuration process of the sample data includes: Based on the canvas size information of the sample poster, and the position information of the text layer and the specified image layer in the sample poster, calculate the index value of the specified image layer; Generate sample data, which includes the index values of the specified image layer and is labeled with the type label of the specified image layer.
8. An image layer classification device, characterized in that, include: The input unit is used to obtain the canvas size information of the target poster, as well as the position information of the text layer and the image layer to be classified in the target poster; The calculation unit is used to calculate index values based on the canvas size information, the position information of the text layer and the position information of the image layer to be classified. The index values include: a first index value for characterizing the proportion of the image layer in the poster relative to the entire poster canvas, a second index value for characterizing the overlap of the text layer in the poster relative to the image layer in the poster, and a third index value for characterizing the positional offset of the text layer in the poster relative to the image layer in the poster. The classification unit is used to determine the judgment conditions satisfied by the image layer to be classified from the judgment conditions corresponding to the canvas background layer, text background layer and decoration layer, based on the index value of the image layer to be classified, and to determine the image layer type corresponding to the satisfied judgment conditions as the image layer type of the image layer to be classified; wherein, the judgment conditions corresponding to any type of image layer are set according to the index range of that type of image layer.
9. An image layer classification device, characterized in that, It includes at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the image layer classification device can implement the image layer classification method as described in any one of claims 1 to 7.
10. A computer storage medium, characterized in that, The storage medium carries one or more computer programs that, when executed by an electronic device, enable the electronic device to implement the image layer classification method as described in any one of claims 1 to 7.