Image processing methods, apparatuses and electronic devices
By generating a second sequence of color images in electronic devices, the problems of inflexible configuration and large storage space required for pre-made images are solved, enabling more flexible image display and optimized storage space.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-13
- Publication Date
- 2026-04-03
AI Technical Summary
Pre-made background or theme images in existing electronic devices cannot be configured flexibly and in a variety of ways, and they occupy a large amount of storage space.
By acquiring a first sequence of grayscale images, inserting images are generated based on playback target parameters, and color images are determined using target color and grayscale values, generating a second sequence of color images, thus avoiding direct storage of color images.
It reduces storage space usage and provides more flexible and diverse image display effects when color images need to be output.
Smart Images

Figure CN115205405B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and more specifically, to an image processing method, apparatus, and electronic device. Background Technology
[0002] As electronic devices can display increasingly diverse images, users have higher demands for image display experiences. For example, images can be used as background or main images for certain interfaces. Smartwatches, for instance, can use animated images as watch faces. However, these images are pre-made, limiting the flexibility of configuring background or main images on electronic devices, and pre-made images also occupy relatively large storage spaces. Summary of the Invention
[0003] In view of the above problems, this application proposes an image processing method, apparatus, and electronic device to improve the above problems.
[0004] In a first aspect, this application provides an image processing method applied to an electronic device, the method comprising: acquiring a first sequence of images, wherein each frame of the first sequence of images is a grayscale image; generating an insert image corresponding to the first sequence of images based on playback target parameters and the first sequence of images; determining a color image corresponding to each frame of the first sequence of images and a color image corresponding to the insert image based on a target color and a grayscale value, so as to obtain a second sequence of images; and outputting the second sequence of images.
[0005] Secondly, this application provides an image processing apparatus operating in an electronic device, the apparatus comprising: an image acquisition unit for acquiring a first sequence of images, wherein each frame of the first sequence of images is a grayscale image; an image generation unit for generating an inserted image corresponding to the first sequence of images based on playback target parameters and the first sequence of images; an image processing unit for determining a color image corresponding to each frame of the first sequence of images and a color image corresponding to the inserted image based on a target color and a grayscale value, to obtain a second sequence of images; and an output unit for outputting the second sequence of images.
[0006] Thirdly, this application provides an electronic device including one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs being configured to perform the methods described above.
[0007] Fourthly, this application provides a computer-readable storage medium storing program code, wherein the above-described method is executed when the program code is run.
[0008] This application provides an image processing method, apparatus, and electronic device. After acquiring a first sequence of images, all of which are grayscale images, an inserted image corresponding to the first sequence of images is generated based on playback target parameters and the first sequence of images. Based on the target color and grayscale values, a color image corresponding to each frame in the first sequence of images and the color image corresponding to the inserted image are determined to obtain a second sequence of images, which are then output. This method allows the electronic device to output a color image without storing the color image itself, instead of storing the first sequence of grayscale images. The second sequence of images, which consists of all grayscale images, is then calculated based on the determined target color and the grayscale values of the images in the first sequence of images. This reduces the storage space required by the electronic device and also allows for a more flexible and diverse way of obtaining the second sequence of images for output. Attached Figure Description
[0009] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0010] Figure 1 This paper illustrates an application scenario of the image processing method proposed in this application.
[0011] Figure 2 A flowchart of an image processing method proposed in an embodiment of this application is shown;
[0012] Figure 3 A schematic diagram of the first sequence of images proposed in this application is shown;
[0013] Figure 4 A schematic diagram of a method for selecting a first sequence of images according to this application is shown;
[0014] Figure 5 A schematic diagram of another option for the first sequence image proposed in this application is shown;
[0015] Figure 6 This illustration shows a schematic diagram of inserting a first sequence of images into an image according to the present application;
[0016] Figure 7 A schematic diagram of a second sequence image proposed in this application is shown;
[0017] Figure 8 A flowchart of an image processing method according to another embodiment of this application is shown;
[0018] Figure 9 This application shows Figure 8 A flowchart of one embodiment of S230;
[0019] Figure 10 A schematic diagram of the first time length and the second time length proposed in the embodiments of this application is shown;
[0020] Figure 11 A flowchart of an image processing method according to another embodiment of this application is shown;
[0021] Figure 12 This illustration shows a schematic diagram of a pixel being converted from grayscale mode to color mode in this application;
[0022] Figure 13 A flowchart of an image processing method according to another embodiment of this application is shown;
[0023] Figure 14 A flowchart of an image processing method according to another embodiment of this application is shown;
[0024] Figure 15 This paper shows a structural block diagram of an image processing apparatus according to an embodiment of the present application;
[0025] Figure 16 A structural block diagram of an image processing apparatus according to another embodiment of this application is shown;
[0026] Figure 17 A structural block diagram of an electronic device proposed in this application is shown;
[0027] Figure 18 This is a storage unit in this application embodiment for storing or carrying program code that implements the image processing method according to this application embodiment. Detailed Implementation
[0028] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0029] As users of electronic devices increasingly demand higher visual experiences, many interfaces on these devices now allow for the changing of background or theme images. For example, in smartwatches, the watch face's theme image can be changed according to the user's preferences. Similarly, in smartphones, the desktop background image can also be changed. Furthermore, in electronic devices, pre-acquired source images can be used, allowing the device to select these images as the background or theme image for a specific interface.
[0030] The inventors discovered during their research on relevant source images that images used as background or main images are usually pre-made, which may prevent them from perfectly matching each user's individual needs. Furthermore, pre-made images tend to occupy a relatively large amount of storage space.
[0031] Therefore, the inventors have proposed an image processing method, apparatus, and electronic device in this application. After acquiring a first sequence of images, in which all included images are grayscale images, an inserted image corresponding to the first sequence of images is generated based on playback target parameters and the first sequence of images. Based on the target color and grayscale value, the color image corresponding to each frame of the first sequence of images and the color image corresponding to the inserted image are determined to obtain a second sequence of images, and then the second sequence of images is output.
[0032] Thus, by means of the above method, electronic devices can, when a final color image is required, not store the color image, but instead store a first sequence of images, all of which are grayscale images, and then calculate a second sequence of images, which includes all color images, based on a determined target color and the grayscale values of the images in the first sequence of images. This reduces the storage space occupied by the electronic device, and also enables a more flexible and diverse way to obtain the second sequence of images as output.
[0033] The application scenarios involved in the embodiments of this application will be introduced below.
[0034] like Figure 1 As shown, in Figure 1The scenario shown includes a smartphone 100 and a smartwatch 200. The smartphone 100 and smartwatch 200 can communicate via near-field communication (e.g., WiFi or Bluetooth) or mobile communication (e.g., a communication base station). The image processing method provided in this embodiment can be performed independently by the smartphone 100, independently by the smartwatch 200, or in cooperation between the smartphone 100 and the smartwatch 200. For example, the smartphone 100 can perform the following actions: acquiring a first sequence of images; generating an inserted image corresponding to the first sequence of images based on playback target parameters and the first sequence of images; determining the color image corresponding to each frame of the first sequence of images and the color image corresponding to the inserted image based on the target color and grayscale value to obtain a second sequence of images; then transmitting the second sequence of images to the smartwatch 200, which then continues to output the second sequence of images. Optionally, the smartwatch 200 outputting the second sequence of images may include playing the second sequence of images.
[0035] It should be noted that the smartphone 100 is merely exemplary, and can be replaced by devices such as tablets or computers. Furthermore, the electronic device running the image processing method in this embodiment can be either the smartphone 100 or a smartwatch 200.
[0036] Please see Figure 2 This application provides an image processing method applied to an electronic device, the method comprising:
[0037] S110: Obtain a first sequence of images, wherein each frame of the first sequence of images is a grayscale image.
[0038] This involves pre-storing multiple sets of image sequences, and then selecting one set of image sequences as the first image sequence. Each frame in each set of image sequences is a grayscale image. For example,... Figure 3 As shown, a sequence of images is presented. Figure 3 The sequence of images shown includes 9 frames. The first frame in the playback order is image a. Then, the images are played in the order shown by arrow 10 until image b is played. After image b is played, image c is played. Then, the images are played in the order shown by arrow 11 until image d is played.
[0039] A grayscale image can be understood as an image that uses grayscale to represent content. In the field of computer science, a grayscale image is an image where each pixel has only one sampled color, and a grayscale image can be displayed as grayscale ranging from the darkest black to the brightest white.
[0040] In the embodiments of this application, there are multiple ways to determine the first sequence of images.
[0041] One approach is to determine the first image sequence from multiple sets of image sequences based on the user's selection. It should be noted that the color effects of the resulting second image sequences will differ depending on the set of image sequences. The user can then determine the first image sequence from the multiple sets of image sequences based on the desired color effect of the final second image sequence. Different color effects can characterize the visual effect perceived by the user. For example, color effects can include vibrant, muted, and soft. For instance, as shown... Figure 4 As shown, the interface of the electronic device can display color effects 1, 2, and 3. Each color effect can correspond to a sequence of images. For example, color 1 corresponds to sequence image 20, color 2 corresponds to sequence image 21, and color 3 corresponds to sequence image 22. If color 1 is selected, then sequence image 20 corresponding to color 1 will be used as the first sequence image.
[0042] Alternatively, a first sequence of images can be determined based on images captured by an electronic device. In this method, the electronic device can identify the color effects of the captured images and then use the sequence of images corresponding to the identified color effects as the second sequence of images. Optionally, in this embodiment, the color effects may include image parameters such as the number of colors, saturation, and brightness. After acquiring the captured image, the electronic device can obtain the image parameters of the captured image, then match the image parameters with pre-set image parameters corresponding to each color effect, and then use the color effect corresponding to the matched image parameters as the target color effect, and use the sequence of images corresponding to the target color effect as the first sequence of images.
[0043] In this approach, the images captured by the electronic device can be images captured by a device other than the receiving electronic device, or images captured by the electronic device's own camera. For example, such as... Figure 5 As shown, taking a smartwatch 200 as an example, the smartwatch 200 can receive images 20 captured by the smartphone 100, and then match the color effects of images 20 to obtain a first sequence of images. Alternatively, the smartwatch 200 can also match the color effects of images 21 captured by its own camera 201 to obtain a first sequence of images.
[0044] As another approach, the first sequence of images can be selected using AI. Optionally, a trained neural network model can be used to select the first sequence of images. In this method, reference information can be input into the trained neural network model so that the model can output the selected first sequence of images based on the reference information. Optionally, the neural network model can be a CNN (Convolutional Neural Networks) model. The reference information input into the neural network can be textual or image-based.
[0045] S120: Based on the playback target parameters and the first sequence image, generate the insertion image corresponding to the first sequence image.
[0046] It should be noted that the playback target parameter represents the smoothness of playback of the subsequently generated second sequence of images. As one approach, the playback target parameter includes at least one of playback duration and playback frame rate. It is understood that frame rate is a factor affecting the user's visual experience. Frame rate can be understood as the number of images played per second, or the number of frames refreshed per second. A higher frame rate results in smoother, more realistic animation. Optionally, a frame rate of 30fps indicates 30 frames of images played per second, and a frame rate of 240fps indicates 240 frames of images played per second.
[0047] If the playback duration is extended, and the frame rate of the images in the first sequence is not increased simultaneously, the number of frames played per second will decrease, resulting in a stuttering effect. Therefore, in this embodiment, the insertion images are generated based on the playback duration and / or the playback frame rate, which makes the subsequently generated second sequence of images smoother.
[0048] After determining the playback target parameters, the insertion positions for image insertion in the first image sequence can be calculated based on these parameters. Then, the corresponding inset image is calculated for each insertion position. Optionally, the number of insertion positions can be calculated based on the playback target parameters, and then the specific locations of these insertion positions within the first image sequence can be determined, thus obtaining the insertion position for each inserted image.
[0049] For example, the first sequence of images includes images A, B, C, D, and E. After determining that 8 frames need to be inserted based on the playback target parameters, the insertion positions of these 8 frames can be evenly distributed among adjacent frames in the first sequence. For example, two frames can be inserted between images A and B, between images B and C, between images C and D, and between images D and E. Correspondingly, this means there will be two insertion positions between images A and B, two between images B and C, two between images C and D, and two between images D and E.
[0050] Regarding the insertion positions, besides distributing them evenly among adjacent frames of the first image sequence, all insertion positions can also be centrally configured between specified adjacent frames. For example, taking the first image sequence as including images A, B, C, D, and E, after determining that 6 frames need to be inserted based on the playback target parameters, the insertion positions of the required inset images can be configured between images B and C.
[0051] It should be noted that the images included in the determined first sequence are played in a predetermined chronological order, but the degree of content change between multiple pairs of adjacent frames may vary. For example, please refer to [link to relevant documentation]. Figure 3 In the diagram, image a and its adjacent images are relatively bright, so the grayscale values of image a and its adjacent frames are likely to be large, indicating that the content transformation between image a and its adjacent frames may be small. However, for image d and its adjacent images, image d is relatively bright, while the adjacent images are relatively dark, resulting in a significant difference in grayscale values between image d and its adjacent images. Correspondingly, the content transformation between image d and its adjacent frames may be significant. Therefore, inserting more images between adjacent frames with small content transformations may not significantly improve playback smoothness, while inserting more images between adjacent frames with large content transformations may contribute more to playback smoothness. Furthermore, electronic devices consume system resources when generating inset images. To maximize the playback smoothness of the second sequence of images and avoid unnecessary consumption of system resources, the electronic device can determine the number of insertion positions between adjacent frames based on the content transformation between adjacent frames in the first sequence of images, thus determining the number of inset images between adjacent frames.
[0052] One approach is that the greater the content change between adjacent frames, the more insertion positions are corresponding between those adjacent frames. For example, the first sequence of images includes images A, B, C, D, and E. If the content change between images D and E is the greatest, then the most insertion positions are corresponding between images D and E. It should be noted that in this embodiment, the specific method for determining the insertion positions is not limited; any method that allows for a greater content change between adjacent frames to result in more insertion positions can be applied in this embodiment.
[0053] Electronic devices can determine the degree of content change between adjacent frames in several ways. One method is to use the average grayscale value of adjacent frames. A greater difference in the average grayscale value indicates a greater degree of content change. The average grayscale value is the ratio of the sum of the grayscale values of each pixel to the number of pixels in the image. Another method is to use the number of pixels with the same grayscale value between adjacent frames. A higher number of pixels with the same grayscale value indicates a smaller degree of content change.
[0054] S130: Based on the target color and grayscale value, determine the color image corresponding to each frame in the first sequence of images and the color image corresponding to the inserted image to obtain the second sequence of images.
[0055] In this embodiment, the target color is the base color in the generated second sequence of images. This base color can be understood as all colors in the images included in the second sequence of images, except for this base color, being calculated from the base color. In this way, a correspondence between grayscale values and target colors can be established, allowing the electronic device to determine the degree to which each grayscale value corresponds to the target color based on this correspondence. For example, if the target color includes a first color, a second color, and a third color, and if the correspondence between grayscale value h and the first color is 100%, then during the generation of the second sequence of images, pixels with grayscale value h in the first sequence image or inserted image will be converted back to the first color. Converting to the first color can be understood as changing the values of multiple color channels of a pixel to the values of the respective color channels corresponding to the first color. For example, if the color mode corresponding to the second sequence image is RGB mode, and the multiple color channels corresponding to the first color include a red channel, a green channel, and a blue channel, and the value of the red channel corresponding to the first color is r1, the value of the green channel corresponding to the first color is g1, and the value of the blue channel corresponding to the first color is b1, then in the process of converting the pixel with grayscale value h to the first color, the value of the red channel corresponding to the pixel with grayscale value h will be configured as r1, the value of the green channel corresponding to the pixel with grayscale value h will be configured as g1, and the value of the blue channel corresponding to the pixel with grayscale value h will be configured as b1.
[0056] like Figure 6 As shown, the first sequence image is 40a, and the inserted images include images 51, 52, 53, 54, and 55. Therefore, after inserting the inserted images into the first sequence image 40a, we can obtain... Figure 7 The sequence of images 40b shown is used as an example. After each image in the sequence of images 40b is converted into a corresponding color image, a second sequence of images can be obtained.
[0057] It should be noted that the second image sequence can be generated in either animated image or video format. Animated images can be in GIF format, while video formats can be RMVB, RM, or FLV, etc.
[0058] S140: Output the second sequence image.
[0059] In one manner, outputting the second sequence of images includes playing the second sequence of images. Alternatively, besides directly playing the second sequence of images, the output method can also be sending it to a target terminal device for playback. Optionally, the electronic device is a smartphone, and the target terminal is a smartwatch. This embodiment provides an image processing method that, after acquiring a first sequence of images comprising all grayscale images, generates an inserted image corresponding to the first sequence of images based on playback target parameters and the first sequence of images. Based on the target color and grayscale value, it determines the color image corresponding to each frame in the first sequence of images and the color image corresponding to the inserted image to obtain a second sequence of images, and then outputs the second sequence of images. This method allows the electronic device to output a color image without storing the color image itself, instead storing the first sequence of images, which are all grayscale images, and then calculating the required output second sequence of images, comprising all color images, based on the determined target color and the grayscale value of the images in the first sequence of images. This reduces the storage space occupied by the electronic device and also achieves a more flexible and diverse way of obtaining the second sequence of images as output.
[0060] Please see Figure 8 This application provides an image processing method applied to an electronic device, the method comprising:
[0061] S210: Obtain a first sequence of images, wherein each frame of the first sequence of images is a grayscale image.
[0062] S220: Based on the playback target parameters, determine the insertion position between adjacent frame images in the first sequence of images.
[0063] S230: Based on the adjacent frame images corresponding to the insertion position and the ratio between the first time length and the second time length, determine the insertion image corresponding to the insertion position to obtain the insertion image corresponding to the first sequence image; wherein, the first time length is the time length between the insertion position and the adjacent frame corresponding to the insertion position in the previous frame image, and the second time length is the time length between the adjacent frames corresponding to the insertion position.
[0064] One method is to calculate the inserted image based on the following formula:
[0065] outGray=prevGray*(1-t)+nextGray*t
[0066] Where outGray represents the output color, prevGray represents the color in the previous frame (e.g., the grayscale value of each pixel) in an adjacent frame, nextGray represents the color in the next frame (e.g., the grayscale value of each pixel) in an adjacent frame, and t represents the percentage progress of the current insertion position within this time period (i.e., the time period between adjacent frames corresponding to the current insertion position). Based on this formula, as follows... Figure 9 As shown, determining the insertion image corresponding to the insertion position based on the adjacent frame images corresponding to the insertion position and the ratio between the first time length and the second time length includes:
[0067] S231: Obtain the ratio between the first time length and the second time length corresponding to the insertion position.
[0068] For example, such as Figure 10 As shown, adjacent frame images are image 60 and image 61. The inserted images between image 60 and image 61 include image 62 and image 63. Image 60 corresponds to playback time T0, and image 61 corresponds to playback time T1. The calculated insertion position for image 62 is time T2, and the insertion position for image 63 is time T3. Therefore, in... Figure 10 In the scenario shown, the adjacent frames corresponding to insertion position T2 are images 60 and 61. Therefore, the previous image in the adjacent frames corresponding to insertion position T2 is image 60. The corresponding first time length is T2-T0, and the second time length is T1-T0. For insertion position T3, the first time length is T3-T0, and the second time length is T1-T0.
[0069] S232: Obtain the first reference gray value corresponding to each pixel in the inserted image corresponding to the insertion position. The first reference pixel is the product of the gray value of the pixel in the previous frame image in the adjacent frame corresponding to the insertion position and the reference value. The reference value is the difference between the specified value and the ratio.
[0070] S233: Obtain the second reference gray value corresponding to each pixel in the inserted image corresponding to the insertion position. The second reference pixel is the product of the gray value of the pixel in the next frame image corresponding to the insertion position and the ratio.
[0071] S234: The sum of the first reference gray value and the second reference gray value corresponding to each pixel in the inserted image is used as the gray value of each pixel in the inserted image corresponding to the insertion position, so as to obtain the inserted image corresponding to the insertion position.
[0072] S240: Based on the target color and grayscale value, determine the color image corresponding to each frame in the first sequence of images and the color image corresponding to the inserted image to obtain the second sequence of images.
[0073] S250: Output the second sequence image.
[0074] This embodiment provides an image processing method that allows an electronic device to output a color image without storing the original color image. Instead, it can store a first sequence of grayscale images and then calculate a second sequence of color images based on a determined target color and the grayscale values of the images in the first sequence. This reduces the storage space required by the electronic device and allows for a more flexible and diverse way to obtain the second sequence of images for output. Furthermore, in this embodiment, during the generation of the inserted image, the insertion position can be determined after the insertion position is established, based on the time length between the insertion position and the corresponding adjacent frame in the previous frame. This allows the inserted images between adjacent frames to more naturally reflect the gradation process between them, resulting in a better visual effect for the final generated second sequence of images.
[0075] Please see Figure 11 This application provides an image processing method applied to an electronic device, the method comprising:
[0076] S310: Obtain a first sequence of images, wherein each frame in the first sequence of images is a grayscale image.
[0077] S320: Based on the playback target parameters and the first sequence image, generate the inserted image corresponding to the first sequence image.
[0078] S330: Insert the inserted image into the first sequence image to obtain a reference sequence image.
[0079] S340: Based on the grayscale value and target color of each frame in the reference sequence image, determine the color image corresponding to each frame in the reference sequence image to obtain the second sequence image.
[0080] In one approach, the target color includes a first target color, a second target color, and a third target color. The step of determining the color image corresponding to each frame of the reference sequence image based on the grayscale value and the target color of each frame in the reference sequence image to obtain the second sequence image includes:
[0081] If the grayscale value of a pixel in the reference sequence image is less than the grayscale threshold, add the first color value corresponding to the pixel and the second color value corresponding to the pixel as the color value of the pixel in the color image. Wherein, the first color value is the product of the first target color and the second ratio, the second ratio is the ratio of the first difference to the second difference, the first difference is the difference between the grayscale value of the pixel and the grayscale threshold, the second difference is the ratio of the specified value to the difference between the specified value and the grayscale threshold, the second color value is the product of the second target color and the third ratio, and the third ratio is the difference between the specified value and the second ratio.
[0082] If the grayscale value of a pixel in the reference sequence image is not less than the grayscale threshold, add the third color value corresponding to the pixel and the fourth color value corresponding to the pixel as the color value of the pixel in the color image. Wherein, the third color value is the product of the second target color and the third ratio, the third ratio is the ratio of the grayscale value of the pixel to the grayscale threshold, the fourth color value is the product of the third target color and the fourth ratio, and the fourth ratio is the difference between the specified value and the third ratio.
[0083] It should be noted that the specified value in the embodiments of the present application can be 1.
[0084] In the embodiments of the present application, the color value of a pixel corresponding to the color image can be calculated based on the following formula, and the formula is:
[0085]
[0086] Wherein, outColor is the output color value, gray is the input grayscale value (for example, the grayscale value of a pixel in the aforementioned reference sequence image), and the grayscale value can be mapped to the range of 0 to 1. In the case of mapping to the range of 0 to 1, the range of the input grayscale value is also within the range of 0 to 1. level is the grayscale threshold, and the value of the grayscale threshold is within the range of 0 to 1. Color0 represents the first target color change, Color1 represents the second target color change, and Color2 represents the third target color change. According to the above formula, when gray = 0, outColor is equal to Color2; when gray = level, outColor is equal to Color_1; when gray = 1, outColor is equal to Color0. When gray > 0 and gray < level, outColor is obtained based on Color1 and Color2. When gray > level and gray < 1, outColor is obtained based on Color0 and Color1.
[0087] Such as Figure 12 As shown, the first sequence image or inserted image includes regions q1, q2, and q3. The grayscale values of the main pixels in each region q1, q2, and q3 are different. The grayscale values of pixels in region q1 correspond to the first target color, those in region q2 correspond to the second target color, and those in region q3 correspond to the third target color. After color transformation, most pixels in region q1 will have the color value corresponding to the first target color; most pixels in region q2 will have the color value corresponding to the second target color; and most pixels in region q3 will have the color value corresponding to the third target color. Pixels in region q1 near region q2, and pixels in region q2 near region q1, will gradually transition from the first target color to the second target color after color transformation. Similarly, pixels in region q2 near region q3, and pixels in region q3 near region q2, will gradually transition from the second target color to the third target color after color transformation.
[0088] S350: Output the second sequence image.
[0089] This embodiment provides an image processing method that allows an electronic device to output a color image without storing the original color image. Instead, it can store a first sequence of grayscale images and then calculate a second sequence of color images based on a determined target color and the grayscale values of the images in the first sequence. This reduces the storage space required by the electronic device and allows for a more flexible and diverse way to obtain the second sequence of output images. Furthermore, in this embodiment, the method can determine how to calculate the second sequence of color images based on the grayscale values of pixels in the first sequence and the inserted images, as well as the relationship between the grayscale values and the recovery threshold, thus improving the diversity of the calculated second sequence of images.
[0090] Please see Figure 13 This application provides an image processing method applied to an electronic device, the method comprising:
[0091] S410: Obtain a first sequence of images, wherein each frame in the first sequence of images is a grayscale image.
[0092] S420: Based on the playback target parameters and the first sequence image, generate the inserted image corresponding to the first sequence image.
[0093] S430: Based on the grayscale value and target color of each frame in the first sequence of images, determine the color image corresponding to each frame in the first sequence of images to obtain the first sequence of color images.
[0094] S440: Based on the grayscale value of the inserted image and the target color, determine the color image corresponding to the inserted image to obtain a color inserted image.
[0095] S450: Insert the color insertion image into the first sequence of color images to obtain the second sequence of images.
[0096] S460: Output the second sequence image.
[0097] This embodiment provides an image processing method that allows an electronic device to output a color image without storing the color image itself, even when a color image is required. Instead, it can store a first sequence of images, all of which are grayscale images, and then calculate a second sequence of images, all of which are color images, based on a determined target color and the grayscale values of the images in the first sequence. This reduces the storage space required by the electronic device and also allows for a more flexible and diverse way to obtain the second sequence of images as output.
[0098] Please see Figure 14 This application provides an image processing method applied to an electronic device, the method comprising:
[0099] S510: Receive a target color sent by an external device, the target color being obtained by the external device based on a captured image.
[0100] For example, an external device can take a picture of the user's clothing to obtain an image showing the user's attire. The external device can then use this image to determine a target color. Specifically, the external device can input the image showing the user's clothing into a trained neural network model, which will output the target color. This allows the final generated second sequence of images to match the user's current clothing, improving performance.
[0101] Optionally, the electronic device in this embodiment can be a smartwatch, and the external device can be a smartphone.
[0102] S520: Obtain a first sequence of images, wherein each frame in the first sequence of images is a grayscale image.
[0103] In this embodiment, the first sequence of images acquired by the electronic device can be sent by an external device or read from local memory.
[0104] S530: Based on the playback target parameters and the first sequence image, generate the inserted image corresponding to the first sequence image.
[0105] S540: Based on the target color and grayscale value, determine the color image corresponding to each frame in the first sequence of images and the color image corresponding to the inserted image to obtain the second sequence of images.
[0106] S550: Output the second sequence image.
[0107] In one approach, when the electronic device is a smartwatch, the second sequence of images can be the watch face image of the smartwatch. Therefore, outputting the second sequence of images can be a process of switching the watch face image of the electronic device to the second sequence of images. Correspondingly, the operation of acquiring the first sequence of images can be triggered in response to a watch face switching command. This watch face switching command can be triggered by the user within the electronic device or by an external device.
[0108] For example, after an external device enters watch face switching mode in response to a user's operation, it displays an image acquisition interface. This interface can display a real-time preview image captured by the external device's camera. Once the external device captures an image of the user's clothing, it can trigger a watch face switching command. This command can carry the target color and sequence image identifier determined by the external device based on the image of the user's clothing. Upon receiving the watch face switching command, the electronic device can obtain the target color and sequence image identifier from the command. Then, based on the sequence image identifier, it can obtain a first sequence image from multiple sets of sequence images. Next, it uses the method described in this embodiment to obtain a second sequence image, and finally switches the electronic device's watch face image to the second sequence image.
[0109] This embodiment provides an image processing method that allows an electronic device to output a color image without storing the color image itself, even when a color image is required. Instead, it can store a first sequence of images, all of which are grayscale images, and then calculate a second sequence of images, all of which are color images, based on a determined target color and the grayscale values of the images in the first sequence. This reduces the storage space required by the electronic device and also allows for a more flexible and diverse way to obtain the second sequence of images as output.
[0110] Please see Figure 15 This application provides an image processing apparatus 600, which operates in an electronic device. The apparatus 600 includes:
[0111] The image acquisition unit 610 is used to acquire a first sequence of images, wherein each frame of the first sequence of images is a grayscale image.
[0112] The image generation unit 620 is used to generate an inserted image corresponding to the first sequence image based on the playback target parameters and the first sequence image.
[0113] In one manner, the image generation unit 620 is specifically used to determine the insertion position between adjacent frame images in the first sequence image based on the playback target parameters; and to determine the insertion image corresponding to the insertion position based on the adjacent frame images corresponding to the insertion position and the ratio between the first time length and the second time length, so as to obtain the insertion image corresponding to the first sequence image; wherein, the first time length is the time length between the insertion position and the adjacent frame corresponding to the insertion position in the previous frame image, and the second time length is the time length between the adjacent frames corresponding to the insertion position.
[0114] Optionally, the image generation unit 620 is specifically configured to: obtain the ratio between a first time length and a second time length corresponding to the insertion position; obtain a first reference gray value corresponding to each pixel in the inserted image corresponding to the insertion position, wherein the first reference pixel is the product of the gray value of the pixel in the previous frame image corresponding to the insertion position and a reference value, wherein the reference value is the difference between a specified value and the ratio; obtain a second reference gray value corresponding to each pixel in the inserted image corresponding to the insertion position, wherein the second reference pixel is the product of the gray value of the pixel in the next frame image corresponding to the insertion position and the ratio; and use the sum of the first reference gray value and the second reference gray value corresponding to each pixel in the inserted image as the gray value of each pixel in the inserted image corresponding to the insertion position to obtain the inserted image corresponding to the insertion position.
[0115] Optionally, the playback target parameters include at least one of playback duration and playback frame rate.
[0116] The image processing unit 630 is used to determine the color image corresponding to each frame of the first sequence of images and the color image corresponding to the inserted image based on the target color and grayscale value, so as to obtain the second sequence of images.
[0117] In one manner, the image processing unit 630 is specifically used to insert the inserted image into the first sequence of images to obtain a reference sequence of images; and based on the grayscale value and target color of each frame of the reference sequence of images, to determine the color image corresponding to each frame of the reference sequence of images to obtain a second sequence of images.
[0118] Optionally, the image processing unit 630 is specifically configured to, if the grayscale value of a pixel in the reference sequence image is less than a grayscale threshold, add the first color value corresponding to the pixel and the second color value corresponding to the pixel as the color value of the pixel in the color image, wherein the first color value is the product of the first target color and a second ratio, the second ratio is the ratio of a first difference to a second difference, the first difference is the difference between the grayscale value of the pixel and the grayscale threshold, the second difference is the ratio of a specified value to the difference of the grayscale threshold, the second color value is the product of the second target color and a third ratio, and the third ratio is the difference between the specified value and the second ratio;
[0119] If the grayscale value of a pixel in the reference sequence image is not less than a grayscale threshold, the third color value corresponding to the pixel and the fourth color value corresponding to the pixel are added together to obtain the color value of the pixel in the color image. The third color value is the product of the second target color and the third ratio, the third ratio is the ratio of the grayscale value of the pixel to the grayscale threshold, the fourth color value is the product of the third target color and the fourth ratio, and the fourth ratio is the difference between the specified value and the third ratio.
[0120] Output unit 640 is used to output the second sequence image.
[0121] In one manner, the output unit 640 is specifically used to play the second sequence of images.
[0122] like Figure 16 As shown, the device further includes:
[0123] The parameter acquisition unit 650 is used to receive a target color sent by an external device, the target color being obtained by the external device based on the captured image.
[0124] This application provides an image processing apparatus that, after acquiring a first sequence of images, all of which are grayscale images, generates an inserted image corresponding to the first sequence of images based on playback target parameters and the first sequence of images. Based on the target color and grayscale values, it determines the color image corresponding to each frame in the first sequence of images and the color image corresponding to the inserted image to obtain a second sequence of images, which is then output. This method allows an electronic device to output a color image without storing the original color image. Instead, it can store the first sequence of images, all of which are grayscale images, and then calculate the desired second sequence of images, all of which are color images, based on the determined target color and the grayscale values of the images in the first sequence of images. This reduces the storage space required by the electronic device and also allows for a more flexible and diverse way of obtaining the second sequence of images for output.
[0125] The following will combine Figure 17 This application describes an electronic device.
[0126] Please see Figure 17 Based on the image processing method and apparatus described above, this application also provides another electronic device 100 capable of executing the aforementioned terminal control method. The electronic device 100 includes one or more (only one shown in the figure) processors 102, a memory 104, a network module 106, and an image acquisition device 108 coupled together. The memory 104 stores programs capable of executing the contents of the aforementioned embodiments, and the processor 102 can execute the programs stored in the memory 104.
[0127] The processor 102 may include one or more processing cores. The processor 102 connects to various parts within the electronic device 100 using various interfaces and lines, and performs various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 104, and by calling data stored in the memory 104. Optionally, the processor 102 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 102 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 102 and may be implemented separately using a communication chip.
[0128] The memory 104 may include random access memory (RAM) or read-only memory (ROM). The memory 104 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 104 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as touch functionality, sound playback functionality, image playback functionality, etc.), and instructions for implementing the various method embodiments described below. The data storage area may also store data created by the terminal 100 during use (such as phonebook data, audio and video data, chat log data, etc.).
[0129] The network module 106 is used to receive and transmit electromagnetic waves, realizing the mutual conversion between electromagnetic waves and electrical signals, thereby communicating with communication networks or other devices, such as audio playback devices. The wireless module 106 may include various existing circuit elements for performing these functions, such as antennas, radio frequency transceivers, digital signal processors, encryption / decryption chips, user identity module (SIM) cards, memory, etc. The wireless module 106 can communicate with various networks such as the Internet, corporate intranets, and wireless networks, or communicate with other devices through wireless networks. The aforementioned wireless networks may include cellular telephone networks, wireless local area networks (WLANs), or metropolitan area networks (MANs).
[0130] Furthermore, the image acquisition device 108 can be used to acquire images. Optionally, the image acquisition device 108 may include a color image acquisition device and a depth image acquisition device.
[0131] Please refer to Figure 18 This diagram illustrates a structural block diagram of a computer-readable storage medium provided in an embodiment of this application. The computer-readable medium 800 stores program code that can be called by a processor to execute the methods described in the above method embodiments.
[0132] The computer-readable storage medium 800 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. Optionally, the computer-readable storage medium 800 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 800 has storage space for program code 810 that performs any of the method steps described above. This program code can be read from or written to one or more computer program products. The program code 810 may be compressed, for example, in a suitable form.
[0133] In summary, the image processing method, apparatus, and electronic device provided in this application, after acquiring a first sequence of images, all of which are grayscale images, generates an inserted image corresponding to the first sequence of images based on playback target parameters and the first sequence of images. Based on the target color and grayscale values, it determines the color image corresponding to each frame in the first sequence of images and the color image corresponding to the inserted image to obtain a second sequence of images, which is then output. This allows the electronic device to output a color image without storing the color image itself, instead storing the first sequence of images, all of which are grayscale images, and then calculating the desired second sequence of images, all of which are color images, based on the determined target color and the grayscale values of the images in the first sequence of images. This reduces the storage space required by the electronic device and also allows for a more flexible and diverse way of obtaining the second sequence of images as output. Furthermore, the image processing method provided in this application can be executed by a GPU, further reducing the consumption of GPU processing resources.
[0134] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. An image processing method, characterized in that, Applied to smartwatches, the method includes: In response to a dial switching command sent by an external device, a first sequence of images is acquired locally, wherein each frame of the first sequence of images is a grayscale image, the dial switching command carries a target color and a sequence image identifier, the sequence image identifier and the target color are determined by the image captured by the external device, and the first sequence of images is determined by the sequence image identifier; Based on the playback target parameters and the first sequence of images, generate an insert image corresponding to the first sequence of images; Based on the target color and grayscale value, the color image corresponding to each frame in the first sequence of images and the color image corresponding to the inserted image are determined to obtain the second sequence of images, which is a dial image; The current watch face image of the smartwatch is switched to the second sequence image.
2. The method according to claim 1, characterized in that, The step of generating the inserted image corresponding to the first sequence image based on the playback target parameters and the first sequence image includes: Based on the playback target parameters, the insertion position between adjacent frame images in the first sequence of images is determined; Based on the adjacent frame images corresponding to the insertion position and the ratio between the first time length and the second time length, the insertion image corresponding to the insertion position is determined, so as to obtain the insertion image corresponding to the first sequence image; Wherein, the first time length is the time length between the insertion position and the adjacent frame corresponding to the insertion position in the previous frame image, and the second time length is the time length between the adjacent frames corresponding to the insertion position.
3. The method according to claim 2, characterized in that, Determining the insertion image corresponding to the insertion position based on the adjacent frame images corresponding to the insertion position and the ratio between the first time length and the second time length includes: Obtain the ratio between the first time length and the second time length corresponding to the insertion position; Obtain the first reference gray value corresponding to each pixel in the inserted image corresponding to the insertion position. The first reference pixel is the product of the gray value of the pixel in the previous frame image in the adjacent frame corresponding to the insertion position and the reference value. The reference value is the difference between the specified value and the ratio. Obtain the second reference gray value corresponding to each pixel in the inserted image corresponding to the insertion position. The second reference pixel is the product of the gray value of the pixel in the next frame image corresponding to the insertion position and the ratio. The sum of the first reference gray value and the second reference gray value corresponding to each pixel in the inserted image is used as the gray value of each pixel in the inserted image corresponding to the insertion position, so as to obtain the inserted image corresponding to the insertion position.
4. The method according to claim 1, characterized in that, The playback target parameters include at least one of playback duration and playback frame rate.
5. The method according to any one of claims 1-4, characterized in that, The step of determining the color image corresponding to each frame in the first sequence of images and the color image corresponding to the inserted image based on the target color and grayscale value to obtain the second sequence of images includes: The inserted image is inserted into the first sequence image to obtain a reference sequence image; Based on the grayscale value and target color of each frame in the reference sequence image, the corresponding color image for each frame in the reference sequence image is determined to obtain the second sequence image.
6. The method according to claim 5, characterized in that, The target color includes a first target color, a second target color, and a third target color. The step of determining the corresponding color image for each frame in the reference sequence image based on the grayscale value and the target color to obtain the second sequence image includes: If the grayscale value of a pixel in the reference sequence image is less than the grayscale threshold, the first color value corresponding to the pixel and the second color value corresponding to the pixel are added together to obtain the color value of the pixel in the color image. The first color value is the product of the first target color and the second ratio, the second ratio is the ratio of the first difference to the second difference, the first difference is the difference between the grayscale value of the pixel and the grayscale threshold, the second difference is the ratio of the difference between the specified value and the grayscale threshold, the second color value is the product of the second target color and the third ratio, and the third ratio is the difference between the specified value and the second ratio. If the grayscale value of a pixel in the reference sequence image is not less than a grayscale threshold, the third color value corresponding to the pixel and the fourth color value corresponding to the pixel are added together to obtain the color value of the pixel in the color image. The third color value is the product of the second target color and the third ratio, the third ratio is the ratio of the grayscale value of the pixel to the grayscale threshold, the fourth color value is the product of the third target color and the fourth ratio, and the fourth ratio is the difference between the specified value and the third ratio.
7. The method according to claim 1, characterized in that, Output the second sequence of images, including: Play the second sequence of images.
8. An image processing apparatus, characterized in that, Operating on a smartwatch, the device includes: An image acquisition unit is configured to acquire a first sequence of images from the local device in response to a dial switching command sent by an external device. Each frame of the first sequence of images is a grayscale image. The dial switching command carries a target color and a sequence image identifier. The sequence image identifier and the target color are determined by the image captured by the external device. The first sequence of images is determined by the sequence image identifier. An image generation unit is configured to generate an inserted image corresponding to the first sequence image based on playback target parameters and the first sequence image; An image processing unit is configured to determine, based on the target color and grayscale value, the color image corresponding to each frame in the first sequence of images and the color image corresponding to the inserted image, so as to obtain a second sequence of images, wherein the second sequence of images is a dial image; The output unit is used to switch the current watch face image of the smartwatch to the second sequence image.
9. A smartwatch, characterized in that, Includes one or more processors and memory; One or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs being configured to perform the method of any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program code, wherein the method described in any one of claims 1-7 is executed when the program code is run.