Dynamic layout method and system for multi-lingual visual materials
Patent Information
- Application Number
- CN202611139336.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-29
- Publication Date
- 2026-10-16
AI Technical Summary
若排版系统为将文字强行约束在预设区域内而缩小字号,则在小尺寸的手机屏幕展示场景下,用户肉眼难以辨认具体的宣传文案内容
[0017]相比于现有技术,本发明的有益效果为:本发明通过从源语言版面像素矩阵提取边缘梯度值与色彩显著度值直接解析出视觉焦点区域坐标集合,并在画布缩放时将其与文字图层坐标、背景图层按同一组缩放系数映射至目标画布坐标系,替代了传统的静态坐标绑定,消除了不同坐标系间空间避让失真问题。以经画布缩放系数同步映射的文本溢出量为触发条件,将文本框位移与字号缩放两个自由度进行联合约束求解,使多语种字符膨胀、排版方向切换与多尺寸画布变化在统一的空间避让机制下协同收敛,从根源上切断了固定位置遮挡焦点与强行缩字号导致不可辨识的双重矛盾的产生路径。在缩放触及可辨识下限时触发的画布内换行并重新测量文本渲染尺寸预估值的回路机制,还在无需独立断句处理模块的前提下同步改善了语种排版方向切换时因机械截断导致的语义不连贯缺陷。最终通过像素级冲突复核闭环,将残余遮挡拦截于交付之前,实现了视觉物料在不同语种、不同尺寸、不同平台上的批量自动化适配,有效降低次品率并摆脱人工逐一调整的依赖,适用于计算机排版自动化及多语种图形适配处理系统。
Smart Images

Figure CN122925680A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of visual material layout technology, and in particular to a dynamic layout method and system for multilingual visual materials. Background Technology
[0002] In the process of batch adaptation of visual materials across multiple languages and sizes, the commonly used technique is to extract the absolute or percentage coordinates of each layer in the source file and then perform text replacement in the target language and proportional scaling of the canvas size based on these coordinates. This technique utilizes fixed spatial mapping relationships to directly transfer the layout of the source material to the target canvas, achieving automatic conversion of layer positions and sizes. However, this method based on static coordinate binding lacks the ability to perceive image content, and the accuracy of its layout transfer depends on the strict proportional consistency between the input and output canvases and the approximation of text character lengths.
[0003] In actual automated typesetting production, when source language materials are replaced with target language text that has significantly increased character length or changed writing direction, and simultaneously adapted to canvases with different aspect ratios, the generated target material often exhibits a phenomenon where large areas of text obscure core visual elements. For example, when converting a Chinese game character poster into a horizontal advertisement in Russian or French, the short vertical text on the right side of the source material, after being replaced with a horizontally extended long sentence in the target language, will directly tile and cover the character's face or weapon details on the left side of the image. If the typesetting system reduces the font size to forcibly confine the text to a preset area, users will find it difficult to discern the specific promotional content on small mobile screens. Such problems result in batch-generated materials generally having improper layout structure and loss of readability of key information. The produced materials cannot be directly used for publishing and must rely on manual dragging of layer positions and fine-tuning of font sizes, significantly reducing the actual production efficiency of automated typesetting. Therefore, how to reduce the occlusion of core visual elements by text layers during the automated generation of multilingual and multi-size materials is an urgent problem to be solved in this field. Summary of the Invention
[0004] To address the shortcomings of existing technologies, the present invention aims to provide a dynamic layout method for multilingual visual materials. By parsing multi-layer source files, calculating visual saliency and mapping it to the target canvas, and constraining text overflow to avoid obscuring the visual focus area, the method achieves adaptive layout for multiple platform specifications while ensuring aesthetically pleasing layout.
[0005] To achieve the above objectives, the present invention adopts the following technical solution: In a first aspect, the present invention provides a dynamic layout method for multilingual visual materials, comprising: The multi-layer file of the visual material in the source language is read through an image acquisition device or a page file parsing interface to generate a pixel matrix of the source language page. The original coordinate set of the text layer is extracted from the multi-layer file, and the physical size value of the canvas in the source language and the canvas specifications of multiple platforms to be adapted are read to generate a list of target canvas physical size values. Edge gradient calculation and color contrast calculation are performed on the pixel matrix of the source language layout to obtain a comprehensive visual saliency value matrix, and the set of coordinates of the visual focus area is defined. The font rendering engine measures the estimated value of the target language text rendering size. Based on the ratio of the target canvas physical size value list to the source language canvas physical size value, the canvas scaling factor is calculated. The original coordinate set of the text layer and the visual focus area coordinate set are mapped according to the canvas scaling factor to obtain the mapped text layer coordinate set and the mapped visual focus area coordinate set. The estimated value of the target language text rendering size is then compared with the mapped text layer coordinate set to obtain the text overflow amount. Based on the text overflow amount and the coordinate set of the mapped visual focus area, the constraint solution is performed to calculate the safe translation distance value of the text box, and the adjusted text box coordinate set and the adjusted font size scaling factor are generated in conjunction. Based on the adjusted text box coordinate set and the adjusted font size scaling factor, the layer compositing engine renders the target language visual material pixel matrix, and performs a conflict check on the target language visual material pixel matrix and the mapped visual focus area coordinate set.
[0006] Preferably, the generated source language layout pixel matrix includes: When the source language visual material is stored in the form of a raster product, the red, green and blue color channel values of each pixel are read by an image acquisition device in a row-by-row and column-by-column scanning manner. When the source language visual material is stored in the form of a layered editable file, the layers are rasterized and merged into a finished raster image according to the layer stacking order through the layout file parsing interface, and then the red, green and blue color channel values of each pixel are read. The read three-channel grayscale values are arranged according to the row and column positions of the pixels to generate the source language layout pixel matrix.
[0007] Preferably, the step of performing edge gradient calculation and color contrast calculation on the source language layout pixel matrix to obtain a comprehensive visual saliency value matrix includes: Gradient operator convolution is performed on the pixel matrix of the source language layout, and the brightness change is calculated pixel by pixel to obtain the image edge gradient value matrix; Perform color channel difference operation on the pixel matrix of the source language layout, calculate the color saturation value and the neighboring color contrast value for each pixel, and obtain the color saliency value matrix. The image edge gradient value matrix and the color saliency value matrix are weighted and superimposed to obtain the visual saliency comprehensive value matrix.
[0008] Preferably, the step of performing gradient operator convolution processing on the source language layout pixel matrix and calculating the brightness change pixel by pixel to obtain the image edge gradient value matrix includes: The red, green, and blue channel components of each pixel in the source language layout pixel matrix are weighted and summed according to the brightness conversion relationship to obtain the brightness matrix; The horizontal Sobel operator and the vertical Sobel operator are applied to the brightness matrix to perform convolution operations, respectively, to obtain the horizontal brightness change and the vertical brightness change of each pixel. For each pixel, the square root of the sum of the squares of its horizontal and vertical brightness changes is taken as the edge gradient value, thus obtaining the image edge gradient value matrix.
[0009] Preferably, the step of performing color channel difference calculation on the source language layout pixel matrix, and calculating the color saturation value and neighborhood color contrast value pixel by pixel to obtain the color saliency value matrix includes: Calculate the difference between the maximum and minimum values of the three-channel components of each pixel, and divide the difference by the maximum value to obtain the color saturation value of each pixel; Take a neighborhood window centered on each pixel, calculate the Euclidean distance between the three-channel color vector of the pixel and the three-channel color vectors of the other pixels in the neighborhood window, and take the average of the Euclidean distances as the neighborhood color contrast value. The color saliency value is obtained by weighting the normalized color saturation value and the normalized neighborhood color contrast value, thereby obtaining the color saliency value matrix.
[0010] Preferably, the step of comparing the estimated text rendering size of the target language with the mapped text layer coordinate set to obtain the text overflow includes: The estimated text rendering size of the target language is mapped according to the canvas scaling factor in the corresponding direction to obtain the mapped estimated text rendering size. The horizontal overflow is obtained by subtracting the width component of the estimated value of the rendered text size after mapping from the width value of the bounding box recorded in the coordinate set of the mapped text layer. The vertical overflow is obtained by subtracting the height component of the estimated text rendering size after mapping from the height value of the mapped bounding box. The text overflow is composed of the horizontal overflow and the vertical overflow.
[0011] Preferably, the step of calculating the safe translation distance of the text box by solving for constraints based on the text overflow amount and the set of coordinates of the mapped visual focus area includes: When the text overflow is greater than zero, calculate the shortest pixel distance between the text placeholder rectangle and the bounding rectangle of each connected component in the coordinate set of the mapped visual focus area. The shortest pixel distance value is compared with a preset safety interval value to determine whether spatial overlap occurs; If spatial overlap is determined to occur, the safe translation distance of the text box is calculated step by step along the normal direction pointing from the coordinate set of the mapped text layer to the outside of the coordinate set of the mapped visual focus area, until the shortest pixel distance between the boundary of the text box and the coordinate set of the mapped visual focus area is greater than or equal to the preset safe interval value.
[0012] Preferably, the stepwise calculation of the safe translation distance value of the text box includes: The direction from the geometric center of the focal point to the geometric center of the text is determined as the normal direction; The boundary coordinates of the text placeholder rectangle are successively offset along the normal direction with a preset moving step size, and the shortest pixel distance value and the cumulative offset are recalculated and recorded after each offset. When the shortest pixel distance value is greater than or equal to the preset safety interval value for the first time, the offset is terminated, and the corresponding cumulative offset is recorded as the safe distance value for the text box to be moved.
[0013] Preferably, the linked generation of the adjusted text box coordinate set and the adjusted font size scaling factor includes: If there is still a residual overflow beyond the target canvas boundary after the text box is moved along the safe distance value of the text box, then calculate the font size reduction factor and determine whether the corresponding scaled font size value is lower than the minimum recognizable font size threshold. If it is lower than the value, the text box can be expanded by shifting the safe distance value and triggering line wrapping within the canvas. The estimated value of the target language text rendering size after mapping is recalculated until the corresponding scaled font size value is not lower than the minimum recognizable font size threshold. The font size scaling factor is generated from the font size reduction factor, and the corresponding bounding box vertex coordinates are combined to generate the adjusted text box coordinate set.
[0014] Preferably, the step of driving the layer compositing engine to render the target language visual material pixel matrix based on the adjusted text box coordinate set and the adjusted font size scaling factor includes: Write the adjusted text box coordinate set and the adjusted font size scaling factor into the text layer parameters of the layer compositing engine; When rendering the background layer and the non-text layer, the background layer and the non-text layer are stretched and scaled in the horizontal and vertical directions respectively in a non-uniform manner according to the canvas scaling factor. The target language text is rendered within the area corresponding to the adjusted text box coordinate set according to the adjusted font size scaling factor, and the target language visual material pixel matrix is output.
[0015] Preferably, the conflict verification of the target language visual material pixel matrix and the mapped visual focus region coordinate set includes: The text layer region is determined from the pixel matrix of the visual material in the target language, and the set of pixels actually covered by the text pixels is read. Calculate the shortest pixel distance between the set of pixels and the bounding rectangles of each connected region in the set of coordinates of the mapped visual focus region; If the shortest pixel distance value is still less than the preset safety interval value, a manual review prompt signal is generated and the process is transferred to manual processing. If the shortest pixel distance value is greater than or equal to the preset safety interval value, then the target language visual material pixel matrix will be output as the final delivery file.
[0016] Secondly, the present invention provides a dynamic typesetting system for multilingual visual materials, comprising: The data acquisition and structuring module is used to read multi-layer files of visual materials in the source language through an image acquisition device, extract color channel values pixel by pixel, obtain the pixel matrix of the source language layout, and parse the original coordinate set of the text layer and the physical size value of the canvas. The visual focus recognition module is used to perform edge gradient calculation and color contrast calculation on the pixel matrix of the source language layout to obtain a comprehensive visual saliency value matrix and delineate the set of coordinates of the visual focus area. The text overflow calculation module is used to measure the estimated value of the target language text rendering size through the font rendering engine, and to obtain the text overflow by comparing it with the original coordinate set of the text layer in combination with the canvas scaling factor. The layout constraint solving module is used to solve constraints based on the text overflow and the set of coordinates of the visual focus area, calculate the safe translation distance of the text box, and generate the adjusted set of text box coordinates and the adjusted font size scaling factor. The rendering and conflict review module is used to drive the layer compositing engine to render the pixel matrix of the target language visual material based on the adjusted text box coordinate set and the adjusted font size scaling factor, and to perform conflict review.
[0017] Compared to existing technologies, the advantages of this invention are as follows: This invention directly parses the set of visual focus area coordinates by extracting edge gradient values and color saliency values from the pixel matrix of the source language layout. During canvas scaling, these coordinates are mapped to the target canvas coordinate system along with the text layer coordinates and the background layer using the same scaling factor, replacing the traditional static coordinate binding and eliminating spatial avoidance distortion between different coordinate systems. Using the text overflow amount synchronously mapped by the canvas scaling factor as the trigger condition, the two degrees of freedom of text box displacement and font size scaling are jointly constrained and solved. This allows multilingual character expansion, layout direction switching, and multi-size canvas changes to converge collaboratively under a unified spatial avoidance mechanism, fundamentally cutting off the path to the dual contradiction of fixed-position focus occlusion and forced font size reduction leading to illegibility. The loop mechanism that triggers line breaks within the canvas and remeasures the estimated text rendering size when scaling reaches the lower limit of legibility also simultaneously improves the semantic incoherence caused by mechanical truncation during language layout direction switching without requiring an independent sentence segmentation module. Ultimately, by using a pixel-level conflict review closed loop, residual occlusion is intercepted before delivery, enabling automated batch adaptation of visual materials across different languages, sizes, and platforms. This effectively reduces the defect rate and eliminates the reliance on manual adjustments, making it suitable for computer typesetting automation and multilingual graphic adaptation processing systems. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a flowchart of the dynamic layout method for multilingual visual materials in this invention; Figure 2 This is a schematic diagram of the original coordinate set of the text layer in an embodiment of the present invention; Figure 3 This is a schematic diagram of mirrored filling of boundary pixel values in an embodiment of the present invention; Figure 4 This is a schematic diagram of the visual focus region coordinate set in an embodiment of the present invention; Figure 5 This is a schematic diagram of proportional mapping in an embodiment of the present invention; Figure 6 This is a schematic diagram of text overflow in an embodiment of the present invention; Figure 7 This is a schematic diagram illustrating spatial overlap determination in an embodiment of the present invention; Figure 8This is a schematic diagram of the successive offset of the normal direction in an embodiment of the present invention; Figure 9 This is a schematic diagram of line wrapping within the canvas in an embodiment of the present invention; Figure 10 This is a functional block diagram of the dynamic layout system for multilingual visual materials in this invention. Detailed Implementation
[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0021] Example 1: Please see Figure 1 As shown, this embodiment provides a dynamic layout method for multilingual visual materials, including: This embodiment provides a dynamic layout method and system for multilingual visual materials, applicable to batch adaptation scenarios of visual materials such as game promotional images, event pages, official website pages, reservation pages, character posters, social media images, and related images across different languages, canvas sizes, and display platforms. The hardware platform relied upon in this embodiment includes an image acquisition device, a layout file parsing interface, a font rendering engine, a layer compositing engine, and a server running the layout scheduling program. The image acquisition device reads finished materials stored in raster form; the layout file parsing interface reads editable source files stored in layered vector form; the font rendering engine measures the geometric dimensions of the text according to character sets and font sizes; and the layer compositing engine combines text layers and background layers into a finished pixel matrix according to layer parameters. The above hardware and program together constitute a closed-loop processing chain from visual focus recognition and layout adjustment to conflict verification. The following detailed description follows steps S1 to S5.
[0022] S1: Read the multi-layer file of the source language visual material through the image acquisition device, extract the color channel values pixel by pixel, obtain the pixel matrix of the source language layout, and parse the original coordinate set of the text layer and the physical size value of the canvas.
[0023] The subsequent step S2 requires pixel-level color data as input to analyze the visual focus of the image's underlying layer. Step S3 requires the bounding box coordinates and font size values of the text layer as input to measure the geometric relationships of the text. Steps S3 and S4 also require calculating the scaling relationship under multi-size adaptation based on the physical dimensions of the source and target canvases. In the scenario of batch adaptation of multilingual visual materials, the source file contains two types of heterogeneous data: raster background and vector text. The dimensions of the source and target canvases also vary depending on the platform. If pixel data, layer coordinate data, and canvas size data are not collected and structured uniformly in the initial step, subsequent steps will lack a traceable and unified data benchmark, resulting in pixel-level analysis and coordinate-level adjustment being unable to coordinate within the same coordinate system. This step establishes a unified data input benchmark for the entire processing chain.
[0024] Further, step S1 includes: S11: Read the multi-layer file of the source language visual material through an image acquisition device or page layout file parsing interface, extract the red, green and blue three-channel gray values pixel by pixel, and generate the source language page layout pixel matrix.
[0025] The source files of multilingual visual materials exist in two storage formats: raster finished products and editable layered files. If only a single reading channel is supported, it cannot cover the two types of files that exist simultaneously in the design delivery. This step uses dual-channel reading to be compatible with both types of source files and converts them into a pixel matrix, a data structure that can be directly used by downstream pixel-level parsing.
[0026] Specifically, when the source language visual material is stored in the form of a raster product, the red, green and blue color channel values of each pixel are read by an image acquisition device in a row-by-row and column-by-column scanning manner. Each color channel value is an integer between 0 and 255.
[0027] When the source language visual materials are stored in the form of layered editable files, the layout file parsing interface first rasterizes and merges each layer into a finished raster image according to the layer stacking order, and then reads the red, green and blue color channel values of each pixel in a row-by-row and column-by-column scanning manner.
[0028] The read three-channel grayscale values are arranged according to the row and column positions of the pixels to generate the source language layout pixel matrix. The source language layout pixel matrix is a three-dimensional matrix with a size equal to the source canvas pixel height multiplied by the source canvas pixel width, and each matrix element is a triple containing three components: red, green, and blue.
[0029] S12: Extract the bounding box vertex coordinates, font size values, and layout direction markers of each text layer from the layer description information of the multi-layer file, and generate the original coordinate set of the text layers.
[0030] The source language layout pixel matrix generated in step S11 only records the color information of the finished image and has lost the editable geometric parameters of the text layer. If the text position is directly deduced based on the pixel matrix, the text bounding box cannot be accurately restored due to the overlap of text and background pixels. Therefore, this step directly extracts the text geometric parameters from the vector layer description information retained in the multi-layer file.
[0031] Specifically, locate all layers marked as text from the layer description information of the multi-layer file. For the currently traversed text layer, read the pixel coordinates of the top left and bottom right vertices of its bounding box. The two vertex coordinates together determine the width and height values of the bounding box of the currently traversed text layer.
[0032] For the currently traversed text layer, read its font size value, which represents the nominal height of a single character in pixels.
[0033] For the currently traversed text layer, read its layout direction mark, which is an enumeration value that can be horizontal or vertical, used to indicate the arrangement direction of characters in the currently traversed text layer.
[0034] After traversing all text layers in a multi-layer file, the bounding box vertex coordinates, font size, and layout direction markers of each text layer are organized into a set of original text layer coordinates. This set of original text layer coordinates is a key-value table with the text layer number as the key and records consisting of the top-left and bottom-right vertex coordinates of the bounding box, the font size, and the layout direction marker as values. See also Figure 2 This is a schematic diagram of the original coordinate set of the text layer provided in this embodiment.
[0035] like Figure 2 As shown in the diagram, a rectangular text layer is illustrated. Its top-left and bottom-right vertices are marked with dots and labeled "Vertex" and "Bottom-Right Vertex" with leaders, respectively. The top of the text layer is labeled with a double-headed arrow indicating the "Boundary Box Width Value," and the right side is labeled with a double-headed arrow indicating the "Boundary Box Height Value." Inside the text layer, multiple dashed squares with intersecting separators represent the space occupied by a single character. To the left of these squares, a vertical caliper indicates the "Font Size Value," representing the nominal height of a single character. Below the text layer, a bold line indicates the "Layout Direction Marker," signifying whether the characters within the layer are arranged horizontally or vertically. This diagram illustrates the process of extracting the boundary box vertex coordinates, font size values, and layout direction marks of each text layer from the layer description information of a multi-layer file. It visually presents a key-value table structure where the original coordinate set of the text layer uses the text layer number as the key and the aforementioned records as values, providing a unified geometric parameter benchmark for subsequent steps S3 (measuring the text's geometric relationship) and S32 (coordinate mapping).
[0036] S13: Read the physical size value of the source language canvas corresponding to the source language visual material, and read the canvas specifications of multiple platforms to be adapted, and generate a list of target canvas physical size values.
[0037] The subsequent step S3 requires calculating the canvas scaling factor using the ratio of the source canvas to the target canvas size as input. If only the source canvas size is collected without simultaneously collecting all the target canvas sizes to be adapted, the collection process needs to be retried for each platform to be adapted. Multi-size batch adaptation will degenerate into serial processing of each size, and cannot be carried out in parallel under a unified numerical benchmark. Therefore, this step collects the source canvas and all target canvas sizes at once.
[0038] Specifically, the canvas description information of the source language visual material is read to obtain the physical size value of the source language canvas. The physical size value of the source language canvas includes two components: the pixel width of the source canvas and the pixel height of the source canvas.
[0039] The system reads multiple platform canvas specifications to be adapted from the platform specification configuration interface. For the currently traversed platform canvas specifications, it reads the canvas pixel width and canvas pixel height to form a target canvas physical size value. The platform canvas specifications are provided by the platform specification configuration table of the layout scheduler. The platform specification configuration table uses the platform identifier as the key and the canvas pixel width and canvas pixel height as the values. Its initial values are obtained from the layout size calibration published by each deployment platform. When a new deployment platform not covered by the platform specification configuration table is accessed, the canvas pixel width and pixel height of that platform are supplemented in the same way. After each batch of adaptation tasks is completed, the system checks the consistency between the actual rendering size and the configured size. If they are inconsistent, the corresponding values in the platform specification configuration table are updated with the actual rendering size.
[0040] After iterating through all the platform canvas specifications to be adapted, the physical size values of each target canvas are arranged according to the platform identifier to generate a list of target canvas physical size values. The list of target canvas physical size values is a key-value table with the platform identifier as the key and the canvas pixel width and canvas pixel height as the values.
[0041] The synchronously collected source language canvas physical size values and target canvas physical size value lists provide a unified numerical benchmark for subsequent multi-size batch adaptation. In multi-platform deployment scenarios, the differences in canvas aspect ratios between landscape web page advertisements, portrait appointment pages, and mobile social media images stem from the physical constraints of the placement on each platform. If the dimensions are collected and scaling relationships are calculated separately for each platform, the scaling coefficients of the same source material at different target sizes will be scattered across different calculation contexts, making horizontal comparison and batch scheduling impossible within the same numerical domain. By organizing all target canvas physical size values into a target canvas physical size value list at once, step S3 can calculate the canvas scaling coefficients in parallel for all target sizes during the same traversal process, ensuring that the calculation benchmark for multi-size adaptation is unified and fixed from the initial stage.
[0042] S2: Perform edge gradient calculation and color contrast calculation on the pixel matrix of the source language layout to obtain the comprehensive value matrix of visual saliency and delineate the set of coordinates of the visual focus area.
[0043] Existing layout systems rely solely on static two-dimensional absolute coordinates or simple relative percentages to bind text boxes and background layers, lacking a mechanism for analyzing the underlying visual content of images. Consequently, they cannot perceive the true positions of core visual anchors such as character faces and product subjects during text replacement and canvas reconstruction. This step addresses this issue by starting with the physical characteristics of the pixel matrix of the source language layout. It directly extracts semantic focus areas composed of high-frequency textures and high color contrast from the pixel-level data, providing unobstructed areas based on image content for spatial avoidance in subsequent step S4. Visual focus areas refer to pixel areas in an image that carry core visual information and should not be covered by text layers during layout adjustments. In game character poster scenarios, these typically correspond to areas such as character faces and weapon highlights, while in product material scenarios, they typically correspond to the outline of the product subject.
[0044] It should be noted that the set of visual focus area coordinates output in this step is established in the source canvas coordinate system corresponding to the pixel matrix of the source language layout. Its corresponding coordinates in the target canvas coordinate system are uniformly mapped by step S32 and used by steps S4 and S5. See step S32 for the specific mapping method.
[0045] Further, step S2 includes: S21: Perform gradient operator convolution on the pixel matrix of the source language layout, calculate the brightness change pixel by pixel, and obtain the gradient value matrix of the image edge.
[0046] Semantic focal points such as character faces, weapon highlights, and product outlines are usually high-frequency areas with drastic brightness changes in images. This physical characteristic determines that extracting brightness changes using gradient operators can effectively label the spatial distribution of semantic focal points. Therefore, this step uses gradient convolution as the first extraction method for focal features.
[0047] Specifically, the red, green, and blue channel components of each pixel in the source language layout pixel matrix are first weighted and summed according to the brightness conversion relationship to obtain the brightness matrix. The brightness conversion relationship is that the brightness value is equal to the sum of the red component multiplied by 0.299, the green component multiplied by 0.587, and the blue component multiplied by 0.114.
[0048] The horizontal Sobel operator and the vertical Sobel operator are applied to the brightness matrix to perform convolution operations, respectively, to obtain the horizontal brightness change and the vertical brightness change of each pixel. The horizontal Sobel operator and the vertical Sobel operator are both fixed convolution kernels with 3 rows and 3 columns.
[0049] For each pixel, the square root of the sum of the squares of its horizontal and vertical brightness changes is taken as the edge gradient value of that pixel. The edge gradient values of all pixels are arranged in rows and columns to obtain the image edge gradient value matrix.
[0050] For example, suppose that after a pixel is convolved with the Sobel operator, the horizontal brightness change is 30 and the vertical brightness change is 40, then the edge gradient value of this pixel is... .
[0051] S22: Perform color channel difference operation on the pixel matrix of the source language layout, calculate the color saturation value and the neighboring color contrast value for each pixel, and obtain the color saliency value matrix.
[0052] The image edge gradient value matrix output in step S21 only reflects the changes in the brightness dimension. For areas with similar brightness but strong color contrast, such as the boundary of highly saturated color blocks between the character's clothing and the background, relying solely on the brightness gradient will result in missed detections. Therefore, this step supplements the extraction of the saliency of the color dimension to cover highly saturated semantic regions that the edge gradient cannot capture.
[0053] Specifically, for each pixel in the pixel matrix of the source language layout, the color saturation value is first calculated according to the saturation calculation relationship. The saturation calculation relationship is that the color saturation value is equal to the difference between the maximum and minimum values of the red, green and blue components of the pixel, and then divided by the maximum value. When the maximum value is 0, the color saturation value is 0.
[0054] For each pixel, a 5x5 neighborhood window is taken centered on that pixel. The Euclidean distance between the three-channel color vector of that pixel and the three-channel color vectors of all other pixels within the neighborhood window is calculated. The average of all Euclidean distances is taken as the neighborhood color contrast value of that pixel. For pixels located at the edge of the source language layout pixel matrix whose 5x5 neighborhood window extends beyond the matrix boundary, the neighborhood window is filled by mirroring the boundary pixel values before calculating the neighborhood color contrast value. See also Figure 3 This is a schematic diagram of the mirrored filling of boundary pixel values provided in this embodiment. For example... Figure 3 As shown in the diagram, the solid-line border and internal grid of the source language layout pixel matrix are illustrated. A central pixel is marked with a diagonal shading in the upper left corner, and a thick dashed frame around the central pixel is labeled "Neighborhood Window," representing a 5x5 neighborhood window centered on that pixel. The matrix boundary is marked with a thick solid line labeled "Matrix Boundary," indicating the physical edge of the source language layout pixel matrix. Inside the matrix, several solid and corresponding hollow circles are marked horizontally and vertically, respectively, connected by an arc labeled "Boundary Pixel Value Mirror Fill," indicating that the color values of the pixels inside the matrix are symmetrically flipped and filled to the neighborhood window positions outside the matrix boundary. This diagram illustrates the process of using boundary pixel value mirror fill to complete the neighborhood window for pixels located at the edge of the source language layout pixel matrix whose 5x5 neighborhood window extends beyond the matrix boundary. This ensures that pixels at the matrix edge still have a complete 5x5 neighborhood window, thus guaranteeing that the calculation of neighborhood color contrast values at the matrix edge pixels is not deviated due to the missing neighborhood window.
[0055] For each pixel, its color saturation value is normalized to the range of 0 to 1, and then added to the neighboring color contrast value after being normalized to the range of 0 to 1 with equal weight to obtain the color saliency value of that pixel. The color saliency values of all pixels are arranged according to their row and column positions to obtain the color saliency value matrix.
[0056] For example, assuming that the red, green, and blue components of a pixel are 200, 40, and 40 respectively, then the color saturation value is... If the normalized neighborhood color contrast value of a pixel is 0.6, then the color saliency value is... .
[0057] S23: Weight the image edge gradient value matrix and the color saliency value matrix to obtain the visual saliency comprehensive value matrix; merge the connected components of the pixel coordinates in the visual saliency comprehensive value matrix that are greater than the preset focus threshold to generate the set of visual focus region coordinates.
[0058] The image edge gradient value matrix output in step S21 and the color saliency value matrix output in step S22 describe the saliency of the image from the brightness dimension and the color dimension, respectively. They are complementary in physical meaning. After fusing the two, the connected region is defined according to the threshold, and a complete visual focus region containing both high-frequency texture focus and high-saturation color focus can be obtained for spatial avoidance constraint in step S4.
[0059] Specifically, the image edge gradient value matrix is first normalized to the interval between 0 and 1 to obtain the normalized edge gradient value matrix; the color saliency value matrix is then normalized to the interval between 0 and 1 to obtain the normalized color saliency value matrix. Both normalizations are performed using linear normalization, which means subtracting the minimum value from each element in the matrix and then dividing by the difference between the maximum and minimum values.
[0060] The normalized edge gradient value matrix and the normalized color saliency value matrix are weighted and superimposed pixel-by-pixel according to the formula for calculating the comprehensive visual saliency value, resulting in the comprehensive visual saliency value matrix. The formula for calculating the comprehensive visual saliency value is as follows: in, For pixels The overall visual saliency value, For pixels in the normalized edge gradient value matrix elements, For pixels in the normalized color saliency value matrix elements, For edge gradient weights, For color saliency weights, both satisfy... The method for determining the edge gradient weight and color saliency weight is as follows: The proportion of elements in the normalized edge gradient value matrix and the normalized color saliency value matrix that are greater than their respective means is calculated. The relative proportions of these two ratios are then used as the two weights, giving greater weight to dimensions with higher frequency information. For example... It can be set to 0.6. It can be set to 0.4. The design principle of the visual saliency comprehensive value calculation expression is as follows: the normalized edge gradient value term reflects the saliency of the image brightness change dimension, and the normalized color saliency value term reflects the saliency of the image color contrast dimension. The two terms are combined by weighted summation rather than multiplication because areas such as the character's face, which have both high brightness gradient and high color saturation, should receive the cumulative enhancement of the saliency of both dimensions. However, areas such as weapon highlights, which only have high brightness gradient and low color saturation, should still enter the focus based on the brightness dimension alone. If multiplication is used, the high saliency of the brightness dimension will be erased when the color saliency is low. The overall design goal is to ensure that pixels with high saliency in any dimension can obtain a high visual saliency comprehensive value, so as not to miss any type of semantic focus.
[0061] Pixels in the visual saliency composite value matrix whose visual saliency composite value is greater than a preset focus threshold are marked as focus pixels. The preset focus threshold is determined by calculating the mean and standard deviation of all elements in the visual saliency composite value matrix, and taking the mean plus one standard deviation as the preset focus threshold. For example, when the normalized mean of the visual saliency composite value is 0.45 and the standard deviation is 0.15, the preset focus threshold is 0.6. If the preset focus threshold calculated by the above method is greater than 1, then the preset focus threshold is taken as the median between the maximum and second-highest values in the normalized visual saliency composite value matrix to ensure that the set of visual focus region coordinates is not empty.
[0062] For all focal pixels, connected component merging is performed. The determination rule for connected component merging is as follows: if two focal pixels are adjacent in their four neighboring regions (top, bottom, left, and right), then the two focal pixels are determined to belong to the same connected component. All focal pixels that can be reached step by step through the adjacency relationship are grouped into the same connected component. For each connected component, the coordinates of the top left vertex and the bottom right vertex of its circumscribed rectangle are taken to generate a set of visual focal area coordinates. The set of visual focal area coordinates is a key-value table with the connected component number as the key and the coordinates of the top left vertex and the bottom right vertex of the circumscribed rectangle as the values. Its coordinate reference is the source canvas coordinate system.
[0063] See Figure 4 This is a schematic diagram of the set of coordinates of the visual focus area provided in this embodiment. For example... Figure 4As shown in the diagram, multiple dark squares are pieced together in an irregular connected shape, labeled "focal pixels," representing pixels whose visual saliency composite value is greater than a preset focal threshold. These focal pixels are collectively surrounded by an orthogonal rectangle, labeled "circumscribed rectangle." The top left corner of the rectangle is marked with a crosshair for "top left vertex coordinates," and the bottom right corner is marked with a crosshair for "bottom right vertex coordinates." Two hollow circles are also used to label "connected components," indicating that focal pixels are merged into the same connected component through their four adjacent neighbors (top, bottom, left, and right). This diagram illustrates the process of merging connected components for focal pixels in the visual saliency composite value matrix that are greater than the preset focal threshold, and taking the coordinates of the top left and bottom right vertices of the circumscribed rectangle for each connected component. It visually presents a key-value table structure where the set of visual focal region coordinates uses the connected component number as the key and the coordinates of the top left and bottom right vertices of the circumscribed rectangle as the values.
[0064] The edge gradient extraction in step S21 and the color saliency extraction in step S22 constitute two complementary focal feature extraction mechanisms. These two mechanisms target different types of visual focal points and operate on different physical dimensions of the image. Step S21 targets high-frequency focal points characterized by drastic brightness changes, such as facial contours and weapon highlights. Step S22 targets focal points characterized by strong color contrast, such as highly saturated clothing color blocks and the main color of the product. If only step S21 is executed without step S22, the boundary of the product subject, which has a similar brightness to the background but a strong color contrast, will not be able to enter the visual focal area coordinate set due to a low brightness gradient. This will cause step S4 to ignore this area during avoidance, and the horizontally extending target language text will still cover the product subject. If only step S22 is executed without step S21, the weapon highlight details located in the low-saturation highlight area will be missed due to low color saliency, causing these details to be occluded after text replacement. The two mechanisms are complementary in terms of physical dimensions. After weighted superposition, the saliency distribution of the merged connected domains simultaneously covers the focus of brightness change and the focus of color contrast. This ensures that the generated set of visual focus area coordinates completely marks the three types of core visual anchor points: character face, weapon highlights, and product body. This completeness is a prerequisite for the accuracy of the spatial avoidance constraint in step S4. The absence of either mechanism will cause the visual focus area coordinate set to have missing focus markings, which will then lead to the text occluding the core anchor points downstream.
[0065] S3: Measure the pixel width of the target language text characters through the font rendering engine, calculate the estimated value of the target language text rendering size by combining the canvas scaling factor, and obtain the text overflow amount by comparing it with the original coordinate set of the text layer.
[0066] In multilingual adaptation scenarios, after the source language text is replaced with the target language text, both the total number of characters and the width of each character may change. Simultaneously, the canvas size changes from the source canvas to the target canvas. These two types of variables cumulatively affect the actual space occupied by the text. This step incorporates the character geometry measurement of the target language text and canvas scaling into a unified calculation, quantifying the degree of overflow of the target language text relative to the mapped bounding box, providing a trigger value for step S4 to determine whether to trigger layout adjustments. The target language text is provided by the translation text interface of the layout scheduler and refers to the character sequence of the target platform's target language after the source language text has been translated.
[0067] Further, step S3 includes: S31: Call the font rendering engine, measure the estimated size of the target language text rendering based on the target language text character set and preset font size value; determine whether the target language typesetting direction is horizontal or vertical based on the typesetting direction mark.
[0068] The difference in nominal width of characters in different languages at the same font size comes from the glyph structure itself. For example, the average character width of Cyrillic and Latin letters is greater than the width corresponding to the equal width characteristic of Chinese characters. This physical characteristic of the glyphs determines that the text width must be measured in reality rather than simply estimated by the number of characters. Therefore, this step calls the font rendering engine to measure the target language text as a whole.
[0069] Specifically, the target language text is input into the font rendering engine as a complete string sequence. Its text shaping interface or bounding box measurement interface is called, using a preset font size as the rendering font size. The overall bounding box width of the string after kerning and ligature processing at that font size is directly obtained and used as the pixel length of the target language text at the preset font size value. The preset font size value is taken from the font size value of the currently processed text layer in step S12. For target languages with ligatures and combination deformation characteristics (such as Arabic, Devanagari, etc.), the font rendering engine includes the ligature units formed by combining adjacent characters into the bounding box measurement according to the language's typography rules. For languages without such characteristics, the bounding box measurement result is equivalent to the character-by-character width accumulation, without the need for additional processing path differentiation.
[0070] Based on the text layer layout direction marker, when the layout direction marker is horizontal, the width component of the target language text rendering size estimate is obtained by using the text content pixel length as the width component and the font size value as the height component. When the layout direction marker is vertical, the height component of the text content pixel length and the font size value as the width component are obtained. The target language text rendering size estimate is a tuple containing the width component and the height component. Its numerical basis is the size corresponding to the preset font size value under the source canvas scale. It has not yet been scaled and mapped to the target canvas. The mapping method is shown in step S33.
[0071] Based on the layout direction mark of the currently processed text layer in step S12, it is determined whether the target language layout direction is horizontal or vertical. When the layout direction required by the target platform is inconsistent with the source layout direction mark, the layout direction required by the target platform is used to cover the layout direction mark. The layout direction required by the target platform is provided by the platform specification configuration table.
[0072] For example, assuming the target language text is measured as a whole by the font rendering engine and the text content pixel length is 480 pixels, the preset font size is 24 pixels, and the layout direction is marked as horizontal, then the width component of the estimated rendering size of the target language text is 480 pixels and the height component is 24 pixels.
[0073] S32: Calculate the canvas scaling factor based on the ratio of the target canvas physical size value to the source language canvas physical size value, and map the original coordinate set of the text layer proportionally according to the canvas scaling factor to obtain the mapped text layer coordinate set.
[0074] The original coordinate set of the text layer output in step S12 is established relative to the source language canvas. If it is directly applied to the target canvas, the coordinate values will lose their spatial correspondence due to the change in canvas size. Therefore, this step first calculates the canvas scaling factor and then maps the original coordinate set of the text layer to the target canvas coordinate system so that the coordinates of the text box and the focus coordinates under the subsequent target canvas are in the same coordinate system.
[0075] Specifically, the target canvas physical size value corresponding to the current processing platform and the source language canvas physical size value output in the target canvas physical size value list output in step S13 are read. The ratio of the target canvas pixel width to the source canvas pixel width is calculated as the horizontal scaling factor, and the ratio of the target canvas pixel height to the source canvas pixel height is calculated as the vertical scaling factor. The horizontal scaling factor and the vertical scaling factor together constitute the canvas scaling factor.
[0076] For the currently traversed text layer in the original coordinate set of the text layer, multiply the horizontal coordinates of the top-left and bottom-right vertices of its bounding box by a horizontal scaling factor, and multiply the vertical coordinates of the top-left and bottom-right vertices of the bounding box by a vertical scaling factor to obtain the mapped bounding box vertex coordinates. Calculate the mapped bounding box width and height values from the mapped bounding box vertex coordinates.
[0077] After traversing all text layers in the original coordinate set of text layers, the vertex coordinates, width value, and height value of the mapped bounding box of each text layer are organized into a set of mapped text layer coordinates. The set of mapped text layer coordinates is a key-value table with the text layer number as the key and the vertex coordinates, width value, and height value of the mapped bounding box as the values.
[0078] Simultaneously, the coordinates of the top-left and bottom-right vertices of the bounding rectangles of each connected component in the visual focus area coordinate set output in step S23 are synchronously and proportionally mapped according to the horizontal and vertical scaling factors calculated in this step, resulting in a mapped visual focus area coordinate set. This mapped visual focus area coordinate set and the mapped text layer coordinate set are in the same target canvas coordinate system, and are used uniformly in steps S4 and S5. The mapped visual focus area coordinate set is a key-value table with the connected component number as the key and the coordinates of the top-left and bottom-right vertices of the mapped bounding rectangle as the values. (See also...) Figure 5 This is a schematic diagram of the proportional mapping provided in this embodiment. For example... Figure 5 As shown in the diagram, the left side uses a solid rectangle to represent the "source language canvas," with a small rectangle in the upper left corner representing the source text layer and another small rectangle in the lower right corner representing the source visual focus area. The right side uses a dashed rectangle to represent the "target canvas," with enlarged rectangles drawn at corresponding positions inside, labeled with "mapped text layer coordinates" and "mapped visual focus area coordinates." The left and right sides are connected by a dashed arrow, labeled with "horizontal scaling factor" and "vertical scaling factor." This diagram illustrates the process of calculating the canvas scaling factor based on the ratio of the target canvas's physical size to the source language canvas's physical size, and synchronously mapping the original coordinate set of the text layer and the visual focus area coordinate set using the same set of horizontal and vertical scaling factors. This demonstrates that the mapped text layer coordinate set and the mapped visual focus area coordinate set are under the same target canvas coordinate system, providing a unified benchmark for direct comparison between the text box coordinates and the focus coordinates in the target canvas, thus providing a basis for the spatial avoidance determination in step S4.
[0079] The background layer and other non-text layers are stretched and scaled non-proportionally using the same horizontal and vertical scaling factors as the text layer coordinates and the visual focus area coordinates to fit the target canvas. The specific stretching and scaling method is shown in step S51. Since the background layer and the visual focus area coordinates are mapped using the same set of scaling factors, the relative positions of the background content pixels and the connected components of the visual focus area remain consistent before and after mapping. Therefore, the set of visual focus area coordinates after mapping can directly reflect the actual display position of the focus content in the target canvas without additional cropping or white space offset correction.
[0080] For example, assuming the source canvas has a pixel width of 1080 and the target canvas has a pixel width of 1920, the horizontal scaling factor is: If the source canvas height is 1920 pixels and the target canvas height is 1080 pixels, then the vertical scaling factor is... If the coordinates of the top-left vertex of a text layer's bounding box are (600, 300), then the coordinates of the top-left vertex after mapping are... If the coordinates of the top-left vertex of the bounding rectangle of a certain visual focus region are (500, 800), then the coordinates of the top-left vertex after mapping using the same set of scaling factors are... .
[0081] S33: Perform a difference calculation between the estimated value of the target language text rendering size and the bounding box width and height values recorded in the coordinate set of the mapped text layer to obtain the text overflow amount; when the text overflow amount is greater than zero, it is marked as overflow state.
[0082] The subsequent step S4 requires the specific number of pixels the text exceeds the mapped bounding box as input to determine the trigger and magnitude of the layout adjustment. The estimated target language text rendering size output in step S31 is a value measured at the source canvas scale, while the mapped bounding box size output in step S32 is a value at the target canvas scale. If these two are not unified to the same scale and directly subtracted, a dimensional misalignment will occur because the canvas scaling factor is not taken into account. This step first maps the estimated target language text rendering size to the target canvas scale according to the canvas scaling factor, and then subtracts it from the mapped bounding box size to generate a unified representation of the text overflow amount, which characterizes the combined effect of text expansion and canvas scaling.
[0083] Specifically, for the currently traversed text layer, the estimated text rendering size of the target language output in step S31 is first mapped according to its layout direction mark, using the canvas scaling factor of the corresponding direction: when the layout direction mark is horizontal, the width component (pixel length of text content) is multiplied by the horizontal scaling factor, and the height component (font size value) is multiplied by the vertical scaling factor; when the layout direction mark is vertical, the height component (pixel length of text content) is multiplied by the vertical scaling factor, and the width component (font size value) is multiplied by the horizontal scaling factor, to obtain the estimated text rendering size after mapping. The estimated text rendering size after mapping and the coordinate set of the mapped text layer are in the same target canvas coordinate system and the same numerical scale.
[0084] The horizontal overflow is obtained by subtracting the width component of the estimated value of the rendered text size after mapping from the width value of the bounding box of the corresponding text layer in the coordinate set of the mapped text layer output in step S32; the vertical overflow is obtained by subtracting the height component of the estimated value of the rendered text size after mapping from the height value of the bounding box after mapping. The horizontal overflow and the vertical overflow together constitute the text overflow.
[0085] When the horizontal overflow is greater than zero or the vertical overflow is greater than zero, the currently traversed text layer is marked as overflowing; when both the horizontal and vertical overflow are less than or equal to zero, the currently traversed text layer is marked as non-overflowing.
[0086] Write the text overflow amount and overflow status flag of each text layer into a text overflow record table with the text layer number as the key. After traversing all text layers, output the text overflow record table.
[0087] See Figure 6 This is a diagram illustrating text overflow provided in this embodiment. For example... Figure 6As shown in the figure, the "target canvas boundary" is marked with a gray dashed rectangle as a background reference. Inside, the bounding box of the mapped text layer is marked with a thick solid rectangle, and above it is marked "Target Language Text (Unoverflowing Part)" and explained as "[Text Layer Bounding Box Range]". The range defined by the estimated value of the mapped text rendering size is marked with a thin dashed rectangle and labeled as "[Estimated Text Rendering Size Range]". This dashed rectangle range is larger than the bounding box range of the mapped text layer represented by the thick solid rectangle in both the horizontal and vertical directions. The difference between the two rectangle ranges is represented by an L-shaped area filled with diagonal lines and marked as "Overflowing Part", which indicates the spatial range of the target language text rendering size exceeding the mapped bounding box. The diagram uses double-headed dimension lines labeled "Horizontal Overflow" and "Vertical Overflow" at the top and left, respectively, to represent the difference between the estimated value of the mapped text rendering size and the width and height values of the mapped bounding box. Simultaneously, double-headed dimension lines are used to label "Mapped Bounding Box Width," "Mapped Bounding Box Height," "Estimated Mapped Text Rendering Width," and "Estimated Mapped Text Rendering Height," representing the four basic dimensional values involved in the difference calculation. This diagram illustrates the process of calculating the text overflow by subtracting the estimated value of the target language text rendering size from the bounding box width and height values recorded in the mapped text layer coordinate set. It visually demonstrates that the horizontal and vertical overflows are constituted by the portion of the estimated mapped text rendering size exceeding the mapped bounding box size in their respective directions. This provides a clear geometric reference for step S4 to determine whether to trigger layout adjustments based on the text overflow and to determine the adjustment range.
[0088] For example, using the example values from steps S31 and S32: the estimated width component of the target language text rendering size is 480 pixels, the height component is 24 pixels, the layout direction is horizontal, the horizontal scaling factor is 1.78, and the vertical scaling factor is 0.5625. Therefore, the width component of the mapped estimated text rendering size is... Pixel and height components are Pixels. If the width of the bounding box after mapping is 320 pixels, then the horizontal overflow is... A pixel value greater than zero indicates that the currently traversed text layer is marked as overflowing.
[0089] By simultaneously incorporating the canvas scaling factor and the estimated target language text rendering size into the text overflow calculation, multi-size canvas adaptation and multi-language character expansion are treated uniformly under the same numerical dimension. In the Russian landscape webpage ad image adaptation scenario, the increase in text content pixel length due to target language character length expansion and the contraction or expansion of the bounding box width due to changes in canvas aspect ratio are two independent sources of text overflow. This step first maps the estimated text rendering size to the target canvas scale, and then subtracts it from the mapped bounding box size, merging the effects of the two sources into the text overflow amount under the same pixel dimension and coordinate scale. This avoids the dimensional misalignment caused by directly subtracting the text size under the source canvas scale from the bounding box size under the target canvas scale, ensuring that the superposition effect of text expansion and canvas scaling is completely and correctly quantified, providing a triggering basis consistent with the actual overflow for step S4.
[0090] S4: Solve the constraints based on the text overflow amount and the coordinate set of the mapped visual focus area, calculate the safe translation distance value of the text box, and generate the adjusted text box coordinate set and the adjusted font size scaling factor in conjunction.
[0091] Existing typesetting systems typically handle text overflow by forcibly reducing the font size while fixing the text box position. This approach results in font sizes below the user's discernible threshold on small materials. Conversely, allowing text to extend unchecked to maintain the font size leads to long, horizontal sentences obscuring visual focal points such as character faces or weapon highlights. This creates a dual contradiction: fixed-position occlusion and forced font size reduction resulting in illegible text. This step addresses this contradiction by using the text box displacement and font size scaling factor as joint variables for constraint solving. While satisfying spatial avoidance conditions, it ensures the font size does not fall below the discernible threshold, allowing typesetting adjustments to converge synergistically across both degrees of freedom. The minimum discernible font size threshold refers to the minimum font size value required for text to remain legible to the user on the display platform corresponding to the target canvas.
[0092] Further, step S4 includes: S41: When the text overflow is greater than zero, calculate the shortest pixel distance between the mapped text layer coordinate set and the mapped visual focus area coordinate set, compare the shortest pixel distance with the preset safety interval value, and determine whether the text box and the mapped visual focus area coordinate set overlap spatially.
[0093] The text overflow amount output in step S33 only indicates that the text exceeds the mapped bounding box, but does not indicate whether the overflowing part falls into the visual focus area. If the spatial relationship between the text box and the visual focus area is not determined first and the adjustment is made directly, it will be impossible to distinguish between overflow that needs to avoid the focus and overflow that only needs to be expanded in the blank area. Therefore, this step first calculates the shortest pixel distance between the two to determine whether spatial overlap occurs. Since the coordinate set of the mapped visual focus area has been uniformly mapped to the same target canvas coordinate system as the coordinate set of the mapped text layer in step S32, the distance calculation in this step is performed under the same coordinate reference and has physical meaning.
[0094] Specifically, the text layers marked as overflowing in the text overflow record table output in step S33 are read. For the currently traversed overflowing text layers, the text placeholder rectangle occupied by the extended text is determined based on the vertex coordinates of the mapped bounding box and the estimated value of the mapped text rendering size.
[0095] Calculate the shortest pixel distance between the text placeholder rectangle and the bounding rectangle of each connected component in the set of coordinates of the mapped visual focus area output in step S32. The method for calculating the shortest pixel distance is as follows: if there is an overlapping area between the text placeholder rectangle and the bounding rectangle, the shortest pixel distance is 0; if there is no overlap, the minimum Euclidean distance between any point on the boundary of the text placeholder rectangle and any point on the boundary of the bounding rectangle is taken.
[0096] The shortest pixel distance value is compared with a preset safety interval value. The preset safety interval value is determined by multiplying the diagonal pixel length of the target canvas by a preset ratio coefficient. The preset ratio coefficient is determined based on the empirical ratio of the minimum spacing required between the text and the focus to avoid visual crowding to the canvas size. For example, the preset ratio coefficient can be set to 0.03. When the diagonal pixel length of the target canvas is 2200 pixels, the preset safety interval value is 66 pixels. When the shortest pixel distance value is less than the preset safety interval value, it is determined that the text box of the currently traversed overflow state text layer spatially overlaps with the coordinate set of the mapped visual focus area.
[0097] See Figure 7 This is a schematic diagram of spatial overlap determination provided in this embodiment. For example... Figure 7As shown in the diagram, the "circumscribed rectangle" is labeled with a solid line, and the "text placeholder rectangle" is labeled with a dashed line. There is a partial overlap between the two rectangles, which is densely filled with diagonal lines and labeled "overlapping area." Below the diagram, two levers are labeled "preset safety interval value" and "shortest pixel distance value," respectively. The preset safety interval lever is a complete long line segment, while the shortest pixel distance lever is a shorter line segment, with the difference between the two represented by a dashed extension. This diagram corresponds to the calculation of the shortest pixel distance value between the mapped text layer coordinate set and the mapped visual focus area coordinate set, and compares the shortest pixel distance value with the preset safety interval value to determine whether the text box and the mapped visual focus area coordinate set spatially overlap. It visually presents the situation where the shortest pixel distance value is zero and significantly less than the preset safety interval value when there is an overlap between the text placeholder rectangle and the circumscribed rectangle, providing a basis for triggering the normal direction offset in step S42.
[0098] S42: If spatial overlap is determined to occur, calculate the safe translation distance value of the text box step by step along the normal direction pointing from the coordinate set of the mapped text layer to the outside of the coordinate set of the mapped visual focus area, until the shortest pixel distance between the boundary of the text box and the coordinate set of the mapped visual focus area is greater than or equal to the preset safe interval value.
[0099] When step S41 determines that the text box and the coordinate set of the visual focus area overlap spatially, it is necessary to move the text box away from the focus area first without changing the font size. In this step, the text box is moved iteratively along the normal direction away from the focus until the safety interval condition is met, so as to achieve spatial avoidance of the focus while keeping the text recognizable.
[0100] Further, step S42 includes: S421: The text box boundary coordinates are successively offset along the normal direction with a preset movement step size, and the shortest pixel distance value is recalculated after each offset.
[0101] Approaching the safety interval iteratively avoids large-scale translations at once that could cause the text box to extend beyond the available blank area of the canvas. Each sub-step approaches the text box with a fixed step size, stopping the movement just as the text box is no longer in focus, thus preserving the original layout to the greatest extent possible.
[0102] Specifically, the normal direction is first determined. The normal direction is the opposite direction from the geometric center of the text placeholder rectangle to the geometric center of the outer rectangle of the connected domain of the mapped visual focus area that overlaps with it, that is, the direction from the geometric center of the focus to the geometric center of the text.
[0103] The boundary coordinates of the text placeholder rectangle are shifted successively along the normal direction with a preset moving step size. The preset moving step size is determined by taking one-quarter of the font size value of the currently traversed overflow state text layer. For example, when the font size value is 24 pixels, the preset moving step size is 6 pixels.
[0104] After each offset, the shortest pixel distance between the offset text placeholder rectangle and the bounding rectangle of the connected domain of the mapped visual focus area is recalculated according to the shortest pixel distance calculation method described in step S41, and the current cumulative offset is recorded.
[0105] See Figure 8 This is a schematic diagram of the successive offset of the normal direction provided in this embodiment. For example... Figure 8 As shown, the lower left corner of the image is marked with a solid rectangle labeled "circumscribed rectangle," its geometric center marked with a solid dot, and a long straight line running through the image is labeled "normal direction," indicating the direction from the geometric center of the focal point to the opposite direction of the text's geometric center. Multiple dashed rectangles are arranged sequentially from the lower left to the upper right, representing the intermediate positions of the text placeholder rectangle during the successive offset process, with the final position marked with a solid rectangle labeled "text placeholder rectangle." The image also indicates the "preset movement step size," represented by a double-headed arrow at an angle, indicating the fixed movement distance between two adjacent offsets. A double-headed arrow running through multiple rectangles is used to indicate the "cumulative offset," representing the total offset from the initial overlapping position to the final position. This diagram illustrates the process of successively offsetting the text box boundary coordinates along the normal direction with a preset movement step size, recalculating the shortest pixel distance value after each offset, and recording the cumulative offset as the safe translation distance of the text box when the shortest pixel distance value first exceeds or equals the preset safety interval value. This demonstrates the effect of iteratively approaching the safety interval and preserving the original layout to the maximum extent.
[0106] S422: When the shortest pixel distance value is greater than or equal to the preset safety interval value for the first time, the cumulative offset is recorded as the safe distance value for the text box to be moved.
[0107] The cumulative offset sequence generated by the successive offset process in sub-step S421 needs a clear termination criterion to determine the final translation amount. This sub-step terminates when the shortest pixel distance value first reaches the preset safety interval value. The output text box can be translated by a safety distance value for step S43 to further determine whether the font size still needs to be scaled.
[0108] Specifically, during the successive offset process in sub-step S421, the shortest pixel distance value recalculated after each offset is continuously compared with the preset safety interval value described in step S41. When the shortest pixel distance value is greater than or equal to the preset safety interval value for the first time, the offset is terminated, and the cumulative offset at this time is recorded as the safe distance value that the text box can be translated.
[0109] If any boundary of the text placeholder rectangle exceeds the canvas boundary defined by the physical size value of the target canvas during the offset process, the offset is terminated and the cumulative offset at this time is recorded as the safe translation distance value of the text box constrained by the canvas boundary. At the same time, it is marked that there is a residual overflow part that exceeds the canvas boundary, which is used for the font size scaling operation in step S43.
[0110] S43: Read the minimum recognizable font size threshold corresponding to the physical size value of the target canvas, and substitute the text overflow amount and the safe translation distance value of the text box into the joint calculation: If there is still an overflow portion beyond the boundary of the target canvas after the text box is moved along the safe translation distance value of the text box, calculate the font size reduction coefficient and determine whether its corresponding font size value is lower than the minimum recognizable font size threshold; if it is lower, expand the safe translation distance value of the text box and trigger the line wrapping processing in the canvas, recalculate the estimated value of the text rendering size after mapping, until the corresponding font size value is not lower than the minimum recognizable font size threshold.
[0111] Simple translation is insufficient to accommodate the expanded target language text when the blank area of the canvas is insufficient. At this time, font size scaling needs to be introduced. However, font size scaling is constrained by the minimum recognizable font size threshold. This step solves the two degrees of freedom of text box displacement and font size scaling simultaneously. When translation is insufficient, scaling is used to make up for it. When scaling reaches the recognizable lower limit, line breaks are used to release space, so that the layout adjustment converges in both degrees of freedom.
[0112] Specifically, the minimum recognizable font size threshold corresponding to the physical size value of the target canvas output in step S13 is read. The method for determining the minimum recognizable font size threshold is as follows: based on the typical viewing distance of the target platform and the pixel density of the target canvas, the pixel height corresponding to the smallest character angle that the human eye can distinguish at that viewing distance is taken. For example, the minimum recognizable font size threshold of the mobile information flow platform can be set to 24 pixels, and the minimum recognizable font size threshold of the landscape web platform can be set to 18 pixels.
[0113] Determine whether the text box translation safety distance value output in step S422 includes a mark indicating any residual overflow beyond the canvas boundary. If not, the text box has no residual overflow after being moved along the text box translation safety distance value, and the font size reduction factor is set to 1, i.e., the font size is not scaled.
[0114] If a residual overflow portion is marked, a font size reduction factor is calculated. The font size reduction factor is calculated as follows: the ratio of the available pixel length that can accommodate the text within the target canvas after the text box has been moved along the safe translation distance of the text box to the corresponding directional component in the estimated value of the mapped text rendering size. The font size reduction factor is equal to this ratio. The font size reduction factor is multiplied by the mapped preset font size value to obtain the scaled font size value, where the mapped preset font size value is equal to the preset font size value in step S31 multiplied by the canvas scaling factor in the corresponding direction: when the layout direction is marked horizontally, the vertical scaling factor is used; when the layout direction is marked vertically, the horizontal scaling factor is used. This correspondence is consistent with the definition of the font size value as a height or width component in step S31 and the mapping direction of the estimated value of the mapped text rendering size in step S33.
[0115] The scaled font size value is compared with the minimum recognizable font size threshold. If the scaled font size value is not lower than the minimum recognizable font size threshold, the current font size reduction factor is accepted. If the scaled font size value is lower than the minimum recognizable font size threshold, the text box is expanded by a safe translation distance and a line break is triggered within the canvas. The line break refers to dividing the target language text into multiple lines according to the number of characters corresponding to the available width within the target canvas. The number of lines is the directional component corresponding to the estimated text rendering size after mapping, divided by the available pixel length, and then rounded up. After the line break, the estimated text rendering size of the target language is remeasured under the new line width constraint according to the overall bounding box measurement method described in step S31, and the estimated text rendering size after mapping is recalculated according to the mapping method described in step S33. Based on this, the font size reduction factor is recalculated.
[0116] See Figure 9 This is a schematic diagram of line wrapping within the canvas provided in this embodiment. For example... Figure 9As shown, the upper half of the diagram uses two vertical walls to represent the boundaries of the available width of the target canvas. A gray horizontal band between the walls represents the background area. Outside the walls, a dashed long frame indicates the text length corresponding to the "estimated value of the mapped text rendering size," and this dashed frame extends beyond the two walls. Between the walls, a measurement line with a double-headed arrow marks the "available pixel length," indicating the pixel length within the target canvas that can accommodate the text. The middle of the diagram uses a folding arrow to indicate "line wrapping within the canvas." The lower half of the diagram shows three rows of dark solid rectangles arranged after line wrapping, each row falling within the available pixel length defined by the two vertical walls. This diagram illustrates the process of expanding the text box by a safe translation distance and triggering line wrapping when the scaled font size is below the minimum recognizable font size threshold; dividing the target language text into multiple lines according to the available width; and rounding up the number of lines by dividing the directional component corresponding to the estimated value of the mapped text rendering size by the available pixel length. This demonstrates the effect of confining the text within the available pixel length of the target canvas after line wrapping.
[0117] The process of repeatedly expanding the safe distance value for translation of the text box, triggering line wrapping within the canvas, and recalculating the estimated value of the text rendering size after mapping continues until the scaled font size value is not lower than the minimum recognizable font size threshold. The termination condition of the repeated process is that the scaled font size value is not lower than the minimum recognizable font size threshold. If the scaled font size value is still lower than the minimum recognizable font size threshold when the safe distance value for translation of the text box is expanded to the upper limit of the available blank area of the canvas and the number of line wraps reaches the maximum number of lines allowed by the height of the text placeholder rectangle, then the repetition is terminated and the currently traversed text layer is marked as awaiting manual review.
[0118] For example, continuing with the previous example, if a text layer is laid out horizontally, has a preset font size of 24 pixels, and a vertical scaling factor of 0.5625, then the mapped preset font size will be: Pixels. If the calculated font size reduction factor is 0.8, then the scaled font size value will be... If the target platform is a landscape webpage and the minimum recognizable font size threshold is 18 pixels, then 10.8 pixels is lower than 18 pixels. This triggers the expansion of the text box, which can be shifted by a safe distance and performs line breaks within the canvas. The estimated value of the text rendering size after mapping and the font size reduction factor are recalculated until the font size value after scaling is not lower than 18 pixels.
[0119] S44: Output the set of adjusted text box coordinates and the adjusted font size scaling factor that simultaneously satisfy the space avoidance condition and the minimum recognizable font size threshold condition.
[0120] Steps S41 to S43 respectively solve the intermediate results for the two degrees of freedom of text box displacement and font size scaling. The solution results of the two degrees of freedom need to be integrated into the layout parameters that can directly drive layer composition. This step integrates and outputs the displacement and scaling results that meet the spatial avoidance conditions and the recognizable conditions as the input for rendering in step S5.
[0121] Specifically, the translational safety distance value of the text box output in step S422 is superimposed on the coordinates of the vertex of the currently traversed text layer in the coordinate set of the mapped text layer to obtain the adjusted vertex coordinates of the bounding box.
[0122] The font size reduction factor determined in step S43 is used as the adjusted font size scaling factor. If step S43 triggers line wrapping within the canvas, the number of lines after the wrapping and the character distribution of each line are written into the text layout parameters corresponding to the vertex coordinates of the adjusted bounding box.
[0123] After traversing all overflowing text layers, the adjusted bounding box vertex coordinates of each text layer are organized into an adjusted text box coordinate set, and the adjusted font size scaling factor of each text layer is organized into an adjusted font size scaling factor record with the text layer number as the key. The adjusted text box coordinate set is a key-value table with the text layer number as the key and the adjusted bounding box vertex coordinates and text layout parameters as the values.
[0124] Steps S41 to S44 use the text box displacement and font size scaling factor as joint variables for constraint solving, rather than using a single method of forcibly reducing the font size at a fixed position. This fundamentally cuts off the path that creates the dual contradiction of occlusion caused by fixed position and illegibility caused by forced font size reduction: when text overflow occurs, the canvas blank area is first consumed by translation, and font size scaling is only introduced when the translation is still insufficient due to the constraints of the canvas boundary. Moreover, the scaling is locked at the lower limit by the minimum recognizable font size threshold, and the two degrees of freedom converge collaboratively according to this priority. In this collaborative solving process, the loop mechanism of line wrapping within the canvas triggered in step S43 when the scaling reaches the recognizable lower limit and recalculating the estimated value of the text rendering size after mapping also unexpectedly alleviates the semantic coherence problem when switching between different language layout directions. When the vertical short text of the source Chinese version is switched to a horizontal long sentence in Russian or French, the horizontal long sentence will inevitably wrap within the limited canvas width. If the wrap position is mechanically truncated by the number of characters, it will break in the middle of the word and destroy the semantic coherence. In this loop mechanism, the number of wrap lines is determined by rounding up the ratio of the available pixel length to the estimated value of the rendered text size after mapping. After each wrap, the font rendering engine remeasures the width of the text bounding box as a whole under the new line width, so that the wrap position is dynamically adjusted with the actual character width and falls in the blank space between words. This improvement in sentence continuity was not the original design goal of step S4. The design goal of step S4 was only to constrain the font size to not be lower than the recognizable lower limit while avoiding the focus. However, the loop formed between the calculation of the number of line breaks and the recalculation of the estimated text rendering size has a mathematical structure that naturally aligns the line break position with the character width distribution while handling the font size constraint. This allows the readability and continuity of the text in cross-language conversion scenarios to be improved simultaneously without the need to introduce an independent sentence break processing module. This overcomes the hidden defect of existing typesetting methods that destroy semantic continuity due to the mechanical truncation of line break positions when switching language typesetting directions.
[0125] S5: Based on the adjusted text box coordinate set and the adjusted font size scaling factor, drive the layer compositing engine to render the pixel matrix of the target language visual material and perform conflict verification.
[0126] The adjusted text box coordinate set and adjusted font size scaling factor output in step S4 are parametric typesetting results, which have not yet been translated into a deliverable finished pixel image. Furthermore, the constraint solution is based on the estimated geometry of the text placeholder rectangle. The pixel-level relationship between the text and the focus after actual rendering may deviate from the estimate. This step first drives the layer compositing engine to render the finished product, and then performs conflict verification by pixel-level comparison, forming a closed loop from adjustment to verification.
[0127] Further, step S5 includes: S51: Write the adjusted text box coordinate set and the adjusted font size scaling factor into the text layer parameters of the layer compositing engine, drive the layer compositing engine to render layer by layer according to the layer stacking order, and output the target language visual material pixel matrix.
[0128] The layout parameters output in step S4 need to be converted into actual finished images before they can be delivered for distribution. This sub-step writes the layout parameters into the layer compositing engine and renders them in layer order to generate the finished pixel representation of the visual material in the target language.
[0129] Specifically, the adjusted bounding box vertex coordinates and text layout parameters of each text layer in the adjusted text box coordinate set output in step S44, as well as the adjusted font size scaling factor of the corresponding text layer in the adjusted font size scaling factor record, are written into the text layer parameters of the layer compositing engine.
[0130] The driving layer compositing engine first renders the background layer and non-text layer. When rendering the background layer and non-text layer, based on the horizontal and vertical scaling factors calculated in step S32, the background layer and non-text layer are stretched and scaled non-proportionally in the horizontal and vertical directions respectively, so that their pixel size is stretched from the pixel width and height of the source canvas to the pixel width and height of the target canvas. This ensures that the background content pixels, the coordinates of the mapped visual focus area, and the coordinates of the adjusted text box are under the same mapping reference in the target canvas, ensuring that the focus position and text position in the rendering result strictly correspond to the constraint solution result of step S4. Then, according to the scaled font size value corresponding to the adjusted font size scaling factor, the target language text is rendered in the area defined by the vertex coordinates of the adjusted bounding box, and the text is arranged with line breaks according to the text layout parameters. The layers are then composited layer by layer from bottom to top according to the original layer stacking order of the multi-layer file.
[0131] After the layer compositing engine completes the compositing, it reads the red, green, and blue channel values of each pixel in the compositing result in a row-by-row and column-by-column scanning manner to generate a target language visual material pixel matrix. The target language visual material pixel matrix is a three-dimensional matrix with a size equal to the target canvas pixel height multiplied by the target canvas pixel width, and each element is a triplet of red, green, and blue components.
[0132] S52: Re-perform pixel-level overlap comparison between the text layer region in the target language visual material pixel matrix and the coordinate set of the mapped visual focus region, and calculate the shortest pixel distance value; if the shortest pixel distance value is still less than the preset safety interval value, generate a manual review prompt signal and mark the corresponding material number, and transfer to the manual processing flow; if the comparison passes, output the target language visual material pixel matrix as the final delivery file.
[0133] The pixel matrix of the target language visual material obtained by rendering in step S51 is the finished product after the text is actually placed. The constraint solution in step S4 is based on the estimated geometry of the text placeholder rectangle. If the finished product is not checked at the pixel level, the deviation between the estimation and the actual rendering may cause residual occlusion to enter the delivery file. This sub-step re-performs pixel-level comparison on the finished product to intercept residual conflicts.
[0134] Specifically, from the target language visual material pixel matrix output in step S51, the text layer area is determined according to the adjusted bounding box vertex coordinates recorded in the adjusted text box coordinate set, and the set of pixels actually covered by text pixels within the text layer area is read.
[0135] Following the method for calculating the shortest pixel distance described in step S41, the shortest pixel distance between the set of pixels actually covered by text pixels within the text layer area and the bounding rectangles of each connected component in the mapped visual focus area coordinate set output in step S32 is calculated. Since the background layer has been stretched and mapped using the same scaling factor as the text layer and the visual focus area coordinates in step S51, the two sets of coordinates compared in this step are in the same target canvas coordinate system, and the comparison result has physical meaning.
[0136] The shortest pixel distance value is compared with the preset safety interval value described in step S41. If the shortest pixel distance value is still less than the preset safety interval value, a manual review prompt signal is generated, and the material number corresponding to the current target language visual material is written into the manual review queue and transferred to the manual processing flow. If the shortest pixel distance value is greater than or equal to the preset safety interval value, the comparison is determined to be successful, and the pixel matrix of the target language visual material is output as the final delivery file.
[0137] The comparison results and final delivery status of visual materials in each target language are written into a batch adaptation result record table with the material number as the key. After traversing all platforms and all target languages in the target canvas physical size value list, the batch adaptation result record table is output, completing the closed-loop processing link from visual focus recognition, layout adjustment to conflict verification.
[0138] In summary, this embodiment directly parses the set of coordinates of the visual focus area from the edge gradient values and color saliency values of the pixel matrix of the source language layout. In step S32, this set of coordinates, along with the coordinates of the text layer and the background layer, is mapped to the target canvas coordinate system using the same set of horizontal and vertical scaling factors. This replaces the traditional static coordinate binding and eliminates the spatial avoidance distortion problem caused by direct comparison between different coordinate systems. Furthermore, using the text overflow amount synchronously mapped by the canvas scaling factor as the trigger condition, the two degrees of freedom of text box displacement and font size scaling are jointly constrained and solved. This allows multilingual character expansion, layout direction switching, and multi-size canvas changes to converge collaboratively under a unified spatial avoidance mechanism. Finally, the layer compositing engine completes the rendering of the background, text, and focus position alignment under the same mapping reference and automatically verifies the pixel-level comparison to intercept residual occlusion before delivery. This achieves batch automated adaptation of visual materials in different languages, sizes, and platforms.
[0139] Example 2: This embodiment, based on Embodiment 1, provides a dynamic typesetting system for multilingual visual materials, such as... Figure 10 As shown, it includes: The data acquisition and structuring module is used to read multi-layer files of visual materials in the source language through an image acquisition device, extract color channel values pixel by pixel, obtain the pixel matrix of the source language layout, and parse the original coordinate set of the text layer and the physical size value of the canvas. The visual focus recognition module is used to perform edge gradient calculation and color contrast calculation on the pixel matrix of the source language layout to obtain a comprehensive visual saliency value matrix and delineate the set of coordinates of the visual focus area. The text overflow calculation module is used to measure the estimated value of the target language text rendering size through the font rendering engine, and to obtain the text overflow by comparing it with the original coordinate set of the text layer in combination with the canvas scaling factor. The layout constraint solving module is used to solve constraints based on the text overflow and the set of coordinates of the visual focus area, calculate the safe translation distance of the text box, and generate the adjusted set of text box coordinates and the adjusted font size scaling factor. The rendering and conflict review module is used to drive the layer compositing engine to render the pixel matrix of the target language visual material based on the adjusted text box coordinate set and the adjusted font size scaling factor, and to perform conflict review.
Claims
1. A dynamic layout method for multilingual visual materials, characterized in that, include: The image acquisition device reads the multi-layer file of the visual material in the source language, extracts the color channel values pixel by pixel, obtains the pixel matrix of the source language layout, and analyzes the original coordinate set of the text layer and the physical size value of the canvas. Edge gradient calculation and color contrast calculation are performed on the pixel matrix of the source language layout to obtain the comprehensive visual saliency value matrix and delineate the set of coordinates of the visual focus area. The estimated text rendering size of the target language is measured by the font rendering engine, and the text overflow is obtained by comparing the original coordinate set of the text layer with the canvas scaling factor. Constraints are solved based on the text overflow and the coordinate set of the visual focus area. The safe translation distance of the text box is calculated, and the adjusted coordinate set of the text box and the adjusted font size scaling factor are generated in conjunction. Based on the adjusted text box coordinate set and the adjusted font size scaling factor, the layer compositing engine renders the pixel matrix of the target language visual material and performs a conflict check.
2. The dynamic layout method for multilingual visual materials according to claim 1, characterized in that, The process of obtaining the source language layout pixel matrix and parsing the original coordinate set of the text layer and the physical size value of the canvas includes: The multi-layer file of the visual material in the source language is read through an image acquisition device or a page file parsing interface, and the gray values of the red, green and blue three channels are extracted pixel by pixel to generate the pixel matrix of the page in the source language. Extract the bounding box vertex coordinates, font size values, and layout direction markers of each text layer from the layer description information of the multi-layer file to generate the original coordinate set of the text layers; Read the physical size value of the canvas corresponding to the visual material in the source language, and read the canvas specifications of multiple platforms to be adapted, and generate a list of target canvas physical size values.
3. The dynamic layout method for multilingual visual materials according to claim 2, characterized in that, The generated source language layout pixel matrix includes: When the source language visual material is stored in the form of a raster product, the red, green, and blue color channel values of each pixel are read by scanning row by row and column by column using an image acquisition device. Each color channel value is an integer between 0 and 255. When the source language visual material is stored in the form of a layered editable file, the layers are first rasterized and merged into a finished raster image according to the stacking order through the layout file parsing interface, and then scanned and read row by row and column by column. The three-channel grayscale values are arranged according to the row and column positions to generate a three-dimensional matrix with a size equal to the pixel height of the source canvas multiplied by the width, and each element being a red, green, and blue triplet as the source language layout pixel matrix.
4. The dynamic layout method for multilingual visual materials according to claim 2, characterized in that, The list of generated target canvas physical size values includes: The platform canvas specifications are provided by the platform specification configuration table, which uses the platform identifier as the key and the canvas pixel width and canvas pixel height as values. Its initial values are obtained from the publicly available placement size of each platform. When accessing a new platform not covered by the platform specification configuration table, the canvas pixel width and canvas pixel height of that platform are supplemented in the same way. After each batch of adaptation tasks is completed, the consistency between the actual rendering size and the configured size is verified. If they are inconsistent, the corresponding values in the platform specification configuration table are updated with the actual rendering size.
5. The dynamic layout method for multilingual visual materials according to claim 1, characterized in that, The method for obtaining the comprehensive visual saliency value matrix and defining the set of coordinates for the visual focus region includes: Gradient operator convolution is performed on the pixel matrix of the source language layout, and the brightness change is calculated pixel by pixel to obtain the image edge gradient value matrix; Perform color channel difference calculation on the pixel matrix of the source language layout, calculate the color saturation value and the neighboring color contrast value for each pixel, and obtain the color saliency value matrix. The image edge gradient value matrix and the color saliency value matrix are weighted and superimposed to obtain the visual saliency comprehensive value matrix. The coordinates of pixels with values greater than the preset focus threshold in the visual saliency comprehensive value matrix are merged into connected components to generate a set of visual focus region coordinates.
6. The dynamic layout method for multilingual visual materials according to claim 5, characterized in that, The obtained image edge gradient value matrix includes: The luminance matrix is obtained by weighting and summing the red, green, and blue channel components of each pixel in the source language layout pixel matrix according to the luminance transformation relationship, where the luminance value is equal to the sum of the red component multiplied by 0.299, the green component multiplied by 0.587, and the blue component multiplied by 0.
114. The luminance matrix is then convolved with Sobel operators in the horizontal and vertical directions to obtain the luminance changes of each pixel in the horizontal and vertical directions. The square root of the sum of the two squares is taken as the edge gradient value of that pixel, and the edges are arranged in rows and columns to obtain the image edge gradient value matrix.
7. The dynamic layout method for multilingual visual materials according to claim 5, characterized in that, The obtained color saliency value matrix includes: For each pixel, the color saturation value is calculated according to the saturation calculation relationship, which is that the color saturation value is equal to the difference between the maximum and minimum values of the red, green, and blue components of the pixel, divided by the maximum value. When the maximum value is 0, the color saturation value is 0. A 5x5 neighborhood window is taken with each pixel as the center. The average of the Euclidean distances between the three-channel color vector of the neighborhood window and the color vectors of the other pixels in the window is taken as the neighborhood color contrast value. For pixels in the neighborhood window that exceed the matrix boundary, the boundary pixel values are used to fill in the gaps before recalculation. The normalized color saturation value and the neighborhood color contrast value are added together with equal weight to obtain the color saliency value.
8. The dynamic layout method for multilingual visual materials according to claim 5, characterized in that, The set of coordinates for the generated visual focus region includes: First, the image edge gradient value matrix and color saliency value matrix are linearly normalized to the interval between 0 and 1. Then, the visual saliency comprehensive value is obtained by weighting and superimposing the edge gradient weight and color saliency weight pixel by pixel, where the sum of the edge gradient weight and color saliency weight is 1. The preset focus threshold is the mean of all elements in the visual saliency comprehensive value matrix plus one standard deviation. For focus pixels with values greater than the preset focus threshold, connected components are merged according to the four-neighbor adjacency rule. The coordinates of the upper left and lower right vertices of the bounding rectangle of each connected component are taken to generate a set of visual focus region coordinates.
9. The dynamic typesetting method for multilingual visual materials according to claim 1, characterized in that, The text overflow amount obtained by comparing the original coordinate set of the text layer with the canvas scaling factor includes: The font rendering engine is invoked to measure the estimated rendering size of the target language text based on the target language text character set and the preset font size value, and to determine whether the target language typesetting direction is horizontal or vertical based on the typesetting direction mark. Calculate the canvas scaling factor based on the ratio of the target canvas physical size value to the source language canvas physical size value, and map the original coordinate set of the text layer proportionally according to the canvas scaling factor to obtain the mapped coordinate set of the text layer. The text overflow amount is obtained by performing a difference calculation between the estimated value of the target language text rendering size and the bounding box width and height values recorded in the coordinate set of the mapped text layer. When the text overflow amount is greater than zero, it is marked as an overflow state.
10. The dynamic layout method for multilingual visual materials according to claim 9, characterized in that, The obtained set of coordinates for the mapped text layer includes: The ratio of the target canvas pixel width to the source canvas pixel width is calculated as the horizontal scaling factor, and the ratio of the target canvas pixel height to the source canvas pixel height is calculated as the vertical scaling factor. These two factors constitute the canvas scaling factor. The horizontal scaling factor is multiplied by the horizontal scaling factor and the vertical scaling factor is multiplied by the vertical scaling factor for the x-coordinate of each bounding box vertex in the original coordinate set of the text layer to obtain the mapped text layer coordinate set. At the same time, the coordinates of the vertices of the bounding rectangles of each connected component in the visual focus area coordinate set are mapped synchronously and proportionally according to the same set of scaling factors to obtain the mapped visual focus area coordinate set in the same target canvas coordinate system as the mapped text layer coordinate set.
11. The dynamic layout method for multilingual visual materials according to claim 10, characterized in that, The linked generation of the adjusted text box coordinate set and the adjusted font size scaling factor include: When the text overflow is greater than zero, calculate the shortest pixel distance between the mapped text layer coordinate set and the mapped visual focus area coordinate set, compare it with the preset safety interval value, and determine whether the text box overlaps with the mapped visual focus area coordinate set. If spatial overlap occurs, the safe translation distance value of the text box is calculated step by step along the normal direction outside the coordinate set of the visual focus area after the pointing map, until the shortest pixel distance value is greater than or equal to the preset safe interval value. Read the minimum recognizable font size threshold, substitute the text overflow amount and the text box's safe translation distance into the simultaneous operation to calculate the font size reduction coefficient, and when the font size is lower than the minimum recognizable font size threshold, expand the text box's safe translation distance and trigger line wrapping in the canvas; Output the set of adjusted text box coordinates and the adjusted font size scaling factor.
12. The dynamic layout method for multilingual visual materials according to claim 11, characterized in that, The driving layer compositing engine renders the pixel matrix of visual materials in the target language and performs conflict checks, including: Write the adjusted text box coordinate set and the adjusted font size scaling factor into the text layer parameters of the layer compositing engine. First, stretch the background layer and non-text layer to the target canvas size by non-proportional scaling factor according to the horizontal scaling factor and vertical scaling factor. Then, render the target language text in the adjusted bounding box according to the adjusted font size scaling factor and composite it layer by layer from bottom to top according to the layer stacking order, and output the target language visual material pixel matrix. The pixel-level overlap comparison between the text layer region and the mapped visual focus region coordinate set in the pixel matrix of the target language visual material is re-performed, and the shortest pixel distance value is calculated. If it is still less than the preset safety interval value, a manual review prompt signal is generated and the corresponding material number is marked. Otherwise, the pixel matrix of the target language visual material is output as the final delivery file.
13. A dynamic typesetting system for multilingual visual materials, used to implement the dynamic typesetting method for multilingual visual materials as described in any one of claims 1 to 12, characterized in that, The system includes: The data acquisition and structuring module is used to read multi-layer files of visual materials in the source language through an image acquisition device, extract color channel values pixel by pixel, obtain the pixel matrix of the source language layout, and parse the original coordinate set of the text layer and the physical size value of the canvas. The visual focus recognition module is used to perform edge gradient calculation and color contrast calculation on the pixel matrix of the source language layout to obtain a comprehensive visual saliency value matrix and delineate the set of coordinates of the visual focus area. The text overflow calculation module is used to measure the estimated value of the target language text rendering size through the font rendering engine, and to obtain the text overflow by comparing it with the original coordinate set of the text layer in combination with the canvas scaling factor. The layout constraint solving module is used to solve constraints based on the text overflow and the set of coordinates of the visual focus area, calculate the safe translation distance of the text box, and generate the adjusted set of text box coordinates and the adjusted font size scaling factor. The rendering and conflict review module is used to drive the layer compositing engine to render the pixel matrix of the target language visual material based on the adjusted text box coordinate set and the adjusted font size scaling factor, and to perform conflict review.