Layer restoration method, device, computer-readable storage medium, and computer equipment

By constructing a layer tree through layer recognition, the system automatically identifies layer information in JPEG and PNG format images, solving the problem of the large workload for designers to manually restore layers and achieving efficient layer restoration and design draft generation.

CN111986292BActive Publication Date: 2025-01-14TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201910427141.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-05-22
Publication Date
2025-01-14
Estimated Expiration
2039-08-27

AI Technical Summary

Technical Problem

In traditional methods, designers need to manually process JPEG and PNG image materials to restore them to the layers in the UI design draft, which is a huge workload. Furthermore, existing AI technology relies on manually labeled data, which limits its applicability.

Method used

By constructing a layer tree through layer recognition, it automatically identifies layer information in JPEG and PNG format images, including text, graphics, and image information, and generates design draft images with layer structure.

Benefits of technology

It achieves automated layer restoration, improves designers' work efficiency, reduces manual processing workload, and avoids the limitations of existing AI technologies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111986292B_ABST
    Figure CN111986292B_ABST
Patent Text Reader

Abstract

The present application relates to a layer restoration method, device, computer-readable storage medium and computer equipment, the method comprising: obtaining a to-be-processed image, which does not contain layer information. Performing layer identification on the to-be-processed image to construct a layer tree, and performing layer restoration on the to-be-processed image according to the layer tree to obtain a design draft image with layer information. Performing layer identification on the to-be-processed image that does not contain layer information, and constructing a layer tree. Because the layer tree contains layer structure information, the to-be-processed image can be layer restored based on the layer tree of the to-be-processed image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a layer restoration method, device, computer-readable storage medium and computer equipment. Background Art

[0002] In the traditional method, when designers use online image materials, because many of the online image materials are in JPEG (full name: Joint Photographic Experts Group) format and PNG (full name: Portable Network Graphics) format, images in this format do not contain layer information, so designers often need to manually process the online image materials to restore them to the layers in the UI (User Interface) design draft, which consumes a huge amount of work. Summary of the invention

[0003] Based on this, it is necessary to provide a layer restoration method, apparatus, computer-readable storage medium and computer equipment to address the technical problem that the workload of manually restoring layers is too large.

[0004] A layer restoration method, comprising:

[0005] Obtaining a picture to be processed, wherein the picture to be processed does not contain layer information;

[0006] Perform layer identification on the image to be processed to construct a layer tree;

[0007] The image to be processed is restored in layers according to the layer tree to obtain a design draft image with layer information.

[0008] A layer restoration device, comprising:

[0009] A module for obtaining a picture to be processed, used to obtain a picture to be processed, wherein the picture to be processed does not contain layer information;

[0010] A layer identification module, used for performing layer identification on the image to be processed to construct a layer tree;

[0011] The layer restoration module is used to restore the layers of the image to be processed according to the layer tree to obtain a design draft image with layer information.

[0012] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the steps of the method described above.

[0013] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above method.

[0014] The above-mentioned layer restoration method, device, computer-readable storage medium and computer equipment obtain a to-be-processed image, which does not contain layer information. The to-be-processed image is layer-identified to construct a layer tree, and the to-be-processed image is layer-restored according to the layer tree to obtain a design draft image with layer information. The to-be-processed image that does not contain layer information is layer-identified, and a layer tree is constructed. Because the layer tree contains layer structure information, the to-be-processed image can be layer-restored according to the layer tree of the to-be-processed image. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 A diagram showing an application environment of a layer restoration method in an embodiment;

[0016] Figure 2 A schematic diagram of a process of layer restoration method in one embodiment;

[0017] Figure 3 for Figure 2 A flowchart of a method for constructing a layer tree for layer recognition of a processed image is shown in FIG.

[0018] Figure 4 for Figure 3 A flowchart of a method for obtaining a text layer instance by performing text layer recognition on a processed image;

[0019] Figure 5 A schematic diagram of an interface for performing text area detection on a picture to be processed in one embodiment;

[0020] Figure 6 A schematic diagram of a text content recognition result in one embodiment;

[0021] Figure 7 for Figure 3 A flowchart of a method for obtaining a graphic layer instance by performing graphic layer recognition on a processed image;

[0022] Figure 8 for Figure 3 A flowchart of a method for obtaining an image layer instance by performing image layer recognition on a processed image;

[0023] Fig. 9 for Figure 3 Flowchart of the method for constructing a layer tree;

[0024] Fig.10 is a schematic diagram of a layer instance having a containment relationship in one embodiment;

[0025] Fig.11 A schematic diagram of a process of a layer restoration method in another embodiment;

[0026] Fig.12 It is a flowchart of a layer restoration method in a specific embodiment;

[0027] Fig.13 This is a schematic diagram of the interface of the home page of a picture-to-design draft tool in one embodiment;

[0028] Fig.14 This is a schematic diagram of an interface of a tool page of a picture-to-design draft tool in one embodiment;

[0029] Fig.14A It is a design draft picture obtained by selecting to export all layers on the tool page in an embodiment;

[0030] Fig. 14B It is a design draft picture obtained by selecting to export part of the layers on the tool page in one embodiment;

[0031] Fig.15 is a structural block diagram of a layer restoration device in an embodiment;

[0032] Fig.16 for Fig.15 The structural block diagram of the layer recognition module in the middle;

[0033] Fig.17 for Fig.16 The structural diagram of the Chinese text layer recognition unit;

[0034] Fig.18 for Fig.16 The structural block diagram of the graphic layer recognition unit;

[0035] Fig.19 for Fig.16 The structural block diagram of the image layer recognition unit in the figure;

[0036] Fig. 20 for Fig.16 The structural diagram of the layer tree construction unit in the middle layer;

[0037] Fig.21 is a structural block diagram of a layer restoration device in another embodiment;

[0038] Fig. 22 FIG. 4 is a structural block diagram of a computer device in one embodiment. DETAILED DESCRIPTION

[0039] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0040] Figure 1 FIG. 1 is an application environment diagram of a layer restoration method in an embodiment. Figure 1 , the layer restoration method is applied to a layer restoration system. The layer restoration system includes a terminal 110 and a server 120. The terminal 110 and the server 120 are connected via a network. The terminal 110 can be a desktop terminal or a mobile terminal, and the mobile terminal can be at least one of a mobile phone, a tablet computer, a laptop computer, etc. The server 120 can be implemented by an independent server or a server cluster composed of multiple servers. The layer restoration method includes: obtaining a picture to be processed, which does not contain layer information; performing layer identification on the picture to be processed to construct a layer tree; performing layer restoration on the picture to be processed according to the layer tree to obtain a design draft picture with layer information.

[0041] like Figure 2 As shown, in one embodiment, a layer restoration method is provided. This embodiment mainly applies the method to the above Figure 1 The server 120 in FIG. Figure 2 , the layer restoration method specifically includes the following steps:

[0042] S220, obtaining a picture to be processed, wherein the picture to be processed does not contain layer information.

[0043] Get the image to be processed, where the image to be processed can be an image material downloaded from the Internet, and the image material does not contain layer information. Specifically, in general, the images downloaded from the Internet are mostly in JPEG format, PNG format, etc. After being compressed into JPEG and PNG formats, these formats of images do not contain layer information. However, images in PSD (Photoshop Document) and TIF (Tagged Image File Format) formats retain layer information during the compression process.

[0044] S240, performing layer recognition on the image to be processed to construct a layer tree.

[0045] Perform layer recognition on the image to be processed that does not contain layer information to construct a layer tree. The image to be processed contains text information, graphic information, image information, etc., and the image to be processed is composed of different layers corresponding to the text information, graphic information, and image information. Therefore, perform layer recognition on the image to be processed, identify the different layers corresponding to the text information, graphic information, and image information, and then construct a layer tree from different layers. The layer tree contains the different layers in the image to be processed, and contains the structural relationship between different layers.

[0046] S260, performing layer restoration on the image to be processed according to the layer tree to obtain a design draft image with layer information.

[0047] Because the layer tree contains the different layers in the image to be processed and the structural relationship between different layers, the layer tree can be used to restore the layers of the image to be processed. That is, the layer structure information of the image to be processed is restored to obtain the design draft image with layer information. Designers can directly and freely edit and modify the different layers in the design draft image to obtain the edited and modified image.

[0048] In the embodiment of the present application, a picture to be processed is obtained, and the picture to be processed does not contain layer information. Layer identification is performed on the picture to be processed to construct a layer tree, and the layer restoration is performed on the picture to be processed according to the layer tree to obtain a design draft picture with layer information. Layer identification is performed on the picture to be processed that does not contain layer information, and a layer tree is constructed. Because the layer tree contains layer structure information, the layer restoration of the picture to be processed can be performed based on the layer tree of the picture to be processed.

[0049] In one embodiment, Figure 3 As shown, S240, performing layer identification on the image to be processed to construct a layer tree includes:

[0050] S242, performing text layer recognition on the image to be processed to obtain a text layer instance.

[0051] The image to be processed is composed of different layers corresponding to text information, graphic information and image information. Therefore, firstly, the text layer recognition is performed on the image to be processed, that is, the text information in the image to be processed is recognized, and then a text layer instance is created accordingly according to the recognized text information. The text here specifically includes text (including Chinese, English and various languages, etc.), numbers (including Arabic numerals and Roman numerals, etc.) and symbols (including punctuation marks, punctuation marks and special symbols such as operation symbols). Of course, the above is not exhaustive, and other forms of text can also be included. Correspondingly, the text information refers to the information corresponding to the text, numbers and symbols, including but not limited to the coordinates, width and height, content, color, size and other information corresponding to the text, numbers and symbols. Among them, the coordinates refer to the coordinates of the position where the text, number or symbol appears in the image to be processed. The width and height refer to the width and height of the text, number or symbol presented in the image to be processed. If the image to be processed contains multiple text information, multiple text layer instances will be created accordingly. For each text information, a text layer instance is created accordingly, and the text layer instance refers to the layer containing one text information.

[0052] S244, performing graphic layer recognition on the image to be processed to obtain a graphic layer instance.

[0053] After the text layer is identified on the image to be processed to obtain a text layer instance, the graphic layer is further identified on the image to be processed to obtain a graphic layer instance. Specifically, the graphic information contained in the image to be processed is identified, and a graphic layer instance is created accordingly based on the identified graphic information. The graphics here specifically refer to the basic geometric figures in the image to be processed, including regular geometric figures and irregular geometric figures, including plane geometric figures and solid geometric figures. Among them, the plane geometric figures include (1) circles: including perfect circles, ellipses, and multi-focus circles - ovals. (2) Polygons: triangles, quadrilaterals, pentagons, etc. (3) Arches: superior arc arches, inferior arc arches, parabolic arches, etc. (4) Multiple arcs: crescent shapes, grain shapes, Tai Chi shapes, gourd shapes, etc.

[0054] Correspondingly, the graphic information refers to the information corresponding to the above-mentioned basic geometric figures, including but not limited to the coordinates, width and height, graphic type, graphic color, path set, radius, rounded corners and other information of the basic geometric figures. Among them, the coordinates refer to the coordinates of the position where the graphic appears in the image to be processed. The width and height refer to the width and height of the graphic presented in the image to be processed. The path set refers to the path for creating the graphic, for example, the path set of the graphic is obtained through the path of SVG (Scalable Vector Graphics). Among them, the path element is the most powerful one of the basic shapes of SVG. It can not only create other basic shapes, but also create more other shapes. The path element can be used to draw rectangles (right-angled rectangles or rounded rectangles), circles, ellipses, polylines, polygons, and some other shapes, such as Bezier curves, quadratic curves and other curves. After obtaining the path set of the graphic through SVG, the interface of the third-party design software can be called to redraw the graphic layer instance according to the path set of the graphic. Among them, the third-party design software can be photoshop, skepch, Adobe XD, etc.

[0055] If the image to be processed contains multiple graphic information, multiple graphic layer instances will be created accordingly. For each graphic information, a graphic layer instance is created accordingly. A graphic layer instance refers to a layer containing one graphic information.

[0056] S246, performing image layer recognition on the image to be processed to obtain an image layer instance.

[0057] After the image to be processed is identified by the graphic layer to obtain the graphic layer instance, the image to be processed is further identified by the image layer to obtain the image layer instance. Specifically, the image information contained in the image to be processed is identified, and the image layer instance is created accordingly according to the identified image information. Here, the image refers to the complex area left after the text layer instance and the graphic layer instance are identified in the image to be processed. Cutting processing is used when identifying the complex area in the image to be processed. Correspondingly, the image information refers to the coordinates, width, height and image path corresponding to the above complex area. Among them, the coordinates refer to the coordinates of the position where the image to be cut out appears in the image to be processed. The width and height refer to the width and height of the image to be cut out in the image to be processed. The image path refers to the address of the image file generated after cutting out. If the image to be processed contains multiple image information, multiple image layer instances will be created accordingly. For each image information, an image layer instance is created accordingly, and the image layer instance refers to the layer containing one image information.

[0058] S248, creating a group layer instance according to the text layer instance, the graphic layer instance and the image layer instance, and constructing a layer tree by the group layer instance.

[0059] After the above three recognitions are performed on the image to be processed to obtain multiple text layer instances, multiple graphic layer instances, and multiple image layer instances, a group layer instance is created according to the relationship between these layer instances, and then a layer tree of the image to be processed is constructed from the group layer instance. The layer tree contains each layer instance in the image to be processed, and includes the relationship between different layer instances.

[0060] In the embodiment of the present application, the text information, graphic information and image information in the image to be processed are respectively identified to obtain multiple text layer instances, multiple graphic layer instances and multiple image layer instances. Thus, the text information, graphic information and image information contained in the image to be processed are disassembled, and a layer tree of the image to be processed is created, and the image to be processed is restored in layers according to the layer tree. The image in JPEG or PNG format that does not contain layer information is redrawn to obtain a PSD (Photoshop Document) or TIF (Tagged Image File Format) format image, so that any layer in the layer tree can be selected for editing.

[0061] In one embodiment, Figure 4 As shown, S242, performing text layer recognition on the image to be processed to obtain a text layer instance includes:

[0062] S242a, performing text region detection on the image to be processed to obtain a text region.

[0063] Text area detection refers to detecting the text area of ​​the image to be processed and obtaining the text area. Figure 5 As shown in the figure, the box in the figure refers to the text area. The text area refers to the area containing text, and a picture to be processed may contain multiple text areas. The EAST algorithm can be used to detect text areas, among which the EAST (Efficient and AccuracyScene Text) algorithm can achieve efficient and accurate scene text detection.

[0064] S242b, performing text content recognition on the text area to obtain a text content recognition result.

[0065] After obtaining the text area, the text content is recognized in the text area. Specifically, the RNN+CTC model can be used for recognition. Among them, RNN (Recurrent Neural Network) is a type of neural network used to process sequence data. CTC (Connectionist Temporal Classification) is a loss function used to measure the difference between the output obtained after the input sequence data passes through the RNN neural network and the actual output. After the RNN+CTC model performs text content recognition, the text content and the corresponding confidence level are obtained. Figure 6 As shown, for Figure 5 The text area within the box is subjected to text content recognition to obtain a text content recognition result.

[0066] S242c, calculating attribute information of the text content recognition result to obtain attribute information of the text content recognition result.

[0067] In getting Figure 6 After the text content recognition result is shown, the attribute information of the text content recognition result is calculated. Specifically, the attribute information of each text content is calculated, such as the coordinates, width, height, content, color, size and other information corresponding to each text content.

[0068] S242d, creating a text layer instance according to the text content recognition result and the attribute information of the text content recognition result.

[0069] The text content recognition result includes the text content and the corresponding confidence level after text content recognition. The attribute information of the text content recognition result includes the coordinates, width, height, content, color, size and other information corresponding to each text content. Therefore, a text layer instance can be created based on the text content and the coordinates, width, height, content, color, size and other information corresponding to each text content.

[0070] In the embodiment of the present application, the text area in the image to be processed is obtained by text area detection, and then the text content is identified in the text area to obtain the text content and the corresponding confidence, and then the attribute information of the text content is obtained. The attribute information includes the coordinates, width, height, content, color, size and other information corresponding to each text content. Therefore, according to the text content and the attribute information of the text content, the text information in the image to be processed can be redrawn to create a text layer instance of the image to be processed.

[0071] In one embodiment, Figure 7 As shown, S244, performing graphic layer recognition on the image to be processed to obtain a graphic layer instance includes:

[0072] S244a, performing text area filtering on the image to be processed to obtain a first target image.

[0073] The process of text area filtering refers to obtaining the boundary color of the text area in the image to be processed, and filling the text area with color according to the boundary color of the text area, thereby obtaining the first target image. Figure 5 The text area in the box is filled with the border color of the text area to cover the text area. That is, the first target image does not contain a text area.

[0074] S244b, performing graphic detection on the first target image to obtain a graphic detection result.

[0075] After obtaining the first target image, the graphics in the first target image are detected to obtain the graphics detection result. Specifically, the first target image is input into the graphics (circle, rectangle, triangle, etc.) function, and all basic graphics are obtained through Hough transform, that is, the graphics detection result is obtained. For example, Figure 8 As shown, the image to be processed contains circles, sectors, rectangles and polygons. Among them, the graphic function is a function that can identify basic graphics such as circles, rectangles, triangles, etc. Then, the graphics in the graphic detection results are cleaned of junk graphics to remove irreversible graphics. The steps for cleaning junk graphics are as follows: sample the pixel points in the graphics in the graphic detection results. If the color is the same, it is filled with a solid color. If the color conforms to the linear transformation, it is a gradient fill. Otherwise, it is regarded as an irreversible graphic and the irreversible graphic is removed, that is, the subsequent steps of calculating attribute information are not performed.

[0076] S244c, calculating attribute information of the graphic detection result to obtain attribute information of the graphic detection result.

[0077] After obtaining the graphic detection results, the attribute information of each graphic detection result is calculated. Specifically, the coordinates, width and height, graphic type, graphic color, path set, radius, fillet and other information corresponding to the graphic detection result are calculated. Among them, the path set refers to the path for creating the graphic.

[0078] S244d, creating a graphic layer instance according to the graphic detection result and the attribute information of the graphic detection result.

[0079] Specifically, after obtaining the coordinates, width and height, graphic type, graphic color, path set, radius, rounded corners and other information corresponding to the graphic detection result, the graphics in the image to be processed can be redrawn to create a graphic layer instance. When redrawing the basic graphics (circle, rectangle, triangle, etc.) to create a graphic layer instance, the API (Application Programming Interface) of the third-party design software is directly called according to the attribute information corresponding to the graphic detection result for drawing. When drawing complex graphics such as polygons, SVG path is used for drawing according to the attribute information corresponding to the graphic detection result.

[0080] In the embodiment of the present application, after filtering the text area of ​​the image to be processed, a first target image without a text area is obtained. Then, the graphics in the first target image are further detected to obtain the shape of the graphics and the attribute information of the graphics. Redraw and create a graphics layer instance according to the shape of the graphics and the attribute information of the graphics. First, the text area is filtered to remove the text area of ​​the text layer that has been created in the image to be processed, which reduces the noise when performing graphics detection, speeds up the efficiency of graphics detection, and also improves the accuracy of graphics detection.

[0081] In one embodiment, S244a, performing text area filtering on the image to be processed to obtain a first target image includes:

[0082] Get the border color of the text area in the image to be processed;

[0083] The text area is filled with color according to the boundary color of the text area to obtain a first target image.

[0084] Specifically, the first target image is Figure 5 The text area within the box is filled with the border color of the text area to cover the text area. That is, the first target image does not contain any text area. For example, for the rounded rectangles outside the four "+Follow" text areas, the border color of the text area (pure white) is used to fill the "+Follow" text area with color (pure white filling). Similarly, the same method is used to fill the other text areas with color to obtain the first target image. The purpose of filling the text area with color is to avoid eliminating the graphics containing the text area as complex graphics. Because graphic detection cannot process complex graphics, complex graphics can only be processed during subsequent image recognition.

[0085] In the embodiment of the present application, the text area is filled with color using the border color of the text area, so that the text area in the image to be processed that has already created the text layer is removed, the noise during the subsequent graphics and image detection is reduced, the efficiency of layer creation is accelerated, and the accuracy of layer creation is also improved. And the text area is filled with color using the border color of the text area, which avoids cleaning the restorable graphics containing the text area as junk graphics, which increases the amount of tasks for subsequent processing of the restorable graphics as images, and the image processing method is obviously more complicated than the graphics processing method, which complicates the simple processing process and reduces the processing efficiency.

[0086] In one embodiment, Figure 8 As shown, S246, performing image layer recognition on the image to be processed to obtain an image layer instance includes:

[0087] S246a, performing graphic area filtering on the first target image to obtain a second target image.

[0088] The first target image is obtained by performing text area filtering on the image to be processed, and does not contain the text area. The first target image is then subjected to graphic area filtering, that is, the graphic area contained in the first target image is removed to obtain the second target image, and the second target image does not contain the graphic area.

[0089] Specifically, the method for filtering the graphic area of ​​the first target image is the same as the method for filtering the text area of ​​the image to be processed. The process of text area filtering refers to obtaining the boundary color of the text area in the image to be processed, and filling the text area with color according to the boundary color of the text area, thereby obtaining the first target image. Correspondingly, the process of graphic area filtering refers to obtaining the boundary color of the graphic area in the first target image, and filling the graphic area with color according to the boundary color of the graphic area, thereby obtaining the second target image.

[0090] S246b, performing image segmentation on the second target image to obtain an image segmentation result.

[0091] Among them, the second target image includes neither text areas nor graphic areas, but only complex image areas and irreversible graphic areas after junk image cleaning, that is, it includes image areas other than text areas and graphic areas in the image to be processed. Such areas are mainly processed by image segmentation methods, such as using a cutout method to obtain image segmentation results. Specifically, edge cropping is used to cut out each image area in the second target image. For example, a watershed algorithm can be used to crop the edges of each image area in the second target image to achieve cutout and output of a new image file. After the independent blocks in the second target image are cut out here, each independent image area corresponds to the output of an image file, such as an image saved in JPEG or PNG format, and is included in a fixed path for subsequent call when creating an image layer instance. For example, in Figure 5 The separate image area in the image refers to the avatar. The output image files are the image segmentation results. The watershed algorithm is an image region segmentation method. In the segmentation process, the similarity between adjacent pixels is used as an important reference, so that pixels with similar spatial positions and similar gray values ​​are connected to form a closed contour. The common operation steps of the watershed algorithm are: grayscale the color image, then calculate the gradient map, and finally perform the watershed algorithm based on the gradient map to calculate the edge line of the segmented image.

[0092] S246c, calculating attribute information of the image segmentation result to obtain attribute information of the image segmentation result.

[0093] After performing image segmentation on the second target image and obtaining the image segmentation result, the attribute information of the image segmentation result is calculated. The attribute information here includes corresponding coordinates, width, height, and image path information. Among them, the image path refers to the address of the image file generated after the cutout.

[0094] S246d, creating an image layer instance according to the image segmentation result and the attribute information of the image segmentation result.

[0095] After obtaining the image segmentation result in the second target image and the attribute information of the image segmentation result, an image layer instance can be created based on the two, that is, the image area excluding the text area and the image area in the processed image is drawn, and each image file obtained by cutout is drawn according to the corresponding attribute information to obtain an image layer instance.

[0096] In the example of the present application, the graphic area in the first target image is filtered to obtain the second target image. The second target image includes neither text area nor graphic area, and only includes the image area excluding the text area and the graphic area in the image to be processed. In this way, when the second target image is segmented, the noise caused by the text area and the graphic area is avoided. Each individual image area in the second target image is directly cut out to obtain an image file, which is saved in a fixed path. Therefore, when creating an image layer instance, the image file can be directly called under the path, and then according to the attribute information corresponding to the image file, the corresponding image layer instance can be created, thereby realizing layer restoration of the image to be processed.

[0097] In one embodiment, Fig. 9 As shown, S248 creates a group layer instance according to the text layer instance, the graphic layer instance and the image layer instance, and constructs a layer tree from the group layer instance, including:

[0098] S248a, performing inclusion relationship analysis on the text layer instance, the graphic layer instance and the image layer instance to obtain inclusion relationship analysis results.

[0099] After layer recognition of the image to be processed, text layer instances, graphic layer instances, and image layer instances are obtained. There is a containment relationship between these layer instances, which can also be called a nested relationship. Fig.10 As shown in the figure, "+Follow" is a text layer instance, and the rounded rectangle box nested outside "+Follow" is a graphic layer instance. There is a nested relationship between the graphic layer instance and the text layer instance, that is, the graphic layer instance contains the text layer instance. Similarly, all layer instances contained in the processed image are analyzed for inclusion relationship in turn to obtain the inclusion relationship analysis result.

[0100] S248b, obtaining a layer instance having a containment relationship according to the containment relationship analysis result, and creating a group layer instance from the layer instance having the containment relationship.

[0101] After performing inclusion relationship analysis on all layer instances in the image to be processed and obtaining the inclusion relationship analysis results, obtain the layer instances with inclusion relationship from the inclusion relationship analysis results. Specifically, you can start from any layer instance in the layer instance and obtain it step by step downwards to obtain the layer instances contained in the layer instance until a layer instance does not contain any layer instances downwards. Then, start from the layer instance and obtain it step by step upwards until a layer instance does not contain any layer instances upwards. Fig.10As shown, "+Follow" is a text layer instance, and the rounded rectangle box nested outside "+Follow" is a graphic layer instance. There is a nested relationship between the graphic layer instance and the text layer instance, that is, the graphic layer instance contains the text layer instance. Then, from the relationship analysis result, the layer instance of the graphic layer instance corresponding to the rounded rectangle box nested outside "+Follow" is further obtained. Because the "+Follow" text layer instance does not include layer instances downward, it is obtained step by step upward until a certain layer instance has no layer instances contained upward. In this way, all layer instances that have a containing and contained relationship with the "+Follow" text layer instance constitute a group layer instance. After obtaining a group layer instance, the layer instances that appear in the group layer instance are excluded from all layer instances. Thus, the excluded layer instances are used to construct a group layer instance in the same way. After obtaining the next group layer instance, the layer instances that appear in the group layer instance are excluded, and the next group layer instance is continued to be constructed. This cycle is repeated until all layer instances are constructed into group layer instances.

[0102] S248c, construct a layer tree from the group layer instance.

[0103] The layer tree is constructed from all the group layer instances obtained above. The layer instances in the same group layer instance have a containment and contained relationship. The layer tree composed of group layer instances intuitively represents the layer structure of the image to be processed. As shown in the figure,

[0104] In an embodiment of the present application, first, the layer instances contained in the image to be processed are sorted out to determine the inclusion relationships between each other, and then a group layer instance is created based on the inclusion relationship, and the layer instances in the group layer instance have an inclusion and being included relationship. In this way, the disorganized layer instances identified by the image to be processed are sorted into a clear layer directory based on the inclusion relationship, and the layer directory is a manifestation of the layer tree. The layer directory is like a folder directory, which can clearly and intuitively represent the layer structure of the image to be processed. After constructing the layer tree, the layer of the image to be processed is restored according to the layer tree to obtain a design draft image with layer information. As a result, the designer can perform secondary editing on the layer instances in the design draft image.

[0105] In one embodiment, S248b, obtaining a layer instance having a containment relationship according to the containment relationship analysis result, and creating a group layer instance from the layer instance having the containment relationship includes:

[0106] Sort the text layer instances, the graphic layer instances and the image layer instances according to their area sizes to obtain a sorting result;

[0107] From the sorting results, the corresponding layer instances are obtained in order of area from small to large as the parent node layer instances, and the layer instance set contained in the parent node layer instance is obtained according to the inclusion relationship analysis result;

[0108] Insert the layer instance collection contained in the parent node layer instance as child nodes into the parent node layer instance to obtain a group layer instance.

[0109] Specifically, when obtaining a layer instance with a containment relationship based on the containment relationship analysis result and creating a group layer instance from the layer instance with a containment relationship, the text layer instance, the graphic layer instance, and the image layer instance can be sorted by area to obtain a sorting result. Here, the layer instances can be sorted from small to large in terms of area, or from large to small in terms of area to obtain a sorting result of the layer instances.

[0110] Then, from the sorting results, the corresponding layer instances are obtained in order from small to large areas as the parent node layer instances, and the layer instance set contained in the parent node layer instance is obtained according to the inclusion relationship analysis result. For example, the layer instances are obtained in order from small to large areas, and the "+Follow" text layer instance is obtained. The "+Follow" text layer instance is used as the parent node layer instance, and the layer instance set contained in the parent node layer instance is obtained according to the inclusion relationship analysis result. Obviously, the "+Follow" text layer instance does not contain any layer instances.

[0111] Continue to obtain layer instances in order of area from small to large. For example, if you obtain the graphic layer instance of the rounded rectangular box nested outside the "+Follow", then use the graphic layer instance as the parent node layer instance, and obtain the layer instance set contained in the parent node layer instance according to the inclusion relationship analysis result. Obviously, the parent node layer instance contains the text layer instance of "+Follow". Insert the layer instance set contained in the parent node layer instance as a child node into the parent node layer instance to obtain a group layer instance. That is, insert the text layer instance of "+Follow" as a child node into the graphic layer instance of the rounded rectangular box nested outside the "+Follow", obtain a group layer instance, and assign the coordinates and width and height of the graphic layer instance of the rounded rectangular box nested outside the "+Follow" to the group layer instance as the coordinates and width and height of the group layer instance.

[0112] Continue to obtain layer instances in order of area from small to large, use the obtained layer instances as parent node layer instances, and obtain the layer instance set contained in the parent node layer instance according to the inclusion relationship analysis result. Insert the layer instance set contained in the parent node layer instance as a child node into the parent node layer instance to obtain a group layer instance, and assign the coordinates and width and height of the parent node layer instance to the group layer instance as the coordinates and width and height of the group layer instance. Among them, the number of layer instances in the layer instance set contained in the parent node layer instance can be one or more.

[0113] If a layer instance is obtained as a parent node layer instance, and the parent node layer instance contains a group layer instance, then the group layer instance is inserted into the parent node layer instance as a child node to obtain a new group layer instance, and the coordinates and width and height of the parent node layer instance are assigned to the new group layer instance as the coordinates and width and height of the new group layer instance. Among them, the number of layer instances in the layer instance set contained in the parent node layer instance can be two or more.

[0114] In the embodiment of the present application, the corresponding layer instances are obtained from the sorting results in order from small to large areas as the parent node layer instances, so that no layer instances are missed. Then, the layer instance set contained in the parent node layer instance is obtained according to the inclusion relationship analysis result. The layer instance set contained in the parent node layer instance is inserted into the parent node layer instance as a child node, and the group layer instances are obtained step by step.

[0115] In one embodiment, Fig.11 As shown, after S260 restores the layers of the image to be processed according to the layer tree to obtain the design draft image with layer information, it includes:

[0116] S280, editing the layer of the design draft image with layer information to obtain a new design draft image.

[0117] In the embodiment of the present application, the text information, graphic information and image information in the image to be processed are respectively identified by layers to obtain text layer instances, graphic layer instances and image layer instances. A layer tree is then constructed from the text layer instance, graphic layer instance and image layer instance, and the layer of the image to be processed is restored according to the layer tree to obtain a design draft image with layer information. At this point, the designer can directly edit the design draft image with layer information. Specifically, the designer can modify, replace or delete any layer instance in the design draft image to obtain a new design draft image.

[0118] In traditional methods, for JPEG and PNG format image materials on the Internet, images in this format do not contain layer information, so designers often need to manually process the image materials on the Internet before they can be restored to the layers in the design draft, which consumes a huge amount of work. Or use the sketch2Code platform provided by Microsoft to analyze and identify the user's hand-drawn UI (User Interface) draft through AI (Artificial Intelligence), and finally convert it into code. However, the sketch2Code platform can only recognize hand-drawn design drafts, and the restored object is code, which cannot be reused by designers. In addition, the sketch2Code platform uses AI technology to recognize hand-drawn design drafts, which requires relying on a large amount of manually annotated data to train AI models to realize AI technology. Manually annotated data is relatively limited, so the AI ​​model at the training site has limited applicability, does not use extensions, and the cost of manual annotation is too high.

[0119] In one embodiment, Fig.12 As shown, a layer restoration method in a specific embodiment is provided, and the method steps are as follows:

[0120] First, combine Fig.13 The figure shows an interface diagram of the homepage of a picture-to-design draft tool in one embodiment. The picture-to-design draft tool can implement the above-mentioned layer restoration method. The user enters the homepage and clicks the upload button in the upper right corner to upload the material picture. The preview page displays the picture preview. The user selects the target area. The picture corresponding to the target area is the original picture. Then the user clicks the convert button. The picture-to-design draft tool performs layer recognition on the original picture to construct a layer tree. After obtaining the layer tree, the tool page is entered, as shown in FIG. Fig.14 shown.

[0121] Among them, the process of the image-to-design tool performing layer recognition on the original image and constructing a layer tree includes: inputting the original image into the image-to-design tool for text layer recognition, specifically, after the text area detection of the original image is obtained, the text area is subjected to text content recognition OCR (Optical Character Recognition) to identify the text in the text area. Then the attribute information of the text is calculated, and the attribute information of the text includes the corresponding coordinates, width, height, content, color, size and other information. Then, a text layer instance is created based on the recognized text and its attribute information.

[0122] After creating the text layer instance, the graphic layer recognition process is entered. Specifically, the text area of ​​the image to be processed is filtered according to the text area to obtain the first target image, and the first target image is subjected to graphic detection to obtain the graphic detection result, which is a rectangle, circle or polygon. The attribute information of the graphic detection result is further calculated to obtain the attribute information of the graphic detection result. The attribute information of the graphic detection result includes information such as coordinates, width and height, graphic type, graphic color, path set, radius, and fillet. Among them, the path set refers to the path for creating the graphic. Then, a graphic layer instance is created based on the identified graphic detection result and the attribute information of the graphic detection result.

[0123] After creating the graphic layer instance, the image layer recognition process is entered. Specifically, the first target image is filtered by the graphic area to obtain the second target image, and the second target image is segmented to obtain the image segmentation result. The image segmentation method can be used for image segmentation, including using the watershed algorithm to crop the edges of each individual image area in the second target image to achieve the output of a new image file by cutting out. The output image file is saved as an image in JPEG or PNG format, and included in a fixed path for subsequent call when creating an image layer instance. Then, the attribute information of the image file obtained by cutting out is calculated, and the attribute information here includes the corresponding coordinates, width, height, and image path information. Among them, the image path refers to the address of the image file generated after cutting out. Each image file obtained by cutting out is drawn according to the corresponding attribute information to obtain an image layer instance.

[0124] After obtaining the text layer instance, the graphic layer instance and the image layer instance, the process of constructing the layer tree is entered. Specifically, the inclusion relationship analysis is performed on the text layer instance, the graphic layer instance and the image layer instance to obtain the inclusion relationship analysis result. The text layer instance, the graphic layer instance and the image layer instance are further sorted according to the area size to obtain the sorting result, and then the corresponding layer instances are obtained from the sorting result in order from the small to the large area as the parent node layer instance. Combined with the inclusion relationship analysis result, it is determined whether there is a contained layer in the parent node layer instance. If so, the layer instance set contained in the parent node layer instance is obtained, and the layer instance set contained in the parent node layer instance is inserted as a child node into the parent node layer instance to obtain the group layer instance. The layer tree is constructed according to the group layer instance.

[0125] After getting the layer tree of the original image, jump to Fig.14The tool page shown in the figure. The left column of the tool page shows the layer structure, which is the layer tree of the original image, and the right column shows the attribute information of a single layer. When the user selects to export all layers in the right column of the tool page, the layer tree is traversed to call the interface of the design software to restore the layers of the original image, and the design draft image with all layer information is obtained, such as Fig.14A When the user selects a layer in the left column of the tool page (for example, select the "+Follow" text layer instance on the far left), and selects to export the selected layer in the right column, the interface of the third-party design software is called to restore the layer of the original image, and the design draft image corresponding to the layer is obtained, as shown in the figure below. Fig. 14B shown.

[0126] In the embodiment of the present application, first, directly input the taken picture or the picture downloaded from the Internet (excluding layer information) into the picture-to-design draft tool for processing; then, use the frame line to select the target area from the input picture, click the conversion button to create a layer tree for the picture of the target area through the picture-to-design draft tool, and finally, select Export Layer on the tool page to restore the layer to obtain the design draft picture with layer information. This solves the problem that in the traditional method, when designers use taken pictures or online picture materials, because many online picture materials are in JPEG format and PNG format, and pictures in this format do not contain layer information, designers often need to manually process the online picture materials to restore them to the layers in the UI design draft, which is time-consuming and labor-intensive. The method in the embodiment of the present application fully realizes the automatic layer restoration to obtain the design draft, greatly improves the efficiency of layer restoration, and facilitates subsequent designers to edit the design draft.

[0127] In one embodiment, Fig.15 As shown, a layer restoration device 300 is provided, comprising: a to-be-processed image acquisition module 320, a layer identification module 340 and a layer restoration module 360.

[0128] The to-be-processed picture acquisition module 320 is used to acquire the to-be-processed picture, which does not contain layer information;

[0129] A layer identification module 340 is used to perform layer identification on the image to be processed and construct a layer tree;

[0130] The layer restoration module 360 ​​is used to restore the layers of the image to be processed according to the layer tree to obtain a design draft image with layer information.

[0131] In one embodiment, Fig.16 As shown, the layer identification module 340 includes:

[0132] A text layer recognition unit 342, used for performing text layer recognition on the image to be processed to obtain a text layer instance;

[0133] A graphic layer identification unit 344, used for performing graphic layer identification on the image to be processed to obtain a graphic layer instance;

[0134] An image layer instance unit 346 is used to perform image layer recognition on the image to be processed to obtain an image layer instance;

[0135] The layer tree construction unit 348 is used to create a group layer instance according to the text layer instance, the graphic layer instance and the image layer instance, and construct a layer tree from the group layer instance.

[0136] In one embodiment, Fig.17 As shown, the text layer recognition unit 342 includes:

[0137] A text region detection unit 342a, configured to perform text region detection on the image to be processed to obtain a text region;

[0138] The text content recognition unit 342b is used to perform text content recognition on the text area to obtain a text content recognition result;

[0139] A first attribute information calculation unit 342c, used to calculate attribute information of the text content recognition result to obtain attribute information of the text content recognition result;

[0140] The text layer instance creating unit 342d is used to create a text layer instance according to the text content recognition result and the attribute information of the text content recognition result.

[0141] In one embodiment, Fig.18 As shown, the graphic layer identification unit 344 includes:

[0142] A text area filtering unit 344a, configured to perform text area filtering on the image to be processed to obtain a first target image;

[0143] The graphic detection unit 344b is used to perform graphic detection on the first target image to obtain a graphic detection result;

[0144] The second attribute information calculation unit 344c is used to calculate the attribute information of the graphic detection result to obtain the attribute information of the graphic detection result;

[0145] The graphic layer instance creation unit 344d is used to create a graphic layer instance according to the graphic detection result and the attribute information of the graphic detection result.

[0146] In one embodiment, the text region filtering unit 344a is further used to obtain the boundary color of the text region in the image to be processed; and fill the text region with color according to the boundary color of the text region to obtain the first target image.

[0147] In one embodiment, Fig.19 As shown, the image layer instance unit 346 includes:

[0148] A graphic region filtering unit 346a, configured to perform graphic region filtering on the first target image to obtain a second target image;

[0149] The image segmentation unit 346b is used to perform image segmentation on the second target image to obtain an image segmentation result;

[0150] The third attribute information calculation unit 346c is used to calculate the attribute information of the image segmentation result to obtain the attribute information of the image segmentation result;

[0151] The image layer instance creating unit 346d is used to create an image layer instance according to the image segmentation result and the attribute information of the image segmentation result.

[0152] In one embodiment, Fig. 20 As shown, the layer tree construction unit 348 includes:

[0153] The inclusion relationship analysis unit 348a is used to perform inclusion relationship analysis on the text layer instance, the graphic layer instance and the image layer instance to obtain the inclusion relationship analysis result;

[0154] The group layer instance creation unit 348b is used to obtain the layer instances with the inclusion relationship according to the inclusion relationship analysis result, and create the group layer instance from the layer instances with the inclusion relationship;

[0155] The layer tree construction unit 348c is used to construct a layer tree from group layer instances.

[0156] In one embodiment, the group layer instance creation unit 348b is also used to sort the text layer instances, graphic layer instances and image layer instances according to the area size to obtain a sorting result; obtain the corresponding layer instances from the sorting result in order from small to large according to the area as the parent node layer instance, and obtain the layer instance set contained in the parent node layer instance according to the inclusion relationship analysis result; insert the layer instance set contained in the parent node layer instance as a child node into the parent node layer instance to obtain a group layer instance.

[0157] In one embodiment, Fig.21 As shown, a layer restoration device 300 is provided, which also includes:

[0158] The new design draft picture generating module 380 is used to edit the layer of the design draft picture with layer information to obtain a new design draft picture.

[0159] It should be understood that, although the various steps in the above-mentioned flow chart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the above-mentioned flow chart may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0160] Fig. 22 The internal structure diagram of a computer device in one embodiment is shown. The computer device may specifically be Figure 1 The terminal 110 in FIG. Fig. 22 As shown, the computer device includes a processor, a memory, a network interface, an input device, a display screen, a camera, a sound collection device and a speaker connected through a system bus. Among them, the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor can implement the above-mentioned layer restoration method. The internal memory may also store a computer program. When the computer program is executed by the processor, the processor can execute the above-mentioned layer restoration method. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device may be a touch layer covered on the display screen, or a key, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse.

[0161] Those skilled in the art will understand that Fig. 22 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0162] In one embodiment, the layer restoration device provided by the present application can be implemented in the form of a computer program. The computer program can be used in Fig. 22 The computer device shown in the figure is run. The memory of the computer device can store various program modules constituting the layer restoration device, for example, Fig.15The illustrated to-be-processed picture acquisition module 320, layer identification module 340 and layer restoration module 360. The computer program composed of each program module enables the processor to execute the steps of the layer restoration method of each embodiment of the present application described in this specification.

[0163] For example, Fig. 22 The computer device shown can be Fig.15 The to-be-processed image acquisition module 320 in the layer restoration device shown in the figure executes step S220. The computer device may execute step S240 through the layer identification module 340. The computer device may execute step S260 through the layer restoration module 360.

[0164] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above-mentioned layer restoration method. The steps of the layer restoration method here may be the steps of the layer restoration method in each of the above-mentioned embodiments.

[0165] In one embodiment, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the processor executes the steps of the above-mentioned layer restoration method. The steps of the layer restoration method here can be the steps of the layer restoration method in each of the above-mentioned embodiments.

[0166] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0167] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0168] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A layer restoration method, comprising: Obtaining a picture to be processed, wherein the picture to be processed does not contain layer information; Performing text layer recognition on the image to be processed to obtain a text layer instance; Performing graphic layer recognition on the image to be processed to obtain a graphic layer instance; Performing image layer recognition on the image to be processed to obtain an image layer instance; Performing inclusion relationship analysis on the text layer instance, the graphic layer instance and the image layer instance to obtain an inclusion relationship analysis result; Acquire a layer instance having a containment relationship according to the containment relationship analysis result, and create a group layer instance from the layer instance having the containment relationship; Constructing a layer tree from the group of layer instances; The image to be processed is restored in layers according to the layer tree to obtain a design draft image with layer information.

2. The method according to claim 1, characterized in that The step of performing text layer recognition on the image to be processed to obtain a text layer instance includes: Performing text area detection on the image to be processed to obtain a text area; Performing text content recognition on the text area to obtain a text content recognition result; Calculating attribute information of the text content recognition result to obtain attribute information of the text content recognition result; A text layer instance is created according to the text content recognition result and the attribute information of the text content recognition result.

3. The method according to claim 2, characterized in that The step of performing graphic layer recognition on the image to be processed to obtain a graphic layer instance includes: Performing text area filtering on the image to be processed to obtain a first target image; Performing graphic detection on the first target image to obtain a graphic detection result; Calculating attribute information of the graphic detection result to obtain the attribute information of the graphic detection result; A graphic layer instance is created according to the graphic detection result and the attribute information of the graphic detection result.

4. The method according to claim 3, characterized in that The step of filtering the image to be processed by a text region to obtain a first target image includes: Obtaining the border color of the text area in the image to be processed; The text area is filled with color according to the boundary color of the text area to obtain a first target image.

5. The method according to claim 4, characterized in that The step of performing image layer recognition on the image to be processed to obtain an image layer instance includes: Performing graphic area filtering on the first target image to obtain a second target image; Performing image segmentation on the second target image to obtain an image segmentation result; Calculating attribute information of the image segmentation result to obtain attribute information of the image segmentation result; An image layer instance is created according to the image segmentation result and the attribute information of the image segmentation result.

6. The method according to claim 1, characterized in that The step of obtaining a layer instance having a containment relationship according to the containment relationship analysis result, and creating a group layer instance from the layer instance having the containment relationship includes: Sorting the text layer instance, the graphic layer instance and the image layer instance according to their area to obtain a sorting result; From the sorting results, corresponding layer instances are obtained in order from small to large areas as parent node layer instances, and a set of layer instances included in the parent node layer instance is obtained according to the inclusion relationship analysis result; The layer instance set contained in the parent node layer instance is inserted into the parent node layer instance as child nodes to obtain a group layer instance.

7. The method according to claim 1, characterized in that After the image to be processed is restored in layers according to the layer tree to obtain a design draft image with layer information, the method includes: The layer of the design draft picture with layer information is edited to obtain a new design draft picture.

8. A layer restoration device, characterized in that: The device comprises: A module for obtaining a picture to be processed, used to obtain a picture to be processed, wherein the picture to be processed does not contain layer information; A text layer recognition unit, used for performing text layer recognition on the image to be processed to obtain a text layer instance; A graphic layer identification unit, used for performing graphic layer identification on the image to be processed to obtain a graphic layer instance; An image layer instance unit, used for performing image layer recognition on the image to be processed to obtain an image layer instance; An inclusion relationship analysis unit, used for performing inclusion relationship analysis on the text layer instance, the graphic layer instance and the image layer instance to obtain an inclusion relationship analysis result; A group layer instance creation unit, used for acquiring layer instances with a containment relationship according to the containment relationship analysis result, and creating a group layer instance from the layer instances with the containment relationship; A layer tree construction unit, used for constructing a layer tree from the group of layer instances; The layer restoration module is used to restore the layers of the image to be processed according to the layer tree to obtain a design draft image with layer information.

9. The device according to claim 8, characterized in that The text layer recognition unit comprises: A text region detection unit, used for performing text region detection on the image to be processed to obtain a text region; A text content recognition unit, used for performing text content recognition on the text area to obtain a text content recognition result; A first attribute information calculation unit, used to calculate attribute information on the text content recognition result to obtain the attribute information of the text content recognition result; The text layer instance creation unit is used to create a text layer instance according to the text content recognition result and the attribute information of the text content recognition result.

10. The device according to claim 9, characterized in that The graphic layer recognition unit comprises: A text area filtering unit, used for performing text area filtering on the image to be processed to obtain a first target image; A graphic detection unit, configured to perform graphic detection on the first target image to obtain a graphic detection result; a second attribute information calculation unit, configured to calculate attribute information on the graphic detection result to obtain the attribute information of the graphic detection result; The graphic layer instance creation unit is used to create a graphic layer instance according to the graphic detection result and the attribute information of the graphic detection result.

11. The device according to claim 10, characterized in that The text area filtering unit is further used to obtain the boundary color of the text area in the image to be processed; and fill the text area with color according to the boundary color of the text area to obtain a first target image.

12. The device according to claim 11, characterized in that The image layer instance unit includes: A graphic region filtering unit, configured to perform graphic region filtering on the first target image to obtain a second target image; An image segmentation unit, configured to perform image segmentation on the second target image to obtain an image segmentation result; a third attribute information calculation unit, configured to calculate attribute information on the image segmentation result to obtain the attribute information of the image segmentation result; The image layer instance creation unit is used to create an image layer instance according to the image segmentation result and the attribute information of the image segmentation result.

13. The device according to claim 8, characterized in that The group layer instance creation unit is also used to sort the text layer instance, the graphic layer instance and the image layer instance according to the area size to obtain a sorting result; obtain the corresponding layer instances in the sorting result in order from small to large areas as parent node layer instances, and obtain the layer instance set contained in the parent node layer instance according to the inclusion relationship analysis result; insert the layer instance set contained in the parent node layer instance as a child node into the parent node layer instance to obtain a group layer instance.

14. The device according to claim 8, characterized in that The device also includes: The new design draft picture generation module is used to edit the layer of the design draft picture with layer information to obtain a new design draft picture.

15. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 7.

16. A computer device comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • A cartoon form conversion method and device

    CN109741426A