Image drawing method, device, computer equipment and storage medium
By segmenting the image and identifying the different area, only refreshing the changing area, the problem of large resource usage during image refreshing is solved, the frame rate is improved, and the user experience is improved.
Patent Information
- Application Number
- CN202111661848.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2041-12-31
AI Technical Summary
During the image refresh process, the redrawing of the entire image leads to multiple drawings of unchanged areas, occupying large computing resources and affecting the frame rate of image refresh.
By segmenting the current image and the target image, the difference area is determined and only the difference area is refreshed to avoid refreshing the entire image. The specific method includes segmenting according to the pixel information of the pixel points, combining pixel points using the minimum spanning tree algorithm, matching sub-images, identifying differences areas, and refreshing corresponding content based on the differences areas of the target image.
Reduces resource usage caused by image refresh, improves the frame rate of image refresh, and improves the user's viewing experience.
Smart Images

Figure CN114332297B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an image drawing method, device, computer equipment and storage medium. Background Art
[0002] With the development of science and technology, various terminals with display screens are increasingly used in people's lives. Users can perform various operations on the display screen of the terminal, such as making calls, playing games, watching videos, browsing the web, etc., to meet various needs of life. In the process of operating the display screen, in order to ensure the smoothness of the display screen displaying images, the display screen needs to be continuously refreshed. However, if the entire image is redrawn during drawing, the unchanged areas in the image will be drawn multiple times, occupying a large amount of computing resources and affecting the frame rate of image refresh. Therefore, how to reduce the resource occupation caused by image refresh and increase the frame rate of image refresh has become a technical problem that needs to be solved urgently. Summary of the invention
[0003] Based on this, it is necessary to provide an image drawing method, device, computer equipment and storage medium that can reduce resource occupation caused by image refresh and improve the frame rate of image refresh in order to solve the above technical problems.
[0004] A method for drawing an image, the method comprising:
[0005] According to the pixel information of each pixel in the current image and the pixel information of each pixel in the target image, the current image and the target image are segmented to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image;
[0006] Determining a difference area between the current image and the target image according to each of the first sub-images and each of the second sub-images;
[0007] According to the image content at the position corresponding to the difference area in the target image, the image content at the position corresponding to the difference area in the current image is refreshed to obtain a display image.
[0008] In one embodiment, the current image and the target image are RGB images, and the pixel information includes component values of three color channels; according to the pixel information of each pixel in the current image and the pixel information of each pixel in the target image, the current image and the target image are segmented to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image, including: calculating according to the component values of the three color channels in each pixel in the current image to obtain a first dissimilarity between any pixel in the current image and its adjacent pixels; calculating according to the component values of the three color channels in each pixel in the target image to obtain a second dissimilarity between any pixel in the target image and its adjacent pixels; according to the first dissimilarity and the second dissimilarity, the current image and the target image are segmented to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image.
[0009] In one embodiment, the current image and the target image are segmented according to the first dissimilarity and the second dissimilarity, respectively, to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image, including: according to the first dissimilarity, taking each pixel in the current image as a vertex, using a minimum spanning tree algorithm to merge each pixel in the current image, to obtain at least one first minimum spanning tree corresponding to the current image; based on the pixels included in each first minimum spanning tree, the current image is segmented to obtain at least one first sub-image corresponding to the current image; according to the second dissimilarity, taking each pixel in the target image as a vertex, using a minimum spanning tree algorithm to merge each pixel in the target image, to obtain at least one second minimum spanning tree corresponding to the target image; based on the pixels included in each second minimum spanning tree, the target image is segmented to obtain at least one second sub-image corresponding to the target image.
[0010] In one of the embodiments, the difference area between the current image and the target image is determined based on each of the first sub-images and each of the second sub-images, including: matching each of the second sub-images with a first sub-image within a specified range in the current image based on position information of each of the second sub-images in the target image to determine matching first sub-images and second sub-images, the specified range corresponding to the position information; and identifying an area where the second sub-image where there is no matching first sub-image as a difference area.
[0011] In one of the embodiments, according to the position information of each second sub-image in the target image, the second sub-image is matched with the first sub-image in the current image within a predetermined range of the position information to determine the matching first sub-image and second sub-image, including: determining the specified range in the current image corresponding to the position information of each second sub-image according to the position information of each second sub-image in the target image and a preset image translation threshold, the translation threshold including a horizontal translation threshold and a vertical translation threshold; matching each second sub-image with the first sub-image within the specified range in the current image to determine the matching first sub-image and second sub-image.
[0012] In one of the embodiments, before determining the specified range in the current image corresponding to the position information of each second sub-image based on the position information of each second sub-image in the target image and a preset image translation threshold, it also includes: matching each second sub-image with each first sub-image respectively to determine the first sub-image with the highest degree of match with each second sub-image; and determining the horizontal translation amount and the vertical translation amount between the second sub-image and the first sub-image with the highest degree of match based on the position information of the second sub-image and the position information of the first sub-image with the highest degree of match with the second sub-image, to serve as the horizontal translation threshold and the vertical translation threshold corresponding to the second sub-image, respectively.
[0013] A device for drawing an image, the device comprising:
[0014] a segmentation module, configured to segment the current image and the target image respectively according to pixel information of each pixel in the current image and pixel information of each pixel in the target image, so as to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image;
[0015] a determination module, configured to determine a difference area between the current image and the target image according to each of the first sub-images and each of the second sub-images;
[0016] The processing module is used to refresh the image content at the position corresponding to the difference area in the current image according to the image content at the position corresponding to the difference area in the target image to obtain a display image.
[0017] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0018] According to the pixel information of each pixel in the current image and the pixel information of each pixel in the target image, the current image and the target image are segmented to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image;
[0019] Determining a difference area between the current image and the target image according to each of the first sub-images and each of the second sub-images;
[0020] According to the image content at the position corresponding to the difference area in the target image, the image content at the position corresponding to the difference area in the current image is refreshed to obtain a display image.
[0021] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0022] According to the pixel information of each pixel in the current image and the pixel information of each pixel in the target image, the current image and the target image are segmented to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image;
[0023] Determining a difference area between the current image and the target image according to each of the first sub-images and each of the second sub-images;
[0024] According to the image content at the position corresponding to the difference area in the target image, the image content at the position corresponding to the difference area in the current image is refreshed to obtain a display image.
[0025] One of the above technical solutions has the following advantages and beneficial effects:
[0026] The above-mentioned image drawing method, device, computer equipment and storage medium, by segmenting the current image and the target image respectively according to the pixel point information of each pixel point in the current image and the pixel point information of each pixel point in the target image, obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image, then determine the difference area between the current image and the target image according to each first sub-image and the second sub-image, then refresh the image content of the position corresponding to the difference area in the current image according to the image content of the position corresponding to the difference area in the target image, and obtain the display image. Therefore, there is no need to refresh and draw the entire current image, only the content corresponding to the difference area needs to be refreshed, thereby reducing the resource occupation caused by image refresh, and at the same time, the frame rate of image refresh can be improved, ensuring the user's viewing experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 Schematic diagram of the process of drawing an image in an embodiment of the present application.
[0028] Figure 2 In the embodiment of this application Figure 1 FIG. 4 is a flow chart of step S110 in the method for drawing an image.
[0029] Figure 3 It is a structural block diagram of the image drawing device in the embodiment of the present application.
[0030] Figure 4 Schematic diagram of the internal structure of a computer device in an embodiment of the present application. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0032] In one embodiment, Figure 1 As shown, a method for drawing an image is provided, which can be applied to a terminal or a server, wherein the terminal may include but is not limited to one or more of a smart phone, a tablet computer, a portable computer or a desktop computer. Of course, the terminal may also be an intelligent terminal device with image processing and screen display functions, such as VR glasses, car computers, etc.
[0033] In addition, the server can be a physical server or a cloud server that provides various cloud services. It is worth noting that this application does not limit the number of terminals or servers. According to the implementation needs, there can be any number of terminals or servers. For example, the server can be a single server or a server cluster composed of multiple servers.
[0034] according to Figure 1 The method for drawing an image shown in the figure includes at least steps S110 to S130, which are described in detail as follows (the following description is given by taking application to a terminal as an example):
[0035] In step S110, the current image and the target image are segmented according to the pixel information of each pixel in the current image and the pixel information of each pixel in the target image, so as to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image.
[0036] The current image may be the image to be refreshed that is currently displayed, and the target image may be the image that is refreshed by overwriting the current image. In one example, the current image and the target image may be adjacent video frames in a video frame set, wherein the current image is the video frame displayed first, and the target image is the video frame displayed later.
[0037] The pixel information may be information used to describe the color characteristics of the pixel. For example, the pixel information may be a pixel value, a grayscale value, or a component value of each color channel (eg, red, green, blue, etc.).
[0038] In an exemplary embodiment of the present application, the terminal can obtain pixel information of each pixel in the current image and pixel information of each pixel in the target image, and respectively perform segmentation processing on the current image and the target image according to the pixel information of each pixel in the current image and the pixel information of each pixel in the target image, so as to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image.
[0039] In one example, the terminal can classify the pixels contained in the current image according to the pixel information of each pixel in the current image, for example, classify the pixels whose difference between pixel values is less than a predetermined threshold into one category, etc., so as to obtain multiple categories of pixels. Thus, the terminal can segment the current image according to the areas where the multiple categories of pixels are located, and obtain at least one first sub-image corresponding to the multiple categories of pixels. It should be noted that the areas where the same category of pixels are located can be continuous or separate, and the present application does not make special restrictions on this. Similarly, the terminal can also segment the target image according to the pixel information of each pixel of the target image, and obtain at least one second sub-image corresponding to each category of pixels in the target image.
[0040] It should be noted that there is no overlap between any two first sub-images or between any two second sub-images, and all first sub-images can be combined into a complete current image, and all second sub-images can also be combined into a complete target image.
[0041] It should be understood that the at least one mentioned in the present application may be one, or may be any number of two or more than two, and the present application does not make any special limitation on this.
[0042] In step S120, a difference area between the current image and the target image is determined according to each of the first sub-images and each of the second sub-images.
[0043] In an exemplary embodiment of the present application, after segmenting to obtain the first sub-image and the second sub-image, the terminal may match the first sub-image and the second sub-image to determine whether there are matching first sub-images and second sub-images. If a first sub-image matches a second sub-image, it means that the second sub-image has not changed relative to the first sub-image, that is, there is no need to refresh the first sub-image. If a second sub-image does not have a matching first sub-image, it means that the first sub-image at the same position as the second sub-image needs to be refreshed.
[0044] In one example, the terminal can compare pixel information of pixel points at corresponding positions in the first sub-image and the second sub-image. If the total difference between the pixel information of pixel points at corresponding positions in the first sub-image and the second sub-image is less than a certain threshold, it can indicate that the first sub-image matches the second sub-image.
[0045] In other examples, the terminal may also compare the number of pixels contained in the first sub-image and the second sub-image or the total value of the pixel values of each pixel in the first sub-image and the second sub-image, for example, whether the number of pixels contained in the first sub-image and the second sub-image is equal, or whether the total value of the pixel values of the pixels is equal or close, etc., to determine whether the first sub-image matches the second sub-image. Those skilled in the art may select the above corresponding matching method or adopt other matching methods according to actual implementation needs, and this application does not specifically limit this.
[0046] In this embodiment, if a second sub-image does not match the corresponding first sub-image, the area where the second sub-image is located can be identified as a difference area, and during subsequent refreshes, only the difference area can be refreshed, thereby improving the frame rate of image refresh.
[0047] In step S130, the image content at the position corresponding to the difference area in the current image is refreshed according to the image content at the position corresponding to the difference area in the target image to obtain a display image.
[0048] In this embodiment, after the difference area is determined, the image content at the position corresponding to the difference area in the current image can be refreshed according to the position information of the difference area and the image content at the position corresponding to the difference area in the target image, so as to obtain a display image for display.
[0049] Therefore, in Figure 1In the embodiment shown, the current image and the target image are segmented according to the pixel information of each pixel in the current image and the pixel information of each pixel in the target image, so as to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image, and then the difference area between the current image and the target image is determined according to each first sub-image and the second sub-image, and then the image content at the position corresponding to the difference area in the current image is refreshed according to the image content at the position corresponding to the difference area in the target image to obtain the display image. Therefore, it is not necessary to refresh and draw the entire current image, but only the content corresponding to the difference area needs to be refreshed, so that the resource occupation caused by image refresh can be reduced, and the frame rate of image refresh can also be improved, thereby ensuring the viewing experience of users.
[0050] based on Figure 1 The embodiment shown, Figure 2 An embodiment according to the present application is shown. Figure 1 The schematic diagram of the flow chart of step S110 in the method for drawing an image of Figure 2 As shown, both the current image and the target image are RGB images, and the pixel information includes component values of three color channels; then step S110 at least includes steps S210 to S230, which are described in detail as follows:
[0051] In step S210, a calculation is performed based on the component values of the three color channels in each pixel in the current image to obtain a first dissimilarity between any pixel in the current image and its adjacent pixels.
[0052] The dissimilarity can be used to describe the difference between adjacent pixels. The greater the dissimilarity, the greater the difference between the adjacent pixels, and vice versa.
[0053] Among them, the adjacent pixel points may be four pixel points located above, below, to the left, and to the right of the pixel point, or eight pixel points located above, below, to the left, to the right, to the upper left, to the upper right, to the lower left, and to the lower right of the pixel point, etc. Those skilled in the art may calculate the dissimilarity between adjacent pixel points according to actual implementation requirements. For example, if the processing accuracy requirement is high, the dissimilarity between eight adjacent pixel points may be calculated.
[0054] In an exemplary embodiment of the present application, the terminal can calculate based on the component values of the three color channels of each pixel in the current image to obtain the first dissimilarity between any pixel and its adjacent pixel. In one example, if the component values of the three color channels of a certain pixel are A, B, and C, respectively, and the component values of the three color channels of the adjacent pixel are a, b, and c, respectively, the dissimilarity S between the two can be calculated by the following formula:
[0055]
[0056] Thus, the difference between adjacent pixels can be accurately calculated by the above formula. It should be noted that those skilled in the art may also use other formulas for calculation, and this application does not make any special limitation thereto.
[0057] In step S220, a calculation is performed based on the component values of the three color channels in each pixel in the target image to obtain a second dissimilarity between any pixel in the target image and its adjacent pixels.
[0058] In this step, the terminal may perform calculation based on the above-mentioned first dissimilarity calculation method to obtain a second dissimilarity between any pixel point in the target image and its adjacent pixel points, which will not be described in detail in this application.
[0059] In step S230, the current image and the target image are segmented according to the first dissimilarity and the second dissimilarity to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image.
[0060] Therefore, by performing segmentation processing on the current image and the target image through the dissimilarity between adjacent pixels, it is possible to ensure the differences between the first sub-images and the second sub-images obtained by segmentation, thereby ensuring the accuracy of subsequent matching.
[0061] In one example, according to the first dissimilarity and the second dissimilarity, the current image and the target image are segmented to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image, including:
[0062] According to the first dissimilarity, taking each pixel point in the current image as a vertex, using a minimum spanning tree algorithm to merge each pixel point in the current image, so as to obtain at least one first minimum spanning tree corresponding to the current image;
[0063] Segmenting the current image based on the pixels included in each first minimum spanning tree to obtain at least one first sub-image corresponding to the current image;
[0064] According to the second dissimilarity, taking each pixel in the target image as a vertex, using a minimum spanning tree algorithm to merge each pixel in the target image, so as to obtain at least one second minimum spanning tree corresponding to the target image;
[0065] The target image is segmented based on the pixel points included in each second minimum spanning tree to obtain at least one second sub-image corresponding to the target image.
[0066] In this embodiment, the terminal can use a minimum spanning tree algorithm, with each pixel in the current image as a vertex, and the first dissimilarity as the weight of the corresponding edge, so as to merge each pixel in the current image and obtain at least one first minimum spanning tree corresponding to the current image. It should be understood that each first minimum spanning tree can contain at least one pixel, and the combination of the pixels contained in all first minimum spanning trees is all the pixels in the current image. The terminal can perform segmentation processing on the current image according to the pixels contained in each first minimum spanning tree to obtain at least one first sub-image corresponding to the current image. Therefore, compared with the clustering algorithm, segmentation by generating a minimum spanning tree can improve segmentation efficiency, ensure the difference between different first sub-images, and ensure the accuracy of subsequent matching.
[0067] Similarly, the terminal may also perform segmentation processing on the target image to obtain at least one corresponding second sub-image, which will not be described in detail in this application.
[0068] based on Figure 1 In the embodiment shown, in an exemplary embodiment of the present application, determining the difference area between the current image and the target image according to each of the first sub-images and each of the second sub-images includes:
[0069] According to the position information of each second sub-image in the target image, each second sub-image is matched with a first sub-image within a specified range in the current image to determine a matching first sub-image and a second sub-image, wherein the specified range corresponds to the position information;
[0070] An area of the second sub-image where no matching first sub-image exists is identified as a difference area.
[0071] In this embodiment, in order to improve the matching efficiency, the terminal can match each second sub-image with the first sub-image within a specified range in the current image according to the position information of each second sub-image in the target image, thereby determining the matching first sub-image and second sub-image, wherein the specified range corresponds to the position information of each second sub-image.
[0072] In one example, the specified range may be pre-set by a person skilled in the art based on prior experience, for example, the specified range may be a range within 500 pixels centered on the position of the second sub-image, etc. A person skilled in the art may determine the corresponding specified range based on actual implementation needs, and this application does not specifically limit this. Thus, the second sub-image does not need to be matched with all of the first sub-images, and the matching efficiency can be improved while ensuring the matching accuracy.
[0073] If there is no matching first sub-image within the specified range, the second sub-image is determined to be a changed area. Therefore, the area where the second sub-image is located can be identified as a difference area, and the image content in the difference area in the current image needs to be refreshed.
[0074] Based on the above embodiment, in an exemplary embodiment of the present application, according to the position information of each second sub-image in the target image, matching the second sub-image with the first sub-image in the current image within a predetermined range of the position information, and determining the matching first sub-image and second sub-image includes:
[0075] Determining a designated range in the current image corresponding to the position information of each second sub-image according to the position information of each second sub-image in the target image and a preset image translation threshold, wherein the translation threshold includes a horizontal translation threshold and a vertical translation threshold;
[0076] Each of the second sub-images is matched with a first sub-image within a specified range in the current image to determine the first sub-image and the second sub-image that match each other.
[0077] In this embodiment, those skilled in the art can pre-set the allowed image translation threshold based on prior experience, and the translation threshold may include a horizontal translation threshold and a vertical translation threshold. Based on the position information of the second sub-image and the translation threshold, the terminal can determine the specified range corresponding to the position of the second sub-image. For example, assuming that the maximum allowable displacement (i.e., the translation threshold) of the image block in the horizontal and vertical directions is Xmax and Ymax, then within the range of (M+2*Xmax, N+2*Ymax) centered on the position (M, N) of the second sub-image, each possible first sub-image is matched to determine whether there is a first sub-image that matches the second sub-image. As a result, each second sub-image does not need to be matched with all first sub-images, which improves the matching efficiency and thereby improves the frame rate of subsequent image refreshes.
[0078] In an exemplary embodiment of the present application, before determining the specified range corresponding to the position information of each second sub-image in the current image according to the position information of each second sub-image in the target image and a preset image translation threshold, the method further includes:
[0079] Matching each of the second sub-images with each of the first sub-images respectively, and determining the first sub-image with the highest matching degree with each of the second sub-images;
[0080] Based on the position information of the second sub-image and the position information of the first sub-image with the highest matching degree with the second sub-image, the horizontal translation amount and the vertical translation amount between the second sub-image and the first sub-image with the highest matching degree are determined to serve as the horizontal translation threshold and the vertical translation threshold corresponding to the second sub-image, respectively.
[0081] In this embodiment, the terminal can match the second sub-image with each first sub-image in the current image respectively, so as to determine the matching degree between each second sub-image and each first sub-image. The matching degree is used to characterize the similarity between the second sub-image and the first sub-image. The higher the matching degree, the more similar the two are.
[0082] The terminal may determine that the first sub-image with the highest matching degree with the second sub-image is the "fixed-point sub-image", and determine the horizontal translation amount and the vertical translation amount between the second sub-image and the "fixed-point sub-image" with the highest matching degree according to the position information of the two. Thus, the horizontal translation amount is used as the horizontal translation threshold corresponding to the second sub-image, and the vertical translation amount is used as the vertical translation threshold corresponding to the second sub-image.
[0083] It can be understood that by determining the first sub-image with the highest matching degree with the second sub-image, the horizontal translation threshold and the vertical translation threshold corresponding to the second sub-image are determined, and then the specified range corresponding to the second sub-image is determined based on the horizontal translation threshold and the vertical translation threshold, thereby improving the efficiency and accuracy of subsequent matching and avoiding large-range matching that affects the matching efficiency.
[0084] In one example, when determining the translation threshold, a rougher matching method can be used, such as only comparing the number of pixels between the first sub-image and the second sub-image, so as to quickly determine the translation threshold. When subsequently matching within a specified range, multi-dimensional information can be compared, such as the number of pixels, the size of pixel values, the shape of the image, etc., and a more refined matching method can be used to improve the accuracy of the matching results.
[0085] It should be understood that although Figure 1-2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1-2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0086] In one embodiment, Figure 3 As shown, a device for drawing an image is provided, comprising:
[0087] The segmentation module 310 is used to segment the current image and the target image according to the pixel information of each pixel in the current image and the pixel information of each pixel in the target image, so as to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image;
[0088] A determination module 320, configured to determine a difference area between the current image and the target image according to each of the first sub-images and each of the second sub-images;
[0089] The processing module 330 is used to refresh the image content at the position corresponding to the difference area in the current image according to the image content at the position corresponding to the difference area in the target image to obtain a display image.
[0090] In one embodiment, the current image and the target image are RGB images, and the pixel information includes component values of three color channels; the segmentation module 310 includes:
[0091] a first calculation unit, configured to calculate, based on component values of three color channels in each pixel in the current image, to obtain a first dissimilarity between any pixel in the current image and its adjacent pixels;
[0092] a second calculation unit, configured to calculate, based on the component values of the three color channels in each pixel in the target image, to obtain a second dissimilarity between any pixel in the target image and its adjacent pixels;
[0093] A segmentation unit is used to segment the current image and the target image according to the first dissimilarity and the second dissimilarity, respectively, to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image.
[0094] In one embodiment, the segmentation unit is used to: based on the first dissimilarity, take each pixel point in the current image as a vertex, use a minimum spanning tree algorithm to merge each pixel point in the current image, and obtain at least one first minimum spanning tree corresponding to the current image; based on the pixel points included in each first minimum spanning tree, segment the current image to obtain at least one first sub-image corresponding to the current image; based on the second dissimilarity, take each pixel point in the target image as a vertex, use a minimum spanning tree algorithm to merge each pixel point in the target image, and obtain at least one second minimum spanning tree corresponding to the target image; based on the pixel points included in each second minimum spanning tree, segment the target image to obtain at least one second sub-image corresponding to the target image.
[0095] In one embodiment, the determination module 320 is used to: match each of the second sub-images with the first sub-image within a specified range in the current image according to the position information of each of the second sub-images in the target image, determine the matching first sub-image and second sub-image, and the specified range corresponds to the position information; identify the area where the second sub-image is located where there is no matching first sub-image as a difference area.
[0096] In one embodiment, the determination module 320 is used to: determine a specified range in the current image corresponding to the position information of each second sub-image based on the position information of each second sub-image in the target image and a preset image translation threshold, wherein the translation threshold includes a horizontal translation threshold and a vertical translation threshold; match each second sub-image with a first sub-image within the specified range in the current image to determine matching first sub-images and second sub-images.
[0097] In one embodiment, the determination module 320 is further used to: match each of the second sub-images with each of the first sub-images respectively to determine the first sub-image with the highest degree of match with each of the second sub-images; and determine the horizontal translation amount and the vertical translation amount between the second sub-image and the first sub-image with the highest degree of match with the second sub-image based on the position information of the second sub-image and the position information of the first sub-image with the highest degree of match with the second sub-image, to serve as the horizontal translation threshold and the vertical translation threshold corresponding to the second sub-image, respectively.
[0098] The specific definition of the image drawing device can refer to the definition of the image drawing method above, which will not be repeated here. Each module in the above-mentioned image drawing device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0099] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for drawing an image is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0100] Those skilled in the art will understand that Figure 4The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0101] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0102] According to pixel information of each pixel in the current image and pixel information of each pixel in the target image, segment the current image and the target image respectively to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image;
[0103] Determining a difference area between the current image and the target image according to each of the first sub-images and each of the second sub-images;
[0104] According to the image content at the position corresponding to the difference area in the target image, the image content at the position corresponding to the difference area in the current image is refreshed to obtain a display image.
[0105] In one embodiment, the current image and the target image are RGB images, and the pixel information includes component values of three color channels; when the processor executes the computer program, the following steps are further implemented:
[0106] A first dissimilarity between any pixel in the current image and its adjacent pixel is calculated based on the component values of the three color channels in each pixel in the current image; a second dissimilarity between any pixel in the target image and its adjacent pixel is calculated based on the component values of the three color channels in each pixel in the target image; and a segmentation process is performed on the current image and the target image based on the first dissimilarity and the second dissimilarity, respectively, to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image.
[0107] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0108] According to the first dissimilarity, taking each pixel point in the current image as a vertex, a minimum spanning tree algorithm is used to merge each pixel point in the current image to obtain at least one first minimum spanning tree corresponding to the current image; based on the pixel points included in each first minimum spanning tree, the current image is segmented to obtain at least one first sub-image corresponding to the current image; according to the second dissimilarity, taking each pixel point in the target image as a vertex, a minimum spanning tree algorithm is used to merge each pixel point in the target image to obtain at least one second minimum spanning tree corresponding to the target image; based on the pixel points included in each second minimum spanning tree, the target image is segmented to obtain at least one second sub-image corresponding to the target image.
[0109] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0110] According to the position information of each second sub-image in the target image, each second sub-image is matched with the first sub-image within a specified range in the current image to determine the matching first sub-image and second sub-image, and the specified range corresponds to the position information; the area where the second sub-image does not exist and the matching first sub-image is located is identified as the difference area.
[0111] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0112] According to the position information of each second sub-image in the target image and a preset image translation threshold, a specified range in the current image corresponding to the position information of each second sub-image is determined, and the translation threshold includes a horizontal translation threshold and a vertical translation threshold; each second sub-image is matched with the first sub-image within the specified range in the current image to determine the matching first sub-image and second sub-image.
[0113] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0114] Match each of the second sub-images with each of the first sub-images respectively to determine the first sub-image with the highest degree of match with each of the second sub-images; determine the horizontal translation amount and the vertical translation amount between the second sub-image and the first sub-image with the highest degree of match with the second sub-image based on the position information of the second sub-image and the position information of the first sub-image with the highest degree of match with the second sub-image, as the horizontal translation threshold and the vertical translation threshold corresponding to the second sub-image, respectively.
[0115] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0116] According to pixel information of each pixel in the current image and pixel information of each pixel in the target image, segment the current image and the target image respectively to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image;
[0117] Determining a difference area between the current image and the target image according to each of the first sub-images and each of the second sub-images;
[0118] According to the image content at the position corresponding to the difference area in the target image, the image content at the position corresponding to the difference area in the current image is refreshed to obtain a display image.
[0119] In one embodiment, the current image and the target image are RGB images, and the pixel information includes component values of three color channels; when the computer program is executed by the processor, the following steps are also implemented:
[0120] A first dissimilarity between any pixel in the current image and its adjacent pixel is calculated based on the component values of the three color channels in each pixel in the current image; a second dissimilarity between any pixel in the target image and its adjacent pixel is calculated based on the component values of the three color channels in each pixel in the target image; and a segmentation process is performed on the current image and the target image based on the first dissimilarity and the second dissimilarity, respectively, to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image.
[0121] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0122] According to the first dissimilarity, taking each pixel point in the current image as a vertex, a minimum spanning tree algorithm is used to merge each pixel point in the current image to obtain at least one first minimum spanning tree corresponding to the current image; based on the pixel points included in each first minimum spanning tree, the current image is segmented to obtain at least one first sub-image corresponding to the current image; according to the second dissimilarity, taking each pixel point in the target image as a vertex, a minimum spanning tree algorithm is used to merge each pixel point in the target image to obtain at least one second minimum spanning tree corresponding to the target image; based on the pixel points included in each second minimum spanning tree, the target image is segmented to obtain at least one second sub-image corresponding to the target image.
[0123] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0124] According to the position information of each second sub-image in the target image, each second sub-image is matched with the first sub-image within a specified range in the current image to determine the matching first sub-image and second sub-image, and the specified range corresponds to the position information; the area where the second sub-image does not exist and the matching first sub-image is located is identified as the difference area.
[0125] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0126] According to the position information of each second sub-image in the target image and a preset image translation threshold, a specified range in the current image corresponding to the position information of each second sub-image is determined, and the translation threshold includes a horizontal translation threshold and a vertical translation threshold; each second sub-image is matched with the first sub-image within the specified range in the current image to determine the matching first sub-image and second sub-image.
[0127] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0128] Match each of the second sub-images with each of the first sub-images respectively to determine the first sub-image with the highest degree of match with each of the second sub-images; determine the horizontal translation amount and the vertical translation amount between the second sub-image and the first sub-image with the highest degree of match with the second sub-image based on the position information of the second sub-image and the position information of the first sub-image with the highest degree of match with the second sub-image, as the horizontal translation threshold and the vertical translation threshold corresponding to the second sub-image, respectively.
[0129] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0130] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0131] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the patent application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent application shall be subject to the attached claims.
Claims
1. A method for drawing an image, characterized in that: include: According to pixel information of each pixel in the current image and pixel information of each pixel in the target image, segment the current image and the target image respectively to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image; Determining the difference area between the current image and the target image according to each of the first sub-images and each of the second sub-images includes: matching each of the second sub-images with a first sub-image within a specified range in the current image according to position information of each of the second sub-images in the target image to determine a matched first sub-image and a second sub-image, wherein the specified range corresponds to the position information; and identifying an area where the second sub-image does not have a matched first sub-image as a difference area; Refreshing the image content at the position corresponding to the difference area in the current image according to the image content at the position corresponding to the difference area in the target image to obtain a display image; Among them, according to the position information of each second sub-image in the target image, the second sub-image is matched with the first sub-image in the current image within a predetermined range of the position information to determine the matching first sub-image and second sub-image, including: according to the position information of each second sub-image in the target image and a preset image translation threshold, a specified range in the current image corresponding to the position information of each second sub-image is determined, the translation threshold including a horizontal translation threshold and a vertical translation threshold; each second sub-image is matched with the first sub-image within the specified range in the current image to determine the matching first sub-image and second sub-image.
2. The image drawing method according to claim 1, characterized in that: The current image and the target image are RGB images, and the pixel information includes component values of three color channels; According to pixel point information of each pixel point in the current image and pixel point information of each pixel point in the target image, the current image and the target image are segmented to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image, including: Calculating according to the component values of the three color channels in each pixel in the current image, to obtain a first dissimilarity between any pixel in the current image and its adjacent pixels; Calculating according to the component values of the three color channels in each pixel in the target image, obtaining a second dissimilarity between any pixel in the target image and its adjacent pixels; According to the first dissimilarity and the second dissimilarity, the current image and the target image are segmented to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image.
3. The image drawing method according to claim 2, characterized in that: According to the first dissimilarity and the second dissimilarity, the current image and the target image are segmented to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image, including: According to the first dissimilarity, taking each pixel point in the current image as a vertex, using a minimum spanning tree algorithm to merge each pixel point in the current image, so as to obtain at least one first minimum spanning tree corresponding to the current image; Segmenting the current image based on the pixels included in each first minimum spanning tree to obtain at least one first sub-image corresponding to the current image; According to the second dissimilarity, taking each pixel in the target image as a vertex, using a minimum spanning tree algorithm to merge each pixel in the target image, so as to obtain at least one second minimum spanning tree corresponding to the target image; The target image is segmented based on the pixel points included in each second minimum spanning tree to obtain at least one second sub-image corresponding to the target image.
4. The image drawing method according to claim 1, characterized in that: Before determining the designated range corresponding to the position information of each second sub-image in the current image according to the position information of each second sub-image in the target image and a preset image translation threshold, the method further includes: Matching each of the second sub-images with each of the first sub-images respectively, and determining the first sub-image with the highest matching degree with each of the second sub-images; Based on the position information of the second sub-image and the position information of the first sub-image with the highest matching degree with the second sub-image, the horizontal translation amount and the vertical translation amount between the second sub-image and the first sub-image with the highest matching degree are determined to serve as the horizontal translation threshold and the vertical translation threshold corresponding to the second sub-image, respectively.
5. An image drawing device, characterized in that: The device comprises: a segmentation module, configured to segment the current image and the target image respectively according to pixel information of each pixel in the current image and pixel information of each pixel in the target image, so as to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image; a determination module, configured to determine a difference region between the current image and the target image according to each of the first sub-images and each of the second sub-images, comprising: matching each of the second sub-images with a first sub-image within a specified range in the current image according to position information of each of the second sub-images in the target image, and determining a matched first sub-image and a second sub-image, wherein the specified range corresponds to the position information; and identifying a region where the second sub-image does not have a matched first sub-image as a difference region; A processing module, configured to refresh the image content at the position corresponding to the difference area in the current image according to the image content at the position corresponding to the difference area in the target image, so as to obtain a display image; The determination module is specifically used to: determine the specified range in the current image corresponding to the position information of each second sub-image based on the position information of each second sub-image in the target image and a preset image translation threshold, wherein the translation threshold includes a horizontal translation threshold and a vertical translation threshold; match each second sub-image with the first sub-image within the specified range in the current image to determine the matching first sub-image and second sub-image.
6. The image drawing device according to claim 5, characterized in that: The current image and the target image are RGB images, and the pixel information includes component values of three color channels; the segmentation module includes: a first calculation unit, configured to calculate, based on component values of three color channels in each pixel in the current image, to obtain a first dissimilarity between any pixel in the current image and its adjacent pixels; a second calculation unit, configured to calculate, based on the component values of the three color channels in each pixel in the target image, to obtain a second dissimilarity between any pixel in the target image and its adjacent pixels; A segmentation unit is used to segment the current image and the target image according to the first dissimilarity and the second dissimilarity, respectively, to obtain at least one first sub-image corresponding to the current image and at least one second sub-image corresponding to the target image.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
8. A computer-readable storage medium having a computer program stored thereon, 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 4 are implemented.
