A grayscale field quantization analysis method and system for Chinese character typesetting
By initializing global analysis configuration parameters, constructing a visual scene physical model, and performing multi-step chained image processing, the problem of lack of indicators in cross-font and cross-scene quantitative analysis is solved, enabling scientific grayscale field evaluation and objective diagnosis of typesetting.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUNAN NORMAL UNIVERSITY
- Filing Date
- 2026-04-29
- Publication Date
- 2026-07-17
AI Technical Summary
Existing Chinese character typesetting tools lack unified indicators in quantitative analysis across fonts and scenarios, making it impossible to accurately simulate real viewing scenarios. This results in typesetting grayscale evaluation relying on subjective experience and failing to output scientific and reproducible numerical conclusions.
By acquiring font resources and typographic text, initializing global analysis configuration parameters, estimating and compensating for character frame ratios, constructing a visual scene physical model, generating scene degradation parameters, performing multi-step chained image processing, calculating the statistical index chain of the typographic grayscale field, and generating an objective diagnostic report.
It enables quantitative analysis across fonts and scenarios, strips away the inherent differences between fonts, accurately simulates real viewing conditions, outputs scientific grayscale statistical indicators for typesetting, supports multi-scale semantic sampling, and generates objective diagnostic reports.
Smart Images

Figure CN122113844B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical fields of computer graphics and digital typesetting, and in particular to a grayscale field quantization analysis method and system for Chinese character typesetting. Background Technology
[0002] The presentation of Chinese characters on various media, including screens, e-paper, indoor and outdoor LEDs, and paper proofs, depends not only on the character shape itself but also on a combination of factors such as viewing distance, pixel density (or pixel pitch), ambient glare, the luminous properties of the medium, and the observer's visual acuity. In actual design and typesetting projects, when judging the uniformity of grayscale, rhythm, detail fidelity, and local crowding of the same text in different scenarios, R&D and design personnel often rely heavily on subjective experience and repeated screenshot comparisons. However, existing font analysis tools are mostly limited to dissecting the geometric structure of individual characters (such as center of gravity, character size, and stroke thickness). Once continuous typesetting scenarios at the paragraph or page level are involved, the overall visual effects, such as density interaction between characters, grayscale fluctuations between lines, and outliers at the character position level, lack unified cross-font and cross-scenario quantitative indicators. This results in the actual workflow remaining at the stage of visual evaluation, making it difficult to output scientific and reproducible numerical conclusions.
[0003] Furthermore, traditional workflows have significant technical blind spots in the deep quantization of grayscale in typesetting and the simulation of visual scenes. On the one hand, existing density analyses are often granular, relying only on global statistical methods from traditional image processing (such as average brightness), and cannot simultaneously consider four scales: whole-segment, row-column, character-position, and local magnification. This lack of dimension makes it difficult for the system to reveal the intrinsic relationship between overall grayscale fluctuations and local spatial issues of individual characters; at the same time, the inherent differences in character proportions (the ratio of the effective area of a character to its frame) between different fonts are not effectively separated when comparing typesetting. Without strict normalization compensation, directly comparing the grayscale distribution of typesetting with the same font size will result in serious data bias and will fail to reflect the true density characteristics of the typesetting.
[0004] On the other hand, existing typesetting analysis tools almost completely strip away the physical intervention of real-world viewing conditions on visual presentation, performing only static calculations under ideal conditions. The description of differences in real-world viewing scenarios by designers often only stays at the subjective qualitative level of "more blurry, more indistinct, brighter." The industry urgently needs an engineering approximation model that can map optical and visual physiological parameters such as viewing distance, pixel visual angle, minimum angle of view / log minimum angle of view (MAR / logMAR), point spread function (PSF), and Nyquist sampling upper limit to the final text appearance changes.
[0005] Therefore, there is an urgent need for a Chinese character typesetting grayscale field quantitative analysis technology that can unify literal benchmarks, accurately simulate real viewing scenarios, support multi-scale semantic sampling, and ultimately output a complete statistical indicator chain. Summary of the Invention
[0006] This application aims to at least partially address one of the technical problems in the related art.
[0007] To achieve the above objectives, the first aspect of this application proposes a grayscale field quantization analysis method for Chinese character typesetting, comprising the following steps:
[0008] S1. Obtain at least one font resource and the typesetting text to be analyzed, and initialize the global analysis configuration parameters, which include typesetting parameters, normalization switch, scene parameters and sampling parameters.
[0009] S2, based on the font resources and the layout parameters, perform character frame ratio estimation for each font resource, and compensate the target font size in the layout parameters according to the estimation results to obtain the compensated actual rendered font size;
[0010] S3. Based on the compensated actual rendered font size and the layout parameters, perform layout rendering on the text to be analyzed after blank cleaning to obtain a baseline rendering image and record the layout information of each rendered character.
[0011] S4. Based on the scene parameters, the actual rendered font size, and the font frame ratio, construct a visual scene physical model, and generate a set of scene degradation parameters based on the visual scene physical model.
[0012] S5, taking the baseline rendering image as input, and synthesizing a scene simulation image through multi-step chain image processing according to the scene degradation parameters;
[0013] S6, sample the grayscale density distribution of the baseline rendering image, the scene simulation image and the character layout information at multiple semantic levels to obtain the density matrix and the character-level density;
[0014] S7. Based on the density matrix and the character-level density, calculate the statistical index chain of the typesetting grayscale field;
[0015] S8, taking the scene degradation parameters and the statistical indicator chain as input, and generating an objective diagnostic report using a preset rule template.
[0016] In addition, the grayscale field quantization analysis method and system for Chinese character typesetting proposed above in this application may also have the following additional technical features:
[0017] In one embodiment of this application, step S2 further includes:
[0018] Select a set of representative sample characters for drawing, and calculate the vertical range of the characters based on the drawing results;
[0019] When the normalization switch is true, a compensation coefficient is calculated based on the ratio of the preset target character size to the character frame size, and the target font size in the typesetting parameters is compensated to obtain the actual rendered font size.
[0020] In one embodiment of this application, step S4 further includes:
[0021] Obtain the corresponding feature coefficients based on the preset display medium type;
[0022] The physical size of a single pixel is determined based on the type of display medium, and the visual angle of the pixel and the number of pixels per visual degree are calculated in combination with the viewing distance.
[0023] Convert the input visual acuity level into the minimum resolvable angle;
[0024] Based on the actual rendered font size, the font frame ratio, and the pixel visual angle, the font height visual angle is calculated, and combined with the minimum resolution angle, the reading pressure coefficient is calculated.
[0025] Based on the minimum resolution angle, the reading pressure coefficient, the feature coefficient, the pixel visual angle, and the environmental glare coefficient in the scene parameters, a joint point spread function width proxy model is constructed to obtain the joint point spread function width;
[0026] The scene degradation parameters are generated based on the number of pixels per visual degree and the width of the joint point spread function.
[0027] In one embodiment of this application, step S5 further includes:
[0028] Based on the detail fidelity in the scene degradation parameters, the baseline rendering image is scaled to obtain a first intermediate image.
[0029] Based on the point spread function width in the scene degradation parameters, Gaussian blur is applied to the first intermediate image to obtain the second intermediate image;
[0030] Based on the emission diffusion radius in the scene degradation parameters, the second intermediate image is subjected to emission diffusion superposition to obtain the third intermediate image;
[0031] Based on the contrast preservation coefficient and black level enhancement in the scene degradation parameters, luminance remapping is performed on the third intermediate image to generate the scene simulation image.
[0032] In one embodiment of this application, step S6 further includes:
[0033] The baseline rendered image and the scene simulation image are respectively converted into grayscale density measures;
[0034] The sampling grid size is determined based on the sampling parameters and the layout parameters. The average gray density within each sampling grid is calculated using the sampling grid as a unit, and the density matrix is generated by the gray density metric.
[0035] Traverse the character slots in the character layout information, calculate the average gray density in the image area corresponding to each character slot, and generate the character-level density.
[0036] In one embodiment of this application, step S7 further includes:
[0037] Calculate global statistics based on the density matrix. The global statistics include average gray density, gray dispersion, and coefficient of variation.
[0038] Calculate the row-direction density fluctuation and column-direction density fluctuation based on the density matrix;
[0039] Calculate the gray-level frequency distribution and information entropy based on the density matrix;
[0040] The above indicators were calculated for both the baseline rendering and the scene simulation to obtain the baseline statistical indicators and the simulation statistical indicators.
[0041] In one embodiment of this application, step S8 further includes:
[0042] Based on the scene degradation parameters and the statistical indicator chain, output scene location description, degradation link description and grayscale field change diagnosis;
[0043] The frequency stress status of the current scene is determined based on a preset frequency threshold, and corresponding warnings are output.
[0044] The light diffusion state of the current medium is determined based on the preset light diffusion threshold, and a corresponding prompt is output.
[0045] In one embodiment of this application, the method further includes:
[0046] The first activated font is used as the master font, and a complete analysis of all steps is performed. The remaining activated fonts are used as slave fonts, and only a lightweight comparison path of basic density matrix and positional density sampling is performed. Under the same typesetting conditions and scene parameters, density heatmaps and core comparison indicators are output side by side for all activated fonts.
[0047] The second aspect of this application proposes a grayscale field quantization analysis system for Chinese character typesetting, which is implemented based on a grayscale field quantization analysis method for Chinese character typesetting.
[0048] A third aspect of this application provides a computer execution device, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of a grayscale field quantization analysis method for Chinese character typesetting.
[0049] Compared with existing technologies, this invention overcomes the technical shortcomings of traditional Chinese character typesetting evaluation, which relies heavily on subjective experience and single static calculations, and fills the gap in cross-font and cross-scenario quantitative indicators, including at least the following beneficial effects:
[0050] 1. By estimating and compensating for the character frame ratio, the layout of different fonts is placed on a unified visual area benchmark, effectively eliminating the data offset caused by inherent differences in character frame ratio. By introducing surrogate models of visual angle, point spread function, modulation transfer function, and scene parameter chain, the actual viewing conditions such as media characteristics, viewing distance, ambient glare, and observer's vision are accurately transformed into executable image degradation simulations.
[0051] 2. By combining global grid density matrix, fine grid, character-level density statistics and local hotspot analysis, multi-scale semantic sampling from macro layout to micro single character was realized, and statistical index chains such as mean, dispersion, coefficient of variation, information entropy and row and column density fluctuations were calculated, effectively compressing complex gray-scale field features into directly comparable quantitative data.
[0052] 3. The system takes scene degradation parameters and statistical indicator chains as input and automatically generates objective diagnostic reports through preset rule templates. It intuitively transforms the sources of scene stress and grayscale performance into readable text, changing the dilemma that traditional typesetting analysis cannot output scientific and reproducible numerical conclusions.
[0053] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0054] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0055] Figure 1 This is a flowchart illustrating the steps of a grayscale field quantization analysis method for Chinese character typesetting according to this application. Detailed Implementation
[0056] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0057] The following describes a grayscale field quantization analysis method and system for Chinese character typesetting according to an embodiment of this application, with reference to the accompanying drawings.
[0058] This application provides a grayscale field quantization analysis method and system for Chinese character typesetting, which involves the interdisciplinary fields of computer graphics, typesetting engineering, and visual science. In particular, it relates to a method based on off-screen canvas rendering, character frame normalization compensation, and visual scene physical modeling (including visual angle and point spread function). Modulation transfer function A method for quantizing the grayscale field of Chinese character typesetting, including contrast attenuation, multi-scale semantic density sampling, and statistical index chain analysis, is proposed, and the system, electronic equipment, and computer-readable storage medium for implementing the method are also described.
[0059] like Figure 1 As shown in the embodiment of this application, a grayscale field quantization analysis method for Chinese character typesetting is presented.
[0060] Includes the following steps:
[0061] S1. Obtain at least one font resource and the typesetting text to be analyzed, and initialize the global analysis configuration parameters, which include typesetting parameters, normalization switch, scene parameters and sampling parameters.
[0062] It should be noted that, in one embodiment of this application, step S1 further includes:
[0063] (a) Font Resource Acquisition and Registration: Acquire at least one font resource, including system-preset fonts and user-uploaded fonts. For system-preset fonts, directly reference the font family name built into the operating system or browser (such as SimHei, SongTi, KaiTi), without additional loading; for user-uploaded fonts, read the binary data ArrayBuffer of the font file (TTF / OTF / WOFF / WOFF2, etc.) through the file interface, and dynamically register it to the font collection of the runtime environment via FontFaceAPI; for uncompressed container formats, parse the head table to read the number of units per em. (unitsPerEm) is recorded as font metadata;
[0064] (b) Unique Font Identification and Management: Assign a unique family name identifier to each font (for user-uploaded fonts, use a random suffix to avoid naming conflicts), and maintain a font list. Where fᵢ represents the i-th registered font object, n is the total number of fonts, and each font object records: display name, family name identifier, and metadata (including...). The list displays the enabled / disabled status of fonts. Users can dynamically add, delete, and toggle the enabled status of fonts in the list, creating an "active font set." .
[0065] (c) Text Acquisition and Whitespace Cleaning: Receive the Chinese text string to be analyzed from the user input, remove all whitespace characters (spaces, newlines, tabs, etc.), and generate a pure character sequence. Where cᵢ represents the i-th Chinese character to be typed, and m is the total number of cleaned characters, which serves as the standardized input for subsequent typesetting.
[0066] (d) Global configuration initialization: Set the following global analysis parameters as unified inputs for subsequent steps:
[0067] Layout parameters: target font size (e.g., 48px), line spacing multiples (e.g., 1.) Number of characters per line (e.g., 14), layout direction (horizontal / vertical);
[0068] Normalization switch: Literal frame compensation switch (Boolean value) Controls whether text box normalization is enabled;
[0069] Scene parameters: Display media type Viewing distance Pixel density / pixel pitch, ambient glare coefficient (0-1) Visual acuity level ;
[0070] Sampling parameters: lateral sampling coefficients (e.g., 0.28) Longitudinal sampling coefficient (e.g., 0.32).
[0071] S2, based on the font resources and the layout parameters, perform character frame ratio estimation for each font resource, and compensate the target font size in the layout parameters according to the estimation results to obtain the compensated actual rendered font size;
[0072] In one embodiment of this application, step S2 further includes:
[0073] Select a set of representative sample character sets for drawing, and based on the drawing results, count the vertical range of the characters and calculate the ratio of the literal box;
[0074] Specifically, select a set of Chinese representative sample character sets ={country, wind, forever, book, mountain, field, sun, bright, observe, view}, draw on a temporary off-screen canvas with a fixed reference font size size_ref (size reference, the reference value of the size reference, used to unify the reference for estimating the ratio of the literal box of different fonts), and then scan the alpha channel of the canvas pixels (the image transparency channel, used to determine whether each pixel contains glyph stroke information), and count the vertical range of all non-transparent pixels (alpha > T_alpha_min) , and calculate the ratio of the literal box : Among them, the alpha channel of the canvas pixels is used to reflect the transparency of the pixels, and T_alpha_min is the minimum alpha threshold for determining non-transparent pixels, that is, the transparency determination threshold. Pixels with an alpha value greater than this threshold are regarded as valid glyph pixels. is the ordinate of the uppermost pixel of the glyph stroke, is the ordinate of the lowermost pixel, and the two jointly define the vertical boundary of the glyph.
[0075] When the normalization switch is true, calculate the compensation coefficient according to the ratio of the preset target literal ratio to the ratio of the literal box, and compensate the target font size in the layout parameters to obtain the actual rendering font size.
[0076] If the literal box compensation switch is true, use the target literal ratio (such as = 0.84) as the benchmark to calculate the compensation coefficient :
[0077] ;
[0078] Among them, is the truncation function, that is, limit within , that is, the closed interval composed of the lower limit value min and the upper limit value max.
[0079] The actual rendering font size after compensation is: ; The compensation logic is: fonts with a smaller literal ( < ) obtain a compensation coefficient greater than 1 and are slightly enlarged, and fonts with a larger literal ( > A compensation coefficient less than 1 is obtained to slightly reduce the size, thus allowing subsequent grayscale field comparisons to be based on a more uniform visual area. Afterwards, the wordbox proportion estimation results are cached, with the cache key generated jointly by the font family name and the reference font size to avoid duplicate calculations.
[0080] S3. Based on the compensated actual rendered font size and the layout parameters, perform layout rendering on the text to be analyzed after blank cleaning to obtain a baseline rendering image and record the layout information of each rendered character.
[0081] It should be noted that, in one embodiment of this application, step S3 further includes:
[0082] Layout parameter calculation: based on the compensated rendered font size Line spacing multiple and the number of characters per line Calculate the typesetting geometric parameters: ; ;
[0083] in, express , This indicates the character width, which is the number of horizontal pixels in each character slot.
[0084] Divide the character sequence T into lines. Characters split into lines (horizontal mode) or by column Calculate the total canvas size by dividing the characters into columns (vertical layout mode). This includes preset inner margins. .
[0085] Off-screen canvas rendering: Creates an off-screen canvas with dimensions of [size missing]. ×DPR and ×DPR;
[0086] in, Indicates logical width, The logical height is [height], DPR is the device pixel ratio, and the background is filled with white. Iterate through the character sequence after line / column splits, and draw each character centered within its slot. The rendered font is the family name of the currently active font, and the font size is [size]. .
[0087] Character-by-character layout information recording: For each rendered character, the system records the following layout tuple. = ;
[0088] in: The specific character currently being rendered; The coordinates of the top left corner and the width and height of the character slot; The X and Y coordinates are the starting points for the actual drawing of the character (calculated based on center alignment). The formula for calculating the compact bounding box obtained based on the measureText() API is as follows:
[0089] tightX=drawX-actualBoundingBoxLeft;
[0090] tightY=baseY-actualBoundingBoxAscent;
[0091] tightW=actualBoundingBoxLeft+actualBoundingBoxRight;
[0092] tightH=actualBoundingBoxAscent+actualBoundingBoxDescent;
[0093] Where, tightX is the true left boundary X coordinate, tightY is the true top boundary Y coordinate, tightW is the total width of the bounding box, and tightH is the total height of the bounding box; actualBoundingBoxLeft is the distance from the drawing origin drawX to the leftmost pixel of the text, actualBoundingBoxRight is the distance from the drawing origin drawX to the rightmost pixel of the text, actualBoundingBoxAscent is the distance from the baseline baseY upwards to the highest pixel of the text (e.g., the top of a capital letter); actualBoundingBoxDescent is the distance from the baseline baseY downwards to the lowest pixel of the text (in Western texts, such as the lowercase letters g, p, y, the part that extends below the baseline; in Chinese, this value is usually smaller, but it is still used to accurately define the lower boundary of the character).
[0094] Understandably, a compact bounding box is used for precise cropping when zooming in on local hotspots, avoiding the use of the entire slot and causing interference from surrounding blank spaces.
[0095] S4. Based on the scene parameters, the actual rendered font size, and the font frame ratio, construct a visual scene physical model, and generate a set of scene degradation parameters based on the visual scene physical model.
[0096] In one embodiment of this application, step S4 further includes:
[0097] The system obtains the corresponding feature coefficients based on the preset display media types; among them, the system presets six types of display media. ={Paper / Proofing, Electronic Paper, LCD / IPS, OLED / Mobile Screen, Indoor LED, Outdoor LED}, each type of medium carries the following characteristic coefficient: Display Diffusion Coefficient (Contribution of pixel edge blurring by the medium itself); Scattering coefficient (Ambient light scattering intensity on the medium surface); reference contrast (The inherent maximum contrast retention of the medium); luminescence coefficient (Edge light leakage intensity of self-emissive media: 0 for paper / electronic paper, highest for LED).
[0098] The physical size of a single pixel is determined based on the type of display medium, and the visual angle of the pixel and the number of pixels per visual degree are calculated in combination with the viewing distance.
[0099] The steps for calculating the pixel visual angle and the number of pixels per visual degree are as follows: Determine the physical size of a single pixel based on the medium type. For continuous pixel displays (LCD / OLED / electronic paper / paper), the conversion is made using PPI (Pixels Per Inch, representing the pixel density of the display medium):
[0100] =25.4 / PPI;
[0101] For LED dot matrix displays, the pixel pitch (mm) is used directly as... .
[0102] Then the visual angle of a single pixel in front of the viewer is calculated. (Unit: arcminutes) and pixels per visual degree (Pixels Per Degree, the number of pixels per visual angle, used to measure the number of pixels contained within each degree of the viewer's field of view):
[0103] =arctan( / )×3437.75; ;
[0104] in The distance is the viewing distance (in millimeters), and 3437.75 is the conversion constant from radians to minutes. The larger the value, the coarser the individual pixel, and the easier it is to lose details.
[0105] Convert the input visual acuity level into the minimum resolvable angle;
[0106] Visual acuity (visual acuity level) The system will express (logarithmic minimum resolvable angle) the user input. Value converted to minimum resolution angle (cents):
[0107] ;
[0108] 20 / 20 standard visual acuity Centimeters, The larger the value, the worse the eyesight and the lower the ability to distinguish.
[0109] Then, based on the actual rendered font size, the font frame ratio, and the pixel visual angle, the font height visual angle is calculated, and combined with the minimum resolution angle, the reading pressure coefficient is calculated.
[0110] The method for assessing the visual angle and reading pressure of Chinese characters is as follows: Calculate the visual angle of the character height in the current layout and current scenario for the current font size. (Angle fractions), and compared with the Chinese comfortable reading benchmark angle based on visual acuity level:
[0111] ;
[0112] ;
[0113] ;
[0114] in, The 42-minute angle is the baseline angle for comfortable reading, established based on research into visual needs in Chinese reading. (Wang et al.'s research indicates that the threshold for Chinese characters in normal subjects is approximately 7.1 ± 0.9 minutes. The acuity reserve (visual acuity reserve, i.e., the margin between the actual font size and the minimum recognizable threshold, used to ensure visual redundancy for comfortable reading) required for comfortable reading is typically 5-6 times the threshold. This is the font size pressure coefficient; the larger the value, the closer the current font size is to the readability boundary.
[0115] At the same time, a resolution pressure coefficient is introduced:
[0116] ;
[0117] ;
[0118] The proxy value for the number of pixels per visual degree under comfortable viewing conditions. This indicates the current display sampling pressure on reading.
[0119] Based on the minimum resolution angle, the reading pressure coefficient, the feature coefficient, the pixel visual angle, and the environmental glare coefficient in the scene parameters, a joint point spread function width proxy model is constructed to obtain the joint point spread function width;
[0120] The joint point spread function (PSF) surrogate model is a PSF width surrogate model jointly composed of three factors: the eye's optical system, the display medium, and environmental scattering. The visual angular scale blur of each factor is also considered. (Angle fractions) are respectively:
[0121] ;
[0122] ;
[0123] ;
[0124] in, Corresponding to the optical diffusion of the human eye itself (including engineering agents such as pupil diffraction, lens aberration, and retinal scattering), its baseline value of 0.25 arcminutes reflects the minimum PSF width under normal vision, which widens as vision decreases and font pressure increases; Additional diffusion at the edges of corresponding medium pixels; This corresponds to diffusion caused by the superposition of ambient light scattering. Assuming that the three terms are independent and follow a normal distribution, the combined PSF width is synthesized using the root mean square (RMS) formula: ;
[0125] Converted to pixel scale: ;
[0126] The scene degradation parameters are generated based on the number of pixels per visual degree and the width of the joint point spread function.
[0127] To visually represent how much contrast is retained for typographic details at different spatial frequencies in the current scene, we calculate the MTF (Modulation Transfer Function) proxy curve (i.e., the equivalent performance curve simulated using mathematical models or simplified parameters when physical optical systems cannot be directly measured). This includes: calculating the MTF proxy value corresponding to the spatial frequency f (cycles per degree, cpd) based on the frequency domain analytical solution of the Gaussian PSF (i.e., the estimated contrast retention rate of typographic details after visual scene degradation at that spatial frequency, with a value ranging from 0 to 1, the closer to 1, the more complete the detail retention at that frequency), and overlaying the Nyquist sampling constraint.
[0128] ,in The frequency is Nyquist.
[0129] ;
[0130] ;
[0131] It should be noted that, among them, The spatial frequency is the modulation transfer function surrogate value at f, which represents the amplitude attenuation ratio of the frequency component after scene degradation. MTF(30) and MTF(60) serve as key reference points to reflect the retention rates of the intermediate frequency and high frequency, respectively.
[0132] Then, the above visual physical quantities are combined and transformed into four executable image degradation parameters:
[0133] Detail fidelity (resolution resampling factor): ;
[0134] Light diffusion radius (pixels): ;
[0135] Contrast retention factor: ;
[0136] Black position rise: ;
[0137] The above four parameters constitute the scene degradation parameter vector. This is then passed into the subsequent scene simulation image synthesis step.
[0138] S5, taking the baseline rendering image as input, and synthesizing a scene simulation image through multi-step chain image processing according to the scene degradation parameters;
[0139] In one embodiment of this application, step S5 further includes:
[0140] Based on the detail fidelity D_scale in the scene degradation parameters, the baseline rendering image is scaled to a resolution. First, shrink the baseline rendering image to... and
[0141] (in For the logical width of the canvas, For the canvas logical height, A temporary canvas (the product of the detail fidelity (i.e., the resolution resampling factor) is created and then restored to its original size, and so on. (That is, restore the logical width and logical height of the original canvas) to obtain the first intermediate image; it should be noted that high-frequency details are lost due to bilinear interpolation in this process, simulating sampling loss under low PPD or long viewing distance conditions.
[0142] Based on the point spread function width in the scene degradation parameters Apply Gaussian blur to the first intermediate image: if Apply a radius of to the resampled image The pixel-wise Gaussian blur filter simulates the widening effect of the human eye and the medium combined with the PSF on the edges of the characters to obtain the second intermediate image;
[0143] According to the luminescence diffusion radius in the scene degradation parameters Perform light diffusion superposition on the second intermediate image if Furthermore, the medium possesses self-illuminating properties. The blurred image is then overlaid with a wider radius (1.35×) using the multiply blending mode (i.e., a composite image mode that multiplies corresponding pixel values of two layers to achieve the effect of bright areas showing through and dark areas deepening, used to simulate the grayscale filling effect of light diffusion). Gaussian blurring is applied to obtain the third intermediate image. It should be noted that the superposition of light diffusion is used to simulate the gray-scale filling effect caused by the diffusion of light from the edges of strokes to the surroundings in self-emissive media such as OLEDs / LEDs.
[0144] Based on the contrast retention coefficient in the scene degradation parameters and the amount of black position rise Perform brightness remapping on the third intermediate image, assuming the original normalized brightness is... (0 represents black, 1 represents white), the mapping formula is: ;in, v is the brightness value after contrast adjustment; v is the original normalized brightness. This is the contrast retention factor; the formula linearly scales the brightness around 0.5 to simulate the contrast decay effect of the display medium.
[0145] ;
[0146] in, This is the final brightness value after the black level is raised; This is the amount of black level enhancement; the formula enhances the dark areas towards the white area as a whole, simulating the effect of ambient light scattering causing the black levels to become lighter.
[0147] The first step is to compress the contrast ratio with the brightness centered at 0.5. When the dynamic range is less than 1, the second step is to lift the dark areas towards the white areas (simulating ambient light scattering causing blacks to become lighter). Finally... through Then write back the RGB three channels and output the scene simulation image.
[0148] Calculate the brightness difference between the baseline rendered image and the scene simulation image pixel by pixel:
[0149] ;
[0150] ;
[0151] in, Indicates setting The pixel-by-pixel brightness difference is used to quantify the impact of scene degradation on the brightness of that pixel; This represents the brightness value at pixel position (ij) in the baseline rendering image; This represents the brightness value at pixel position (i,j) in the scene simulation image; The difference in brightness at position (i,j) is used to visualize the brightness, where i is the pixel row index and j is the pixel column index. This means that the brightness difference Δ is magnified by a factor of 3 and then inverted and mapped to the [0.1] range. The larger the difference, the more... The closer to 0, the darker the color.
[0152] It should be noted that the darker areas in the difference map represent locations where the difference from the baseline rendering is greater, visually reflecting the distribution of the impact of scene degradation on the layout. The scene simulation image results are cached. This process generates the scene simulation image.
[0153] S6, sample the grayscale density distribution of the baseline rendering image, the scene simulation image and the character layout information at multiple semantic levels to obtain the density matrix and the character-level density;
[0154] In one embodiment of this application, step S6 further includes:
[0155] The baseline rendered image and the scene simulation image are respectively converted into grayscale density measures;
[0156] Specifically, for any pixel in the image Define ink coverage for:
[0157] ;
[0158] in, The horizontal coordinates of the pixels. Here are the vertical coordinates of the pixel; R, G, and B are the red, green, and blue channel component values of the pixel, respectively, with values ranging from 0 to 255; this formula converts RGB color information into a normalized grayscale density measure; it should be noted that the ink coverage rate is the grayscale density measure value at the pixel location.
[0159] White background (255,255,255) corresponds to =0, pure black (0,0,0) corresponds to =1. This definition converts an RGB image into a normalized grayscale density measure.
[0160] The sampling grid size is determined based on the sampling parameters and the layout parameters. The average gray density within each sampling grid is calculated using the sampling grid as a unit, and the density matrix is generated by the gray density metric.
[0161] Specifically, based on the sampling coefficient Calculate the sample grid size using the character layout parameters:
[0162] ; ;
[0163] ; ;
[0164] in, This indicates the sampling grid width, which is the number of horizontal pixels in a single grayscale sampling grid. This represents the sampling grid height, which is the vertical number of pixels in a single grayscale sampling grid. This indicates the number of sampling columns, that is, the total number of sampling cells in the horizontal direction; This indicates the number of sampling rows, that is, the total number of sampling cells in the vertical direction.
[0165] For each sampling grid (i.e., located at the ) line, number (The column's sampling grid cells) are used to traverse all physical pixels within their coverage area and calculate the average ink coverage: Output density matrix , where each element This represents the average grayscale density of the sampled grid. This sampling is performed on both the baseline rendered image and the scene simulation image to obtain the results. and ,in This is the density matrix obtained after sampling the baseline rendered image. This is the density matrix obtained after sampling the scene simulation graph.
[0166] In this embodiment, an additional fine sampling is performed on the main font, and the sampling coefficients are compressed to:
[0167] ;
[0168] ;
[0169] in, These are fine-grained lateral sampling coefficients used for higher-resolution local density sampling on the main font. These are fine-grained vertical sampling coefficients used for higher-resolution local density sampling on the main font.
[0170] By providing each character with a local density background of approximately 10×10, a higher resolution density field is provided for subsequent local hotspot analysis.
[0171] Traverse the character slots in the character layout information, calculate the average gray density in the image area corresponding to each character slot, and generate the character-level density.
[0172] Specifically, iterate through each character slot in the character layout array `placements`. Calculate the average ink coverage within the corresponding image area:
[0173] ;
[0174] Obtain the bit-level density array This step is a crucial foundation that distinguishes the system from ordinary image heatmap analysis. The system can not only identify the grayscale distribution characteristics of the entire object, but also make refined judgments on the relative grayscale, structural density, and feature outlier characteristics of individual characters.
[0175] To eliminate the masking effect of global density features on individual character structure differences and accurately locate visual faults, positional outlier detection is also required. The steps are as follows: calculate the mean of positional density. with standard deviation :
[0176] ;
[0177] ;
[0178] This is used to identify high-density outlier characters (hot characters) and low-density outlier characters (cold characters):
[0179] ;
[0180] ;
[0181] It should be noted that, among them The hot character set is a set of characters with a gray density significantly higher than the average level, representing characters with dense strokes and visual emphasis; This is a set of cold characters, which are characters with a density and gray level significantly lower than the average level. They represent characters with sparse strokes and a lighter visual appearance.
[0182] When a user selects a character card, the system reads the compact bounding box of that character. The system simultaneously crops the original rendered image, scene simulation image, and difference image using a "proportional scaling + white space filling" method to prevent local characters from being horizontally flattened or vertically elongated. The difference interpretation panel categorizes local changes into four types: clustering and darkening (stroke areas become darker), white gap contraction (white gaps become narrower), detail fading (contrast loss in fine strokes), and intersection crowding (blending of dense edge areas), and outputs the percentage of changed pixels, average absolute difference, average signed difference, and the percentage of each category.
[0183] S7. Based on the density matrix and the character-level density, calculate the statistical index chain of the typesetting grayscale field;
[0184] In one embodiment of this application, step S7 further includes:
[0185] Calculate global statistics based on the density matrix. The global statistics include average gray density, gray dispersion, and coefficient of variation.
[0186] ;
[0187] ;
[0188] ;
[0189] in, The average gray density, This refers to the dispersion (the intensity of grayscale fluctuations). The coefficient of variation (normalizing the dispersion makes it easier to compare fluctuations under different average density conditions).
[0190] Then, the row density fluctuation and column density fluctuation are calculated based on the density matrix.
[0191] Row / column density fluctuations:
[0192] ;
[0193] ;
[0194] ;
[0195] in, Indicates the first The row average density is the average gray value of all sampled cells in the r-th row of the density matrix; Indicates the first The column mean density is the average gray value of all sampled cells in the c-th column of the density matrix; It represents the standard deviation of the average density sequence for each row, and measures the intensity of fluctuations in grayscale between rows; It represents the standard deviation of the average density sequence of each column, and measures the intensity of the fluctuation of gray level between columns.
[0196] It should be noted that, in this embodiment, the directional fluctuation... This reveals the vertical density fluctuations (inter-row grayscale differences) and column-wise fluctuations in the typography. Reveals lateral density fluctuations. This is simultaneously plotted as a line chart in the visualization, with a dashed mean line providing an overall reference level.
[0197] Calculate the gray-level frequency distribution and information entropy based on the density matrix;
[0198] ;
[0199] ;
[0200] ;
[0201] in, The total number of bins in the grayscale histogram, that is, dividing the grayscale value range equally into... The intervals are used for frequency statistics; Indicates the first The count value of each bin is used to count the number of density matrix elements falling into that interval; For the first Each grayscale binning interval. The frequency of the kth sub-bin is the proportion of the number of sampling cells in this grayscale range to the total number of sampling cells.
[0202] The histogram (hist) reflects the range of density values; the information entropy (H) represents the degree of dispersion of the distribution. High entropy does not necessarily mean "better," it only indicates that the distribution is more dispersed, and it needs to be judged in conjunction with the CV (coefficient of variation) and the mean.
[0203] The above metrics were calculated for both baseline rendering and scene simulation to obtain baseline statistical metrics and simulation statistical metrics. , The changes in the layout and amplitude reveal the systematic impact of scene degradation on the grayscale field of the typesetting.
[0204] S8, taking the scene degradation parameters and the statistical indicator chain as input, and generating an objective diagnostic report using a preset rule template.
[0205] In one embodiment of this application, step S8 further includes:
[0206] Based on the scene degradation parameters and the statistical indicator chain, output scene location description, degradation link description and grayscale field change diagnosis;
[0207] Output the pixel view angle of the current scene ppd, text height, visual angle The relationship with the 42-minute reference point determines whether the current position is within the comfort zone. (or restricted area)
[0208] List the resolution resampling factor PSF blur Light diffusion Maintaining contrast Four parameters explain the structure of the simulated link.
[0209] Compare (The ratio of the baseline average density to the simulated average density is used to determine whether scene degradation causes the overall grayscale of the layout to "darken" (i.e., become darker) or "lighten" (i.e. become lighter). (The ratio of the baseline coefficient of variation to the simulated coefficient of variation is used to determine whether scene degradation amplifies or compresses grayscale fluctuations.)
[0210] The frequency stress status of the current scene is determined based on a preset frequency threshold, and corresponding warnings are output.
[0211] The light diffusion state of the current medium is determined based on the preset light diffusion threshold, and a corresponding prompt is output.
[0212] like The output shows a warning that the Nyquist limit is lower than 20 / 20, which is the commonly used 30cpd reference. This indicates that the fine strokes, sharp corners, and narrow white mouths of complex Chinese characters will be compressed first.
[0213] like The output medium has a high light diffusion rate, suggesting that you should pay more attention to the local white space and the spacing between strokes rather than simply pursuing a full character surface.
[0214] This report is generated from a rule template, and its output is stable, reproducible, and controllable. It does not rely on a natural language model and will not change its technical judgment due to random fluctuations.
[0215] In one embodiment of this application, the method further includes:
[0216] The first activated font is used as the master font, and a complete analysis of all steps is performed; the remaining activated fonts are used as slave fonts, and only a lightweight comparison path of basic density matrix and positional density sampling is performed; under the same typesetting conditions and scene parameters, density heatmaps and core comparison indicators are output side by side for all activated fonts.
[0217] When the font collection is activated The system performs multi-font side-by-side analysis. To balance depth and performance, a master-slave analysis strategy is adopted: the first activated font is designated as the "master font," and all five levels of fine sampling (including fine density matrix, bit-level sampling, outlier detection, difference interpretation panel, and objective report) are performed in steps S2-S8. The remaining fonts are designated as "slave fonts," and only lightweight paths such as normalization, scene simulation, standard density matrix, and bit-level density are performed, retaining core comparison metrics but skipping fine sampling and diagnostic reports.
[0218] Under the same typesetting conditions and scene parameters, output density heatmaps for all active fonts. Compared with CV, it makes it easier for designers to compare the differences in grayscale performance of different fonts in the same layout.
[0219] Independent cache pools are maintained for rendering results, literal ratio estimation, and scene simulation results (faceRatioCache for literal ratio estimation results, renderCache for baseline rendering results, and postCache for scene simulation results). These cache pools are cleared entirely when their capacity exceeds the limit. During analysis, an analysisToken (a unique token identifying the current analysis task; old tokens automatically become invalid when a new task starts, interrupting the old task) mechanism supports interrupting old tasks. Browser control is returned using sleepFrame() (a frame-by-frame sleep function that actively relinquishes execution during each frame's rendering interval) / sleepIdle() (an idle sleep function that returns control during browser downtime) to avoid prolonged blocking. A phased progress bar provides feedback on the analysis progress.
[0220] Furthermore, this application also includes a grayscale field quantization analysis system for Chinese character typesetting, which is implemented based on the aforementioned grayscale field quantization analysis method for Chinese character typesetting. The system includes visualization and interaction: based on all results from S2 to S9, a layered result panel is constructed in the visualization interface, specifically including:
[0221] The L1 panel displays the original render and the compensated render side-by-side, showing the text frame ratio. With compensation coefficient ;
[0222] L2 panel: Displays scene parameter card group ( ppd , , , ), comparison between baseline image and scene simulation image, difference map and MTF proxy curve;
[0223] L3 panel: Standard density heatmap, fine density heatmap, pixel-level grayscale density bands (including high outlier and low outlier markers), local hotspot magnified triptych, and difference interpretation panel;
[0224] L4 Panel: KPI Card Set ( , , , , , ), row and column fluctuation line charts, and grayscale frequency distribution histograms;
[0225] L5 panel: Objective report text panel;
[0226] Multi-font side-by-side comparison panel: Displayed when more than 1 fonts are active, showing the density heatmap and core metrics of all fonts side-by-side in a grid of cards.
[0227] A computer execution device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of a grayscale field quantization analysis method for Chinese character typesetting.
[0228] In the description of this specification, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0229] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0230] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.
Claims
1. A grayscale field quantization analysis method for Chinese character typesetting, characterized in that, Includes the following steps: S1. Obtain at least one font resource and the typesetting text to be analyzed, and initialize the global analysis configuration parameters, which include typesetting parameters, normalization switch, scene parameters and sampling parameters. S2, based on the font resources and the layout parameters, perform character frame ratio estimation for each font resource, and compensate the target font size in the layout parameters according to the estimation results to obtain the compensated actual rendered font size; S3. Based on the compensated actual rendered font size and the layout parameters, perform layout rendering on the text to be analyzed after blank cleaning to obtain a baseline rendering image and record the layout information of each rendered character. S4. Based on the scene parameters, the actual rendered font size, and the font frame ratio, construct a visual scene physical model, and generate a set of scene degradation parameters based on the visual scene physical model. Step S4 further includes: Obtain the corresponding feature coefficients based on the preset display medium type; The physical size of a single pixel is determined based on the type of display medium, and the visual angle of the pixel and the number of pixels per visual degree are calculated in combination with the viewing distance. Convert the input visual acuity level into the minimum resolvable angle; Based on the actual rendered font size, the font frame ratio, and the pixel visual angle, the font height visual angle is calculated, and combined with the minimum resolution angle, the reading pressure coefficient is calculated. Based on the minimum resolution angle, the reading pressure coefficient, the feature coefficient, the pixel visual angle, and the environmental glare coefficient in the scene parameters, a joint point spread function width proxy model is constructed to obtain the joint point spread function width; The scene degradation parameters are generated based on the number of pixels per visual degree and the width of the joint point spread function; S5, taking the baseline rendering image as input, and synthesizing a scene simulation image through multi-step chain image processing according to the scene degradation parameters; S6, sample the grayscale density distribution of the baseline rendering image, the scene simulation image and the character layout information at multiple semantic levels to obtain the density matrix and the character-level density; S7. Based on the density matrix and the character-level density, calculate the statistical index chain of the typesetting grayscale field; S8, taking the scene degradation parameters and the statistical indicator chain as input, and generating an objective diagnostic report using a preset rule template.
2. The grayscale field quantization analysis method for Chinese character typesetting according to claim 1, characterized in that, Step S2 further includes: Select a set of representative sample characters for drawing, and calculate the vertical range of the characters based on the drawing results; When the normalization switch is true, a compensation coefficient is calculated based on the ratio of the preset target character size to the character frame size, and the target font size in the typesetting parameters is compensated to obtain the actual rendered font size.
3. The grayscale field quantization analysis method for Chinese character typesetting according to claim 1, characterized in that, Step S5 further includes: Based on the detail fidelity in the scene degradation parameters, the baseline rendering image is scaled to obtain a first intermediate image. Based on the point spread function width in the scene degradation parameters, Gaussian blur is applied to the first intermediate image to obtain the second intermediate image; Based on the emission diffusion radius in the scene degradation parameters, the second intermediate image is subjected to emission diffusion superposition to obtain the third intermediate image; Based on the contrast preservation coefficient and black level enhancement in the scene degradation parameters, luminance remapping is performed on the third intermediate image to generate the scene simulation image.
4. The grayscale field quantization analysis method for Chinese character typesetting according to claim 1, characterized in that, Step S6 further includes: The baseline rendered image and the scene simulation image are respectively converted into grayscale density measures; The sampling grid size is determined based on the sampling parameters and the layout parameters. The average gray density within each sampling grid is calculated using the sampling grid as a unit, and the density matrix is generated by the gray density metric. Traverse the character slots in the character layout information, calculate the average gray density in the image area corresponding to each character slot, and generate the character-level density.
5. The grayscale field quantization analysis method for Chinese character typesetting according to claim 1, characterized in that, Step S7 further includes: Calculate global statistics based on the density matrix. The global statistics include average gray density, gray dispersion, and coefficient of variation. Calculate the row-direction density fluctuation and column-direction density fluctuation based on the density matrix; Calculate the gray-level frequency distribution and information entropy based on the density matrix; The above indicators were calculated for both the baseline rendering and the scene simulation to obtain the baseline statistical indicators and the simulation statistical indicators.
6. The grayscale field quantization analysis method for Chinese character typesetting according to claim 1, characterized in that, Step S8 further includes: Based on the scene degradation parameters and the statistical indicator chain, output scene location description, degradation link description and grayscale field change diagnosis; The frequency stress status of the current scene is determined based on a preset frequency threshold, and corresponding warnings are output. The light diffusion state of the current medium is determined based on the preset light diffusion threshold, and a corresponding prompt is output.
7. The grayscale field quantization analysis method for Chinese character typesetting according to claim 1, characterized in that, The method further includes: The first activated font is used as the master font, and a complete analysis of all steps is performed. The remaining activated fonts are used as slave fonts, and only a lightweight comparison path of basic density matrix and positional density sampling is performed. Under the same typesetting conditions and scene parameters, density heatmaps and core comparison indicators are output side by side for all activated fonts.
8. A grayscale field quantization analysis system for Chinese character typesetting, characterized in that, It is implemented based on the grayscale field quantization analysis method for Chinese character typesetting as described in any one of claims 1-7.
9. A computer execution device, comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, it implements the steps of the grayscale field quantization analysis method for Chinese character typesetting as described in any one of claims 1-7.