Method, system, device and medium for automatically extracting pictorial template style
By performing text detection, dividing layout blocks, style analysis and color detection on the pictorial template, a style parameter information table is generated, which solves the problem of high time cost of manually extracting style information, realizes the automatic extraction of pictorial template style, and improves production efficiency. and quality.
Patent Information
- Application Number
- CN202210441726.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-25
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2042-04-25
AI Technical Summary
In the existing technology, the process of relying on manual extraction of style information of a pictorial template is too time-consuming, and it is difficult to realize batch automated processing.
By performing text detection, layout block division, style analysis, color detection and non-occluded target detection on the pictorial template, a style parameter information table is generated to realize automatic extraction of style information of the pictorial template.
It saves a lot of work time in early stage style extraction and integration, improves the efficiency and quality of pictorial production, and realizes the automatic extraction of pictorial template styles.
Smart Images

Figure CN114821619B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of image intelligent processing, and in particular to a method, system, electronic device and computer-readable storage medium for automatically extracting the style of a pictorial template. Background Art
[0002] At present, the process of pictorial production is becoming more and more intelligent. Users can choose a pictorial template with a pre-designed style in the pictorial production system, and then enter the corresponding text paragraph. The pictorial production system will adaptively replace the text on the pictorial template based on the text paragraph entered by the user, and finally form the text pictorial required by the user.
[0003] In the process of realizing the intelligent generation of the above-mentioned text pictorials, the pictorial production system needs to use the style information of the pictorial template, so it is necessary to extract the style of each set of pictorial templates with designed styles. For a batch of pictorial templates, it is unrealistic to manually extract the style information of the pictorial templates one by one and input them into the pictorial production system, which will result in too high a time cost. Therefore, how to automatically extract the style information of pictorial templates of different styles is an urgent problem to be solved. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a method, system, electronic device and computer-readable storage medium for automatically extracting the style of a pictorial template, aiming to solve the problem of excessively high time cost caused by manually extracting the design style from the pictorial.
[0005] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes a method for automatically extracting the style of a pictorial template, the method comprising:
[0006] Performing text detection on the pictorial template to obtain multiple text blocks in the pictorial template;
[0007] Based on each of the text blocks, the pictorial template is divided into a plurality of layout blocks, and a block attribute of each of the layout blocks is determined;
[0008] Performing style analysis on each of the layout blocks to obtain typesetting style parameters of each of the layout blocks;
[0009] Performing color detection on each of the layout blocks respectively, obtaining color change parameters of each of the layout blocks, and determining expandable area parameters of the layout blocks according to the color change parameters;
[0010] Performing unobstructed object detection on each of the layout blocks, and for a layout block with an unobstructed object, determining an unobstructed area parameter of the layout block according to a position of the unobstructed object in the layout block;
[0011] A style parameter information table is generated according to the block attributes, typesetting style parameters, expandable area parameters and non-blockable area parameters of each of the layout blocks.
[0012] According to the method for automatically extracting the style of a pictorial template provided in some embodiments of the present application, the pictorial template is divided into a plurality of layout blocks based on each of the text blocks, and the block attributes of each of the layout blocks are determined, including:
[0013] For each of the text blocks, obtaining the position information and text attributes of the text block;
[0014] Dividing the pictorial template according to the position information and text attributes of each text block to obtain a plurality of layout blocks;
[0015] For each of the layout blocks, the block attributes of the layout block are determined according to the text attributes of the text block included in the layout block.
[0016] According to the method for automatically extracting the style of a pictorial template provided in some embodiments of the present application, the pictorial template is divided according to the position information and text attributes of each text block to obtain multiple layout blocks, including:
[0017] According to the position information of each text block, the position order of each text block is determined, each text block is traversed in the position order, and the following processing is performed during the traversal: the text attributes of the currently traversed text block and the previously traversed text block are compared, and when the text attributes of the currently traversed text block are the same as the text attributes of the previously traversed text block, the currently traversed text block and the previously traversed text block are merged into the same block text set;
[0018] According to the block text set obtained after traversal, the pictorial template is divided to obtain multiple layout blocks.
[0019] According to the method for automatically extracting the style of a pictorial template provided in some embodiments of the present application, color detection is performed on each of the layout blocks to obtain color change parameters of each of the layout blocks, and the expandable area parameters of the layout blocks are determined according to the color change parameters, including performing the following processing on each of the layout blocks:
[0020] Performing color detection in the length direction on the area of the layout block except the text block to obtain color change parameters in the length direction;
[0021] Determine, according to the color change parameter, a starting position parameter at which the color of the layout block no longer changes;
[0022] The expandable area parameter corresponding to the layout block is obtained according to the starting position parameter.
[0023] According to the method for automatically extracting the style of a pictorial template provided in some embodiments of the present application, the non-obstructable object detection for each layout block includes performing the following processing for each layout block:
[0024] Extracting edge colors of text blocks in the layout block to obtain edge color parameters of the text blocks;
[0025] Determine the color threshold interval of the layout block according to the text block edge color parameter;
[0026] The color parameters of the area other than the text block in the layout block are obtained, and the area whose color parameters are not within the color threshold range is regarded as a non-blockable target object.
[0027] According to the method for automatically extracting the style of a pictorial template provided by some embodiments of the present application, determining the unobstructed area parameters of the layout block according to the position of the unobstructed target object in the layout block includes:
[0028] Obtaining the coordinate range of the unobstructed target object in the layout block;
[0029] The unobstructed area parameter is obtained according to the coordinate range.
[0030] According to the method for automatically extracting the style of a pictorial template provided in some embodiments of the present application, the style analysis process is performed on each of the layout blocks to obtain the typesetting style parameters of each of the layout blocks, including:
[0031] Perform style analysis on each of the layout blocks to obtain at least one of the following typesetting style parameters for each layout block: font size, font, font color, text center point, alignment, text line spacing, text top position, and text bottom position.
[0032] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application proposes a system for automatically extracting the style of a pictorial template, the system comprising:
[0033] A text detection module, used to perform text detection on the pictorial template to obtain multiple text blocks in the pictorial template;
[0034] A block division module, used for dividing the pictorial template into a plurality of layout blocks based on each of the text blocks, and determining a block attribute of each of the layout blocks;
[0035] A style analysis module, used to perform style analysis on each of the layout blocks to obtain typesetting style parameters of each of the layout blocks;
[0036] An expandable area detection module, used to perform color detection on each of the layout blocks, obtain color change parameters of each of the layout blocks, and determine expandable area parameters of the layout blocks according to the color change parameters;
[0037] An unobstructed area detection module is used to perform unobstructed target object detection on each of the layout blocks, and for a layout block with an unobstructed target object, determine the unobstructed area parameters of the layout block according to the position of the unobstructed target object in the layout block;
[0038] The table generation module is used to generate a style parameter information table according to the block attributes, typesetting style parameters, expandable area parameters and non-blockable area parameters of each of the layout blocks.
[0039] To achieve the above-mentioned purpose, a third aspect of an embodiment of the present application provides an electronic device, including: at least one processor;
[0040] at least one processor; and,
[0041] a memory communicatively connected to the at least one processor; wherein,
[0042] The memory stores a computer program, and when the computer program is executed by the at least one processor, the at least one processor executes the method for automatically extracting the style of a pictorial template as described in any one of the embodiments of the first aspect above.
[0043] To achieve the above-mentioned purpose, the fourth aspect of the embodiments of the present application proposes a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the method for automatically extracting the style of a pictorial template as described in any embodiment of the first aspect above.
[0044] The embodiment of the present application proposes a method, system, electronic device and computer-readable storage medium for automatically extracting the style of a pictorial template, which performs text detection on a pictorial template to obtain multiple text blocks in the pictorial template; divides the pictorial template into multiple layout blocks based on each of the text blocks, and determines the block attributes of each of the layout blocks; performs style analysis processing on each of the layout blocks to obtain the typesetting style parameters of each of the layout blocks; performs color detection on each of the layout blocks to obtain the color change parameters of each of the layout blocks, and determines the expandable area parameters of the layout blocks according to the color change parameters; performs unobstructed target object detection on each of the layout blocks, and for layout blocks with unobstructed targets, determines the unobstructed area parameters of the layout blocks according to the position of the unobstructed targets in the layout blocks; generates a style parameter information table according to the block attributes, typesetting style parameters, expandable area parameters and unobstructed area parameters of each of the layout blocks. The solution of the embodiment of the present application can automatically extract the typesetting style parameters, expandable area parameters and unobstructed area parameters of each block in the pictorial template, saving a lot of work time for early style extraction and integration. The pictorial production system can directly and intelligently produce pictorials based on the extracted various style parameters, thereby improving the production efficiency and production quality of the pictorials. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 It is a flowchart of a method for automatically extracting the style of a pictorial template provided in an embodiment of the present application;
[0046] Figure 2 yes Figure 1 Schematic diagram of sub-steps of step S120 in FIG.
[0047] Figure 3 yes Figure 2 Schematic diagram of sub-steps of step S122 in FIG.
[0048] Figure 4 yes Figure 1 Schematic diagram of sub-steps of step S140 in FIG.
[0049] Figure 5 yes Figure 1 The sub-steps of step S150 in FIG. Figure 1 ;
[0050] Figure 6 yes Figure 1 The sub-steps of step S150 in FIG. Figure 2 ;
[0051] Figure 7 This is an example diagram of a poster template described in an embodiment of the present application;
[0052] Figure 8 is an example diagram of a style parameter information table provided in an embodiment of the present application;
[0053] Fig. 9 It is a structural schematic diagram of a pictorial template style automatic extraction system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] 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.
[0055] It should be noted that, unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0056] First, some nouns involved in this application are analyzed:
[0057] Artificial Intelligence (AI): It is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence. AI is a branch of computer science. AI attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Research in this field includes robots, language recognition, image recognition, natural language processing and expert systems. AI can simulate the information process of human consciousness and thinking. AI is also a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0058] The main purpose of the embodiments of the present application is to propose a method, device, electronic device and computer-readable storage medium for automatically extracting the style of a pictorial template, aiming to solve the problem of high time cost caused by manually extracting the design style in the pictorial. Through the solution provided by the embodiments of the present application, the design style in the pictorial, such as color, font size, alignment and the design style of the text content, can be automatically extracted, and new pictorials with the design style of the original pictorial can be automatically generated in batches through the extracted style parameters.
[0059] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0060] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0061] The method for automatically extracting the style of a pictorial template provided in the embodiment of the present application relates to the field of artificial intelligence and intelligent image processing technology. The method for automatically extracting the style of a pictorial template provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or can be configured as a server cluster or a distributed system composed of multiple physical servers, or can be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the method for automatically extracting the style of a pictorial template, etc., but is not limited to the above forms.
[0062] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer-readable storage media including storage devices.
[0063] See also Figure 1 , Figure 1 FIG. 2 is a flow chart showing a method for automatically extracting the style of a pictorial template proposed in an embodiment of the present application. Figure 1 As shown, the method provided in the embodiment of the present application includes but is not limited to the following steps:
[0064] Step S110 , performing text detection on the pictorial template to obtain a plurality of text blocks in the pictorial template.
[0065] For example, optical character recognition (OCR) can be used to perform text detection on the pictorial template to obtain multiple text blocks in the pictorial template. The text blocks described in the embodiment of the present application are specifically images containing text content.
[0066] Specifically, Figure 7 As an example, the poster template shown in the figure is used to perform text detection on the pictorial template using OCR, and multiple target boxes (such as Figure 7 The target frame is used to frame the text row or text column on the pictorial template. The image of the pictorial template is intercepted according to the target frame to obtain the image of the text block.
[0067] Step S120 , dividing the pictorial template into a plurality of layout blocks based on each of the text blocks, and determining a block attribute of each of the layout blocks.
[0068] The above block attributes may include: title, foreword, body, conclusion and other types.
[0069] See also Figure 2 , step S120 may specifically include the following steps S121-S123.
[0070] Step S121, for each of the text blocks, obtaining the position information and text attributes of the text block.
[0071] It is understandable that after all text blocks of the pictorial template are obtained through text detection, for each text block in the pictorial template, the position information of the text block in the pictorial template is first obtained to further determine the text attribute of the text block according to the position information of the text block. The text attributes may include: title, preface, body, conclusion, etc.
[0072] In a specific embodiment, all text blocks in the pictorial template and the position information of each text block are obtained by OCR. The position information of the text block refers to the coordinate position of the text block in the pictorial template. For example, the upper left corner of the pictorial module is taken as the original coordinate (0, 0), and then the upper left corner coordinate, upper right corner coordinate, lower left corner coordinate, and lower right corner coordinate of the text block in the pictorial template are obtained, and the four corner coordinates of the text block are combined into the position information of the text block.
[0073] It is understandable that, based on the position information of each text block, the layout analysis of the pictorial template can be performed to obtain the layout direction of the text block, and the text blocks can be sorted according to the layout direction to form a text block sequence. For example, if the text blocks in the pictorial template are arranged vertically, the text blocks are sorted in the vertical order to form a text block sequence. The text block sequence contains images of multiple text blocks.
[0074] It can be understood that after obtaining the text block sequence, in order to determine the text attributes of the text block, the text block sequence can be converted into a corresponding string sequence, which contains strings corresponding to the text blocks in the text block sequence one by one; the string sequence is input into a pre-trained text attribute classification model, and the feature vectors of each string in the string sequence are extracted by the text attribute classification model, and based on the feature vectors of each string, an attribute label sequence is output, which contains attribute labels corresponding to the text blocks in the text block sequence one by one; the text attributes of each text block can be determined according to the attribute label sequence. Here, the text attribute classification model uses the string sequence for text attribute classification, the purpose of which is to obtain the context information of the current string to be classified from the string sequence (i.e., the feature vectors of the previous and next strings), and then perform attribute classification based on the context information, so that the output attribute label sequence is more accurate.
[0075] Step S122, dividing the pictorial template according to the position information and text attributes of each text block to obtain a plurality of layout blocks.
[0076] It can be understood that after obtaining the position information and text attributes of each text block, the embodiment of the present application divides the pictorial template into multiple layout blocks according to the position information and text attributes of each text block, so as to perform style extraction on each layout block separately in subsequent steps.
[0077] See also Figure 3 , step S122 may specifically include the following steps S1221-S1222.
[0078] Step S1221, determine the position order of each text block according to the position information of each text block, traverse each text block in the position order, and perform the following processing during the traversal: compare the text attributes of the currently traversed text block and the previously traversed text block, and when the text attributes of the currently traversed text block are the same as the text attributes of the previously traversed text block, merge the currently traversed text block and the previously traversed text block into the same block text set.
[0079] Specifically, based on the position information of each text block, the layout analysis of the pictorial template can be performed to obtain the layout direction of the text block, and the position order of each text block can be determined according to the layout direction, and each text block can be traversed in the position order. For example, if the text blocks in the pictorial template are arranged vertically, then each text block is traversed in the vertical order, where text block A and text block B are text blocks that are adjacent to each other in the pictorial template, the text attribute of text block A is text, the text attribute of text block B is also text, and text block A belongs to block text set 1, then text block B is also merged into block text set 1.
[0080] Step S1222, dividing the pictorial template according to the block text set obtained after traversal to obtain a plurality of layout blocks.
[0081] Step S123, for each of the layout blocks, determining the block attributes of the layout block according to the text attributes of the text block contained in the layout block.
[0082] by Figure 7 Taking the poster template shown as an example, after traversal and merging, four block text sets 1 are finally obtained. The text attributes of the text blocks contained in these four text blocks correspond to title, preface, main text, and conclusion. Then the pictorial template is divided accordingly to obtain layout blocks 1-4. The block attributes of layout blocks 1-4 correspond to title, preface, main text, and conclusion.
[0083] Step S130, performing style analysis on each of the layout blocks to obtain typesetting style parameters of each of the layout blocks.
[0084] As an example, step S130 may specifically include: performing style analysis on each of the layout blocks to obtain at least one of the following typesetting style parameters for each layout block: font size, font, font color, text center point, alignment, text line spacing, text top position, and text bottom position.
[0085] In specific implementation, the image of each layout block can be input into a pre-trained font style discrimination model, and the font style discrimination model is used to output the typesetting style parameters corresponding to each layout block. The embodiment of the present application does not impose any particular restrictions on the specific process of obtaining the typesetting style parameters of the layout block.
[0086] Step S140, performing color detection on each of the layout blocks respectively, obtaining color change parameters of each of the layout blocks, and determining expandable area parameters of the layout blocks according to the color change parameters.
[0087] It is understandable that when using the poster module to generate a new poster, if the text entered by the user is too long and the original text area of the poster module cannot fully display the text entered by the user, the page length of the poster module needs to be extended. In order to realize that the template can adapt to fill text of any length, when extracting the poster template style in the early stage, it is also necessary to extract the expandable area parameters of the poster template.
[0088] See also Figure 4 Step S140 may specifically include performing the following steps S141-S143 for each of the layout blocks:
[0089] Step S141, performing color detection in the length direction on the area of the layout block except the text block to obtain color change parameters in the length direction.
[0090] Step S142, determining the starting position parameter where the color of the layout block no longer changes according to the color change parameter.
[0091] Step S143, obtaining expandable area parameters corresponding to the layout block according to the starting position parameters.
[0092] Specifically, the color of the template area except the text block is detected in the length direction of the template, and the starting position (specifically, it can be a coordinate parameter) where the color no longer changes is detected. This position is the expandable area of the template. When filling long text, the length of the template is expanded from this position, and the expanded area will not produce color jumps.
[0093] Step S150, performing unobstructed target object detection on each of the layout blocks, and for a layout block with an unobstructed target object, determining the unobstructed area parameters of the layout block according to the position of the unobstructed target object in the layout block.
[0094] It is understandable that the unobstructed objects refer to patterns such as logos, trademarks or portraits in the poster template. When filling text on the poster template, these unobstructed objects should be avoided, and there should be no text blocking the unobstructed objects.
[0095] See also Figure 5 The step S150 of performing non-obstructable object detection on each of the layout blocks may specifically include performing the following steps S151-S153 on each of the layout blocks:
[0096] Step S151, extracting edge color of the text block in the layout block to obtain edge color parameters of the text block;
[0097] Step S152, determining a color threshold interval of the layout block according to the text block edge color parameter;
[0098] Step S153, obtaining color parameters of the area other than the text block in the layout block, and treating the area whose color parameters are not within the color threshold range as a non-blockable target object.
[0099] by Figure 7 Take the poster template shown as an example. Figure 7 There are two unobstructed targets (unobstructed target 1 and unobstructed target 2) in the layout block. If there is an unobstructed target in the layout block, the unobstructed target usually has a color jump relative to the edge of the text block in the layout block. Therefore, a color threshold interval can be determined according to the color of the edge of the text block, and the color parameters of the area outside the text block are compared with the threshold interval. The area whose color parameters are not within the color threshold interval is regarded as an unobstructed target.
[0100] See also Figure 6 The step S150 of determining the unobstructed area parameters of the layout block according to the position of the unobstructed target object in the layout block may specifically include steps S154 and S155:
[0101] Step S154, obtaining the coordinate range of the unobstructed target object in the layout block;
[0102] Step S155, obtaining the unobstructed area parameters according to the coordinate range.
[0103] It can be understood that the coordinate range of the area whose color parameters are not within the color threshold interval is obtained, and the coordinate range is used as the non-blockable area parameter.
[0104] Step S160, generating a style parameter information table according to the block attributes, typesetting style parameters, expandable area parameters and non-blockable area parameters of each of the layout blocks.
[0105] It is understandable that after obtaining the block attributes, typesetting style parameters, expandable area parameters and non-blockable area parameters of each layout block, this information can be structured output to generate Figure 8 The style parameter information table shown in the example.
[0106] The solution of the embodiment of the present application is to obtain multiple text blocks in the pictorial template by performing text detection on the pictorial template; based on each of the text blocks, the pictorial template is divided into multiple layout blocks, and the block attributes of each of the layout blocks are determined; style analysis is performed on each of the layout blocks to obtain typesetting style parameters of each of the layout blocks; color detection is performed on each of the layout blocks to obtain color change parameters of each of the layout blocks, and expandable area parameters of the layout blocks are determined according to the color change parameters; unobstructed target object detection is performed on each of the layout blocks, and for layout blocks with unobstructed targets, the unobstructed area parameters of the layout blocks are determined according to the position of the unobstructed targets in the layout blocks; a style parameter information table is generated according to the block attributes, typesetting style parameters, expandable area parameters and unobstructed area parameters of each of the layout blocks. The solution of the embodiment of the present application can automatically extract the typesetting style parameters, expandable area parameters and unobstructed area parameters of each block in the pictorial template, saving a lot of work time for early style extraction and integration. The pictorial production system can directly and intelligently produce pictorials based on the extracted various style parameters, thereby improving the production efficiency and production quality of the pictorials.
[0107] To achieve the above purpose, the second aspect of the embodiment of the present application proposes a system for automatically extracting the style of a pictorial template, see Fig. 9 , the system comprising:
[0108] A text detection module, used to perform text detection on the pictorial template to obtain multiple text blocks in the pictorial template;
[0109] A block division module, used for dividing the pictorial template into a plurality of layout blocks based on each of the text blocks, and determining a block attribute of each of the layout blocks;
[0110] A style analysis module, used to perform style analysis on each of the layout blocks to obtain typesetting style parameters of each of the layout blocks;
[0111] An expandable area detection module, used to perform color detection on each of the layout blocks, obtain color change parameters of each of the layout blocks, and determine expandable area parameters of the layout blocks according to the color change parameters;
[0112] An unobstructed area detection module is used to perform unobstructed target object detection on each of the layout blocks, and for a layout block with an unobstructed target object, determine the unobstructed area parameters of the layout block according to the position of the unobstructed target object in the layout block;
[0113] The table generation module is used to generate a style parameter information table according to the block attributes, typesetting style parameters, expandable area parameters and non-blockable area parameters of each of the layout blocks.
[0114] Exemplarily, the block division module specifically includes:
[0115] A first determining unit, configured to obtain, for each of the text blocks, position information and text attributes of the text block;
[0116] A division unit, used for dividing the pictorial template according to the position information and text attributes of each text block to obtain a plurality of layout blocks;
[0117] The second determination unit is used to determine the block attribute of each layout block according to the text attribute of the text block included in the layout block.
[0118] Exemplarily, the division unit specifically includes:
[0119] The traversal subunit is used to determine the position order of each text block according to the position information of each text block, traverse each text block according to the position order, and perform the following processing during the traversal: compare the text attributes of the currently traversed text block and the previously traversed text block, and when the text attributes of the currently traversed text block are the same as the text attributes of the previously traversed text block, merge the currently traversed text block and the previously traversed text block into the same block text set;
[0120] The division subunit is used to divide the pictorial template according to the block text set obtained after traversal to obtain multiple layout blocks.
[0121] Exemplarily, the scalable area detection module specifically includes:
[0122] A color detection unit, for performing color detection in the length direction of the area in each layout block except the text block, to obtain a color change parameter in the length direction;
[0123] A third determining unit, configured to determine, according to the color change parameter, a starting position parameter at which the color of the layout block no longer changes;
[0124] The fourth determining unit is used to obtain the expandable area parameter corresponding to the layout block according to the starting position parameter.
[0125] Exemplarily, the unobstructed area detection module specifically includes:
[0126] An extraction unit, for extracting edge color of a text block in each layout block to obtain edge color parameters of the text block;
[0127] A fifth determining unit, configured to determine a color threshold interval of the layout block according to the text block edge color parameter;
[0128] The sixth determination unit is used to obtain color parameters of areas other than the text blocks in the layout block, and regard areas whose color parameters are not within the color threshold range as non-obstructible targets.
[0129] Exemplarily, the scalable area detection module further includes:
[0130] A first acquisition unit is used to acquire a coordinate range of the unobstructed target object in the layout block;
[0131] A seventh determining unit is used to obtain the unobstructed area parameter according to the coordinate range.
[0132] Exemplarily, the style analysis module specifically includes:
[0133] A processing unit, used for performing style analysis on each of the layout blocks;
[0134] The second acquisition unit is used to acquire at least one of the following typesetting style parameters of each layout block: font size, font, font color, text center point, alignment, text line spacing, text top position and text bottom position.
[0135] The present application also provides an electronic device, including:
[0136] at least one processor; and,
[0137] a memory communicatively connected to the at least one processor; wherein,
[0138] The memory stores a computer program, and when the computer program is executed by the at least one processor, the at least one processor implements the method for automatically extracting the style of a pictorial template as described in any one of the above embodiments.
[0139] The embodiment of the present application further proposes a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the method for automatically extracting the style of a pictorial template as described in any of the above embodiments is implemented.
[0140] The above embodiments may be used in combination, and modules with the same name in different embodiments may be the same or different.
[0141] The above describes specific embodiments of the present application, and other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily have to be performed in the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0142] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system, device, and computer-readable storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0143] The system, device, computer-readable storage medium and method provided in the embodiments of the present application correspond to each other. Therefore, the system, device and non-volatile computer-readable storage medium also have similar beneficial technical effects as the corresponding method. Since the beneficial technical effects of the method have been described in detail above, the beneficial technical effects of the corresponding system, device and computer-readable storage medium will not be repeated here.
[0144] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0145] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0146] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0147] For the convenience of description, the above devices are described in terms of functions and are divided into various units. Of course, when implementing the embodiments of the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0148] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the embodiments of the present application may adopt the form of complete hardware embodiments, complete software embodiments, or embodiments in combination with software and hardware. Moreover, the embodiments of the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0149] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0150] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0151] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0152] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0153] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0154] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0155] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0156] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.
[0157] Embodiments of the present application may be described in the general context of computer executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. Embodiments of the present application may also be practiced in distributed computing environments, where tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules may be located in local and remote computer readable storage media including storage devices.
[0158] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0159] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A method for automatically extracting the style of a pictorial template, characterized in that: The method comprises: Performing text detection on the pictorial template to obtain multiple text blocks in the pictorial template; For each of the text blocks, obtaining the position information and text attributes of the text block; According to the position information of each text block, the position order of each text block is determined, each text block is traversed in the position order, and the following processing is performed during the traversal: the text attributes of the currently traversed text block and the previously traversed text block are compared, and when the text attributes of the currently traversed text block are the same as the text attributes of the previously traversed text block, the currently traversed text block and the previously traversed text block are merged into the same block text set; Divide the pictorial template according to the block text set obtained after traversal to obtain multiple layout blocks; For each of the layout blocks, determining the block attribute of the layout block according to the text attribute of the text block contained in the layout block; Performing style analysis on each of the layout blocks to obtain typesetting style parameters of each of the layout blocks; Performing color detection on each of the layout blocks respectively, obtaining color change parameters of each of the layout blocks, and determining expandable area parameters of the layout blocks according to the color change parameters; Performing unobstructed object detection on each of the layout blocks, and for a layout block with an unobstructed object, determining an unobstructed area parameter of the layout block according to a position of the unobstructed object in the layout block; A style parameter information table is generated according to the block attributes, typesetting style parameters, expandable area parameters and non-blockable area parameters of each of the layout blocks.
2. The method according to claim 1, characterized in that: The color detection is performed on each of the layout blocks to obtain the color change parameters of each of the layout blocks, and the expandable area parameters of the layout blocks are determined according to the color change parameters, including performing the following processing on each of the layout blocks: Performing color detection in the length direction on the area of the layout block except the text block to obtain color change parameters in the length direction; Determine, according to the color change parameter, a starting position parameter at which the color of the layout block no longer changes; The expandable area parameter corresponding to the layout block is obtained according to the starting position parameter.
3. The method according to claim 1, characterized in that The detecting of the unobstructed object for each of the layout blocks includes performing the following processing for each of the layout blocks: Extracting edge colors of text blocks in the layout block to obtain edge color parameters of the text blocks; Determine the color threshold interval of the layout block according to the text block edge color parameter; The color parameters of the area other than the text block in the layout block are obtained, and the area whose color parameters are not within the color threshold range is regarded as a non-blockable target object.
4. The method according to claim 3, characterized in that The step of determining the unobstructed area parameter of the layout block according to the position of the unobstructed target object in the layout block includes: Obtaining the coordinate range of the unobstructed target object in the layout block; The unobstructed area parameter is obtained according to the coordinate range.
5. The method according to claim 1, characterized in that The performing style analysis on each of the layout blocks to obtain typesetting style parameters of each of the layout blocks includes: Perform style analysis on each of the layout blocks to obtain at least one of the following typesetting style parameters for each layout block: font size, font, font color, text center point, alignment, text line spacing, text top position, and text bottom position.
6. A system for automatically extracting the style of a pictorial template, characterized in that: The system comprises: A text detection module, used to perform text detection on the pictorial template to obtain multiple text blocks in the pictorial template; The block division module is used to obtain the position information and text attributes of each text block; determine the position order of each text block according to the position information of each text block, traverse each text block according to the position order, and perform the following processing during the traversal: compare the text attributes of the currently traversed text block and the previously traversed text block, and when the text attributes of the currently traversed text block are the same as the text attributes of the previously traversed text block, merge the currently traversed text block and the previously traversed text block into the same block text set; divide the pictorial template according to the block text set obtained after the traversal to obtain multiple layout blocks; for each layout block, determine the block attributes of the layout block according to the text attributes of the text blocks contained in the layout block; A style analysis module, used to perform style analysis on each of the layout blocks to obtain typesetting style parameters of each of the layout blocks; An expandable area detection module, used to perform color detection on each of the layout blocks, obtain color change parameters of each of the layout blocks, and determine expandable area parameters of the layout blocks according to the color change parameters; An unobstructed area detection module is used to perform unobstructed target object detection on each of the layout blocks, and for a layout block with an unobstructed target object, determine the unobstructed area parameters of the layout block according to the position of the unobstructed target object in the layout block; The table generation module is used to generate a style parameter information table according to the block attributes, typesetting style parameters, expandable area parameters and non-blockable area parameters of each of the layout blocks.
7. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program, and when the computer program is executed by the at least one processor, the at least one processor executes the method for automatically extracting the style of a pictorial template according to any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for automatically extracting the style of a pictorial template according to any one of claims 1 to 5 is implemented.
