Web page image loading method and terminal device

By acquiring and merging pixels of images in web pages, and merging adjacent pixels according to quality control parameter values, the problem of slow loading speed caused by high-definition images is solved, and the loading and access speed of web pages is improved.

CN109783746BActive Publication Date: 2024-10-18PING AN TECH (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201811529039.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-12-14
Publication Date
2024-10-18
Estimated Expiration
2038-12-14

AI Technical Summary

Technical Problem

Because high-definition images have higher resolutions, web pages load slower when loading images with higher resolutions, resulting in reduced loading and access speeds of web pages.

Method used

By obtaining the image to be loaded in the web page, converting it into the second format, obtaining the position and color value of each pixel, determining the number of pixels to be merged based on the preset quality control parameter value and the total number of pixels, and Merge adjacent pixels to obtain the merged image, then convert it back to the first format and load it.

Benefits of technology

The resolution of the images to be loaded in the webpage is reduced, thereby improving the loading speed and access speed of webpages with images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN109783746B_ABST
    Figure CN109783746B_ABST
Patent Text Reader

Abstract

The present invention is applicable to the field of image processing technology, and provides a web page image loading method and terminal equipment, the method comprising: obtaining an image of a first format to be loaded in a web page, and converting the image of the first format into an image of a second format; obtaining the position and color value of each pixel point in the image of the second format and the total number of pixels of the image of the second format; determining the number of pixels to be merged in the image of the second format according to a preset quality control parameter value and the total number of pixels; merging adjacent pixels in the image of the second format according to the number of pixels to be merged, the position and color value of each pixel point, to obtain a merged image; converting the merged image from the second format into the first format, and loading the merged image converted into the first format in the web page, which can reduce the resolution of the image to be loaded in the web page, thereby improving the loading speed and access speed of the web page with the image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of image processing technology, and in particular relates to a web page image loading method and terminal device. Background Art

[0002] With the continuous development of computer technology and the needs of different websites, many web pages often insert a large number of images in order to explain a certain thing, enrich the content of the web page, or make the web page more beautiful.

[0003] Currently, in order to ensure image clarity, web pages usually directly insert high-resolution or ultra-high-resolution images. However, because high-resolution images have a higher resolution, web pages load images more slowly, resulting in reduced page loading and access speeds. Summary of the Invention

[0004] This invention provides a webpage image loading method and terminal device to solve the problem in the prior art where webpages load images with high resolution slowly, resulting in reduced loading and access speeds.

[0005] A first aspect of this invention provides a webpage image loading method, comprising:

[0006] Get the first format image to be loaded from the webpage, and convert the first format image into a second format image;

[0007] Get the position and color value of each pixel in the second format image, as well as the total number of pixels in the second format image;

[0008] The number of pixels to be merged in the second format image is determined based on the preset quality control parameter values ​​and the total number of pixels.

[0009] The second-format image is merged by combining adjacent pixels based on the number of pixels to be merged, the position of each pixel, and its color value, to obtain the merged image.

[0010] The merged image is converted from the second format to the first format, and then the merged image converted to the first format is loaded into the webpage.

[0011] A second aspect of this invention provides a webpage image loading system, comprising:

[0012] The image acquisition module is used to acquire images in the first format to be loaded on the webpage and convert the first format images into second format images;

[0013] The parameter acquisition module is used to obtain the position and color value of each pixel in the second format image, as well as the total number of pixels in the second format image;

[0014] The pixel-to-be-merged determination module is used to determine the number of pixels to be merged in the second-format image based on preset quality control parameter values ​​and the total number of pixels.

[0015] The merging module is used to merge adjacent pixels in a second-format image based on the number of pixels to be merged, the position of each pixel, and its color value, to obtain the merged image.

[0016] The image loading module is used to convert the merged image from the second format to the first format and load the merged image converted to the first format into the webpage.

[0017] A third aspect of the present invention provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it performs the following steps:

[0018] Get the first format image to be loaded from the webpage, and convert the first format image into a second format image;

[0019] Get the position and color value of each pixel in the second format image, as well as the total number of pixels in the second format image;

[0020] The number of pixels to be merged in the second format image is determined based on the preset quality control parameter values ​​and the total number of pixels.

[0021] The second-format image is merged by combining adjacent pixels based on the number of pixels to be merged, the position of each pixel, and its color value, to obtain the merged image.

[0022] The merged image is converted from the second format to the first format, and then the merged image converted to the first format is loaded into the webpage.

[0023] A fourth aspect of the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the webpage image loading method as described in the first aspect.

[0024] The beneficial effects of the embodiments of the present invention compared with the prior art are as follows: The webpage image loading method and terminal device provided by the embodiments of the present invention determine the number of pixels to be merged according to preset quality control parameters and the total number of pixels, merge adjacent pixels in the second format image according to the number of pixels to be merged, the position and color value of each pixel, to obtain the merged image, and load the merged image converted to the first format on the webpage. This can solve the problem in the prior art that, due to the high resolution of high-resolution images, the webpage loads slowly when loading high-resolution images, resulting in reduced webpage loading and access speeds. The present invention can reduce the resolution of the images to be loaded on the webpage, thereby improving the loading and access speeds of webpages with images. Attached Figure Description

[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0026] Figure 1 This is a schematic flowchart of a webpage image loading method provided in an embodiment of the present invention;

[0027] Figure 2 This is a schematic flowchart of a webpage image loading method provided in another embodiment of the present invention;

[0028] Figure 3 This is a schematic flowchart of a webpage image loading method provided in another embodiment of the present invention;

[0029] Figure 4 This is a schematic flowchart of a webpage image loading method provided in another embodiment of the present invention;

[0030] Figure 5 This is a schematic diagram of the structure of a webpage image loading system provided in an embodiment of the present invention;

[0031] Figure 6 This is a schematic diagram of the structure of a terminal device provided in an embodiment of the present invention. Detailed Implementation

[0032] In the following description, specific details such as particular system structures and techniques are provided for purposes of illustration, not limitation, to facilitate a thorough understanding of the embodiments of the present invention. However, it will be apparent to those skilled in the art that the present invention may be practiced in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.

[0033] In order to illustrate the technical solution of the present invention, specific embodiments are provided below.

[0034] See also Figure 1 , Figure 1 This is a schematic flowchart illustrating a webpage image loading method according to an embodiment of the present invention. Figure 1 As shown, in this embodiment, the webpage image loading method may include the following steps:

[0035] S101: Obtain the first format image to be loaded from the webpage, and convert the first format image into a second format image.

[0036] The first image format can be any image format such as JPG, JPEG, PNG, or BMP. The second image format can be a canvas image, which is an HTML image.

[0037] Converting an image in the first format to the second format can be done using JavaScript. Specifically, create a canvas, initialize a JavaScript Image object, read the image in the first format, and use the canvas's Application Programming Interface (API) to draw the Image object onto the canvas, thus obtaining the image in the second format.

[0038] S102: Obtain the position and color value of each pixel in the second format image, as well as the total number of pixels in the second format image.

[0039] In this embodiment of the invention, the getImageData method provided by canvas can be used to obtain the position and color value of each pixel in the second format image, and the total number of pixels in the second format image can be obtained by counting all the pixels.

[0040] The color value is the color value in the RGB color mode, which can be represented by three numbers: Red (R), Green (G), and Blue (B), all of which range from 0 to 255.

[0041] S103: Determine the number of pixels to be merged in the second format image based on the preset quality control parameter values ​​and the total number of pixels.

[0042] The preset quality control parameter value represents the webpage's requirement for image clarity and can be represented by a decimal greater than 0 and less than or equal to 1. A higher preset quality control parameter value indicates a higher requirement for image clarity. If the preset quality control parameter value is 1, then no processing is required for the first-format image, and the first-format image is loaded directly.

[0043] The formula for determining the number of pixels to be merged in the second-format image based on the preset quality control parameter values ​​and the total number of pixels is as follows:

[0044] N = M × (1 - K) (1)

[0045] In equation (1), N is the number of pixels to be merged, M is the total number of pixels, and K is the preset quality control parameter value.

[0046] For example, assuming the total number of pixels is 10,000 and the preset quality control parameter value is 0.6, the number of pixels to be merged is 10,000 × (1 - 0.6) = 4,000.

[0047] S104: Merge adjacent pixels in the second format image according to the number of pixels to be merged, the position of each pixel, and the color value, to obtain the merged image.

[0048] Merging adjacent pixels in the second format image refers to adjusting the color values ​​of adjacent pixels to the same color value, which can be a color value determined based on the color value of each pixel in the adjacent pixel.

[0049] In this embodiment of the invention, adjacent pixels with similar color values ​​can be determined based on the position and color value of each pixel. Then, the number of adjacent pixels equal to the number to be merged is merged to obtain a merged image. The merged image meets the requirements of preset image quality control parameters.

[0050] S105: Convert the merged image from the second format to the first format, and load the merged image converted to the first format into the webpage.

[0051] In this embodiment of the invention, the API interfaces provided by canvas, such as saveAsPNG, saveAsJPEG, saveAsBMP, etc., can be used to convert the merged image from the second format to the first format.

[0052] As described above, the webpage image loading method of this invention determines the number of pixels to be merged based on preset quality control parameters and the total number of pixels. It then merges adjacent pixels in a second-format image based on the number of pixels to be merged, the position of each pixel, and its color value, resulting in a merged image. This merged image, converted to a first-format image, is then loaded onto the webpage. This method solves the problem in the prior art where high-resolution images are slow to load, leading to reduced loading and access speeds. By reducing the resolution of the images to be loaded on the webpage, the loading and access speeds of webpages containing images are improved.

[0053] Please see Figure 2 , Figure 2 This is a schematic flowchart illustrating a webpage image loading method according to another embodiment of the present invention. Based on the above embodiment, step S104 is described in detail below:

[0054] S201: Determine the proportion of pixels to be merged to the total number of pixels, and determine the preset color difference threshold corresponding to the proportion of pixels to be merged to the total number of pixels.

[0055] In this embodiment of the invention, the proportion of pixels to be merged to the total number of pixels is determined based on the number of pixels to be merged and the total number of pixels, or based on a preset quality control parameter value. Furthermore, the terminal device stores a pre-defined correspondence between proportions and thresholds; based on this correspondence, a preset color difference threshold corresponding to the proportion of pixels to be merged to the total number of pixels can be determined.

[0056] S202: Calculate the color value difference between adjacent pixels based on the position and color value of each pixel.

[0057] The formula for calculating the color value difference between adjacent pixels is as follows:

[0058]

[0059] In equation (2), ΔD is the color value difference between adjacent pixels, which includes the first pixel and the second pixel; r1 is the R value of the first pixel; g1 is the G value of the first pixel; b1 is the B value of the first pixel; r2 is the R value of the second pixel; g2 is the G value of the second pixel; b2 is the B value of the second pixel; ω r The first weighting coefficient can be 3, ω g The second weighting coefficient can be 4, ω b This is the third weighting coefficient, and it can take the value 2.

[0060] In this embodiment of the invention, adjacent pixels can be determined based on the position of each pixel, and the color value difference between adjacent pixels can be calculated based on the color value of each pixel in the adjacent pixels.

[0061] S203: If there are adjacent target pixels in the second format image, merge the adjacent target pixels to obtain an intermediate image, and the color value difference between the adjacent target pixels is less than or equal to the preset color difference threshold.

[0062] In this embodiment of the invention, adjacent pixels with a color value difference less than or equal to a preset color difference threshold are referred to as target adjacent pixels.

[0063] If there are adjacent pixels to the target in the second format image, then the adjacent pixels to the target are merged, that is, the color value of each pixel in the adjacent pixels to the same color value is adjusted to obtain the intermediate image.

[0064] S204: If the number of adjacent pixels of the target that have been merged is less than the number of pixels to be merged, then determine the number of pixels that still need to be merged in the intermediate image.

[0065] If the number of target adjacent pixels to be merged in step S203 is less than the number of pixels to be merged, then the number of pixels that still need to be merged in the intermediate image is determined based on the number of pixels to be merged and the number of target adjacent pixels that have already been merged. That is, the number of pixels to be merged minus the number of target adjacent pixels that have already been merged gives the number of pixels that still need to be merged.

[0066] If the number of adjacent pixels of the target that have been merged is equal to the number of pixels to be merged, then the intermediate image is the merged image, and step S205 does not need to be executed.

[0067] S205: Merge adjacent color blocks in the intermediate image according to the number of pixels that still need to be merged, and obtain the merged image. Adjacent pixels with the same color value are called a color block.

[0068] In this context, adjacent pixels with the same color value are called a color block. If the color value of a pixel is different from that of all its adjacent pixels, then that pixel can also be called a color block. If the color value of a pixel is the same as that of its two adjacent pixels or its multiple adjacent pixels, then that pixel and its two adjacent pixels are called a color block, or that pixel and its multiple adjacent pixels are called a color block.

[0069] Calculate the color value difference between adjacent color blocks in the intermediate image, and merge adjacent color blocks with the same number of pixels that still need to be merged based on the color value difference, to obtain the merged image.

[0070] As described above, the webpage image loading method of this embodiment first determines a preset color difference threshold corresponding to the proportion of pixels to be merged to the total number of pixels. Then, it determines target adjacent pixels based on the preset color difference threshold and the position and color value of each pixel, and merges the target adjacent pixels to obtain an intermediate image. Finally, it merges adjacent color blocks of the intermediate image based on the number of pixels that still need to be merged to obtain the merged image. By merging twice, the loading speed and access speed of the webpage can be improved while ensuring that the image is not distorted.

[0071] In one embodiment of the present invention, based on the above embodiments, step S205 may include:

[0072] Calculate the color value difference between adjacent color blocks in the middle image based on the position and color value of each color block in the middle image.

[0073] The merged image is obtained by merging adjacent color blocks in the middle image according to the order of their color value difference from smallest to largest, and merging adjacent color blocks with the same number of adjacent pixels that still need to be merged.

[0074] In this embodiment of the invention, the color value difference between adjacent color blocks in the intermediate image can be calculated according to formula (2). When formula (2) is used to calculate the color value difference between adjacent color blocks, ΔD is the color value difference between adjacent color blocks, the adjacent color blocks include the first color block and the second color block, r1 is the R value of the first color block, g1 is the G value of the first color block, b1 is the B value of the first color block, r2 is the R value of the second color block, g2 is the G value of the second color block, b2 is the B value of the second color block, ω r The first weighting coefficient can be 3, ω g The second weighting coefficient can be 4, ω b This is the third weighting coefficient, which can be 2. Adjacent color blocks are determined based on the position of each color block, and the color value difference between adjacent color blocks is calculated based on the color value of each color block within those adjacent color blocks. The position of each color block can be determined based on the position of each pixel before merging.

[0075] Sort the color value differences of adjacent color blocks in ascending order, and start merging the adjacent color blocks with the smallest color value difference until the number of merged adjacent color blocks is the same as the number of adjacent pixels that still need to be merged, and obtain the merged image.

[0076] Merging adjacent color blocks refers to adjusting the color value of each color block in an adjacent color block to the same color value. This same color value is determined based on the color values ​​of each color block in the adjacent color block. For example, the average of the R, G, and B values ​​corresponding to each color block in an adjacent color block can be used to obtain a new R value, a new G value, and a new B value. The new R value, the new G value, and the new B value are the same color value.

[0077] As can be seen from the above description, the webpage image loading method of this embodiment merges adjacent color blocks in the intermediate image in ascending order of color value difference, and merges adjacent color blocks with the same number of adjacent pixels that still need to be merged, to obtain the merged image. It can merge adjacent color blocks with similar color value differences, thereby reducing the image clarity while ensuring that the image is not distorted as much as possible.

[0078] Please see Figure 3 , Figure 3 This is a schematic flowchart illustrating a webpage image loading method according to another embodiment of the present invention. Based on the above embodiment, step S201 is described in detail below;

[0079] S301: Determine the proportion of pixels to be merged to the total number of pixels based on the number of pixels to be merged and the total number of pixels; or, determine the proportion of pixels to be merged to the total number of pixels based on preset quality control parameter values.

[0080] In this embodiment of the invention, the proportion of pixels to be merged to the total number of pixels can be determined based on the number of pixels to be merged and the total number of pixels, i.e., the proportion of pixels to be merged to the total number of pixels = the number of pixels to be merged / the total number of pixels; or the proportion of pixels to be merged to the total number of pixels can be determined based on a preset quality control parameter value, i.e., the proportion of pixels to be merged to the total number of pixels = 1 - the preset quality control parameter value.

[0081] S302: Based on the pre-stored correspondence between the ratio and the threshold, determine the preset color difference threshold corresponding to the ratio of the pixels to be merged to the total number of pixels.

[0082] In this embodiment of the invention, a correspondence between a ratio and a threshold can be preset and stored in advance. For example, the correspondence between the ratio and the threshold can be shown in Table 1.

[0083] Table 1. Correspondence between ratio and threshold

[0084] The proportion x (0 ≤ x < 1) Threshold 0≤x<10% First threshold 10%≤x<20% Second threshold 20%≤x<30% Third threshold 30%≤x<40% Fourth threshold 40%≤x<50% Fifth threshold 50%≤x<60% Sixth threshold 60%≤x<70% Seventh threshold 70%≤x<80% Eighth threshold 80%≤x<90% Ninth threshold 90%≤x<1 Tenth threshold

[0085] In Table 1, the threshold corresponding to each ratio range can be determined through multiple experiments, so that when the ratio takes the minimum value within the range, the number of merged pixels determined according to the threshold does not exceed the number of pixels to be merged.

[0086] Based on the correspondence between the proportions and thresholds shown in Table 1, the preset color difference threshold corresponding to the proportion of pixels to be merged to the total number of pixels can be determined. For example, assuming that the proportion of pixels to be merged to the total number of pixels is 40%, the preset color difference threshold is the fifth threshold.

[0087] In one embodiment of the present invention, based on the above embodiments, step S203 may further include:

[0088] The intermediate color value is determined based on the color value of each pixel in the target's adjacent pixels.

[0089] Adjust the color value of each pixel in the target's adjacent pixels to the median color value.

[0090] In this embodiment of the invention, when merging target adjacent pixels, an intermediate color value is first determined based on the color value of each pixel in the target adjacent pixels, and then the color value of each pixel in the target adjacent pixels is adjusted to the intermediate color value.

[0091] Among them, the R value of the intermediate color value is the average of the R values ​​of each pixel in the target's neighboring pixels, the G value of the intermediate color value is the average of the G values ​​of each pixel in the target's neighboring pixels, and the B value of the intermediate color value is the average of the B values ​​of each pixel in the target's neighboring pixels.

[0092] See also Figure 4 , Figure 4 This is a schematic flowchart illustrating a webpage image loading method according to another embodiment of the present invention. Based on the above embodiment, after step S104, the following steps may be further included:

[0093] S401: Calculate the color value difference between adjacent color blocks in the merged image based on the position and color value of each color block in the merged image. Adjacent pixels with the same color value are called a color block.

[0094] The definition of the color block is the same as that in step S205, and will not be repeated here.

[0095] In this embodiment of the invention, the color value difference of adjacent color blocks in the merged image can be calculated according to formula (2), which is similar to the calculation of the color value difference of adjacent color blocks in the intermediate image, and will not be repeated here.

[0096] S402: If there are adjacent color blocks in the merged image, merge the adjacent color blocks to obtain a color block image, and the color value difference between the adjacent color blocks is less than a preset threshold.

[0097] In this embodiment of the invention, adjacent color blocks with a color value difference less than a preset threshold are referred to as target adjacent color blocks, wherein the preset threshold can be set according to actual needs. The image after merging the target adjacent color blocks is referred to as a color block image.

[0098] Merging adjacent color blocks refers to adjusting the color value of each color block in the target adjacent color block to the same color value. This same color value is determined based on the color value of each color block in the target adjacent color block. For example, the average value of the R value, G value, and B value corresponding to each color block in the target adjacent color block can be used to obtain a new R value, a new G value, and a new B value. The new R value, the new G value, and the new B value are the same color value.

[0099] S403: Convert the color block image from the second format to the first format and load the converted color block image into the webpage.

[0100] In this embodiment of the invention, API interfaces provided by canvas, such as saveAsPNG, saveAsJPEG, saveAsBMP, etc., can be used to convert the color block image from the second format to the first format.

[0101] As can be seen from the above description, the webpage image loading method of this invention calculates the color value difference between adjacent color blocks in the merged image, determines the target adjacent color block based on the color value difference between adjacent color blocks, and merges the target adjacent color blocks to generate a color block image. In some scenarios, the image is presented in the form of a color block image, which is more expressive.

[0102] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0103] Corresponding to the webpage image loading method described in the above embodiments, Figure 5 A schematic diagram of a webpage image loading system provided by an embodiment of the present invention is shown. For ease of explanation, only the parts relevant to this embodiment are shown.

[0104] In one embodiment of the present invention, a webpage image loading system may include:

[0105] Image acquisition module 501 is used to acquire images in a first format to be loaded on a webpage and convert the first format images into second format images;

[0106] The parameter acquisition module 502 is used to acquire the position and color value of each pixel in the second format image and the total number of pixels in the second format image;

[0107] The pixel-to-be-merged determination module 503 is used to determine the number of pixels to be merged in the second format image based on preset quality control parameter values ​​and the total number of pixels.

[0108] The merging module 504 is used to merge adjacent pixels in a second-format image based on the number of pixels to be merged, the position of each pixel, and the color value of each pixel, to obtain the merged image.

[0109] Image loading module 505 is used to convert the merged image from the second format to the first format and load the merged image converted to the first format into the webpage.

[0110] In one embodiment of the present invention, the merging module 504 may include:

[0111] The preset color difference threshold determination unit is used to determine the proportion of pixels to be merged to the total number of pixels, and to determine the preset color difference threshold corresponding to the proportion of pixels to be merged to the total number of pixels.

[0112] The color value difference calculation unit is used to calculate the color value difference between adjacent pixels based on the position and color value of each pixel.

[0113] The target adjacent pixel merging unit is used to merge the target adjacent pixels if there are target adjacent pixels in the second format image to obtain an intermediate image, wherein the color value difference of the target adjacent pixels is less than or equal to a preset color difference threshold.

[0114] The pixel count calculation unit is used to determine the number of pixels that still need to be merged in the intermediate image if the number of adjacent target pixels that have been merged is less than the number of pixels to be merged.

[0115] The adjacent color block merging unit is used to merge adjacent color blocks of the intermediate image according to the number of pixels that still need to be merged, so as to obtain the merged image. Adjacent pixels with the same color value are called a color block.

[0116] In one embodiment of the present invention, the adjacent color block merging unit is specifically used to calculate the color value difference between adjacent color blocks in the intermediate image based on the position and color value of each color block in the intermediate image;

[0117] The merged image is obtained by merging adjacent color blocks in the middle image according to the order of their color value difference from smallest to largest, and merging adjacent color blocks with the same number of adjacent pixels that still need to be merged.

[0118] In one embodiment of the present invention, the preset color difference threshold determination unit is specifically used to determine the proportion of pixels to be merged to the total number of pixels based on the number of pixels to be merged and the total number of pixels; or,

[0119] The proportion of pixels to be merged to the total number of pixels is determined based on preset quality control parameter values.

[0120] Based on the pre-stored correspondence between the ratio and the threshold, the preset color difference threshold corresponding to the ratio of the pixels to be merged to the total number of pixels is determined.

[0121] In one embodiment of the present invention, the target adjacent pixel merging unit is further configured to determine an intermediate color value based on the color value of each pixel in the target adjacent pixels;

[0122] Adjust the color value of each pixel in the target's adjacent pixels to the median color value.

[0123] In one embodiment of the present invention, a webpage image loading system may further include:

[0124] The color value difference calculation module is used to calculate the color value difference between adjacent color blocks in the merged image based on the position and color value of each color block in the merged image. Adjacent pixels with the same color value are called a color block.

[0125] The target adjacent color block merging module is used to merge target adjacent color blocks if they exist in the merged image to obtain a color block image, wherein the color value difference between the target adjacent color blocks is less than a preset threshold.

[0126] The color block image conversion module is used to convert color block images from a second format to a first format and load the converted color block images into the first format on a webpage.

[0127] Corresponding to the webpage image loading method described in the above embodiments, Figure 6 A schematic diagram of the terminal device provided in an embodiment of the present invention is shown. For ease of explanation, only the parts relevant to this embodiment are shown.

[0128] In this embodiment, the webpage image loader 600 is installed and runs on the terminal device 60. The terminal device 60 may be a mobile terminal, a handheld computer, a server, etc. The terminal device 60 may include, but is not limited to, a memory 601, a processor 602, and a display 603. Figure 6 Only a terminal device 60 with components 601-603 is shown; however, it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0129] In some embodiments, the memory 601 may be an internal storage unit of the terminal device 60, such as a hard disk or memory of the terminal device 60. In other embodiments, the memory 601 may be an external storage device of the terminal device 60, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the terminal device 60. Further, the memory 601 may include both internal and external storage units of the terminal device 60. The memory 601 is used to store application software and various types of data installed on the terminal device 60, such as the program code of the webpage image loader 600. The memory 601 can also be used to temporarily store data that has been output or will be output.

[0130] In some embodiments, the processor 602 may be a central processing unit (CPU), a microprocessor, or other data processing chip, used to run program code stored in the memory 601 or process data, such as executing the web page image loading program 600.

[0131] In some embodiments, the display 603 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an organic light-emitting diode (OLED) touchscreen. The display 603 is used to display information processed in the terminal device 60 and to display a visual user interface, such as an application menu interface or an application icon interface. The components 601-603 of the terminal device 60 communicate with each other via a system bus.

[0132] In this embodiment, the webpage image loading program 600 can be divided into one or more modules, which are stored in the memory 601 and executed by one or more processors (processor 602 in this embodiment) to complete the present invention. For example, in Figure 5 The webpage image loading program 600 described herein can be divided into an image acquisition module, a parameter acquisition module, a pixel point determination module, a merging module, and an image loading module. The term "module" in this invention refers to a series of computer program instruction segments capable of performing specific functions, and is more suitable than "program" for describing the execution process of the webpage image loading program 600 in the terminal device 60. The following description will specifically introduce the functions of each module.

[0133] The image acquisition module is used to acquire images in a first format to be loaded on the webpage and convert the first format images into second format images.

[0134] The parameter acquisition module is used to obtain the position and color value of each pixel in the second format image, as well as the total number of pixels in the second format image;

[0135] The pixel-to-be-merged determination module is used to determine the number of pixels to be merged in the second-format image based on preset quality control parameter values ​​and the total number of pixels.

[0136] The merging module is used to merge adjacent pixels in a second-format image based on the number of pixels to be merged, the position of each pixel, and its color value, to obtain the merged image.

[0137] The image loading module is used to convert the merged image from the second format to the first format and load the merged image converted to the first format into the webpage.

[0138] Other modules or units can be referred to Figure 5 The descriptions in the illustrated embodiments will not be repeated here.

[0139] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0140] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.

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

[0142] In the embodiments provided by this invention, it should be understood that the disclosed apparatus / terminal devices and methods can be implemented in other ways. For example, the apparatus / terminal device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

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

[0144] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0145] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.

[0146] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.

Claims

1. A web page image loading method, characterized in that: include: Obtaining a picture in a first format to be loaded in a webpage, and converting the picture in the first format into a picture in a second format; Obtaining a position and a color value of each pixel in the picture in the second format and a total number of pixels in the picture in the second format; Determining the number of pixels to be merged in the picture of the second format according to a preset quality control parameter value and the total number of pixels; wherein the quality control parameter value is used to indicate the webpage's requirement for picture clarity, and the quality control parameter value is positively correlated with the webpage's requirement for picture clarity; Determine the proportion of pixels to be merged to the total pixels, and determine a preset color difference threshold corresponding to the proportion of pixels to be merged to the total pixels; calculate the color value difference of adjacent pixels according to the position and color value of each pixel; if there are target adjacent pixels in the picture of the second format, merge the target adjacent pixels to obtain an intermediate picture, and the color value difference of the target adjacent pixels is less than or equal to the preset color difference threshold; if the number of merged target adjacent pixels is less than the number of pixels to be merged, determine the number of pixels that still need to be merged in the intermediate picture; merge adjacent color blocks of the intermediate picture according to the number of pixels that still need to be merged to obtain a merged picture, wherein adjacent pixels with the same color value are referred to as a color block; The merged image is converted from the second format to the first format, and the merged image converted into the first format is loaded into the webpage.

2. The web page image loading method according to claim 1, characterized in that: The step of merging adjacent color blocks of the intermediate image according to the number of pixels that still need to be merged to obtain the merged image includes: Calculating the color value difference between adjacent color blocks in the intermediate image according to the position and color value of each color block in the intermediate image; Adjacent color blocks having the same number as the adjacent pixel points that still need to be merged are merged in the order of color value differences of the adjacent color blocks in the intermediate image from small to large, to obtain the merged image.

3. The web page image loading method according to claim 1, characterized in that: The determining the ratio of the pixels to be merged to the total pixels, and determining the preset color difference threshold corresponding to the ratio of the pixels to be merged to the total pixels, includes: Determine the ratio of the pixels to be merged to the total number of pixels according to the number of the pixels to be merged and the total number of pixels; or, Determining the ratio of the pixels to be merged to the total pixels according to the preset quality control parameter value; According to the pre-stored correspondence between the ratio and the threshold, a preset color difference threshold corresponding to the ratio of the pixels to be merged to the total pixels is determined.

4. The web page image loading method according to claim 1, characterized in that: The merging of the target adjacent pixels comprises: Determine an intermediate color value according to the color value of each pixel point among the target adjacent pixels; The color value of each pixel point in the target adjacent pixel points is adjusted to the intermediate color value.

5. The web page image loading method according to claim 1, characterized in that: After getting the merged picture, it also includes: Calculating the color value difference between adjacent color blocks in the merged image according to the position and color value of each color block in the merged image, wherein adjacent pixels having the same color value are referred to as a color block; If there are target adjacent color blocks in the merged image, merge the target adjacent color blocks to obtain a color block map, and the color value difference of the target adjacent color blocks is less than a preset threshold; The color block image is converted from the second format to the first format, and the color block image converted into the first format is loaded into the webpage.

6. A web page image loading system, characterized in that: include: An image acquisition module is used to acquire an image in a first format to be loaded in a webpage, and convert the image in the first format into an image in a second format; A parameter acquisition module, used to acquire the position and color value of each pixel in the picture in the second format and the total number of pixels in the picture in the second format; a module for determining pixels to be merged, used to determine the number of pixels to be merged in the picture of the second format according to a preset quality control parameter value and the total number of pixels; wherein the quality control parameter value is used to represent the requirement of the web page for the picture clarity, and the quality control parameter value is positively correlated with the requirement of the web page for the picture clarity; A merging module, used to determine the proportion of pixels to be merged to the total pixels, and determine a preset color difference threshold corresponding to the proportion of pixels to be merged to the total pixels; calculate the color value difference of adjacent pixels according to the position and color value of each pixel; if there are target adjacent pixels in the picture of the second format, merge the target adjacent pixels to obtain an intermediate picture, and the color value difference of the target adjacent pixels is less than or equal to the preset color difference threshold; if the number of merged target adjacent pixels is less than the number of pixels to be merged, determine the number of pixels that still need to be merged in the intermediate picture; merge adjacent color blocks of the intermediate picture according to the number of pixels that still need to be merged to obtain a merged picture, wherein adjacent pixels with the same color value are referred to as a color block; The image loading module is used to convert the merged image from the second format to the first format, and load the merged image converted into the first format into the web page.

7. A terminal device, characterized in that: The invention comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: Obtaining a picture in a first format to be loaded in a webpage, and converting the picture in the first format into a picture in a second format; Obtaining a position and a color value of each pixel in the picture in the second format and a total number of pixels in the picture in the second format; Determining the number of pixels to be merged in the picture of the second format according to a preset quality control parameter value and the total number of pixels; wherein the quality control parameter value is used to indicate the webpage's requirement for picture clarity, and the quality control parameter value is positively correlated with the webpage's requirement for picture clarity; Determine the proportion of pixels to be merged to the total pixels, and determine a preset color difference threshold corresponding to the proportion of pixels to be merged to the total pixels; calculate the color value difference of adjacent pixels according to the position and color value of each pixel; if there are target adjacent pixels in the picture of the second format, merge the target adjacent pixels to obtain an intermediate picture, and the color value difference of the target adjacent pixels is less than or equal to the preset color difference threshold; if the number of merged target adjacent pixels is less than the number of pixels to be merged, determine the number of pixels that still need to be merged in the intermediate picture; merge adjacent color blocks of the intermediate picture according to the number of pixels that still need to be merged to obtain a merged picture, wherein adjacent pixels with the same color value are referred to as a color block; The merged image is converted from the second format to the first format, and the merged image converted into the first format is loaded into the webpage.

8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the web page image loading method as claimed in any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Picture searching method and system

    CN107832359A

  • Method and device for identifying text area in image

    WO2018040342A1