Image loading method, device, electronic device and readable storage medium
By performing color gamut channel grayscale processing, bit layering and slicing processing on the target image, the problem of too long loading time when loading large file pictures is solved, achieving faster image loading speed and better user experience.
Patent Information
- Application Number
- CN202310959819.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-28
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2043-07-28
AI Technical Summary
In the prior art, the loading time is too long when loading large file pictures, resulting in poor user experience when obtaining information.
By performing grayscale processing of the target image according to the color gamut channel, the target grayscale image is obtained, and then bit layering is performed on each target grayscale image to obtain the bit image. Then each bit image is sliced to obtain a slice image, and the slice image is transferred to the client for loading and displaying.
This method further compresses the target image through image grayscale processing and bit layering technology, significantly improving the speed of loading images and optimizing the user's application experience in scenes such as browsing photos online.
Smart Images

Figure CN116993611B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer vision technology, and in particular to an image loading method, device, electronic device and readable storage medium. Background Art
[0002] When users are using browsers or other software to obtain information, they often need to use images to help them understand the information or to make the text more interesting. However, in reality, the memory occupied by an image is much larger than a text description of 1,000 words, and the size of some high-resolution images is very large. When the image is very large, it will take a long time to request it from the server, and it will take a long time to load it. The long loading time will bring a bad experience to users when obtaining information.
[0003] Therefore, the prior art has the problem of taking too long to load large file images. Summary of the invention
[0004] In view of this, the embodiments of the present application provide an image loading method, device, electronic device and readable storage medium to solve the problem of long loading time when loading large file images in the prior art.
[0005] A first aspect of an embodiment of the present application provides an image loading method, which is applied to a server and includes:
[0006] Performing grayscale processing on the target image according to the color gamut channel to obtain a target grayscale image, wherein the target grayscale image includes a first grayscale image corresponding to the red channel, a second grayscale image corresponding to the green channel, and a third grayscale image corresponding to the blue channel;
[0007] Performing bit layering processing on each of the target grayscale images to obtain bit images corresponding to N bit layers corresponding to each of the target grayscale images, wherein the number of bits corresponding to the N bit layers is greater than the number of bits corresponding to other bit layers in all the bit layers;
[0008] Performing segmentation processing on each of the bit images to obtain segmented slice images;
[0009] The slice image is transmitted to a client, so that the client loads and displays the target image based on the slice image.
[0010] A second aspect of an embodiment of the present application provides an image loading method, which is applied to a client and includes:
[0011] Receive a slice image sent by a server, wherein the slice image is obtained by the server performing a slicing process on each bit image, the bit image is obtained by the server performing a bit layering process on each target grayscale image, and the bit image is an image corresponding to N layers with a larger number of bits among all bit layers, the target grayscale image is obtained by performing a grayscale process on the target image according to a color gamut channel, and the target grayscale image includes a first grayscale image corresponding to a red channel, a second grayscale image corresponding to a green channel, and a third grayscale image corresponding to a blue channel;
[0012] The target image is displayed according to the slice image.
[0013] According to a third aspect of the embodiments of the present application, there is provided an image loading device, comprising:
[0014] A grayscale processing module is used to perform grayscale processing on the target image according to the color gamut channel to obtain a target grayscale image, wherein the target grayscale image includes a first grayscale image corresponding to the red channel, a second grayscale image corresponding to the green channel, and a third grayscale image corresponding to the blue channel;
[0015] A bit layering module, used for performing bit layering processing on each of the target grayscale images to obtain bit images corresponding to N bit layers corresponding to each of the target grayscale images, wherein the number of bits corresponding to the N bit layers is greater than the number of bits corresponding to other bit layers in all the bit layers;
[0016] A cutting module, used for cutting each bit image to obtain a cut slice image;
[0017] The transmission module is used to transmit the slice image to the client, so that the client loads and displays the target image based on the slice image.
[0018] According to a fourth aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0019] According to a fifth aspect of an embodiment of the present application, a readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0020] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0021] The server performs grayscale processing on the target image according to the color gamut channel to obtain the target grayscale image, including the first grayscale image corresponding to the red channel, the second grayscale image corresponding to the green channel, and the third grayscale image corresponding to the blue channel; each target grayscale image is then subjected to bit layering processing to obtain the bit images corresponding to the N bit layers corresponding to each target grayscale image, wherein the number of bits corresponding to the N bit layers is greater than the number of bits corresponding to the other bit layers in all the bit layers. The bit layers with a larger number of bits are closer to the original target image, and the more information is retained. Discarding some bit layers with a smaller number of bits can be regarded as image compression to reduce the amount of calculation. Then each bit image is subjected to a certain segmentation processing, and the same segmentation method is adopted for each bit image to obtain the segmented slice map, and the slice map of the target image is transmitted to the client, and the client displays the target image based on the slice map. The image loading method not only segments the target image, but also further compresses the target image through image grayscale processing and bit layering technology, thereby improving the speed of loading the image, optimizing the user's application experience when browsing photos and other scenes on the Internet, and solving the problem of long loading time when loading large file images in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0023] Figure 1 is a schematic diagram of an application scenario of an embodiment of the present application;
[0024] Figure 2 It is a flowchart of an image loading method provided in an embodiment of the present application;
[0025] Figure 3 is a flowchart of another image loading method provided in an embodiment of the present application;
[0026] Figure 4 is a structural schematic diagram of an image loading device provided in an embodiment of the present application;
[0027] Figure 5 is a structural schematic diagram of another image loading device provided in an embodiment of the present application;
[0028] Figure 6 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0030] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0031] In addition, it should be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "includes..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0032] An image loading method and device according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0033] Figure 1 1 is a schematic diagram of an application scenario of an embodiment of the present application. The application scenario may include client devices 1, 2 and 3, a server 4 and a network 5.
[0034] The first client device 1, the second client device 2 and the third client device 3 can be hardware or software. When the first client device 1, the second client device 2 and the third client device 3 are hardware, they can be various electronic devices with display screens and supporting communication with the server 4, including but not limited to smart phones, tablet computers, laptop portable computers and desktop computers, etc.; when the first client device 1, the second client device 2 and the third client device 3 are software, they can be installed in the electronic devices as described above. The client devices 1, 2 and 3 can be implemented as multiple software or software modules, or as a single software or software module, which is not limited in the embodiments of the present application. Furthermore, various applications can be installed on the first client device 1, the second client device 2 and the third client device 3, such as data processing applications, instant messaging tools, social platform software, search applications, shopping applications, etc.
[0035] The server 4 may be a server that provides various services, for example, a background server that receives a request sent by a client device that establishes a communication connection with the server, and the background server may receive and analyze the request sent by the client device, and generate a processing result. The server 4 may be a single server, or a server cluster composed of several servers, or a cloud computing service center, which is not limited in the present embodiment of the application.
[0036] It should be noted that the server 4 can be hardware or software. When the server 4 is hardware, it can be various electronic devices that provide various services to the first client device 1, the second client device 2, and the third client device 3. When the server 4 is software, it can be multiple software or software modules that provide various services to the first client device 1, the second client device 2, and the third client device 3, or it can be a single software or software module that provides various services to the first client device 1, the second client device 2, and the third client device 3, and the embodiment of the present application does not limit this.
[0037] The network 5 can be a wired network connected by coaxial cable, twisted pair and optical fiber, or it can be a wireless network that can interconnect various communication devices without wiring, such as Bluetooth, Near Field Communication (NFC), infrared, etc., which is not limited in the embodiments of the present application.
[0038] The user can establish a communication connection with the server 4 via the network 5 through the first client device 1 , the second client device 2 and the third client device 3 to receive or send information, etc.
[0039] It should be noted that the specific types, quantities and combinations of the first client device 1, the second client device 2 and the third client device 3, the server 4 and the network 5 can be adjusted according to the actual needs of the application scenario, and the embodiments of the present application do not limit this.
[0040] Figure 2 It is a flow chart of an image loading method provided in an embodiment of the present application, which is applied to a server. Figure 2 The image loading method can be Figure 1 Server 4 executes. Figure 2 As shown, the image loading method includes:
[0041] Step 201, grayscale processing is performed on the target image according to the color gamut channel to obtain a target grayscale image, wherein the target grayscale image includes a first grayscale image corresponding to the red channel, a second grayscale image corresponding to the green channel, and a third grayscale image corresponding to the blue channel;
[0042] Specifically, in practical applications, color images generally have more information than grayscale images. Grayscale images have two-dimensional information of length and width, while color images can be parsed into three dimensions of length, width and depth. Depth refers to the number of color gamut channels. Most color images can be expressed by a combination of three colors, namely red, green and blue. Therefore, the target image is grayscaled according to the color gamut channels, and the target grayscale image obtained is the first grayscale image corresponding to the red channel, the second grayscale image corresponding to the green channel, and the third grayscale image corresponding to the blue channel. In this application, grayscale processing of a target image means separating the three-channel target image into three single-channel grayscale images.
[0043] In practice, the target image can be grayscaled according to the color gamut channel using the openCV open source technology. OpenCV is a cross-platform computer vision library released under the BSD license. As a popular open source library, it has a rich library of commonly used image processing functions. It can run on a variety of operating systems and can quickly implement some image recognition and processing tasks. For example, by using the function cv2.imread to read the target image, you can know the number of pixels and channels of the target image, and then use the function cv2.split to extract the corresponding three grayscale images of the red channel, green channel, and blue channel according to the color gamut channel. Pixels are the smallest image unit. An image is composed of many pixels, that is, a small square area. The size of the image is often expressed as height*width, for example, 200*100, which means that the image has 200 pixels in the vertical direction and 100 pixels in the horizontal direction.
[0044] The color of each pixel in a color image is determined by three components: R, G, and B, and the value range of each component is between 0 and 255. For a computer, a pixel in a color image will have a range of 256*256*256=16777216 colors. Grayscale processing of the target image according to the color gamut channel to obtain the corresponding three target images can simplify the image matrix and improve the calculation speed.
[0045] Step 202 , performing bit layering processing on each target grayscale image to obtain bit images corresponding to N bit layers corresponding to each target grayscale image.
[0046] The number of bits corresponding to the N bit layers is greater than the number of bits corresponding to other bit layers in all the bit layers.
[0047] Specifically, in a grayscale image, the grayscale value of a pixel ranges from 0 to 255, that is, there are 256 levels of grayscale values, and each pixel grayscale value is composed of 8 bits. Bit image stratification is to read the number of pixel bits of the grayscale image separately. An 8-bit image is composed of 8 1-bit layers. These 8 bit layers are separated to form 8 new pictures, and the bit stratification is completed.
[0048] In addition, specifically, a grayscale image is bit-layered to obtain eight bit layer maps with different bit numbers, which are arranged from large to small in order: the 7th bit layer, the 6th bit layer, the 5th bit layer, the 4th bit layer, the 3rd bit layer, the 2nd bit layer, the 1st bit layer, and the 0th bit layer. The higher the bit number of the bit layer map, the closer the display effect is to the original image. In actual processing, the bit layer images with low bit numbers are discarded as needed to obtain bit images corresponding to N bit layers corresponding to each target grayscale image.
[0049] It should be noted that the value of N can be set according to actual needs, for example, it can be 5 or 6.
[0050] For example, as an example, a grayscale image has four pixels (2*2), and the pixel values are 1, 2, 3, and 4 respectively. The image matrix is:
[0051]
[0052] Convert these values into binary: 1 (00000001), 2 (00000010), 3 (00000011), 4 (00000100). The eight-bit images obtained by bit layering of the image are arranged in descending order according to the number of bits:
[0053]
[0054] The higher the bit number, the closer the display effect of the bitmap is to the original image. In actual processing, the bitmap with low bit number is discarded according to the demand. For example, here the two bitmaps with the smallest bit number are discarded, and the image is compressed to obtain the bitmap corresponding to the 6 bit layers corresponding to the grayscale image, that is:
[0055]
[0056] By performing bit-layering processing on each target grayscale image, we can intuitively see the contribution of a certain grayscale range to the image, with white contributing and black not contributing. Ultimately, we can reconstruct the target image through several main contribution layers to achieve image compression, ultimately achieving the goal of speeding up image loading.
[0057] Step 203, segment each bit image to obtain a segmented slice image.
[0058] Specifically, the same cutting method is adopted for each bit image to obtain the sliced images after cutting. For example, a bit image (90*90) with 8100 pixels is cut according to a specific cutting method to obtain nine slices (30*30) with 900 pixels. After each bit image is cut, the size of each sliced image is further reduced. When these sliced images are subsequently requested, the request speed can be accelerated, the computer calculation time can be reduced, and the purpose of speeding up the image loading speed is finally achieved.
[0059] Step 204: Transmit the slice image to the client, so that the client loads and displays the target image based on the slice image.
[0060] Specifically, the client sends a request to the server for the required target image. Based on this request, the server transmits a slice image of the target image to the client. The client processes the slice image accordingly, such as synthesizing the slice image, and loads and displays the synthesized image on the client screen.
[0061] The server performs grayscale processing on the target image according to the color gamut channel to obtain the target grayscale image, including the first grayscale image corresponding to the red channel, the second grayscale image corresponding to the green channel, and the third grayscale image corresponding to the blue channel; each target grayscale image is then subjected to bit layering processing to obtain the bit images corresponding to the N bit layers corresponding to each target grayscale image, wherein the N bit layers are the N layers with the largest number of bits in all bit layers. The closer the bit layer with the largest number of bits is to the original target image, the more information is retained. Discarding some bit layers with small number of bits can be regarded as compression of the image to reduce the amount of calculation. Then each bit image is subjected to certain segmentation processing, and the same segmentation method is adopted for each bit image to obtain the segmented slice map; the client sends a target image request to the server, and the server transmits the slice map of the target image to the client, and the client displays the target image based on the slice map. The image loading method not only divides the target image, but also further compresses the target image through image grayscale processing and bit layering technology, thereby improving the speed of loading the image, optimizing the application experience of users in scenes such as browsing photos on the Internet, and solving the problem of long loading time when loading large file images in the prior art.
[0062] In some embodiments, each bit image is segmented to obtain a segmented slice image, including:
[0063] The bit image is segmented according to the resolution width and resolution height corresponding to the segmentation window to obtain a slice image corresponding to each bit image;
[0064] Alternatively, the width and height of the segmentation window are determined according to the preset total number of slice images corresponding to each bit image, and the bit image is segmented according to the width and height of the segmentation window to obtain the slice image corresponding to each bit image;
[0065] The naming index of the slice image includes the color gamut channel, bit layer and slice number corresponding to the slice image, and the slice numbers corresponding to the same positions of N bit layers in the same color gamut channel are the same.
[0066] Specifically, there are two main methods for segmenting each bit image. The first method is to first determine the size of the final slice image, including the length and width of the slice image, that is, the resolution width and resolution height corresponding to the segmentation window. Image resolution refers to the amount of information stored in the image, which is the number of pixels per inch. For example, the resolution width and resolution height corresponding to the segmentation window are both configured to be E. Combined with the resolution width and resolution height of the bit image, the bit image is segmented to obtain a certain number of slice images. The same segmentation method is adopted for each bit image, and the number of slice images obtained after segmentation of each bit image is the same, and the width and height of the slice images of all bit images are consistent.
[0067] The second segmentation method is to first determine the total number of slices corresponding to each bit image, and then determine the width and height of the segmentation window based on the resolution width and resolution height of the bit image. For example, if the total number of slices after a bit image is segmented is determined to be 9, and the resolution width and resolution height of the bit image are 90 and 90, the width and height of the segmentation window can be set to 30 and 30. After setting the width and height of the segmentation window, the bit image is segmented according to the width and height of the segmentation window to obtain the corresponding slices. The same segmentation method is used for each bit image, and the number of slices obtained after each bit image is segmented is the same, and the width and height of the slices of all bit images are consistent.
[0068] The naming index of a slice image includes the color gamut channel, bit layer and slice number corresponding to the slice image. For example, the naming index of a slice image can be set to channel_bit number_slice number, such as: R_b3_1. The slice number corresponding to the same position of each bit image is the same. Taking the slice number 1 as an example, a target image is grayscaled according to the color gamut channel to obtain three target grayscale images, and then the target grayscale image is bit-layered to obtain eight bit images. After all the bit images are segmented, 24 slice images will have a slice number of 1 among all the slice images. By creating a unique naming index, the uniqueness of the slice image data can be guaranteed, and the subsequent request for slice image data through the naming index can be accelerated.
[0069] Figure 3 It is a flowchart of an image loading method provided in an embodiment of the present application, which is applied to a client. Figure 3 The image loading method can be Figure 1 The client device executes. Figure 3 As shown, the image loading method includes:
[0070] Step 301, receiving a slice image sent by a server, wherein the slice image is obtained by the server performing a slice process on each bit image, the bit image is obtained by the server performing a bit layering process on each target grayscale image, and the bit image is an image corresponding to N layers with a larger number of bits in all bit layers, and the target grayscale image is obtained by performing a grayscale process on the target image according to a color gamut channel, and the target grayscale image includes a first grayscale image corresponding to a red channel, a second grayscale image corresponding to a green channel, and a third grayscale image corresponding to a blue channel;
[0071] Specifically, before the client receives the slice map sent by the server, it can send a request message to the server, and then receive the slice map sent by the server based on the request message. Of course, it should be noted that the client can request and receive the slice map data of the target image in parallel, and the server transmits the slice map of the target image to the client in parallel based on this request. The slice map is obtained by the server segmenting each bit image, and the bit image is obtained by the server performing bit layering processing on each target grayscale image, and the bit image is the image corresponding to the N layers with the largest number of bits in all bit layers. The target grayscale image is obtained by grayscale processing the target image according to the color gamut channel, and the target grayscale image includes a first grayscale image corresponding to the red channel, a second grayscale image corresponding to the green channel, and a third grayscale image corresponding to the blue channel.
[0072] Step 302, displaying the target image according to the slice image;
[0073] The client receives the sent slice image, and then performs corresponding synthesis processing based on the slice image. After obtaining the synthesized image, it is loaded and displayed on the client screen, which improves the speed of loading images, optimizes the user's application experience when browsing photos on the Internet, and solves the problem of long loading time when loading large file images in the prior art.
[0074] In some embodiments, the naming index of the slice image includes the color gamut channel, bit layer and slice number corresponding to the slice image; wherein the slice numbers corresponding to the same positions of N bit layers in the same color gamut channel are the same.
[0075] Specifically, the naming index of a slice image can be set to channel_bit number_slice number, for example: R_b2_2. The slice number corresponding to the same position in each bit image is the same. Taking the slice number 2 as an example, a target image is grayscaled according to the color gamut channel to obtain three target grayscale images, and then the target grayscale image is bit-layered to obtain eight-bit images. Then all the bit images are segmented, and among all the slice images obtained, there will be 24 slice images with the slice number 2. And the slice image with the number 2 is located in the same position in all the bit images.
[0076] By creating a unique named index, you can ensure the uniqueness of the slice map data, and you can also speed up the process of requesting slice map data through the named index.
[0077] In addition, according to the slice map, the target image is displayed, including:
[0078] According to the total number of slice numbers of the slice image, the image display area is divided, wherein each divided area has the same size as the slice image and is used to display the slice image of the corresponding slice number;
[0079] The slice images with the same color gamut channel and the same slice sequence number are synthesized to obtain a synthesized slice image;
[0080] The synthesized slice image is rendered into a region corresponding to the slice sequence number of the synthesized slice image.
[0081] Specifically, the image display area is divided according to the total number of slice numbers of the slice image and the size of the slice image, and is used to display the synthesized slice image. For example, a 90*90 bit image is divided into nine slice images, each of which is 10*10 in size. Correspondingly, the size of each area of the divided display area is the same as the size of the slice image, and the area after division is also 9 areas.
[0082] After the client receives all the slice images sent by the server, it synthesizes the slice images with the same color gamut channel and the same slice number to obtain a synthesized slice image; finally, the synthesized slice image is rendered into the area corresponding to the slice number of the synthesized slice image, and the image matrix is generated as a visual image to realize the loading and rendering of the target image, thereby improving the speed of loading images and optimizing the user's application experience when browsing photos online.
[0083] In some embodiments, the slice images with the same color gamut channel and the same slice sequence number are synthesized to obtain a synthesized slice image, including:
[0084] Classifying the slice images according to the color gamut channels corresponding to the slice images to obtain a first channel slice image corresponding to the red channel, a second channel slice image corresponding to the green channel, and a third channel slice image corresponding to the blue channel;
[0085] Performing bit image reconstruction on the first channel slice image with the same slice number to obtain a first grayscale image slice, performing bit image reconstruction on the second channel slice image with the same slice number to obtain a second grayscale image slice, and performing bit image reconstruction on the third channel slice image with the same slice number to obtain a third grayscale image slice;
[0086] The first grayscale image slice, the second grayscale image slice and the third grayscale image slice are merged to generate a synthesized slice image.
[0087] Specifically, the server performs grayscale processing on the target image according to the color gamut channels to obtain a target grayscale image corresponding to the three color gamut channels, and then performs bit layering processing on the target grayscale image to obtain a bit image. The slice image is obtained by performing the same segmentation processing on all bit images, so the slice image is classified according to the corresponding color gamut channels, and can also be classified to obtain a first channel slice image corresponding to the red channel, a second channel slice image corresponding to the green channel, and a third channel slice image corresponding to the blue channel.
[0088] Then, the first channel slice image with the same slice number is subjected to bit image reconstruction to obtain the first grayscale image slice, the second channel slice image with the same slice number is subjected to bit image reconstruction to obtain the second grayscale image slice, and the third channel slice image with the same number is subjected to bit image reconstruction to obtain the third grayscale image slice. In the bit image reconstruction process, the discarded bit image can be supplemented with 0 to form eight bit images, and then the eight bit images are reconstructed to obtain grayscale image slices of different channels respectively.
[0089] Finally, the first grayscale image slice, the second grayscale image slice and the third grayscale image slice with the same sequence number are merged to generate a synthesized slice image.
[0090] In specific practice, optionally, the cv2.merge function can be used to merge the first grayscale image slice, the second grayscale image slice and the third grayscale image slice with the same sequence number to obtain a synthesized slice image.
[0091] Each bit image records certain information of the original target image. Combining multiple bit images can obtain most of the information of the original target image. Then the bit images of the three color gamut channels are merged, and finally the merged image is visualized. This can restore the original target image as much as possible and speed up the loading of the image.
[0092] In some embodiments, performing bit image reconstruction on the first channel slice image with the same slice sequence number to obtain the first grayscale image slice includes:
[0093] Convert all the first channel slice images with the same slice number into a binary gray value matrix;
[0094] The entire binary grayscale value matrix is converted into a decimal grayscale value matrix, and the decimal grayscale value matrix is converted into a first grayscale image slice.
[0095] Specifically, before all first channel slice images with the same slice number are converted into binary gray value matrices, the bit images discarded in the bit image layering process can be filled with 0 to form eight bit image slices with all first channel slice images with the same slice number.
[0096] For example, for six bitmap slices of the same color gamut channel with the same slice number, the pixels are all 4 (2*2), and the bitmap slice matrix is:
[0097]
[0098] The discarded bit image can be filled with 0 to complete the eight-bit image, and then the eight-bit image is reconstructed into a bit image. The obtained grayscale image slice matrix is:
[0099]
[0100] Convert binary to decimal, and the grayscale image slice matrix is:
[0101]
[0102] Bit plane layering and re-bit plane image reconstruction can, on the one hand, compress images to increase the image loading speed, and on the other hand, highlight some bit features based on the compressed image. Most of the features of the original image are retained in the high-order bit image to basically meet user needs.
[0103] In some embodiments, displaying a target image according to the slice image includes:
[0104] According to the naming index of the slice map, a target slice map corresponding to a preset channel and a preset bit range is selected from the slice map;
[0105] A target image is obtained according to the target slice image, and the target image is displayed.
[0106] Specifically, each slice image records certain information of the original target image, so the target slice image corresponding to the preset channel and the preset bit range can be selectively selected according to the naming index of the slice image, and the target slice image is reconstructed and merged to obtain the target image, and then the target image is visualized and loaded for display to obtain the target image of corresponding clarity.
[0107] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0108] The following are device embodiments of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0109] Figure 4 It is a schematic diagram of an image loading device provided in an embodiment of the present application, which is applied to a server.
[0110] like Figure 4 As shown, the device comprises:
[0111] A grayscale processing module 401 is used to perform grayscale processing on a target image according to a color gamut channel to obtain a target grayscale image, wherein the target grayscale image includes a first grayscale image corresponding to a red channel, a second grayscale image corresponding to a green channel, and a third grayscale image corresponding to a blue channel;
[0112] The bit layering module 402 is used to perform bit layering processing on each target grayscale image to obtain bit images corresponding to N bit layers corresponding to each target grayscale image, wherein the number of bits corresponding to the N bit layers is greater than the number of bits corresponding to other bit layers in all the bit layers;
[0113] The cutting module 403 is used to perform a cutting process on each bit image to obtain a cut slice image;
[0114] The transmission module 404 is used to transmit the slice image to the client, so that the client loads and displays the target image based on the slice image.
[0115] In this embodiment, the grayscale processing module 401 performs grayscale processing on the target image according to the color gamut channel to obtain a target grayscale image, including a first grayscale image corresponding to the red channel, a second grayscale image corresponding to the green channel, and a third grayscale image corresponding to the blue channel; the bit layering module 402 performs bit layering processing on each target grayscale image to obtain a bit image corresponding to N bit layers corresponding to each target grayscale image, wherein the N bit layers are the N layers with the largest number of bits in all bit layers. The closer the bit layer with the largest number of bits is to the original target image, the more information is retained. Discarding some bit layers with small number of bits can be regarded as compression of the image to reduce the amount of calculation. The post-cutting module 403 then performs a certain segmentation processing on each bit image, and adopts the same segmentation method for each bit image to obtain a segmented slice map; the client sends a target image request to the server, and the transmission module 404 transmits the slice map of the target image to the client, and the client displays the target image based on the slice map. This image loading method not only divides the target image, but also further compresses the target image through image grayscale processing and bit layering technology, thereby improving the speed of loading images, optimizing the user's application experience when browsing photos online, and solving the problem of long loading time when loading large file images in the prior art.
[0116] In some embodiments, the cutting module is specifically used to cut the bit image according to the resolution width and resolution height corresponding to the cutting window to obtain a slice image corresponding to each bit image;
[0117] Alternatively, the width and height of the segmentation window are determined according to the preset total number of slice images corresponding to each bit image, and the bit image is segmented according to the width and height of the segmentation window to obtain the slice image corresponding to each bit image;
[0118] The naming index of the slice image includes the color gamut channel, bit layer and slice number corresponding to the slice image, and the slice numbers corresponding to the same positions of N bit layers in the same color gamut channel are the same.
[0119] Figure 5 It is a schematic diagram of an image loading device provided in an embodiment of the present application, which is applied to a client.
[0120] like Figure 5 As shown, the device comprises:
[0121] The receiving module 501 is used to receive the slice image sent by the server, the slice image is obtained by the server performing a slice process on each bit image, the bit image is obtained by the server performing a bit layering process on each target grayscale image, and the bit image is an image corresponding to N layers with a large number of bits in all bit layers, the target grayscale image is obtained by performing a grayscale process on the target image according to the color gamut channel, and the target grayscale image includes a first grayscale image corresponding to a red channel, a second grayscale image corresponding to a green channel, and a third grayscale image corresponding to a blue channel;
[0122] The display module 502 is used to display the target image according to the slice image.
[0123] The client sends a request to the server for the required target image, and requests the slice image data of the target image in parallel. Based on this request, the server transmits the slice image of the target image to the client. The receiving module 501 receives the slice image sent by the server. The slice image is obtained by the server segmenting each bit image, and the bit image is obtained by the server bit layering each target grayscale image, and the bit image is the image corresponding to the N layers with the largest number of bits in all bit layers. The target grayscale image is obtained by grayscale processing the target image according to the color gamut channel, and the target grayscale image includes a first grayscale image corresponding to the red channel, a second grayscale image corresponding to the green channel, and a third grayscale image corresponding to the blue channel; the display module 502 then performs corresponding processing on the slice image, such as performing corresponding synthesis processing on the slice image, and then loads and displays the synthesized image on the client screen.
[0124] The client receives the sent slice image, and then performs corresponding synthesis processing based on the slice image. After obtaining the synthesized image, it is loaded and displayed on the client screen, which improves the speed of loading images, optimizes the user's application experience when browsing photos on the Internet, and solves the problem of long loading time when loading large file images in the prior art.
[0125] In some embodiments, the naming module is specifically used to obtain a naming index of the slice image by naming the slice image according to the color gamut channel, the bit layer and the slice sequence number corresponding to the slice image; wherein the slice sequence numbers corresponding to the same positions of the N bit layers in the same color gamut channel are the same;
[0126] The display module includes a dividing unit, a compositing unit and a rendering unit.
[0127] The dividing unit is used to divide the image display area according to the total number of slice numbers of the slice image, wherein each divided area has the same size as the slice image and is used to display the slice image of the corresponding slice number;
[0128] The synthesis unit is used to synthesize the slice images with the same color gamut channel and the same slice sequence number to obtain a synthesized slice image;
[0129] The rendering unit is used to render the synthesized slice image into an area corresponding to the slice sequence number of the synthesized slice image.
[0130] In some embodiments, the synthesis unit is specifically used to include: classifying the slice images according to the color gamut channels corresponding to the slice images to obtain a first channel slice image corresponding to the red channel, a second channel slice image corresponding to the green channel, and a third channel slice image corresponding to the blue channel;
[0131] Performing bit image reconstruction on the first channel slice image with the same slice number to obtain a first grayscale image slice, performing bit image reconstruction on the second channel slice image with the same slice number to obtain a second grayscale image slice, and performing bit image reconstruction on the third channel slice image with the same slice number to obtain a third grayscale image slice;
[0132] The first grayscale image slice, the second grayscale image slice and the third grayscale image slice are merged to generate a synthesized slice image.
[0133] In some embodiments, the expansion module is specifically used to select a target slice image corresponding to a preset channel and a preset bit range from the slice image according to the naming index of the slice image;
[0134] A target image is obtained according to the target slice image, and the target image is displayed.
[0135] 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 application.
[0136] Figure 6 Schematic diagram of an electronic device 6 provided in an embodiment of the present application. Figure 6As shown, the electronic device 6 of this embodiment includes: a processor 601, a memory 602, and a computer program 603 stored in the memory 602 and executable on the processor 601. When the processor 601 executes the computer program 603, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 601 executes the computer program 603, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0137] The electronic device 6 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 6 may include, but is not limited to, a processor 601 and a memory 602. Those skilled in the art will appreciate that Figure 6 The electronic device 6 is merely an example and does not limit the electronic device 6 . The electronic device 6 may include more or less components than those shown in the figure, or different components.
[0138] The processor 601 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0139] The memory 602 may be an internal storage unit of the electronic device 6, for example, a hard disk or memory of the electronic device 6. The memory 602 may also be an external storage device of the electronic device 6, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 6. The memory 602 may also include both an internal storage unit of the electronic device 6 and an external storage device. The memory 602 is used to store computer programs and other programs and data required by the electronic device.
[0140] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned 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 above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0141] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, which may be in source code form, object code form, executable file or some intermediate form. The readable storage medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice.
[0142] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application 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 embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. An image loading method, applied to a server, characterized in that: include: Performing grayscale processing on the target image according to the color gamut channel to obtain a target grayscale image, wherein the target grayscale image includes a first grayscale image corresponding to the red channel, a second grayscale image corresponding to the green channel, and a third grayscale image corresponding to the blue channel; Performing bit layering processing on each of the target grayscale images to obtain bit images corresponding to N bit layers corresponding to each of the target grayscale images, wherein the number of bits corresponding to the N bit layers is greater than the number of bits corresponding to other bit layers in all the bit layers; Performing a segmentation process on each of the bit images to obtain a segmented slice image; wherein the naming index of the slice image includes the color gamut channel, the bit layer and the slice sequence number corresponding to the slice image, and the slice sequence numbers corresponding to the same positions of the N bit layers in the same color gamut channel are the same; The slice image is transmitted to a client so that the client divides the image display area according to the total number of slice serial numbers of the slice image, wherein each divided area is the same size as the slice image and is used to display the slice image with the corresponding slice serial number; the slice images with the same color gamut channel and the same slice serial number are synthesized to obtain a synthesized slice image; and the synthesized slice image is rendered into an area corresponding to the slice serial number of the synthesized slice image.
2. The image loading method according to claim 1, characterized in that: The step of performing segmentation processing on each of the bit images to obtain a segmented slice image includes: The bit image is segmented according to the resolution width and resolution height corresponding to the segmentation window to obtain a slice image corresponding to each bit image; Alternatively, the width and height of the segmentation window are determined according to a preset total number of slice images corresponding to each of the bit images, and the bit image is segmented according to the width and height of the segmentation window to obtain a slice image corresponding to each of the bit images.
3. An image loading method, applied to a client, characterized in that: include: Receive a slice image sent by a server, wherein the slice image is obtained by the server performing a slicing process on each bit image, the bit image is obtained by the server performing a bit layering process on each target grayscale image, and the bit image is an image corresponding to N bit layers, the number of bits corresponding to the N bit layers is greater than the number of bits corresponding to other bit layers in all the bit layers, the target grayscale image is obtained by performing grayscale processing on the target image according to the color gamut channel, and the target grayscale image includes a first grayscale image corresponding to a red channel, a second grayscale image corresponding to a green channel, and a third grayscale image corresponding to a blue channel; Displaying the target image according to the slice image; The naming index of the slice image includes the color gamut channel, bit layer and slice sequence number corresponding to the slice image; wherein the slice sequence numbers corresponding to the same positions of the N bit layers in the same color gamut channel are the same; The step of displaying the target image according to the slice image comprises: Divide the image display area according to the total number of slice numbers of the slice image, wherein each divided area has the same size as the slice image and is used to display the slice image with the corresponding slice number; The slice images with the same color gamut channel and the same slice sequence number are synthesized to obtain a synthesized slice image; The synthesized slice image is rendered into a region corresponding to the slice sequence number of the synthesized slice image.
4. The image loading method according to claim 3, characterized in that: The step of synthesizing slice images with the same color gamut channel and the same slice sequence number to obtain a synthesized slice image includes: Classifying the slice images according to the color gamut channels corresponding to the slice images to obtain a first channel slice image corresponding to a red channel, a second channel slice image corresponding to a green channel, and a third channel slice image corresponding to a blue channel; Performing bit image reconstruction on the first channel slice image with the same slice number to obtain a first grayscale image slice, performing bit image reconstruction on the second channel slice image with the same slice number to obtain a second grayscale image slice, and performing bit image reconstruction on the third channel slice image with the same slice number to obtain a third grayscale image slice; The first grayscale image slice, the second grayscale image slice and the third grayscale image slice are combined to generate the synthesized slice image.
5. The image loading method according to claim 4, characterized in that: The step of reconstructing the first channel slice image with the same slice sequence number to obtain the first grayscale image slice comprises: Convert all the first channel slice images with the same slice number into a binary gray value matrix; Convert all of the binary grayscale value matrices into a decimal grayscale value matrix, and convert the decimal grayscale value matrix into the first grayscale image slice.
6. The image loading method according to claim 3, characterized in that: The step of displaying the target image according to the slice image comprises: According to the naming index of the slice map, selecting a target slice map corresponding to a preset channel and a preset bit range from the slice map; The target image is obtained according to the target slice image, and the target image is displayed.
7. An image loading device, applied to a server, characterized in that: include: A grayscale processing module is used to perform grayscale processing on the target image according to the color gamut channel to obtain a target grayscale image, wherein the target grayscale image includes a first grayscale image corresponding to the red channel, a second grayscale image corresponding to the green channel, and a third grayscale image corresponding to the blue channel; A bit layering module is used to perform bit layering processing on each of the target grayscale images to obtain bit images corresponding to N bit layers corresponding to each of the target grayscale images, wherein the number of bits corresponding to the N bit layers is greater than the number of bits corresponding to other bit layers in all the bit layers; A cutting module, used for performing a cutting process on each of the bit images to obtain a cut slice image; wherein the naming index of the slice image includes the color gamut channel, the bit layer and the slice sequence number corresponding to the slice image, and the slice sequence numbers corresponding to the same positions of the N bit layers in the same color gamut channel are the same; A transmission module is used to transmit the slice image to a client so that the client divides the image display area according to the total number of slice serial numbers of the slice image, wherein each divided area is the same size as the slice image and is used to display the slice image with the corresponding slice serial number; synthesize the slice images with the same color gamut channel and the same slice serial number to obtain a synthesized slice image; and render the synthesized slice image into an area corresponding to the slice serial number of the synthesized slice image.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Image display method and apparatus
CN108334412A
Mass picture processing method and device, electronic equipment and storage medium
CN110019865A