A method, device and equipment for converting target graphic effects in document conversion

By segmenting and independently rendering the graphics effect area in the target document, and using tensor calculation to process sub-segments that do not meet the preset requirements, the rendering error problem during complex graphics effect conversion in the prior art is solved, and higher calculation accuracy and performance optimization are achieved.

CN119338669BActive Publication Date: 2025-03-07BEIJING SUWELL TECHNOLOGY CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411907768.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-03-07
Estimated Expiration
2044-12-24

AI Technical Summary

Technical Problem

Existing PDF to OFD conversion tools have rendering errors when dealing with complex graphics effects, such as color deviation, high computing resource consumption, lack of efficient simulation and compatibility issues.

Method used

By obtaining the target graphic effect area in the target document, dividing it into multiple sub-segments according to its attribute feature type, and rendering each sub-segment independently, tensor calculations are used to process sub-segments that do not meet the preset requirements, and finally the rendered sub-segments are merged and optimized to generate the target graphic effect area of ​​the target document.

Benefits of technology

It realizes more accurate graphic effect conversion during document conversion, improves calculation accuracy, reduces errors, and optimizes performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119338669B_ABST
    Figure CN119338669B_ABST
Patent Text Reader

Abstract

The present invention provides a method, device and equipment for converting target graphic effects in document conversion, the method comprising: obtaining a first target graphic effect area in a target document of a first format; dividing the first target graphic effect area according to the attribute feature type of the first target graphic effect area to obtain a plurality of sub-segments; independently rendering the first target graphic effect in each sub-segment to obtain a plurality of sub-segments displayed in a second format with a second target graphic effect; merging and optimizing the plurality of sub-segments displayed in the second format with the second target graphic effect to obtain a second target graphic effect area in the target document of the second format. The scheme of the present invention can realize the graphic effect conversion more accurately in the conversion process of the target document from the first format to the second format, improve the calculation accuracy, reduce the error and optimize the performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer information technology processing technology, and in particular to a method, device and equipment for converting target graphic effects in document conversion. Background Art

[0002] With the continuous development of digital document formats, PDF (Portable Document Format) has become one of the most widely used document formats, while OFD (Open Fixed Document Format), as a localized electronic document standard, is gradually being adopted by more fields. There are certain differences between the two in graphics rendering and display effects, especially in the conversion process of complex graphics effects (such as special shading effects), which faces technical challenges.

[0003] In PDF files, shading effects are usually presented using complex calculation functions and image processing algorithms. For example, gradient filling, texture effects, and transparency processing require precise numerical calculations and pixel rendering. As a result, existing PDF to OFD conversion tools often have certain rendering errors when processing these special shading effects, such as color deviation, high consumption of computing resources, lack of efficient simulation and compatibility, and generality issues. Summary of the invention

[0004] The technical problem to be solved by the present invention is to provide a method, device and equipment for converting target graphic effects in document conversion, which can more accurately realize the conversion of graphic effects in the process of converting the target document from a first format to a second format, improve calculation accuracy, reduce errors and optimize performance.

[0005] In order to solve the above technical problems, the technical solution of the present invention is as follows:

[0006] A method for converting target graphic effects in document conversion, comprising:

[0007] Acquire a first target graphic effect area in a target document of a first format;

[0008] According to the attribute feature type of the first target graphic effect area, the first target graphic effect area is divided into a plurality of sub-segments;

[0009] Performing independent rendering processing on the first target graphic effect in each sub-segment to obtain a plurality of sub-segments displayed in a second target graphic effect in a second format;

[0010] The multiple sub-segments displayed in the second format with the second target graphic effect are merged and optimized to obtain a second target graphic effect area in the target document in the second format.

[0011] Optionally, independently rendering the first target graphic effect in each sub-segment to obtain a plurality of sub-segments displayed in a second target graphic effect in a second format includes:

[0012] Rendering the first target graphic effect in each sub-segment to obtain a preliminarily rendered sub-segment;

[0013] When the sub-segments after the preliminary rendering meet the preset requirements, the plurality of sub-segments after the preliminary rendering are used as the plurality of sub-segments displayed with the second target graphic effect;

[0014] When the initially rendered sub-segments do not meet the preset requirements, tensor calculation processing is performed on the sub-segments that do not meet the preset requirements to obtain a plurality of sub-segments displayed in a second target graphic effect in a second format.

[0015] Optionally, rendering the first target graphic effect in each sub-segment to obtain a preliminarily rendered sub-segment includes:

[0016] Performing attribute analysis on the first target graphic effect in each sub-segment to determine a rendering method of the sub-segment;

[0017] According to the determined rendering mode, gradient calculation is performed on the sub-segment to obtain a first calculation result; texture calculation is performed on the sub-segment to obtain a second calculation result; transparency calculation is performed on the sub-segment to obtain a third calculation result;

[0018] According to the first calculation result, the second calculation result and the third calculation result, the sub-segment is rendered in the order of the first calculation result, the second calculation result and the third calculation result to obtain a preliminarily rendered sub-segment.

[0019] Optionally, when the sub-segment after the preliminary rendering does not meet the preset requirements, performing tensor calculation processing on the sub-segment that does not meet the preset requirements to obtain a sub-segment displayed in a second target graphic effect in a second format, including:

[0020] When the sub-segment after the preliminary rendering does not meet the preset requirements, the sub-segment that does not meet the preset requirements is subjected to tensor modeling to obtain a multi-dimensional tensor;

[0021] Performing local tensor optimization on the multidimensional tensor to obtain a target tensor;

[0022] According to the target tensor, a subsegment displayed in a second target graphic effect in a second format is obtained.

[0023] Optionally, the sub-segments that do not meet the preset requirements are subjected to tensor modeling to obtain a multi-dimensional tensor, including:

[0024] Decomposing the sub-segments that do not meet the preset requirements according to image attributes to obtain image data of each attribute;

[0025] The image data of each attribute is assigned to different dimensions of the tensor to obtain the multidimensional tensor, wherein each dimension of the multidimensional tensor represents the image data of one attribute.

[0026] Optionally, performing local tensor optimization on the multidimensional tensor to obtain a target tensor includes:

[0027] Determining, according to the complexity of the image represented by the multidimensional tensor, a local area whose complexity is greater than a preset threshold;

[0028] Performing tensor decomposition on the local region to obtain a local optimized tensor;

[0029] A target tensor is obtained according to the local optimized tensor.

[0030] Optionally, merging and optimizing the multiple sub-segments displayed in the second target graphic effect in the second format to obtain the second target graphic effect area in the target document in the second format includes:

[0031] splicing the plurality of sub-segments displayed in the second format with the second target graphic effect to obtain a spliced ​​image;

[0032] The spliced ​​image is globally optimized according to the global effect to obtain a second target graphic effect area in the target document in the second format.

[0033] The present invention also provides a target graphic effect conversion device in document conversion, comprising:

[0034] An acquisition module, used for acquiring a first target graphic effect area in a target document of a first format;

[0035] A processing module is used to divide the first target graphic effect area into multiple sub-segments according to the attribute feature type of the first target graphic effect area; independently render the first target graphic effect in each sub-segment to obtain multiple sub-segments displayed in a second format of the second target graphic effect; merge and optimize the multiple sub-segments displayed in the second format of the second target graphic effect to obtain a second target graphic effect area in a target document in the second format.

[0036] The present invention also provides a computing device, comprising: a processor and a memory storing a computer program, wherein when the computer program is run by the processor, the method as described above is executed.

[0037] The present invention also provides a computer-readable storage medium storing instructions, which, when executed on a computer, enable the computer to execute the above method.

[0038] The above solution of the present invention includes at least the following beneficial effects:

[0039] The above scheme of the present invention obtains the first target graphic effect area in the target document of the first format; divides the first target graphic effect area according to the attribute feature type of the first target graphic effect area to obtain multiple sub-segments; independently renders the first target graphic effect in each sub-segment to obtain multiple sub-segments displayed with the second target graphic effect in the second format; and merges and optimizes the multiple sub-segments displayed with the second target graphic effect in the second format to obtain the second target graphic effect area in the target document of the second format. In the process of converting the target document from the first format to the second format, the graphic effect conversion can be realized more accurately, the calculation accuracy can be improved, the error can be reduced, and the performance can be optimized. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 is a flow chart of a method for converting a target graphic effect in a document conversion according to an embodiment of the present invention;

[0041] Figure 2 It is a structural diagram of a target graphic effect conversion device in document conversion according to an embodiment of the present invention. DETAILED DESCRIPTION

[0042] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present invention and to enable the scope of the present invention to be fully communicated to those skilled in the art.

[0043] like Figure 1 As shown, an embodiment of the present invention provides a method for converting a target graphic effect in document conversion, comprising:

[0044] Step 11, obtaining a first target graphic effect area in a target document in a first format;

[0045] Here, the first format may be a PDF (Portable Document Format) format, the target document may be a document in a PDF (Portable Document Format) format, and the first target graphic effect area is a graphic area with a shading effect. The shading effect refers to complex graphic effects such as gradient fills that appear in a document. By analyzing the properties of the first target graphic effect area, the attribute feature type of the first target graphic effect area is obtained, which may include: gradient type (such as linear gradient, radial gradient), transparency, color mode, texture, etc., to determine the characteristics of the shading area. Among them, the gradient type may include: linear gradient and radial gradient; for linear gradient, calculate the gradient direction, start and end points, and distribution of color changes; for radial gradient, calculate the center point, radius, and color distribution; for texture fill, identify the texture type, mapping method, and its deformation properties.

[0046] Step 12, dividing the first target graphic effect area into a plurality of sub-segments according to the attribute feature type of the first target graphic effect area;

[0047] Here, for the graphic area with shading effect, the graphic area where the shading effect appears is segmented. During the segmentation process, the first target graphic effect area needs to be segmented according to the attribute feature type of the shading area; the purpose is to decompose the complex shading area into multiple simpler, computationally controllable small areas to avoid error amplification in a single calculation area. By independently calculating and rendering each sub-segment, complex effects such as gradients, transparency, and textures can be better handled. The segmentation criteria for multiple sub-segments are as follows: Smoothness of gradient changes: For gradient effects, if the color or transparency changes relatively slowly, a larger calculation segment can be set; if the change is drastic, it needs to be segmented into more small segments to ensure calculation accuracy. Geometric features of the graphic area: For example, at the edges of gradients or areas with sharp angles, a more detailed segmentation strategy can be used to avoid edge distortion caused by inaccurate calculations.

[0048] Step 13, independently rendering the first target graphic effect in each sub-segment to obtain a plurality of sub-segments displayed in a second target graphic effect in a second format;

[0049] Here, the second format is OFD (Open Fixed Document Format) format, and the second target graphic effect refers to the graphic effect presented after the shading effect in the PDF format is converted into the OFD format. In the present invention, the second target graphic effect can restore the first target graphic effect to the greatest extent and reduce the rendering error in the document conversion.

[0050] Step 14: merging and optimizing the multiple sub-segments displayed in the second format with the second target graphic effect to obtain a second target graphic effect area in the target document in the second format.

[0051] Here, each independently rendered sub-segment is merged and optimized to obtain a complete second target graphic effect area in OFD format. The second target graphic effect area in OFD format appears in the converted OFD document, and can restore the shading effect in the target document in PDF format in appearance.

[0052] In this embodiment, in order to achieve accurate shading effect conversion, the target graphic effect area is divided into multiple sub-segments during the format conversion process, and calculation and rendering are performed independently in each sub-segment. According to the different graphic effects and complexity in the sub-segments, different rendering strategies are selected accordingly, and finally the rendered sub-segments are merged to achieve accurate shading conversion effects. The present invention improves calculation accuracy, reduces errors, and greatly optimizes performance during the conversion process of image shading effects.

[0053] In an optional embodiment of the present invention, step 13 may include:

[0054] Step 131, rendering the first target graphic effect in each sub-segment to obtain a preliminarily rendered sub-segment;

[0055] Step 132, when the sub-segments after the preliminary rendering meet the preset requirements, the plurality of sub-segments after the preliminary rendering are used as the plurality of sub-segments displayed with the second target graphic effect;

[0056] Step 133 , when the sub-segments after the preliminary rendering do not meet the preset requirements, the sub-segments that do not meet the preset requirements are subjected to tensor calculation processing to obtain a plurality of sub-segments displayed in a second target graphic effect in a second format.

[0057] In this embodiment, it is preferred to render the segmented sub-segments to obtain the preliminarily rendered sub-segments. When the graphic effects displayed by the preliminarily rendered sub-segments meet the preset requirements (the second target graphic rendering parameters in the second format), it is considered that the first graphic effect area has achieved the conversion from PDF to OFD. When the sub-segment effects obtained after the preliminarily rendering of some complex or special shading graphic effects are not ideal and do not meet the preset requirements, the special sub-segment is processed by tensor calculation to finally obtain the second target graphic effect that meets the preset requirements.

[0058] Specifically, step 131 may include:

[0059] Step 1311, performing attribute analysis on the first target graphic effect in each sub-segment to determine a rendering method of the sub-segment;

[0060] Here, for each sub-segment, it is first necessary to analyze the attribute feature type of the sub-segment, such as color gradient, transparency change, texture filling, lighting direction, etc. Based on these attribute feature types, the specific rendering method of the sub-segment is determined.

[0061] Specifically, for

[0062] Gradient attribute feature type: If the sub-segment contains a gradient (such as a linear gradient or a radial gradient), the gradient line segment or arc needs to be calculated based on the gradient's start and end points, direction, color change range, etc.

[0063] For texture attribute feature types: If the sub-segment contains texture filling, analyze the texture type, texture coordinate transformation, whether there are rotation, scaling and other operations, to ensure that the texture can be accurately mapped to the sub-segment area;

[0064] For the transparency attribute feature type: check whether the sub-segment involves a transparency change. If there is a transparency gradient or an opaque area, the transparency transition effect must be accurately calculated;

[0065] Step 1312, according to the determined rendering mode, performing gradient calculation on the sub-segment to obtain a first calculation result; performing texture calculation on the sub-segment to obtain a second calculation result; performing transparency calculation on the sub-segment to obtain a third calculation result;

[0066] According to the analyzed sub-segment attributes, each graphic effect contained in the sub-segment is calculated in turn. For the gradient attribute feature type, when it is a linear gradient, the gradient path is calculated according to the start and end points of the sub-segment, and the color is interpolated on the path;

[0067] When it is a radial gradient, the color change from the center to the edge is calculated, and the smooth transition of color is controlled by the radial distance.

[0068] The gradient property is calculated according to the following formula:

[0069]

[0070] in, is the color of a point in the gradient process, is the color value of the gradient starting point, is the color value of the gradient end point, and t is the normalized parameter of the gradient, usually between 0 and 1.

[0071] For the texture attribute feature type, the UV coordinate transformation of the texture must first be calculated to ensure that the texture can be stretched or repeated in the expected way within the subsegment. In some cases, the texture may undergo transformations such as rotation and scaling, which require corresponding mathematical calculations.

[0072] The texture calculation process usually includes: calculating the mapping relationship of texture coordinates within the sub-segment; using texture sampling technology to obtain the texture color at the coordinate position; considering the transparency of the texture and the blending of the color with gradients or other layers.

[0073] For the transparency attribute feature type, the change of transparency is achieved through linear interpolation or curve interpolation, and the calculation formula is:

[0074]

[0075] in, For the transparency of a point, is the transparency of the starting point, is the transparency of the end point, and t is a normalized parameter, usually between 0 and 1.

[0076] When calculating transparency gradient, it is usually necessary to consider the superimposed transparency effect and ensure that the transparency of each sub-segment transitions smoothly to avoid obvious discontinuities or abrupt visual effects.

[0077] Step 1313: Render the sub-segment in the order of the first calculation result, the second calculation result and the third calculation result according to the first calculation result, the second calculation result and the third calculation result to obtain a preliminarily rendered sub-segment.

[0078] After the sub-segment calculation is completed, in order to ensure the accuracy of the rendering effect of each sub-segment, the rendering process needs to be performed in the order of the first calculation result, the second calculation result and the third calculation result, that is, color filling, texture mapping and transparency processing are performed in sequence.

[0079] The rendering process of sub-segments of each attribute feature type mainly includes:

[0080] Color filling: Based on the color value calculated for each sub-segment, fill the sub-segment area according to the gradient or transparency change. Interpolation is usually required between different colors to ensure a smooth gradient effect.

[0081] Texture mapping: For the texture mapping area, the color value of the texture is applied, and the transparency of the texture is combined with the gradient calculation result to finally obtain the rendering effect of the sub-segment;

[0082] Transparency processing: Transparency blending is performed based on the calculated transparency value. When processing semi-transparent areas, the final display color needs to be synthesized through transparency calculation.

[0083] After the rendering is completed in the above order, the edges of each sub-segment are locally smoothed to avoid obvious jagged or fault phenomena due to calculation accuracy problems. Finally, the sub-segment after preliminary rendering is obtained.

[0084] In an optional embodiment of the present invention, step 133 may include:

[0085] Step 1331, when the sub-segment after the preliminary rendering does not meet the preset requirements, the sub-segment that does not meet the preset requirements is subjected to tensor modeling to obtain a multi-dimensional tensor;

[0086] Step 1332, performing local tensor optimization on the multidimensional tensor to obtain a target tensor;

[0087] Step 1333: Obtain a subsegment displayed in a second target graphic effect in a second format according to the target tensor.

[0088] In this embodiment, when the sub-segment after preliminary rendering does not meet the preset requirements, tensor modeling is performed on the sub-segment, and local tensor optimization is performed on the modeled multi-dimensional tensor to finally obtain a target tensor. According to the target tensor, the shading effect in the original PDF can be restored to the greatest extent.

[0089] Specifically, step 1331 may include:

[0090] Step 13311, decomposing the sub-segments that do not meet the preset requirements according to image attributes to obtain image data of each attribute;

[0091] Step 13312, assigning the image data of each attribute to different dimensions of the tensor to obtain the multidimensional tensor, wherein each dimension of the multidimensional tensor represents the image data of one attribute.

[0092] Here, tensor is a general representation of multidimensional arrays and can be seen as a generalization of matrices. For each pixel or area in the image, multiple attributes (such as color, transparency, texture coordinates, etc.) are stored in different dimensions of the tensor. For example, when the shading effect area is an image with texture mapping, it can be represented as a high-order tensor in which each dimension corresponds to a different attribute (for example, color, depth, transparency, texture coordinates, etc.). For another example, when the shading effect area is a gradient effect, it may include color (RGB) information, transparency (alpha) information, and texture coordinates. Then this information can be represented as a four-dimensional tensor:

[0093] First dimension: width of the image;

[0094] Second dimension: the height of the image;

[0095] The third dimension: color (e.g., RGB);

[0096] The fourth dimension: transparency and texture coordinates;

[0097] By performing operations on this high-order tensor (such as interpolation, transformation, etc.), gradients, textures, and other complex effects can be simulated efficiently.

[0098] If the shading effect area is considered as an image with W×H pixels, and each pixel has multiple attributes (for example, RGB color, transparency, and texture coordinates), these attributes are modeled as a four-dimensional tensor T:

[0099]

[0100] The first and second dimensions represent the width W and height H of the image, the third dimension represents the RGB channels of the color (3), and the fourth dimension contains transparency and texture coordinates (2). Therefore, the attributes of each pixel can be stored in a four-dimensional tensor.

[0101] In an optional embodiment of the present invention, step 1332 may include:

[0102] Step 13321, determining a local area whose complexity is greater than a preset threshold according to the complexity of the image represented by the multidimensional tensor;

[0103] Step 13322, performing tensor decomposition on the local region to obtain a local optimized tensor;

[0104] Step 13323, obtain a target tensor based on the local optimized tensor.

[0105] In this embodiment, for particularly complex areas in the image, higher calculation accuracy and detail restoration are required to ensure the effect of image conversion. Therefore, the tensor decomposition method is used to perform local tensor optimization for the multi-dimensional tensor after modeling. Local tensor optimization optimizes tensor calculation based on local attributes in the area (such as color gradient, detail texture, transparency, etc.) to ensure calculation accuracy.

[0106] In step 13322, the method of performing tensor decomposition in the local area to obtain the local optimized tensor may include:

[0107] Perform local sampling on complex areas to extract detailed information within the area.

[0108] Perform tensor decomposition on the local area to enhance the modeling capabilities of details such as texture and gradient.

[0109] The optimized local optimization tensor is synthesized with the overall image to ensure the fine restoration of local details.

[0110] The tensor decomposition method includes: decomposing a multidimensional tensor into a core tensor and multiple factor matrices. For example, for a four-dimensional tensor T, decomposing it into a small-sized core tensor G and four factor matrices , where the four factor matrices correspond to the four dimensions of the tensor.

[0111] As shown in the following formula:

[0112] Where ×n represents the mode-n multiplication of the tensor, n takes values ​​of 1, 2, 3, 4, and the dimension of the core tensor G is smaller than the original tensor T.

[0113] The local optimized tensor obtained after the tensor decomposition and the tensor of the local area whose complexity is less than or equal to the preset threshold are synthesized to obtain a target tensor. The target tensor is a digital representation of the second target graphic effect area. According to the target tensor, a picture of the second target graphic effect area can be obtained, and the picture can accurately restore the second target graphic effect after the first target graphic effect area is converted into the second format.

[0114] In this embodiment, local tensor optimization is performed through tensor decomposition. On the one hand, the computational efficiency is improved through local constraints, avoiding high-complexity computations in the entire graph, thereby reducing redundant computations. On the other hand, tensor decomposition itself can significantly reduce the complexity of storage and computation, converting large-scale tensor operations into matrix multiplications, thereby improving efficiency.

[0115] In an optional embodiment of the present invention, step 14 may include:

[0116] Step 141, splicing the plurality of sub-segments displayed in the second format with the second target graphic effect to obtain a spliced ​​image;

[0117] Step 142: globally optimize the spliced ​​image according to the global effect to obtain a second target graphic effect area in the target document in a second format.

[0118] In this embodiment, after completing the independent calculation and rendering in each sub-segment, it is necessary to splice the rendering results of these sub-segments into a complete shading effect area. During the splicing process, it is necessary to ensure that the gradient and transparency between different sub-segments transition smoothly to avoid visible seams or unnatural transitions. After completing the splicing of all sub-segments to obtain a spliced ​​image, global optimization is performed based on the global effect to correct small errors that may occur. For example, for a large-scale gradient area, readjust the color interpolation to ensure that the gradient effect of the entire area is consistent and avoid local transition distortion. After global optimization, the second target graphic effect area in the second format is output.

[0119] A specific implementation process of the present invention is as follows:

[0120] Step 111, obtaining a target document in PDF format;

[0121] Step 112, parsing a graphic area of ​​a shading effect in a target document in PDF format, that is, a first target graphic effect area;

[0122] Step 113, parsing the attribute feature type of the first target graphic effect area, including: gradient type (such as linear gradient, radial gradient), transparency, color mode, texture, etc.;

[0123] Step 114, dividing the first target graphic effect area into multiple sub-segments according to the attribute feature type of the first target graphic effect area;

[0124] Step 115, independent calculation and rendering in each sub-segment, specifically includes:

[0125] 1151, Attribute Extraction and Analysis:

[0126] For each sub-segment, we first need to extract the basic attributes within the sub-segment, such as color gradient, transparency change, texture filling, lighting direction, etc. Based on these attributes, we determine the specific rendering method of the sub-segment.

[0127] Gradient attribute analysis: If a sub-segment contains a gradient (such as a linear gradient or a radial gradient), you first need to calculate the specific performance of the gradient line segment or arc based on the gradient's start and end points, direction, color change range, etc.

[0128] Transparency analysis: Check whether the sub-segment involves transparency changes. If there are transparency gradients or opaque areas, the transparency transition effect must be accurately calculated.

[0129] Texture mapping analysis: If the sub-segment contains texture filling, analyze the texture type, texture coordinate transformation, whether there is rotation, scaling and other operations, to ensure that the texture can be accurately mapped to the sub-segment area.

[0130] 1152, Independent Calculation: For each sub-segment, the shading effect is calculated separately to ensure that the rendering results of different sub-segments do not affect each other. During the calculation process, the following strategies are used:

[0131] Gradient calculation: The gradient of each sub-segment is calculated independently. For linear gradient, the gradient path is calculated according to the start and end points of the sub-segment, and the color is interpolated on the path. For radial gradient, the color change from the center to the edge is calculated, and the smooth transition of color is controlled by radial distance.

[0132] The gradient formula is: ; Where C(t) is the color at a certain point in the gradient process, t is the normalized parameter of the gradient (usually between 0 and 1), and Cstart and Cend are the color values ​​of the starting and ending points of the gradient, respectively.

[0133] Transparency gradient calculation: If a transparency gradient is involved in a sub-segment, the change in transparency α can be performed by linear interpolation or curve interpolation in a manner similar to color gradient: .

[0134] When calculating transparency gradient, it is usually necessary to consider the superimposed transparency effect and ensure that the transparency of each sub-segment transitions smoothly to avoid obvious discontinuities or abrupt visual effects.

[0135] Texture calculation: If the sub-segment contains a texture map, the UV coordinate transformation of the texture must be calculated first to ensure that the texture can be stretched or repeated in the expected way within the sub-segment. In some cases, the texture may undergo transformations such as rotation and scaling, which require corresponding mathematical calculations.

[0136] The texture calculation process usually includes: A. Calculating the mapping relationship of texture coordinates within the sub-segment; B. Using texture sampling technology to obtain the texture color at the coordinate position; C. Considering the transparency of the texture and the blending of the color with gradients or other layers.

[0137] 1553, Independent Rendering: After the sub-segment calculation is completed, the rendering process needs to be performed in sequence: color filling, texture mapping, and transparency processing. In order to ensure the accurate rendering effect of each sub-segment, the following steps are required during rendering:

[0138] A, Color overlay: Based on the color value calculated for each sub-segment, fill the sub-segment area with a gradient or transparency change. Interpolation is usually required between different colors to ensure a smooth gradient effect.

[0139] B. Texture mapping application: For the texture mapping area, the color value of the texture is applied, and the transparency of the texture is synthesized with the gradient calculation result to finally obtain the rendering effect of the sub-segment.

[0140] C. Transparency processing: Perform alpha blending based on the calculated transparency value. This step is very critical, especially when processing semi-transparent areas, which require transparency calculation to synthesize the final display color.

[0141] D. If there is still no good effect after color overlay, texture mapping, and transparency processing in special documents, tensor calculation can be used to achieve rendering optimization;

[0142] 1554, Error Control and Optimization: In order to reduce the error in the rendering process, especially in detail processing, the following optimization strategies are adopted:

[0143] Local smoothing: Perform local smoothing on the edge of the sub-segment to avoid obvious jagged edges or faults due to calculation accuracy issues.

[0144] Correction before merging sub-segments: After all sub-segments are rendered independently, the rendering results of each sub-segment are corrected to ensure smooth transitions between each sub-segment and eliminate stitching gaps or color differences.

[0145] Step 116, sub-segment synthesis and overall rendering, after completing the independent calculation and rendering in the sub-segment, the rendering results of these sub-segments need to be merged into a complete shading effect area. During the merging process, the following matters need to be noted:

[0146] 1161, sub-segment stitching: seamlessly stitch the rendering results of each sub-segment. This process needs to ensure smooth transition of gradients and transparency between different sub-segments to avoid visible seams or unnatural transitions.

[0147] 1162, Global Optimization: After all sub-segments are joined, global optimization is used to further correct possible minor errors. For example, for a large gradient area, the color interpolation is readjusted to ensure that the gradient effect of the entire area is consistent and to avoid local transition distortion.

[0148] 1163, Final rendering output: After the synthesis is completed, the final rendering output has a complete shading effect, and ensures that the output document format (such as OFD format) can accurately save the rendering effect of each sub-segment for subsequent viewing and editing.

[0149] The above-mentioned embodiment of the present invention can effectively improve the rendering accuracy and reduce the calculation error of complex shading effects by performing independent calculation and rendering in each sub-segment, especially when dealing with details such as gradient, transparency change, texture mapping, etc. The process of independent rendering of each sub-segment makes the rendering operation more controllable, so that complex graphic effects can be better restored in the conversion from PDF to OFD. At the same time, the application of sub-segment synthesis and global optimization strategy also ensures that the final rendering effect is smooth and natural, meeting the requirements of high-quality document rendering.

[0150] like Figure 2 As shown, the present invention also provides a target graphic effect conversion device 20 in document conversion, comprising:

[0151] An acquisition module 21, configured to acquire a first target graphic effect area in a target document of a first format;

[0152] The processing module 22 is used to divide the first target graphic effect area into multiple sub-segments according to the attribute feature type of the first target graphic effect area; independently render the first target graphic effect in each sub-segment to obtain multiple sub-segments displayed in the second target graphic effect in the second format; merge and optimize the multiple sub-segments displayed in the second target graphic effect in the second format to obtain the second target graphic effect area in the target document in the second format.

[0153] Optionally, independently rendering the first target graphic effect in each sub-segment to obtain a plurality of sub-segments displayed in a second target graphic effect in a second format includes:

[0154] Rendering the first target graphic effect in each sub-segment to obtain a preliminarily rendered sub-segment;

[0155] When the sub-segments after the preliminary rendering meet the preset requirements, the plurality of sub-segments after the preliminary rendering are used as the plurality of sub-segments displayed with the second target graphic effect;

[0156] When the initially rendered sub-segments do not meet the preset requirements, tensor calculation processing is performed on the sub-segments that do not meet the preset requirements to obtain a plurality of sub-segments displayed in a second target graphic effect in a second format.

[0157] Optionally, rendering the first target graphic effect in each sub-segment to obtain a preliminarily rendered sub-segment includes:

[0158] Performing attribute analysis on the first target graphic effect in each sub-segment to determine a rendering method of the sub-segment;

[0159] According to the determined rendering mode, gradient calculation is performed on the sub-segment to obtain a first calculation result; texture calculation is performed on the sub-segment to obtain a second calculation result; transparency calculation is performed on the sub-segment to obtain a third calculation result;

[0160] According to the first calculation result, the second calculation result and the third calculation result, the sub-segment is rendered in the order of the first calculation result, the second calculation result and the third calculation result to obtain a preliminarily rendered sub-segment.

[0161] Optionally, when the sub-segment after the preliminary rendering does not meet the preset requirements, performing tensor calculation processing on the sub-segment that does not meet the preset requirements to obtain a sub-segment displayed in a second target graphic effect in a second format, including:

[0162] When the sub-segment after the preliminary rendering does not meet the preset requirements, the sub-segment that does not meet the preset requirements is subjected to tensor modeling to obtain a multi-dimensional tensor;

[0163] Performing local tensor optimization on the multidimensional tensor to obtain a target tensor;

[0164] According to the target tensor, a subsegment displayed in a second target graphic effect in a second format is obtained.

[0165] Optionally, the sub-segments that do not meet the preset requirements are subjected to tensor modeling to obtain a multi-dimensional tensor, including:

[0166] Decomposing the sub-segments that do not meet the preset requirements according to image attributes to obtain image data of each attribute;

[0167] The image data of each attribute is assigned to different dimensions of the tensor to obtain the multidimensional tensor, wherein each dimension of the multidimensional tensor represents the image data of one attribute.

[0168] Optionally, performing local tensor optimization on the multidimensional tensor to obtain a target tensor includes:

[0169] Determining, according to the complexity of the image represented by the multidimensional tensor, a local area whose complexity is greater than a preset threshold;

[0170] Performing tensor decomposition on the local region to obtain a local optimized tensor;

[0171] A target tensor is obtained according to the local optimized tensor.

[0172] Optionally, merging and optimizing the multiple sub-segments displayed in the second target graphic effect in the second format to obtain the second target graphic effect area in the target document in the second format includes:

[0173] splicing the plurality of sub-segments displayed in the second format with the second target graphic effect to obtain a spliced ​​image;

[0174] The spliced ​​image is globally optimized according to the global effect to obtain a second target graphic effect area in the target document in the second format.

[0175] It should be noted that the device is a device corresponding to the above method, and all implementation methods in the above method embodiments are applicable to the embodiments of the device and can achieve the same technical effects.

[0176] The embodiment of the present invention further provides a computing device, comprising: a processor, a memory storing a computer program, wherein when the computer program is executed by the processor, the method described above is executed. All implementations in the above method embodiment are applicable to this embodiment and can achieve the same technical effect.

[0177] The embodiment of the present invention further provides a computer-readable storage medium storing instructions, which, when executed on a computer, enable the computer to execute the above method. All implementations in the above method embodiment are applicable to this embodiment and can achieve the same technical effect.

[0178] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0179] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0180] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0181] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0182] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0183] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.

[0184] In addition, it should be pointed out that in the apparatus and method of the present invention, it is obvious that each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent schemes of the present invention. Moreover, the steps of performing the above series of processing can naturally be performed in chronological order according to the order of description, but it is not necessary to perform them in chronological order, and some steps can be performed in parallel or independently of each other. For those of ordinary skill in the art, it is understandable that all or any steps or components of the method and apparatus of the present invention can be implemented in hardware, firmware, software or a combination thereof in any computing device (including processors, storage media, etc.) or a network of computing devices, which can be achieved by those of ordinary skill in the art using their basic programming skills after reading the description of the present invention.

[0185] Therefore, the purpose of the present invention can also be achieved by running a program or a group of programs on any computing device. The computing device can be a well-known general device. Therefore, the purpose of the present invention can also be achieved by simply providing a program product containing a program code that implements the method or device. That is to say, such a program product also constitutes the present invention, and the storage medium storing such a program product also constitutes the present invention. Obviously, the storage medium can be any well-known storage medium or any storage medium developed in the future. It should also be pointed out that in the device and method of the present invention, it is obvious that each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent schemes of the present invention. In addition, the steps of performing the above-mentioned series of processing can naturally be performed in chronological order according to the order of description, but it is not necessary to perform them in chronological order. Some steps can be performed in parallel or independently of each other.

[0186] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for converting target graphic effects in document conversion, characterized in that: include: Acquire a first target graphic effect area in a target document in a first format; the first format is a portable document PDF format, and the first target graphic effect area is a graphic area with a coloring effect; According to the attribute feature type of the first target graphic effect area, the first target graphic effect area is divided into a plurality of sub-segments; The first target graphic effect in each sub-segment is independently rendered to obtain a plurality of sub-segments displayed in a second target graphic effect in a second format; the second format is an open fixed document OFD format, and the second target graphic effect is a graphic effect presented after a coloring effect in a portable document PDF format is converted into an open fixed document OFD format; Merging and optimizing the multiple sub-segments displayed in the second format with the second target graphic effect to obtain a second target graphic effect area in the target document in the second format; The first target graphic effect in each sub-segment is independently rendered to obtain multiple sub-segments displayed in a second target graphic effect in a second format, including: Performing attribute analysis on the first target graphic effect in each sub-segment to determine a rendering method of the sub-segment; According to the determined rendering mode, gradient calculation is performed on the sub-segment to obtain a first calculation result; texture calculation is performed on the sub-segment to obtain a second calculation result; Performing transparency calculation on the sub-segment to obtain a third calculation result; According to the first calculation result, the second calculation result and the third calculation result, the sub-segment is rendered in the order of the first calculation result, the second calculation result and the third calculation result to obtain a preliminarily rendered sub-segment; When the sub-segments after the preliminary rendering meet the preset requirements, the plurality of sub-segments after the preliminary rendering are used as the plurality of sub-segments displayed with the second target graphic effect; When the sub-segment after the preliminary rendering does not meet the preset requirements, the sub-segment that does not meet the preset requirements is decomposed according to image attributes to obtain image data of each attribute; Assigning the image data of each attribute to different dimensions of the tensor to obtain a multidimensional tensor, wherein each dimension of the multidimensional tensor represents the image data of one attribute; Determining, according to the complexity of the image represented by the multidimensional tensor, a local area whose complexity is greater than a preset threshold; Performing tensor decomposition on the local region to obtain a local optimized tensor; According to the local optimized tensor, a target tensor is obtained; According to the target tensor, a subsegment displayed in a second target graphic effect in a second format is obtained.

2. The target graphic effect conversion method in document conversion according to claim 1, characterized in that: Merging and optimizing the multiple sub-segments displayed in the second target graphic effect in the second format to obtain the second target graphic effect area in the target document in the second format includes: splicing the plurality of sub-segments displayed in the second format with the second target graphic effect to obtain a spliced ​​image; The spliced ​​image is globally optimized according to the global effect to obtain a second target graphic effect area in the target document in the second format.

3. A target graphic effect conversion device in document conversion, characterized in that: include: An acquisition module, used for acquiring a first target graphic effect area in a target document in a first format; the first format is a portable document PDF format, and the first target graphic effect area is a graphic area with a coloring effect; A processing module is used to divide the first target graphic effect area according to the attribute feature type of the first target graphic effect area to obtain a plurality of sub-segments; independently render the first target graphic effect in each sub-segment to obtain a plurality of sub-segments displayed in a second target graphic effect in a second format; the second format is an open fixed document OFD format, and the second target graphic effect is a graphic effect presented after the coloring effect in the portable document PDF format is converted into the open fixed document OFD format; merge and optimize the plurality of sub-segments displayed in the second target graphic effect in the second format to obtain a second target graphic effect area in the target document in the second format; The first target graphic effect in each sub-segment is independently rendered to obtain multiple sub-segments displayed in a second target graphic effect in a second format, including: Performing attribute analysis on the first target graphic effect in each sub-segment to determine a rendering method of the sub-segment; According to the determined rendering mode, gradient calculation is performed on the sub-segment to obtain a first calculation result; texture calculation is performed on the sub-segment to obtain a second calculation result; transparency calculation is performed on the sub-segment to obtain a third calculation result; According to the first calculation result, the second calculation result and the third calculation result, the sub-segment is rendered in the order of the first calculation result, the second calculation result and the third calculation result to obtain a preliminarily rendered sub-segment; When the sub-segments after the preliminary rendering meet the preset requirements, the plurality of sub-segments after the preliminary rendering are used as the plurality of sub-segments displayed with the second target graphic effect; When the sub-segment after the preliminary rendering does not meet the preset requirements, the sub-segment that does not meet the preset requirements is decomposed according to image attributes to obtain image data of each attribute; Assigning the image data of each attribute to different dimensions of the tensor to obtain a multidimensional tensor, wherein each dimension of the multidimensional tensor represents the image data of one attribute; Determining, according to the complexity of the image represented by the multidimensional tensor, a local area whose complexity is greater than a preset threshold; Decomposing the local region into a tensor to obtain a local optimized tensor; and obtaining a target tensor according to the local optimized tensor; According to the target tensor, a subsegment displayed in a second target graphic effect in a second format is obtained.

4. A computing device, characterized in that include: A processor and a memory storing a computer program, wherein when the computer program is executed by the processor, the method according to any one of claims 1 to 2 is performed.

5. A computer-readable storage medium, characterized in that: Instructions are stored, and when the instructions are executed on a computer, the computer is caused to execute the method according to any one of claims 1 to 2.

Citation Information

Patent Citations

  • OFD document processing method, electronic equipment and computer readable storage medium

    CN111897776A

  • OFD document rapid rendering method and device, electronic equipment and storage medium

    CN115168758A