Image blurring method and electronic device
By modifying the pixel data outside the outline in electronic devices to make it closer to the data inside the outline, the problem of poor outline edge blurring effect is solved, and the display effect is improved.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2025-08-20
- Publication Date
- 2026-03-05
AI Technical Summary
In electronic devices, poor blurring of image outlines results in reduced display quality.
By modifying the data of pixels outside the first contour using the data of pixels within the first contour, the data of pixels outside the first contour becomes closer to the data of pixels within the first contour, thereby improving the blurring effect near the edge of the first contour.
It improves the blurring effect near the edges within the outline, thus enhancing the display quality of electronic devices.
Smart Images

Figure CN2025115783_05032026_PF_FP_ABST
Abstract
Description
Image blurring methods and electronic devices
[0001] This application claims priority to Chinese Patent Application No. 202411216988.5, filed on August 29, 2024, entitled “Method and Electronic Device for Image Blurring”, the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of electronic technology, and more specifically, to a method and electronic device for image blurring. Background Technology
[0003] Users may encounter situations where they need to blur displayed images while using electronic devices. For example, when an electronic device blurs an area within a pre-defined outline in an image, image data outside the outline will participate in the blurring process of the area near the outline's edge. This results in a poor display effect at the outline's edge, thus reducing the overall display quality of the electronic device.
[0004] Therefore, how to improve the blurring effect of the outline edges has become a technical problem that needs to be solved. Summary of the Invention
[0005] This application provides an image blurring method and an electronic device. In this technical solution, when blurring a region within a first contour in an image, the electronic device uses the data of pixels within the first contour to modify the data of pixels outside the first contour, thereby making the data of pixels outside the first contour closer to the data of pixels within the first contour, in order to improve the blurring effect near the contour edge within the first contour.
[0006] In a first aspect, a method for blurring an image is provided. The method is applied to an electronic device, wherein the method involves acquiring a first contour in a first image; modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour to obtain a second image; and blurring the region within the first contour in the second image to obtain a first blurred image.
[0007] For example, the first outline can be a regular shape, such as a circle or a rounded rectangle, or it can be an irregular shape, such as a user-defined shape.
[0008] Optionally, the electronic device may also display the first blurred image after obtaining the first blurred image.
[0009] Based on the embodiments of this application, when an electronic device blurs the region within the first contour in a first image, it uses the data of the pixels within the first contour to modify the data of the pixels outside the first contour, and performs blurring processing on the region within the first contour to obtain a first blurred image.
[0010] In this way, when blurring an image, the data of pixels outside the first contour can be made closer to the data of pixels inside the first contour. Pixels inside the first contour that are close to the edge of the contour will be weighted using the pixel values of some pixels outside the contour to obtain the blurring result of these pixels. Since the data of pixels outside the first contour is closer to the data of pixels inside the first contour, the blurring effect of pixels inside the first contour that are close to the edge of the contour can be improved.
[0011] In some implementations, for the Nth row of pixels in the first image, at least one pixel in the Nth row is located within the first contour, where N is a positive integer. The step of modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes: obtaining the pixel values of a first preset number of pixels within the first contour that are close to the first contour; and modifying the pixel values of pixels outside the first contour in the Nth row based on the pixel values of the first preset number of pixels.
[0012] It should be understood that the specific value of the first preset quantity is not limited in the embodiments of this application. For example, the first preset quantity can be 1, 3, 5, etc.
[0013] Based on the embodiments of this application, for at least one pixel in the Nth row of pixels located within the first contour, the electronic device can obtain the pixel values of a first preset number of pixels close to the first contour, and modify the pixel values of pixels in the Nth row located outside the first contour accordingly.
[0014] This allows the pixel values of pixels outside the modified first contour to be correlated with the pixel values of pixels inside the first contour near the contour edge, thereby improving the blurring effect of these pixels inside the first contour near the contour edge.
[0015] In some implementations, the first preset number of pixels are pixels on the first side near the first contour. Modifying the pixel values of the pixels in the Nth row located outside the first contour based on the pixel values of the first preset number of pixels includes: for M1 pixels in the Nth row located on the first side outside the first contour, modifying the pixel values of the M1 pixels to the average of the pixel values of the first preset number of pixels, where the M1 pixels are adjacent pixels and M1 is a positive integer; and for each pixel Q1 in the Nth row located on the first side outside the first contour (excluding the M1 pixels), modifying the pixel value of pixel Q1 based on the average value and the pixel values of M2 pixels near or far from pixel Q1, where the M2 pixels are pixels in the Nth row located on the first side outside the first contour and M2 is a positive integer.
[0016] For example, the M1 pixels can be M1 pixels in the Nth row that are close to or far from the edge of the first image, or the M1 pixels can be M1 pixels outside the first contour that are close to the contour. Alternatively, the M1 pixels can be M1 pixels in the Nth row that are located in the rectangle 1 including the first contour and are outside the first contour, close to the edge of the rectangle 1.
[0017] For example, the value of M1 can be 3 or 5, and the value of M2 can be 3 or 4. The values of M1 and M2 can be the same or different.
[0018] Based on the embodiments of this application, the electronic device can modify the pixel value of the first side of the pixel located outside the first contour in the Nth row of pixels, and the modified pixel value is associated with the pixel value of some pixels inside the first contour.
[0019] In some implementations, the first preset number of pixels are pixels on a second side close to the first contour, and the second side is in the opposite direction to the first side. The step of modifying the pixel values of the pixels in the Nth row located outside the first contour based on the pixel values of the first preset number of pixels includes: for each pixel G1 in the Nth row located on the second side outside the first contour, modifying the pixel value of pixel G1 based on the average pixel value of the first preset number of pixels and the pixel values of M3 pixels close to pixel G1, where the M3 pixels are pixels in the Nth row and M3 is a positive integer.
[0020] For example, the first side can be the left side outside the first contour, and the second side can be the right side outside the first contour.
[0021] It should be understood that the M3 pixels closest to pixel G1 can be pixels located within contour A in the Nth row of pixels, or pixels whose pixel values outside contour A have been modified.
[0022] This application does not specify the exact value of M3.
[0023] Based on the embodiments of this application, the electronic device can modify the pixel value of the second side of the pixel point located outside the first contour in the Nth row of pixels, and the modified pixel value is associated with the pixel value of some pixels inside the first contour.
[0024] In some implementations, the first preset number of pixels are pixels on a second side closer to the first contour, the second side being in the opposite direction to the first side. The step of modifying the pixel values of the pixels in the Nth row located outside the first contour based on the pixel values of the first preset number of pixels includes: for M1 pixels in the Nth row located on the second side outside the first contour, modifying the pixel values of the M1 pixels to the average of the pixel values of the first preset number of pixels, where the M1 pixels are adjacent pixels and M1 is a positive integer; and for each pixel G1 in the Nth row located on the second side outside the first contour (excluding the M1 pixels), modifying the pixel value of pixel G1 based on the average value and the pixel values of M2 pixels closer to or farther from pixel G1, where the M2 pixels are pixels in the Nth row located on the second side outside the first contour and M2 is a positive integer.
[0025] Based on the embodiments of this application, the electronic device can modify the pixel value of the second side of the pixel point located outside the first contour in the Nth row of pixels, and the modified pixel value is associated with the pixel value of some pixels inside the first contour.
[0026] In some implementations, for the Kth column of pixels in the first image, at least one pixel in the Kth column is located within the first contour, where K is a positive integer. The step of modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes: obtaining the pixel values of a second preset number of pixels within the first contour that are close to the first contour; and modifying the pixel values of pixels outside the first contour based on the pixel values of the second preset number of pixels.
[0027] It should be understood that the specific value of the second preset quantity is not limited in the embodiments of this application. For example, the second preset quantity can be 1, 3, 5, etc.
[0028] Based on the embodiments of this application, for at least one pixel in the Kth column of pixels located within the first contour, the electronic device can obtain the pixel values of a second preset number of pixels in the Kth column of pixels that are close to the first contour, and modify the pixel values of pixels in the Kth column of pixels located outside the first contour accordingly.
[0029] This allows the pixel values of pixels outside the modified first contour to be correlated with the pixel values of pixels inside the first contour near the contour edge, thereby improving the blurring effect of these pixels inside the first contour near the contour edge.
[0030] Optionally, the second preset quantity can be the same as the first preset quantity.
[0031] In some implementations, the second preset number of pixels are pixels on the third side closest to the first contour. The step of modifying the pixel values of the pixels in the Kth column located outside the first contour based on the pixel values of the second preset number of pixels includes: for M4 pixels in the Kth column located on the third side outside the first contour, modifying the pixel values of the M4 pixels to the average value of the second preset number of pixels, where the M4 pixels are adjacent pixels and M4 is a positive integer; and for each pixel Q2 in the Kth column located on the third side outside the first contour (excluding the M4 pixels), modifying the pixel value of pixel Q2 based on the average value and the pixel values of M5 pixels close to or far from pixel Q2, where the M5 pixels are pixels in the Kth column located on the third side outside the first contour and M5 is a positive integer.
[0032] For example, the third side can be the upper side outside the first contour.
[0033] The M4 pixels can be M4 pixels close to the edge of the first image (such as the top edge). Alternatively, the M4 pixels can also be M4 pixels outside the first contour that are close to a second preset number of pixels. This application embodiment does not limit this.
[0034] Alternatively, the M4 pixels can also be the M4 pixels in the Kth column that are located in the rectangle 1 including the first contour and are located outside the first contour, close to the edge of the rectangle 1.
[0035] In other examples, the M4 pixels may not be adjacent to each other. For example, at least two of the M4 pixels may be separated by one or more pixels.
[0036] The M5 pixels can be pixels located on the third side outside the first contour, near or far from pixel Q2. When the M5 pixels are near pixel Q2, the distance between these M5 pixels and the image edge (such as the top edge) is less than the distance between pixel Q2 and the image edge (such as the top edge).
[0037] This application does not limit the specific values of M4 and M5. The values of M4 and M5 can be the same or different.
[0038] Based on the embodiments of this application, the electronic device can modify the pixel value of the pixel on the third side outside the first contour in the Kth column of pixels, and the modified pixel value is associated with the pixel value of some pixels inside the first contour.
[0039] In some implementations, the second preset number of pixels are pixels on a fourth side near the first contour, the fourth side being opposite in direction to the third side. The step of modifying the pixel values of the pixels in the Kth column located outside the first contour based on the pixel values of the second preset number of pixels includes: for each pixel G2 in the Kth column located on the fourth side outside the first contour, modifying the pixel value of pixel G2 based on the average pixel value of the second preset number of pixels and the pixel values of the M6 pixels preceding pixel G2, where the M6 pixels are pixels in the Kth column and M6 is a positive integer.
[0040] For example, the fourth side could be the lower side outside the first contour.
[0041] In other examples, at least two of the M6 pixels are spaced apart by one or more pixels.
[0042] This application does not specify the exact value of M6.
[0043] Based on the embodiments of this application, the electronic device can modify the pixel value of the fourth side of the pixel point located outside the first contour in the Kth column of pixels, and the modified pixel value is associated with the pixel value of some pixels inside the first contour.
[0044] In some implementations, the second preset number of pixels are pixels on a fourth side near the first contour, the fourth side being opposite in direction to the third side. The modification of the pixel values of the pixels in the Kth column located outside the first contour based on the pixel values of the second preset number of pixels includes: for M4 pixels in the Kth column located on the fourth side outside the first contour, modifying the pixel values of the M4 pixels to the average value of the second preset number of pixels, where M4 is a positive integer; and for each pixel G2 in the Kth column located on the fourth side outside the first contour (excluding the M4 pixels), modifying the pixel value of pixel G2 based on the average value and the pixel values of M5 pixels near or far from pixel G2, where the M5 pixels are the pixels in the Kth column located on the fourth side outside the first contour, and M5 is a positive integer.
[0045] The M4 and M5 pixels can be found in the description above.
[0046] Based on the embodiments of this application, the electronic device can modify the pixel value of the fourth side of the pixel point located outside the first contour in the Kth column of pixels, and the modified pixel value is associated with the pixel value of some pixels inside the first contour.
[0047] Optionally, the values of M1, M2, M3, M4, M5, and M6 mentioned above may be the same or different, and this application does not limit this.
[0048] In some implementations, before modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour to obtain a second image, the method further includes: performing data sampling processing on the first image to obtain a third image; wherein, modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour to obtain a second image includes: modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour in the third image to obtain the second image.
[0049] Based on the embodiments of this application, before obtaining the second image, the electronic device may further perform data sampling processing on the first image to obtain the third image, and modify the pixel values of the pixels within the first contour in the third image to the pixel values of the pixels outside the first contour to obtain the second image.
[0050] By sampling the image data, the number of pixels in the image that needs to be processed later can be reduced, thereby increasing the speed at which electronic devices can blur images.
[0051] In some implementations, blurring the region within the first contour in the second image to obtain a first blurred image includes: blurring the region within the first contour in the second image to obtain a second blurred image; and interpolating the second blurred image based on the information from the data sampling to obtain the first blurred image.
[0052] Based on the embodiments of this application, since data sampling processing has been performed, the electronic device can perform interpolation processing on the second blurred image based on the data sampling information, so that the size of the first blurred image can be restored to that before data sampling, thereby facilitating the display of the first blurred image at a normal size by the electronic device.
[0053] In some implementations, the first image includes a D-th row of pixels, where D is a positive integer. Modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes: during data sampling of the D-th row of pixels, modifying the pixel values of pixels outside the first contour within the D-th row of pixels based on the pixel values of pixels within the first contour. Blurring the region within the first contour in the second image includes: during data sampling of the D-th row of pixels, blurring the pixels within the first contour within the D-th row of pixels.
[0054] It should be understood that electronic devices can use this method to sample and blur data for all rows of pixels except for row D.
[0055] Based on the embodiments of this application, the electronic device can simultaneously modify the pixel values of pixels outside the first contour according to the pixel values of pixels within the first contour during the data sampling process of the D-th row of pixels, and blur the pixels within the first contour in the D-th row of pixels during the data sampling process.
[0056] In this way, electronic devices can improve the speed of fuzzy processing, which is beneficial to improving the fuzzy performance of electronic devices.
[0057] In some implementations, the first image includes a column E of pixels, where E is a positive integer. Modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes: during data sampling of the column E of pixels, modifying the pixel values of pixels outside the first contour within the column E of pixels based on the pixel values of pixels within the first contour in the column E of pixels. Blurring the region within the first contour in the second image includes: during data sampling of the column E of pixels, blurring the pixels within the first contour within the column E of pixels.
[0058] It should be understood that electronic devices can use this method to sample and blur data for all columns of pixels except for column E.
[0059] Based on the embodiments of this application, the electronic device can simultaneously modify the pixel values of pixels outside the first contour according to the pixel values of pixels within the first contour during the data sampling process of the E column pixels, and blur the pixels within the first contour in the E column pixels during the data sampling process.
[0060] This can improve the speed of fuzzy processing in electronic devices, which is beneficial for improving the fuzzy performance of electronic devices.
[0061] In some implementations, blurring the region within the first contour in the second image includes: blurring the pixels within the first contour row by row when performing data sampling processing on the rows containing the pixels within the first contour, and blurring the pixels within the first contour column by column when performing data sampling processing on the columns containing the pixels within the first contour.
[0062] Based on the embodiments of this application, when the electronic device samples data row by row of the pixels within the first contour, it can perform blurring processing row by row; and when the electronic device samples data column by column of the pixels within the first contour, it can perform blurring processing column by column.
[0063] This allows the electronic device to perform blurring on pixels within the first contour while sampling data from row pixels, thereby improving the speed of blurring and enhancing the blurring performance of the electronic device.
[0064] In some implementations, the electronic device includes a first processor and a second processor. The blurring of the region within the first contour in the second image includes: using the first processor to blur the pixels within the first target row of a plurality of rows containing pixels within the first contour when performing data sampling processing; and using the second processor to blur the pixels within the second target row of a plurality of rows containing pixels within the first contour when performing data sampling processing; or, using the first processor to blur the pixels within the first target column of a plurality of columns containing pixels within the first contour when performing data sampling processing; and using the second processor to blur the pixels within the second target column of a plurality of columns containing pixels within the first contour when performing data sampling processing.
[0065] Based on the embodiments of this application, the electronic device may include a first processor and a second processor, and the first processor and the second processor may process row pixels or column pixels in parallel, thereby improving the speed of blur processing of the electronic device and improving the blur performance of the electronic device.
[0066] In some implementations, modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes: when performing data sampling processing row by row on the row containing the pixels outside the first contour, modifying the pixel values of pixels outside the first contour row by row based on the pixel values of pixels within the first contour; and when performing data sampling processing column by column on the column containing the pixels outside the first contour, modifying the pixel values of pixels outside the first contour column by column based on the pixel values of pixels within the first contour.
[0067] Based on the embodiments of this application, the electronic device can modify the pixels outside the first contour while sampling the row pixels and column pixels, thereby improving the speed of blur processing and enhancing the blur performance of the electronic device.
[0068] In some implementations, the electronic device includes a first processor and a second processor. Modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes: using the first processor, when performing data sampling processing on a first target row among multiple rows containing pixels outside the first contour, modifying the pixel values of pixels in the first target row outside the first contour based on the pixel values of pixels within the first contour; and using the second processor, when performing data sampling processing on a second target row among multiple rows containing pixels within the first contour, modifying the pixel values of pixels in the second target row within the first contour based on the pixel values of pixels within the first contour; or, using the first processor, when performing data sampling processing on a first target column among multiple columns containing pixels within the first contour, modifying the pixel values of pixels in the first target column within the first contour based on the pixel values of pixels within the first contour; and using the second processor, when performing data sampling processing on a second target column among multiple columns containing pixels within the first contour, modifying the pixel values of pixels in the second target column within the first contour based on the pixel values of pixels within the first contour.
[0069] Based on the embodiments of this application, the electronic device may include a first processor and a second processor, and the first processor and the second processor may process row pixels or column pixels in parallel, thereby improving the speed of blur processing of the electronic device and improving the blur performance of the electronic device.
[0070] In a second aspect, an electronic device is provided, comprising: one or more processors; one or more memories; said one or more memories storing one or more programs that, when executed by said one or more processors, cause an image blurring method as described in the first aspect and any possible implementation thereof to be performed.
[0071] Thirdly, an image blurring apparatus is provided, comprising modules for implementing the image blurring method as described in the first aspect and any possible implementation thereof.
[0072] Fourthly, a chip is provided, the chip including a processor and a communication interface, the communication interface being used to receive signals and transmit signals to the processor, the processor processing the signals such that the image blurring method as described in the first aspect and any possible implementation thereof is executed.
[0073] Fifthly, a readable storage medium is provided, in which instructions are stored, which, when executed on an electronic device, cause the image blurring method described in the first aspect and any possible implementation thereof to be performed.
[0074] In a sixth aspect, a program product is provided, the program product including program code, which, when run on an electronic device, causes the image blurring method as described in the first aspect and any possible implementation thereof to be executed. Attached Figure Description
[0075] Figure 1 is a schematic diagram of an electronic device displaying a blurred image according to an embodiment of this application.
[0076] Figure 2 is a schematic architecture diagram of an electronic device provided in an embodiment of this application.
[0077] Figure 3 is a schematic architecture diagram of another electronic device provided in an embodiment of this application.
[0078] Figure 4 is a schematic flowchart of an image blurring method provided in an embodiment of this application.
[0079] Figure 5 is a schematic diagram of modifying pixels outside contour A according to an embodiment of this application.
[0080] Figure 6 is a schematic diagram of another modification of pixels outside contour A provided by an embodiment of this application.
[0081] Figure 7 is a schematic flowchart of another image blurring method provided in an embodiment of this application.
[0082] Figure 8 is a schematic flowchart of pixel processing provided in an embodiment of this application.
[0083] Figure 9 is a schematic flowchart of an image blurring method provided in an embodiment of this application.
[0084] Figure 10 is a schematic flowchart of an image blurring method provided in an embodiment of this application. Detailed Implementation
[0085] The technical solutions in this application will now be described with reference to the accompanying drawings.
[0086] The methods described in this application embodiment can be applied to electronic devices such as smartwatches, smart bracelets, smartphones, tablets, laptops, personal computers (PCs), ultra-mobile personal computers (UMPCs), smart TVs, netbooks, in-vehicle devices, and Internet of Things (IoT) devices.
[0087] Users may encounter situations where they need to blur displayed images while using electronic devices. For example, when an electronic device blurs an area within a pre-defined outline in an image, image data outside the outline will participate in the blurring process of the area near the outline's edge. This results in a poor display effect at the outline's edge, thus reducing the overall display quality of the electronic device.
[0088] Taking a circle as an example of the preset shape outline, Figure 1 is a schematic diagram of an electronic device displaying a blurred image according to an embodiment of this application. As shown in Figure 1, the smartwatch has a circular display screen, and the images stored in the smartwatch are generally rectangular images. In this case, the circular image displayed on the smartwatch screen is a part of the rectangular image. When it is necessary to blur the circular image, the smartwatch needs to blur the entire rectangular image. As a result, invalid data in the rectangular image that is not displayed on the smartwatch screen also participates in the blurring process, leading to a poor blurring effect on the edge of the circular outline of the display screen and reducing the display effect of the smartwatch.
[0089] In view of this, embodiments of this application provide an image blurring method and an electronic device. In this technical solution, when the electronic device blurs a region within a first contour in an image, it uses the data of pixels within the first contour to modify the data of pixels outside the first contour, thereby making the data of pixels outside the first contour closer to the data of pixels within the first contour, in order to improve the blurring effect near the edge of the first contour.
[0090] The following section will describe the schematic architecture diagram of the electronic device in the embodiments of this application with reference to Figures 2-3.
[0091] For example, FIG2 is a schematic architecture diagram of an electronic device provided in an embodiment of the present application. As shown in FIG2, the electronic device 100a may include at least a central processing unit (CPU) 110, a graphics processor 120, and a display screen 130.
[0092] In some examples, the graphics processor 120 may include a graphics processing unit (GPU), 2D direct memory access (DMA2D), etc. The graphics processor 120 may also include a data processing module 121.
[0093] In some examples, the CPU 110 may include an image acquisition module 111, a data processing module 112, a cache module 113, and a display module 114.
[0094] The image acquisition module 111 can be used to acquire the original data of the first image and the first contour in the first image, wherein the area within the first contour is the area in the first image that needs to be blurred.
[0095] For example, the image acquisition module 111 can obtain the raw data of the first image from the cache.
[0096] In one example, the image acquisition module 111 can determine a first contour based on the outline of the display screen. In some cases, referring to Figure 1, the electronic device is a smartwatch, and the first contour can be the outline of the smartwatch's display screen.
[0097] In another example, if the first outline is a display control with a preset shape, the image acquisition module 111 can also determine the outline of the display control as the first outline.
[0098] The image acquisition module 111 can also be used to acquire the blur parameters of the blur algorithm used to blur the region within the first contour.
[0099] For example, the blurring algorithm is Gaussian blur, and the blurring parameters can include the number of neighboring pixels used when blurring a pixel and the weight factor of each pixel. For example, the blurring parameters include using the three pixels adjacent to pixel 1 when blurring pixel 1, and the weight factors of each pixel are w1, w2, w3, and w4, where w1 represents the weight factor of pixel 1, and w2, w3, and w4 are the weight factors of the three pixels adjacent to pixel 1, respectively.
[0100] In other examples, the fuzzing algorithm can also be mean fuzzing, bilateral fuzzing, etc. The specific fuzzing algorithm used in this application embodiment is not limited.
[0101] The data processing module 112 can be used to modify the pixel values of pixels outside the first contour.
[0102] For example, the data processing module 112 can modify the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour.
[0103] For example, the data processing module 112 can obtain the target pixel value within the first contour and use the target pixel value to modify the pixel value of pixels outside the first contour. It should be understood that the target pixel value can be the pixel value of a single pixel within the first contour, or it can be obtained based on the pixel values of multiple pixels within the first contour. For example, the target pixel value can be the average of the pixel values of multiple pixels within the first contour.
[0104] It should be understood that the data processing module 112 uses the target pixel value to modify the pixel value of the pixels outside the first contour. This can be understood as the data processing module 112 modifying the pixel value of the pixels outside the first contour to the target pixel value or half, one-third, or the like of the target pixel value.
[0105] For example, the data processing module 112 can also modify the pixel values of pixels outside the first contour row by row and column by column.
[0106] In some implementations, the data processing module 112 can first modify the pixel values of the pixels outside the first contour row by row, and then modify the pixel values of the pixels outside the first contour column by column. Alternatively, the data processing module 112 can also first modify the pixel values of the pixels outside the first contour column by column, and then modify the pixel values of the pixels outside the first contour row by row.
[0107] In some implementations, when the data processing module 112 modifies the pixel value of a pixel in the target row that is outside the first contour, it can obtain the target pixel value of the target row that is inside the first contour and use the target pixel value to modify the pixel value of the pixel outside the first contour. It should be understood that the target pixel value can be the pixel value of a single pixel in the target row that is inside the first contour, or it can be obtained based on the pixel values of multiple pixels inside the first contour.
[0108] In some implementations, for pixels on a first side (e.g., the left side) outside the first contour of the target row, the data processing module 112 can modify them using the pixel values of one or more pixels on the first side that are inside the first contour of the target row and close to the first side. For pixels on a second side (e.g., the right side) outside the first contour of the target row, the data processing module 112 can modify them using the pixel values of one or more pixels on the second side that are inside the first contour of the target row and close to the second side.
[0109] It should be understood that the processing of pixels in the target column by the data processing module 112 can be similar to the processing of pixels in the target row, and will not be described in detail for the sake of brevity.
[0110] In some examples, the data processing module 112 can also perform data sampling processing on the first image and perform the above processing on the pixels outside the first contour in the sampled image.
[0111] For example, when sampling data for each row of pixels, the data processing module 112 can sample at preset intervals of a number of pixels to reduce the amount of data processed subsequently. Similarly, when sampling data for each column of pixels, the data processing module 112 can sample at preset intervals of a number of pixels to reduce the amount of data processed subsequently.
[0112] It should be understood that the embodiments of this application do not limit the order in which the data processing module 112 samples data from row pixels and column pixels.
[0113] During the data processing module 112's data sampling process for each row or column of pixels, it can also simultaneously modify the pixel values of pixels located outside the first contour in each row or column of pixels.
[0114] For example, for a target row pixel or a target column pixel, after the data processing module 112 collects the first pixel, it can collect the second pixel while modifying the pixel value of the first pixel using the pixel value within the first contour.
[0115] The data processing module 112 can also be used to blur pixels within the first contour.
[0116] For example, the data processing module 112 can perform blurring processing on the pixels within the first contour row by row and column by column according to the blurring parameters of the aforementioned blurring algorithm. Alternatively, the data processing module 112 can perform blurring processing on the pixels within the first contour column by column and row by row according to the blurring parameters of the aforementioned blurring algorithm.
[0117] During the data sampling process of the first image by the data processing module 112, the pixels within the first contour can also be blurred simultaneously.
[0118] For example, for a target row pixel, after the data processing module 112 acquires the first pixel point of the target row pixel located within the first contour, it can acquire the second pixel point while using the above-mentioned blurring parameters to blur the acquired first pixel point.
[0119] The caching module 113 can be used to cache the blurred image 1 obtained after processing by the data processing module 112.
[0120] Optionally, after the data processing module 112 has sampled the first image, the buffer module 114 can also send the blurred image to the graphics processor 120. The data processing module 121 in the graphics processor 120 can perform interpolation processing on the blurred image 1 to obtain a blurred image 2 of the same size as before data sampling. Then, the data processing module 121 can send the blurred image 2 to the display module 114.
[0121] The display module 114 can be used to transmit the blurred image 2 that needs to be displayed to the display screen 130 for display.
[0122] The display screen 130 can be used to display the blurred image 2.
[0123] In this way, the electronic device 100a can use the pixel values of pixels within the first contour to modify the pixel values of pixels outside the first contour, thereby making the pixel values of pixels outside the first contour closer to the pixel values of pixels within the first contour. Thus, when the electronic device 100a modifies pixels within the first contour, the pixel values of pixels outside the first contour used by pixels near the edge of the first contour have already been modified, resulting in a better blurring effect for pixels near the edge of the first contour.
[0124] For example, FIG3 is a schematic architecture diagram of another electronic device provided in an embodiment of the present application. As shown in FIG3, the electronic device 100b may include at least a central processing unit CPU 140, a graphics processor 150, and a display screen 160.
[0125] The CPU 140 may include one or more CPUs. For example, the CPU 140 may include CPU1, CPU2, CPU3, ... and other CPUs. Each CPU included in the CPU 140 can be referred to in the relevant description of the CPU 110 above, and will not be repeated here for the sake of brevity.
[0126] Unlike electronic device 100a, electronic device 100b includes multiple CPUs that can process data in the first image in parallel.
[0127] Taking CPU140, which includes CPU1, CPU2, and CPU3, as an example, during row pixel processing, CPU1 can process target row 1, CPU2 can simultaneously process target row 2, and CPU3 can simultaneously process target row 3.
[0128] For example, CPU1 can modify the pixel values of pixels in target row 1 that are outside the first contour using the pixel values within the first contour; then, CPU1 blurs the pixels in target row 1 that are within the first contour. During this process, CPU2 can modify the pixel values of pixels in target row 2 that are outside the first contour using the pixel values within the first contour; then, CPU2 blurs the pixels in target row 2 that are within the first contour. Simultaneously, CPU3 can modify the pixel values of pixels in target row 3 that are outside the first contour using the pixel values within the first contour; then, CPU3 blurs the pixels in target row 3 that are within the first contour.
[0129] When each CPU processes the target line, if data sampling is required, the CPU can also perform blurring processing on the target line simultaneously during the data sampling process to improve the speed of blurring processing and enhance the performance of blurred images in electronic devices.
[0130] Optionally, the electronic device 100b may further include a coordination module 170, which can be used to record the processing progress of CPU1, CPU2, and CPU3. The coordination module 170 can also allocate a new row for processing to the target CPU after the target CPU has finished processing a row of pixels.
[0131] For example, after CPU1 finishes processing target line 1, the coordination module 170 can also assign the processing task of target line 4 to CPU1, so that CPU1 can continue to process target line 4.
[0132] It should be understood that after the multiple CPUs have processed all row pixels, they can also process column pixels synchronously. Alternatively, the CPUs can process all column pixels first and then process row pixels synchronously; this embodiment of the application does not limit this.
[0133] It should be understood that the graphics processor 150 can be referred to in the previous description of the graphics processor 120, and the display screen 150 can be referred to in the previous description of the display screen 130.
[0134] In this way, when the electronic device includes multiple CPUs, the multiple CPUs can simultaneously perform row or column processing on the pixels in the first image, shortening the overall blurring time of the first image and improving the image blurring performance of the electronic device.
[0135] The technical solution for image blurring in the embodiments of this application will be described below with reference to Figures 4-9.
[0136] For example, FIG4 is a schematic flowchart of an image blurring method provided in an embodiment of the present application. As shown in FIG4, the method 200 can be applied to an electronic device, and the method 200 may include steps 210 to 250.
[0137] 210. The electronic device acquires the contour A in image A, and the area within the contour A is the area to be blurred.
[0138] For example, image A can be a rectangular image cached in an electronic device, and outline A can be the area in image A that needs to be blurred. For instance, outline A can be the outline of the display screen of the electronic device, such as a circle or a rounded rectangle; or, outline A can also be the outline of a control in image A that needs to be blurred.
[0139] It should be understood that the embodiments of this application do not limit the specific outline of outline A. For example, outline A can be a circle, a rounded rectangle, or other regular outlines, or it can be a custom outline of an irregular shape.
[0140] 220. The electronic device determines the blur parameters for blurring image A.
[0141] It should be understood that this blur parameter is related to the blur algorithm used by the electronic device to sample and blur image A.
[0142] For example, if an electronic device uses a Gaussian blur algorithm to blur image A, the blur parameter can be any of the parameters used by the Gaussian blur algorithm.
[0143] For example, the blur parameter may include the number of adjacent pixels used when blurring a pixel and the weight factor of each pixel. For example, the blur parameter may include that when blurring pixel 1, the three pixels adjacent to pixel 1 need to be used, and the weight factors of each pixel are w1, w2, w3, and w4, where w1 represents the weight factor of pixel 1, and w2, w3, and w4 are the weight factors of the three pixels adjacent to pixel 1, respectively.
[0144] Understandably, electronic devices can also use other blurring algorithms, such as mean blurring and bilateral blurring, to blur image A.
[0145] 230. The electronic device modifies the pixel values of pixels outside contour A based on the pixel values of pixels within contour A.
[0146] In this embodiment of the application, the electronic device may modify the pixel values of pixels outside contour A based on the pixel values of pixels within contour A in one or more of the following ways.
[0147] Method A: The electronic device modifies the pixel values of all pixels outside contour A based on the target pixel values within contour A.
[0148] The target pixel value can be the pixel value of one of the pixels X1 within contour A. Pixel X1 can be any pixel within contour A. For example, pixel X1 can be a pixel randomly selected by the electronic device from within contour A, or pixel X1 can be one of several pixels within contour A that are close to contour A.
[0149] Alternatively, the target pixel value can be obtained based on the pixel values of multiple pixels within contour A. For example, the target pixel value could be the average of the pixel values of multiple pixels within contour A. For instance, the target pixel value could be the average of the pixel values of multiple pixels randomly selected by the electronic device from within contour A. Alternatively, the target pixel value could also be the average of the pixel values of several pixels within contour A that are close to contour A.
[0150] For example, the electronic device can modify the pixel value of all pixels outside contour A to the target pixel value or half, one-third, etc. of the target pixel value.
[0151] Method B: The electronic device modifies the pixel values of the pixels in rectangle 1, which includes contour A, based on the target pixel values within contour A.
[0152] For example, the outline A is a circle 1, and the rectangle 1 can be a rectangle 1 that includes the circle 1. It should be understood that the rectangle 1 can be a rectangle that is a certain number of pixels larger than the circumscribed rectangle of the circle 1. For example, the diameter of the circle 1 is d1, and the diameter of the inscribed circle of the rectangle 1 is d2, where d2 is greater than d1, and d2 is larger than d1 by a preset number of pixels, for example, the preset number can be 10, 15, etc.
[0153] For example, the electronic device can modify the pixel value of a pixel located outside the outline A but within the rectangle 1 to the target pixel value or half, one-third, or the like of the target pixel value.
[0154] In this way, when blurring pixels within contour A, some pixels closer to contour A may use the pixel values of pixels outside contour A for weighted calculation, while the pixel values of pixels farther away from contour A may not participate in the blurring process of pixels within contour A. Therefore, electronic devices can avoid modifying these pixels, thereby reducing the amount of data involved in image blurring and improving image blurring performance.
[0155] Method C: The electronic device modifies the pixel values outside contour A row by row and column by column based on the pixel values within contour A.
[0156] The electronic device can modify the pixel values outside the outline A by first modifying the pixels row by row and then column by column, or it can modify the pixel values outside the outline A by first modifying the pixels column by column and then row by row.
[0157] The following example illustrates how an electronic device modifies the pixel values outside contour A line by line.
[0158] For example, for the Nth row of pixels, at least one pixel in the Nth row is located within contour A, where N is a positive integer. The electronic device can obtain the pixel value 2 of the Nth row of pixels located within contour A, and modify the pixel value of the Nth row of pixels located outside contour A to pixel value 2.
[0159] It should be understood that the pixel value 2 can be obtained from the pixel values of the pixels in the Nth row that are located within contour A. For example, the pixel value 2 can be the pixel value of any pixel in the Nth row that is located within contour A, the pixel value of one of the two pixels closest to contour A within contour A, or the average of the pixel values of the two pixels closest to contour A within contour A.
[0160] It should be understood that, here, the two pixels closest to contour A can be understood as the pixel closest to the left side of contour A and the pixel closest to the right side of contour A.
[0161] For example, referring to FIG5, FIG5 is a schematic diagram of modifying pixels outside contour A according to an embodiment of the present application.
[0162] As shown in Figure 5, for the Nth row of pixels, at least one pixel in the Nth row is located within contour A, where N is a positive integer. The electronic device can obtain the pixel value A1 of the first pixel P1 in the Nth row that is closest to contour A within contour A, and modify the pixel values of the M1 pixels in the Nth row that are located outside contour A (such as on the left) to A1, where M1 is a positive integer and the M1 pixels are adjacent pixels. In the Nth row of pixels, for each pixel Q1 located on the first side outside contour A (excluding the M1 pixels), the electronic device can determine its pixel value AQ1 based on pixel P1 and the M2 pixels that are close to or far from pixel Q1, where M2 is a positive integer and the M2 pixels are pixels in the Nth row located on the first side outside the first contour.
[0163] It should be understood that the M1 pixels here can be the first M1 pixels in the Nth row that are outside contour A and close to the edge of the image. Alternatively, the M1 pixels can also be the first M1 pixels in the Nth row that are located in rectangle 1 including contour A and are outside contour A, close to the edge of rectangle 1. For example, rectangle 1 can be rectangle 1 in method B above. Alternatively, the M1 pixels can also be the M1 pixels in the Nth row that are outside contour A and close to contour A.
[0164] In other examples, the M1 pixels may not be adjacent to each other. For example, there may be one or more pixels between any two pixels in the M1 pixels.
[0165] In other examples, the M1 pixels can also be adjacent pixels obtained by the electronic device on the first side outside the contour A after sampling the data of the Nth row of pixels.
[0166] It should be understood that pixel Q1 may or may not be adjacent to M1 pixels, and this application embodiment does not limit this.
[0167] Referring to Figure 5, the M2 pixels here can be pixels that gradually approach pixel Q1 from left to right.
[0168] In other examples, if M1 pixels are pixels close to the outline, then M2 pixels can also be pixels that gradually move away from pixel Q1 from left to right.
[0169] For example, M1 = 3, denoted as M1-1, M1-2, and M1-3 respectively, all corresponding to pixel values A1, and M2 = 3. For the fourth pixel Q1-4, its pixel value AQ1-4 = (pixel value of P1) * w1 + (pixel value of M1-1) * w2 + (pixel value of M1-2) * w3 + (pixel value of M1-3) * w4, that is, AQ1-4 = A1 * w1 + A1 * w2 + A1 * w3 + A1 * w4.
[0170] For the 5th pixel Q1-5, its pixel value AQ1-5 = (pixel value of P1)*w1 + (pixel value of M1-2)*w2 + (pixel value of M1-3)*w3 + (pixel value of Q1-4)*w4, that is, AQ1-5 = A1*w1 + A1*w2 + A1*w3 + (AQ1-4)*w4.
[0171] Among them, w1, w2, w3, and w4 are the weight factors of each pixel.
[0172] It should be understood that the pixel value A1 can also be the average of the pixel values of pixel point P1 and one or more pixels that are gradually moving away from P1.
[0173] Referring to Figure 5, for each pixel G1 located outside contour A and on the second side (e.g., the right side) of the Nth row, the electronic device can determine its pixel value AG1 based on pixel P2 and the M3 pixels close to pixel G1, where M3 is a positive integer. Pixel P2 is the first pixel inside contour A on the second side close to the outside of contour A, and its corresponding pixel value is pixel value B1.
[0174] It should be understood that the M3 pixels closest to pixel G1 can be pixels located within contour A in the Nth row of pixels, or pixels whose pixel values outside contour A have been modified.
[0175] For example, if pixel G1 is the first pixel on the second side outside contour A, then the M3 pixels that are close to or far from pixel G1 can be pixels in the Nth row that are close to pixel G1 within contour A. Optionally, these M3 pixels can be adjacent pixels.
[0176] Alternatively, the M3 pixels closest to pixel G1 can also be understood as the M3 pixels in the Nth row that are adjacent to pixel G1 within the outline A.
[0177] For example, M3 = 3, denoted as M3-1, M3-2, and M3-3 respectively, with corresponding pixel values of C1, C2, and C3. Then, the pixel value of G1, AG1, is: AG1 = (pixel value of P2) * w1 + (pixel value of M3-1) * w2 + (pixel value of M3-2) * w3 + (pixel value of M3-3) * w4, or AG1 = B1 * w1 + C1 * w2 + C2 * w3 + C3 * w4.
[0178] For example, referring to FIG6, FIG6 is a schematic diagram of another modification of pixels outside contour A provided by an embodiment of the present application. Referring to FIG6, for the Nth row of pixels, the technical solution for the electronic device to modify the pixels on the first side (such as the left side) of the Nth row of pixels located outside contour A can be found in the relevant description in FIG5.
[0179] Unlike Figure 5, in this technical solution, the electronic device modifies the pixels on the second side (such as the right side) outside the outline A in the Nth row in the same way as it modifies the pixels on the first side (such as the left side) outside the outline A in the Nth row.
[0180] For example, the electronic device can first obtain the pixel value B1 of pixel point P2 within the contour A, and assign the pixel value B1 to the M1 pixels of the Nth row located on the second side outside the contour A. For each pixel point G1 of the Nth row located on the second side outside the contour A, excluding the M1 pixels, its pixel value AG1 is determined based on pixel point P2 and the M2 pixels that are close to or far from pixel point G1. For details, please refer to the relevant description above. For the sake of brevity, it will not be repeated here.
[0181] 240. The electronic device blurs the pixels within contour A to obtain a blurred image B.
[0182] For example, the electronic device may use a blurring algorithm to blur the pixels in the outline A first row by pixel and then column by column, or the electronic device may use a blurring algorithm to blur the pixels in the outline A first column by pixel and then row by column.
[0183] When blurring each row of pixels or each column of pixels, blurring can be performed pixel by pixel.
[0184] For example, when an electronic device blurs pixel 1, it needs to use the three adjacent pixels of pixel 1, and the weight factors of each pixel are w1, w2, w3, and w4, where w1 represents the weight factor of pixel 1, and w2, w3, and w4 are the weight factors of the three adjacent pixels of pixel 1, respectively.
[0185] In this way, after the electronic device blurs all the pixels within the outline A, it can obtain a blurred image B.
[0186] It should be understood that the specific execution order of steps 230-240 is not limited in the embodiments of this application. In some examples, step 230 may be executed intermittently with step 240.
[0187] 250, The electronic device displays a blurry image B.
[0188] It should be understood that step 250 is an optional step, and in some examples, step 250 may not be performed. This application embodiment does not limit this.
[0189] Based on the embodiments of this application, when blurring an image, the electronic device can use pixels within contour A to modify pixels outside contour A, and then blur the pixels within contour A. In this way, since the pixel values of pixels outside contour A are modified based on the pixel values of pixels within contour A, the pixel values of pixels outside contour A are correlated with the pixel values of pixels within contour A. This results in a better blurring effect for pixels within contour A that are close to the contour edge, thus improving the display effect of the electronic device.
[0190] In some cases, to reduce the amount of data processed by the electronic device during blurring, the electronic device can also perform data sampling processing on image A. This technical solution will be introduced below with reference to Figure 7.
[0191] For example, FIG7 is a schematic flowchart of another image blurring method provided in an embodiment of the present application. As shown in FIG7, the method 300 can be applied to an electronic device, and the method 300 may include steps 310 to 370.
[0192] 310. The electronic device acquires the contour A in image A, and the area within the contour A is the area to be blurred.
[0193] 320, The electronic device determines the blur parameters for blurring image A.
[0194] It should be understood that steps 310-320 can be referred to in the relevant descriptions of steps 210-220, and for the sake of brevity, they will not be repeated here.
[0195] 330. The electronic device performs data sampling processing on image A to obtain image B.
[0196] An electronic device can perform data sampling processing on all row pixels of image A, row by row, and / or on all column pixels of image A, column by column, to obtain image B. For example, the electronic device can first perform data sampling processing on all row pixels of image A, then perform data sampling processing on all column pixels of image A, column by column, to obtain image B. Alternatively, the electronic device can also first perform data sampling processing on all column pixels of image A, column by column, then perform data sampling processing on all row pixels of image A, row by row, to obtain image B.
[0197] For example, electronic devices can sample at preset intervals of a number of pixels to reduce the amount of data processed subsequently. For example, the preset number can be 5 or 3 pixels, etc. The specific value of the preset number is not limited in the embodiments of this application.
[0198] 340. The electronic device modifies the pixel values of pixels outside contour A based on the pixel values of pixels within contour A.
[0199] 350. The electronic device blurs the pixels within contour A to obtain a blurred image B.
[0200] It should be understood that steps 340-350 can be found in the relevant descriptions of steps 230-240, and for the sake of brevity, they will not be repeated here.
[0201] 360. The electronic device performs interpolation on the blurred image B to obtain the blurred image C.
[0202] It should be understood that because the electronic device performs data sampling processing on image A in step 330, the size of the resulting image B is smaller than the size of image A. Therefore, in step 360, the electronic device can perform interpolation processing on the blurred image B based on the data sampling parameters to obtain a blurred image C, thereby restoring the original size of the blurred image C.
[0203] 370, The electronic device displays a blurry image C.
[0204] It should be understood that step 370 is an optional step, and in some examples, step 370 may not be performed. This application embodiment does not limit this.
[0205] Based on the embodiments of this application, an electronic device can use pixels within contour A to modify pixels outside contour A and blur the pixels within contour A. In this way, since the pixel values of pixels outside contour A are modified based on the pixel values of pixels within contour A, the pixel values of pixels outside contour A are correlated with the pixel values of pixels within contour A. This results in a better blurring effect for pixels near the edge of contour A, improving the display effect of the electronic device.
[0206] In addition, the electronic device performs data sampling processing on image A, which reduces the amount of data that needs to be processed subsequently, thereby improving the speed at which the electronic device blurs the image.
[0207] The following section will describe in detail, with reference to Figure 8, the process of the electronic device in this application processing pixels row by row and column by column.
[0208] For example, FIG8 is a schematic flowchart of a pixel processing embodiment provided in this application. As shown in FIG8, the method 400 can be applied to an electronic device, and the method 400 may include steps 401 to 420.
[0209] 401, The electronic device traverses the Nth row of pixels in the first image.
[0210] An electronic device can traverse each row of pixels in a first image to determine the processing procedure for the pixels included in each row. This application embodiment uses the example of an electronic device traversing the Nth row of pixels for illustration.
[0211] 402. The electronic device determines whether there are any pixels in the Nth row that are within the outline A, where N is an integer.
[0212] The Nth row of pixels can be the row that the electronic device is traversing in the first image.
[0213] The electronic device can determine whether there are any pixels in the Nth row that are located within contour A. For rows where it is determined that there are no pixels located within contour A, the electronic device may not process them. For rows where it is determined that there are pixels located within contour A, the electronic device may continue to execute step 403.
[0214] If no pixels in a row are located within contour A, it can be understood that the pixels in that row are likely far from contour A. Therefore, when the electronic device subsequently blurs the image within contour A, it may not need to use the pixels in that row, thus reducing the amount of data the electronic device needs to process.
[0215] 403, The electronic device determines whether the pixel of the Nth row is located on the first side outside the outline A.
[0216] For example, the first side can be the left side outside contour A. It should be understood that the electronic device can determine whether the pixel of the Nth row of pixels being traversed is located on the first side outside contour A based on the pixel distribution within contour A.
[0217] 404, The electronic device acquires the pixel value A1 of the first side located inside contour A and close to the outside of contour A in the Nth row of pixels.
[0218] For example, referring to Figures 5 and 6, the pixel value A1 can be the pixel value of the first pixel point P1 located inside the contour A and close to the outside of the contour A in the Nth row of pixels.
[0219] Alternatively, the pixel value A1 can also be the average of the pixel values of pixel point P1 and one or more pixels that are gradually moving away from P1, which is not limited in the embodiments of this application.
[0220] 405. The electronic device assigns the pixel value of M1 pixels located on the first side outside the contour A to A1, where M1 is an integer and the M1 pixels are adjacent to each other.
[0221] For example, referring to Figure 5, the first side can be the side where pixel P1 is closer.
[0222] The M1 pixels can be the first M1 pixels closest to the edge of the image. Alternatively, the M1 pixels can also be the first M1 pixels outside contour A closest to pixel P1, but this embodiment does not limit the specific pixels.
[0223] Alternatively, the M1 pixels can also be the first M1 pixels of the Nth row that are located within and outside the outline A of rectangle 1, closest to the edge of rectangle 1. For example, rectangle 1 can be rectangle 1 in method B above.
[0224] In other examples, the M1 pixels may not be adjacent to each other. For example, at least two of the M1 pixels may be separated by one or more pixels.
[0225] The specific value of M1 is not limited in the embodiments of this application. For example, M1 can be 3 or 5.
[0226] 406. For each pixel Q1 in the Nth row of pixels located on the first side outside contour A, excluding the M1 pixels, the electronic device determines its pixel value AQ1 based on pixel value A1 and the pixel values of the M2 pixels closest to or furthest from pixel Q1, where M2 is a positive integer and the M2 pixels are the pixels in the Nth row located on the first side outside contour A. It should be understood that step 406 can be referenced from the description of Figure 5 in method C of step 230 above; for brevity, it will not be repeated here.
[0227] In this way, the electronic device can modify the pixel values of all pixels in the Nth row that are located on the first side outside contour A. Then, when the electronic device continues to traverse the Nth row, it will traverse to pixels located inside contour A, at which point the electronic device can execute step 407.
[0228] 407. The electronic device determines whether a pixel in the Nth row is within contour A.
[0229] For example, an electronic device can determine whether a certain pixel is located within contour A based on the distribution of pixels within contour A.
[0230] When the electronic device determines that a pixel in the Nth row of pixels is within contour A, it can execute step 408. After the electronic device blurs all pixels in the Nth row of pixels that are within contour A, when the electronic device continues to traverse the Nth row of pixels, it will determine that a traversed pixel is not within contour A, and then the electronic device can execute step 409.
[0231] 408. The electronic device blurs the pixels within contour A.
[0232] It should be understood that step 408 can be found in the relevant description of step 240 above.
[0233] In this way, the electronic device can blur the pixels in the Nth row of pixels that are located within contour A. Then, as the electronic device continues to traverse the Nth row of pixels, it will determine whether the next pixel is located within contour A, and then the electronic device can proceed to step 407.
[0234] 409. The electronic device acquires the pixel value B1 of the second side of the Nth row of pixels, which is located inside the contour A and close to the outside of the contour A.
[0235] It should be understood that the direction of the second side can be opposite to that of the first side. For example, the first side is the left side, and the second side is the right side.
[0236] For example, referring to Figures 5 and 6, the pixel value B1 can be the pixel value of the first pixel point P2 located on the second side of the Nth row of pixels, which is inside the contour A and close to the outside of the contour A.
[0237] Alternatively, the pixel value B1 can also be the average of the pixel values of pixel point P2 and one or more pixels within the contour A that gradually approach P2, which is not limited in the embodiments of this application.
[0238] 410. For each pixel G1 located on the second side outside the contour A in the Nth row of pixels outside the contour A, determine its pixel value AG1 based on the pixel value B1 and the pixel values of the M3 pixels closest to pixel G1, where M3 is a positive integer and the M3 pixels are the pixels in the Nth row of pixels.
[0239] It should be understood that step 410 can be referred to in method C of step 230 above for the relevant description of Figure 5. For the sake of brevity, it will not be repeated here.
[0240] In this embodiment, for pixels in the Nth row that are located within contour A, the electronic device can iterate through each pixel in the Nth row. For example, if the electronic device starts its traversal from the first pixel on the left, and the traversed pixel is located on the left side outside contour A, the electronic device can obtain the pixel value A1 of the pixel within contour A that is close to the left side outside contour A, and modify the pixel values of the M1 pixels on the left side of contour A to A1. For each pixel Q1 outside contour A on the left side, excluding the M1 pixels, the electronic device can determine the pixel value AQ1 of pixel Q1 based on pixel value A1 and the pixel values of the M2 pixels that are close to or far from pixel Q1. In this way, the electronic device can modify each pixel on the left side outside contour A. Afterward, when the electronic device continues to traverse the pixels in the Nth row, it will traverse the pixels within contour A. For the pixels within contour A, the electronic device can use a blurring algorithm to blur them. In this way, the electronic device can blur all pixels within contour A. Next, as the electronic device continues to traverse the pixels in the Nth row, it will reach pixel G1 on the right side outside contour A. The electronic device can obtain the pixel value B1 within contour A that is close to the right side outside contour A, and modify the pixel value of pixel G1 based on pixel value B1 and the pixel values of the M3 pixels closest to pixel G1. In this way, the electronic device can modify the pixel value of the pixel on the right side outside contour A. At this point, the electronic device has completed traversing the Nth row of pixels and processing the pixels. The electronic device can use this method to process pixels in other rows where there are pixels located within contour A.
[0241] It should be understood that the process of an electronic device traversing each pixel in a column of pixels can be found in the description of traversing each pixel in a row of pixels, and will not be repeated here for the sake of brevity.
[0242] Alternatively, step 410 can be replaced by steps 4101-4102.
[0243] 4101, the electronic device assigns the pixel value B1 to the M1 pixels located on the second side outside the outline A in the Nth row of pixels. The M1 pixels are adjacent pixels, and M1 is a positive integer.
[0244] The M1 pixels here can be the M1 pixels in the Nth row that are located on the second side outside contour A and close to the image edge. Alternatively, the M1 pixels can also be the M1 pixels in the Nth row that are located in rectangle 1, which includes contour A, and are located outside contour A and close to the edge of rectangle 1. For example, rectangle 1 can be rectangle 1 in method B above.
[0245] In other examples, the M1 pixels may not be adjacent to each other. For example, there may be one or more pixels between any two pixels in the M1 pixels.
[0246] In other examples, the M1 pixels can also be adjacent pixels obtained by the electronic device on the second side outside the contour A after sampling the data of the Nth row of pixels.
[0247] 4102. For each pixel G1 in the Nth row of pixels located on the second side outside the contour A, excluding the M1 pixels, its pixel value AG1 is determined based on the pixel value B1 and the pixel values of the M2 pixels that are close to or far from pixel G1. The M2 pixels are the pixels in the Nth row of pixels located on the second side outside the contour A, and M2 is a positive integer.
[0248] For example, referring to Figure 6, the M2 pixels can be pixels that gradually approach pixel G1 from left to right on the second side outside contour A, and whose pixel values have been modified. The distance between the M2 pixels and the edge of the image (such as the right edge) is less than the distance between pixel G1 and the edge of the graphic (such as the right edge).
[0249] The M2 pixels can be adjacent to each other, or at least two pixels in the M2 pixels can be separated by one or more pixels.
[0250] Through steps 4101 to 4102, the electronic device can modify the pixel value of the pixel point located on the second side outside the outline A in the Nth row of pixels.
[0251] For example, M1 = 3, denoted as M1-1, M1-2, and M1-3 respectively, all corresponding to pixel values B1, and M2 = 3. For the fourth pixel G1-4, its pixel value AG1-4 = (pixel value of P2) * w1 + (pixel value of M1-1) * w2 + (pixel value of M1-2) * w3 + (pixel value of M1-3) * w4, that is, AG1-4 = B1 * w1 + B1 * w2 + B1 * w3 + B1 * w4.
[0252] For the 5th pixel G1-5, its pixel value AG1-5 = (pixel value of P2) * w1 + (pixel value of M1-2) * w2 + (pixel value of M1-3) * w3 + (pixel value of G1-4) * w4, that is, AG1-5 = B1 * w1 + B1 * w2 + B1 * w3 + (AG1-4) * w4.
[0253] Among them, w1, w2, w3, and w4 are the weight factors of each pixel.
[0254] It should be understood that the pixel value B1 can also be the average of the pixel values of pixel point P2 within the contour A and one or more pixels that are gradually approaching P2.
[0255] It should be understood that after the electronic device completes step 410, it can be considered that the electronic device has processed the Nth row of pixels. Afterwards, the electronic device can process the other rows of pixels in the first image row by row in the manner described above. After the electronic device has processed the pixels row by row, it can continue to process the columns of pixels included in the first image column by column.
[0256] The following section will describe, in conjunction with steps 411-420, the process by which the electronic device processes the Kth column pixel in the column pixels.
[0257] 411, The electronic device traverses the Kth column of pixels in the first image.
[0258] An electronic device can traverse each column of pixels in a first image to determine the processing procedure for each column of pixels. This embodiment of the application uses the example of an electronic device traversing the Kth column of pixels for illustration.
[0259] 412, The electronic device determines whether there are any pixels in the Kth column that are within the outline A.
[0260] For example, step 412 can be referred to in the relevant description of step 402, and for the sake of brevity, it will not be repeated here.
[0261] 413, The electronic device determines whether a pixel in the Kth column is located on the third side outside the contour A.
[0262] For example, the third side can be the upper side outside contour A.
[0263] The electronic device can determine whether a pixel in the Kth column is located on the third side outside the contour A based on the distribution of pixels within the contour A.
[0264] When the electronic device determines that a pixel in the Kth column is located on the third side outside the contour A, step 414 can be performed.
[0265] 414, The electronic device acquires the pixel value A3 of the third side of the Kth column of pixels, which is located inside the contour A and close to the outside of the contour A.
[0266] For example, referring to Figure 5, the pixel value A3 can be the pixel value of the first pixel point P3 located on the third side of the contour A, close to the outside of the contour A, in the Kth column of pixels.
[0267] Alternatively, the pixel value A3 can also be the average of the pixel values of pixel point P3 and one or more pixels within the contour A that are gradually moved away from pixel point P3.
[0268] 415. The electronic device assigns the pixel value of the M4 pixels located on the third side outside the contour A in the Kth column to A3, where M4 is a positive integer and the M4 pixels are adjacent pixels.
[0269] For example, referring to Figure 5, the third side can be the side where pixel P3 is closer, such as the top side.
[0270] The M4 pixels can be the first M4 pixels closest to the edge of the image. Alternatively, the M4 pixels can also be the M4 pixels outside contour A closest to pixel P3, but this embodiment does not limit the specific pixels.
[0271] Alternatively, the M4 pixels can also be the M4 pixels in column K that are located within rectangle 1, which includes outline A, but outside outline A, and are close to the edge of rectangle 1. For example, rectangle 1 can be rectangle 1 in method B above.
[0272] In other examples, the M4 pixels may not be adjacent to each other. For example, at least two of the M4 pixels may be separated by one or more pixels.
[0273] The specific value of M4 is not limited in the embodiments of this application. For example, M4 can be 3 or 5, etc.
[0274] 416. For each pixel Q2 in the Kth column of pixels that is located on the third side outside the contour A, excluding the M4 pixels, its pixel value AQ2 is determined based on the pixel value A3 and the pixel values of the M5 pixels that are close to or far from pixel Q2. M5 is a positive integer, and the M5 pixels are the pixels in the Kth column of pixels that are located on the third side outside the first contour.
[0275] For example, referring to Figure 5, the M5 pixels here can be pixels in the Kth column located on the third side outside contour A, close to or far from pixel Q2. In the case where the M5 pixels are pixels close to pixel Q2, the distance between the M5 pixels and the image edge (such as the top edge) is less than the distance between pixel Q2 and the image edge (such as the top edge).
[0276] For example, M4 = 3, denoted as M4-1, M4-2, and M4-3 respectively, all corresponding to pixel values A3, and M5 = 3. For the fourth pixel Q2-4, its pixel value AQ2-4 = (pixel value of P3) * w1 + (pixel value of M4-1) * w2 + (pixel value of M4-2) * w3 + (pixel value of M4-3) * w4, that is, AQ2-4 = A3 * w1 + A3 * w2 + A3 * w3 + A3 * w4.
[0277] For the 5th pixel Q2-5, its pixel value AQ2-5 = (pixel value of P3) * w1 + (pixel value of M4-2) * w2 + (pixel value of M4-3) * w3 + (pixel value of Q2-4) * w4, that is, AQ2-5 = A3 * w1 + A3 * w2 + A3 * w3 + (AQ2-4) * w4.
[0278] Among them, w1, w2, w3, and w4 are the weight factors of each pixel.
[0279] It should be understood that the pixel value A3 can also be the pixel value of pixel point P3 and one or more pixels within the contour A that are gradually moving away from pixel point P3.
[0280] In this way, the electronic device can modify the pixel values of all pixels in the Kth column that are located on the third side outside contour A. Then, when the electronic device continues to traverse the Kth column, it will reach pixels located inside contour A, at which point the electronic device can execute step 417.
[0281] 417. The electronic device determines whether a pixel in the Kth column is located within contour A.
[0282] When the electronic device determines that a pixel in the Kth column is within contour A, step 418 can be executed. After the electronic device blurs all pixels in the Kth column that are within contour A, when the electronic device continues to traverse the Kth column, it will determine that the traversed pixels are not within contour A, and then the electronic device can execute step 419.
[0283] 418. The electronic device blurs the pixels in the Kth column that are located within the outline A.
[0284] It should be understood that steps 417 to 418 can be found in the description of steps 407-408 above.
[0285] In this way, the electronic device can blur the pixels in the Kth column that are within contour A. Then, as the electronic device continues to traverse the Kth column, it will determine whether the next pixel is within contour A, and then the electronic device can proceed to step 417.
[0286] 419. The electronic device acquires the pixel value B4 of the fourth side of the Kth column pixels, which is located inside the contour A and close to the outside of the contour A.
[0287] The fourth side can be the opposite side to the third side. For example, the third side is the upper side, and the fourth side is the lower side.
[0288] For example, referring to Figure 5, the pixel value B4 can be the pixel value of the first pixel point P4 located on the fourth side of the contour A, close to the outside of the contour A, in the Kth column of pixels.
[0289] Alternatively, the pixel value B4 can also be the average of the pixel values of pixel point P4 and one or more pixels within the contour A that gradually approach P4, which is not limited in the embodiments of this application.
[0290] 420. For each pixel G2 located on the fourth side outside the contour A in the Kth column of pixels, the electronic device determines its pixel value AG2 based on the pixel value B4 and the pixel values of the M6 pixels closest to pixel G2, where M6 is a positive integer and the M6 pixels are the pixels in the Kth column of pixels.
[0291] For example, referring to Figure 5, if pixel G2 is the first pixel on the fourth side of the Kth column outside the contour A, the M6 pixels can be pixels inside the contour A that are close to pixel G2.
[0292] If pixel G2 is far from contour A, then the M6 pixels can also be pixels located on the fourth side outside contour A and close to pixel G2, and the distance between the M6 pixels and the image edge is greater than the distance between pixel G2 and the image edge.
[0293] It should be understood that the M6 pixels can be adjacent to each other. Alternatively, at least two of the M6 pixels can be separated by one or more pixels.
[0294] Optionally, step 420 can be replaced by steps 4201-4202.
[0295] 4201, The electronic device assigns the pixel value of the M4 pixels located on the fourth side outside the contour A in the Kth column of pixels to B4, where M4 is a positive integer and the M4 pixels are adjacent pixels.
[0296] The M4 pixels here can be the M1 pixels in the Kth column that are located on the fourth side outside contour A and close to the image edge. Alternatively, the M4 pixels can also be the M4 pixels in the Kth column that are located in rectangle 1, which includes contour A, and are located outside contour A and close to the edge of rectangle 1. For example, rectangle 1 can be rectangle 1 in method B above.
[0297] In other examples, the M4 pixels may not be adjacent to each other. For example, at least two pixels among the M4 pixels may be separated by one or more pixels.
[0298] In other examples, the M4 pixels can also be adjacent pixels obtained by an electronic device located on the fourth side outside contour A after sampling data of the Nth row of pixels.
[0299] 4202. For each pixel G2 located on the fourth side outside contour A in the Kth column of pixels, excluding the M4 pixels, the electronic device determines its pixel value AG2 based on pixel value B4 and the pixel values of the M5 pixels closest to pixel G2, where M5 is a positive integer and the M5 pixels are the pixels located on the fourth side outside contour A in the Kth column of pixels.
[0300] For example, referring to Figure 6, the M5 pixels here can be the pixels in the Kth column that are located on the fourth side outside contour A and are adjacent to pixel G2. For example, the distance between these M5 pixels and the image edge (below the lower edge) is less than the distance between pixel G2 and the image edge (below the lower edge).
[0301] The M5 pixels can be adjacent to each other. Alternatively, the M5 pixels can not be adjacent to each other. For example, at least two pixels in the M5 pixels can be separated by one or more pixels.
[0302] It is understandable that electronic devices can process pixels column by column first, and then process pixels row by row. That is, steps 411-420 above can be performed before steps 401-410, and this application embodiment does not limit this.
[0303] Based on the embodiments of this application, the electronic device can traverse each row and column of pixels in the first image. For row and column pixels where a pixel is located within contour A, the electronic device can modify the pixel values outside contour A using the pixel values within contour A, thereby blurring the pixels within contour A. In this way, since the pixel values outside contour A are modified based on the pixel values within contour A, the pixel values outside contour A are correlated with the pixel values within contour A, resulting in a better blurring effect for pixels near the contour edge within contour A, thus improving the display effect of the electronic device.
[0304] In some cases, to improve the speed of image blurring, electronic devices can also perform image blurring simultaneously during data sampling. The following section will introduce this technical solution with reference to Figure 9, taking the electronic device processing the D row of pixels as an example.
[0305] For example, FIG9 is a schematic flowchart of an image blurring method provided in an embodiment of this application. As shown in FIG9, the method 500 can be applied to an electronic device, and the method 500 may include steps 510 to 520.
[0306] 510. During the data sampling process of the D-th row of pixels, the electronic device uses the pixel values of the D-th row of pixels located within contour A to modify the pixel values of the D-th row of pixels located outside contour A.
[0307] For example, for the pixels in row D, the electronic device can sample at preset intervals of a number of pixels to reduce the amount of data that the subsequent electronic device needs to modify for pixels outside contour A and blur for pixels inside contour A.
[0308] For example, the preset number can be 5 pixels or 3 pixels, etc. The specific value of the preset number is not limited in the embodiments of this application.
[0309] In this embodiment of the application, during the process of data sampling of the pixels in the D row, the electronic device can simultaneously use the pixel values of the pixels in the D row that are located within the contour A to modify the pixel values of the pixels in the D row that are located outside the contour A.
[0310] For example, let's take a preset quantity of 5 pixels as an example. When the electronic device acquires the first pixel E1, it modifies pixel E1 using the target pixel value of the D-row pixel located within contour A. When the electronic device acquires the second pixel E2 after a 5-pixel interval, it modifies pixel E2 using the target pixel value of the D-row pixel located within contour A. Afterward, the electronic device continues to acquire one pixel every 5 pixels. The electronic device can modify each pixel outside the contour acquired by the electronic device in the manner shown in Figure 5.
[0311] The target pixel value can be obtained from the pixel values of one or more pixels within contour A. For example, the target pixel value can be the average of the pixel values of multiple pixels within contour A.
[0312] In other examples, the electronic device may also modify the pixel values of pixels outside contour A in the same row D after sampling the data of the pixels in row D.
[0313] 520. During the data sampling process of the D-th row of pixels, the electronic device performs blurring processing on the pixels located within the contour A in the D-th row of pixels.
[0314] While the electronic device is sampling data from the pixels in row D and acquiring the pixels within contour A, the electronic device can continue to sample data, generally blurring the pixels within contour A.
[0315] For example, the electronic device samples data from the first pixel point near the image edge on the first side outside contour A in row D. When the first pixel point F1 within contour A is sampled, the electronic device uses a blurring algorithm to blur F1. Simultaneously, the electronic device continues to sample the next pixel point F2 every 5 pixels. When pixel point F2 is sampled, the electronic device uses a blurring algorithm to blur F2 within contour A. Afterward, the electronic device continues to sample one pixel within contour A every 5 pixels and blur it, until the processing of the pixels in row D is complete.
[0316] It should be understood that the electronic device uses a blurring algorithm to blur the first pixel F1 within the contour A, as described in the previous text.
[0317] It should be understood that the electronic device can sample and process other rows of pixels in the image in the same way. Alternatively, the electronic device can sample and process column pixels in the image in the same way.
[0318] In this way, during the process of the electronic device sampling data for pixels, the pixel values of the pixels collected outside contour A can be modified simultaneously, and when the data sampling reaches inside contour A, the electronic device can simultaneously blur the pixels collected inside contour A, thereby improving the speed of image blurring by the electronic device.
[0319] Figure 10 is a schematic flowchart of an image blurring method provided in an embodiment of this application. As shown in Figure 10, the method 600 can be applied to an electronic device, and the method 600 may include steps 610 to 630.
[0320] 610, The electronic device acquires the first contour in the first image.
[0321] For example, the first outline can be a regular shape, such as a circle or a rounded rectangle, or it can be an irregular shape, such as a user-defined shape.
[0322] For example, an electronic device can determine a first profile based on the outline of the display screen. In some cases, referring to Figure 1, the electronic device is a smartwatch, and the first profile can be the outline of the smartwatch's display screen.
[0323] For example, if the first outline is a display control with a preset shape, the electronic device can also define the outline of the display control as the first outline.
[0324] 620. The electronic device modifies the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour to obtain a second image.
[0325] It should be understood that step 620 can be referred to in the relevant description of step 230 above, and will not be repeated here for the sake of brevity.
[0326] 630, The electronic device blurs the region within the first contour in the second image to obtain a first blurred image.
[0327] Electronic devices can use a corresponding blurring algorithm to blur the region within the first contour to obtain a first blurred image.
[0328] For example, the fuzzy algorithm can be a Gaussian fuzzy algorithm, a mean fuzzy algorithm, etc.
[0329] Optionally, the electronic device may also display the first blurred image after obtaining the first blurred image.
[0330] Based on the embodiments of this application, when an electronic device blurs the region within the first contour in a first image, it uses the data of the pixels within the first contour to modify the data of the pixels outside the first contour, and performs blurring processing on the region within the first contour to obtain a first blurred image.
[0331] In this way, when blurring an image, the data of pixels outside the first contour can be made closer to the data of pixels inside the first contour. Pixels inside the first contour that are close to the edge of the contour will be weighted using the pixel values of some pixels outside the contour to obtain the blurring result of these pixels. Since the data of pixels outside the first contour is closer to the data of pixels inside the first contour, the blurring effect of pixels inside the first contour that are close to the edge of the contour can be improved.
[0332] In some embodiments, for the Nth row of pixels included in the first image, at least one pixel in the Nth row is located within a first contour, where N is a positive integer. Modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes:
[0333] Obtain the pixel value of a first preset number of pixels that are close to the first contour in the Nth row of pixels;
[0334] The pixel values of the pixels in the Nth row that are located outside the first contour are modified according to the pixel values of the first preset number of pixels.
[0335] It should be understood that the specific value of the first preset quantity is not limited in the embodiments of this application. For example, the first preset quantity can be 1, 3, 5, etc.
[0336] For example, referring to Figure 5, the first contour can be contour A. When the first preset quantity is 1, the pixel in the first contour can be pixel P1 or P2, or any one of P1 to P2.
[0337] Based on the embodiments of this application, for at least one pixel in the Nth row of pixels located within the first contour, the electronic device can obtain the pixel values of a first preset number of pixels close to the first contour, and modify the pixel values of pixels in the Nth row located outside the first contour accordingly.
[0338] This allows the pixel values of pixels outside the modified first contour to be correlated with the pixel values of pixels inside the first contour near the contour edge, thereby improving the blurring effect of these pixels inside the first contour near the contour edge.
[0339] In some embodiments, the first preset number of pixels are pixels on the first side near the first contour, wherein modifying the pixel values of the pixels in the Nth row located outside the first contour according to the pixel values of the first preset number of pixels includes:
[0340] For the M1 pixels located on the first side outside the first contour in the Nth row, modify the pixel value of the M1 pixels to the average of the pixel values of a first preset number of pixels, where the M1 pixels are adjacent pixels and M1 is a positive integer; and
[0341] For each pixel Q1 in the Nth row of pixels located on the first side outside the first contour, excluding the M1 pixels, the pixel value of pixel Q1 is modified according to the average value and the pixel values of the M2 pixels that are close to or far from pixel Q1. Here, the M2 pixels are the pixels in the Nth row of pixels located on the first side outside the first contour, and M2 is a positive integer.
[0342] For example, the M1 pixels can be M1 pixels in the Nth row that are close to or far from the edge of the first image, or the M1 pixels can be M1 pixels outside the first contour that are close to the first contour. Alternatively, the M1 pixels can be M1 pixels in the Nth row that are located in the rectangle 1 including the first contour and are outside the first contour, close to the edge of the rectangle 1.
[0343] Referring to Figure 5, the M2 pixels here can be pixels that gradually approach pixel Q1 from left to right.
[0344] In other examples, if M1 pixels are pixels close to the first contour, then M2 pixels can also be pixels that gradually move away from pixel Q1 from left to right.
[0345] For example, the value of M1 can be 3 or 5, and the value of M2 can be 3 or 4. The values of M1 and M2 can be the same or different.
[0346] For example, referring to Figure 5, the first side can be the left side outside contour A. The first preset number of pixels can be pixel P1 and multiple pixels after P1.
[0347] Alternatively, if the first preset quantity is 1, then the first preset quantity of pixels can be pixel P1.
[0348] Based on the embodiments of this application, the electronic device can modify the pixel value of the first side of the pixel located outside the first contour in the Nth row of pixels, and the modified pixel value is associated with the pixel value of some pixels inside the first contour.
[0349] In some embodiments, the first preset number of pixels are pixels on a second side closer to the first contour, the second side being in the opposite direction to the first side. Modifying the pixel values of the pixels in the Nth row located outside the first contour based on the pixel values of the first preset number of pixels includes:
[0350] For each pixel G1 located on the second side outside the first contour in the Nth row of pixels, the pixel value of pixel G1 is modified according to the average value of the pixel values of the first preset number of pixels and the pixel values of the M3 pixels closest to pixel G1, where the M3 pixels are the pixels in the Nth row of pixels and M3 is a positive integer.
[0351] For example, the first side can be the left side outside the first contour, and the second side can be the right side outside the first contour.
[0352] For example, referring to Figure 5, the first preset number of pixels can be pixel P2 and multiple pixels preceding P2. When the first preset number is 1, the first preset number of pixels is pixel P2.
[0353] This application does not specify the exact value of M3.
[0354] It should be understood that the M3 pixels closest to pixel G1 can be pixels located within contour A in the Nth row of pixels, or pixels whose pixel values outside contour A have been modified.
[0355] Based on the embodiments of this application, the electronic device can modify the pixel value of the second side of the pixel point located outside the first contour in the Nth row of pixels, and the modified pixel value is associated with the pixel value of some pixels inside the first contour.
[0356] In some embodiments, the first preset number of pixels are pixels on a second side closer to the first contour, the second side being in the opposite direction to the first side. Modifying the pixel values of the pixels in the Nth row located outside the first contour based on the pixel values of the first preset number of pixels includes:
[0357] For the M1 pixels located on the second side outside the first contour in the Nth row, modify the pixel value of the M1 pixels to the average of the pixel values of a first preset number of pixels, where the M1 pixels are adjacent pixels and M1 is a positive integer; and
[0358] For each pixel G1 in the Nth row of pixels located on the second side outside the first contour, excluding the M1 pixels, modify the pixel value of pixel G1 according to the average value and the pixel values of the M2 pixels closest to pixel G1, where the M2 pixels are the pixels in the Nth row of pixels located on the second side outside the first contour, and M2 is a positive integer.
[0359] It should be understood that the relevant descriptions of the M1 and M2 pixels can be found in the previous text, and will not be repeated here for the sake of brevity.
[0360] For example, referring to Figure 6, the modification logic for the pixels on the first and second sides outside the first contour in the Nth row can be the same.
[0361] Based on the embodiments of this application, the electronic device can modify the pixel value of the second side of the pixel point located outside the first contour in the Nth row of pixels, and the modified pixel value is associated with the pixel value of some pixels inside the first contour.
[0362] In some embodiments, for the Kth column of pixels included in the first image, at least one pixel in the Kth column is located within a first contour, where K is a positive integer. Modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes:
[0363] Obtain the pixel values of a second preset number of pixels within the first contour that are close to the first contour in the Kth column.
[0364] The pixel values of the pixels in the Kth column that are located outside the first contour are modified according to the pixel values of the second preset number of pixels.
[0365] It should be understood that the specific value of the second preset quantity is not limited in the embodiments of this application. For example, the second preset quantity can be 1, 3, 5, etc.
[0366] For example, referring to Figure 5, the first contour can be contour A. When the second preset quantity is 1, the pixel in the first contour can be pixel P3 or P4, or any one of P3 to P4.
[0367] Based on the embodiments of this application, for at least one pixel in the Kth column of pixels located within the first contour, the electronic device can obtain the pixel values of a second preset number of pixels in the Kth column of pixels that are close to the first contour, and modify the pixel values of pixels in the Kth column of pixels located outside the first contour accordingly.
[0368] This allows the pixel values of pixels outside the modified first contour to be correlated with the pixel values of pixels inside the first contour near the contour edge, thereby improving the blurring effect of these pixels inside the first contour near the contour edge.
[0369] Optionally, the second preset quantity can be the same as the first preset quantity.
[0370] In some embodiments, the second preset number of pixels are pixels on the third side closest to the first contour, wherein modifying the pixel values of the pixels in the Kth column located outside the first contour according to the pixel values of the second preset number of pixels includes:
[0371] For the M4 pixels located on the third side outside the first contour in the Kth column, modify the pixel values of the M4 pixels to the average of the pixel values of a second preset number of pixels, where M4 is a positive integer; and
[0372] For each pixel Q2 located on the third side outside the first contour in the Kth column, excluding the M4 pixels, modify the pixel value of pixel Q2 according to the average value and the pixel values of the M5 pixels that are close to or far from pixel Q2, where M5 is a positive integer.
[0373] For example, the third side can be the upper side outside the first contour.
[0374] For example, referring to Figure 5, if the second preset quantity is 1, then the second preset quantity of pixels is pixel P3. If the second preset quantity is 3, then the second preset quantity of pixels is pixel P3 and the two pixels following P3.
[0375] The M4 pixels can be M4 pixels close to the edge of the first image (such as the top edge). Alternatively, the M4 pixels can also be M4 pixels outside the first contour that are close to a second preset number of pixels. This application embodiment does not limit this.
[0376] Alternatively, the M4 pixels can also be the M4 pixels in the Kth column that are located in the rectangle 1 including the first contour and are located outside the first contour, close to the edge of the rectangle 1.
[0377] In other examples, the M4 pixels may not be adjacent to each other. For example, at least two of the M4 pixels may be separated by one or more pixels.
[0378] The M5 pixels can be pixels located on the third side outside the first contour, near or far from pixel Q2. When the M5 pixels are near pixel Q2, the distance between these M5 pixels and the image edge (such as the top edge) is less than the distance between pixel Q2 and the image edge (such as the top edge).
[0379] This application does not limit the specific values of M4 and M5. The values of M4 and M5 can be the same or different.
[0380] Based on the embodiments of this application, the electronic device can modify the pixel value of the pixel on the third side outside the first contour in the Kth column of pixels, and the modified pixel value is associated with the pixel value of some pixels inside the first contour.
[0381] In some embodiments, the second preset number of pixels are pixels on a fourth side closer to the first contour, the fourth side being in the opposite direction to the third side. Modifying the pixel values of the pixels in the Kth column located outside the first contour based on the pixel values of the second preset number of pixels includes:
[0382] For each pixel G2 located on the fourth side outside the first contour in the Kth column of pixels, the pixel value of pixel G2 is modified according to the average value of the pixel values of the second preset number of pixels and the pixel values of the M6 pixels closest to pixel G2, where the M6 pixels are the pixels in the Kth column of pixels and M6 is a positive integer.
[0383] For example, the fourth side could be the lower side outside the first contour.
[0384] In other examples, at least two of the M6 pixels are spaced apart by one or more pixels.
[0385] For example, referring to Figure 5, when the second preset quantity is 1, the second preset quantity of pixels can be pixel P4. If the second preset quantity is 3, the second preset quantity of pixels can be pixel P4 and the two pixels preceding P4.
[0386] This application does not specify the exact value of M6.
[0387] Based on the embodiments of this application, the electronic device can modify the pixel value of the fourth side of the pixel point located outside the first contour in the Kth column of pixels, and the modified pixel value is associated with the pixel value of some pixels inside the first contour.
[0388] In some embodiments, the second preset number of pixels are pixels on a fourth side closer to the first contour, the fourth side being in the opposite direction to the third side. Modifying the pixel values of the pixels in the Kth column located outside the first contour based on the pixel values of the second preset number of pixels includes:
[0389] For the M4 pixels located on the fourth side outside the first contour in the Kth column, modify the pixel values of these M4 pixels to the average of the pixel values of a second preset number of pixels, where the M4 pixels are adjacent pixels and M4 is a positive integer; and
[0390] For each pixel G2 located on the fourth side outside the first contour in the Kth column of pixels, excluding the M4 pixels, the pixel value of pixel G2 is modified according to the average value and the pixel values of the M5 pixels that are close to or far from pixel G2, where the M5 pixels are the pixels on the fourth side outside the first contour in the Kth column of pixels, and M5 is a positive integer.
[0391] The M4 and M5 pixels can be found in the description above.
[0392] Based on the embodiments of this application, the electronic device can modify the pixel value of the fourth side of the pixel point located outside the first contour in the Kth column of pixels, and the modified pixel value is associated with the pixel value of some pixels inside the first contour.
[0393] Optionally, the values of M1, M2, M3, M4, M5, and M6 mentioned above may be the same or different, and this application does not limit this.
[0394] In some embodiments, before modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour to obtain the second image, the method 600 further includes:
[0395] The first image is subjected to data sampling processing to obtain the third image;
[0396] Specifically, the pixel values of pixels outside the first contour are modified based on the pixel values of pixels within the first contour to obtain the second image, including:
[0397] The pixel values of pixels outside the first contour in the third image are modified based on the pixel values of the pixels within the first contour to obtain the second image.
[0398] Based on the embodiments of this application, before obtaining the second image, the electronic device may further perform data sampling processing on the first image to obtain the third image, and modify the pixel values of the pixels within the first contour in the third image to the pixel values of the pixels outside the first contour to obtain the second image.
[0399] By sampling the image data, the number of pixels in the image that needs to be processed later can be reduced, thereby increasing the speed at which electronic devices can blur images.
[0400] In some embodiments, blurring the region within the first contour in the second image to obtain a first blurred image includes:
[0401] The region within the first contour in the second image is blurred to obtain a second blurred image;
[0402] The second blurred image is interpolated based on the information from the data sampling to obtain the first blurred image.
[0403] Based on the embodiments of this application, since data sampling processing has been performed, the electronic device can perform interpolation processing on the second blurred image based on the data sampling information, so that the size of the first blurred image can be restored to that before data sampling, thereby facilitating the display of the first blurred image at a normal size by the electronic device.
[0404] In some embodiments, the first image includes pixels in row D, where D is a positive integer. Modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes:
[0405] During the data sampling process of the D-th row of pixels, the pixel values of the pixels in the D-th row that are outside the first contour are modified according to the pixel values of the pixels in the D-th row that are within the first contour.
[0406] Blurring the region within the first contour in the second image includes: during the data sampling of the pixels in the Dth row, blurring the pixels located within the first contour in the Dth row.
[0407] For example, see the relevant description of steps 510-520 above.
[0408] It should be understood that electronic devices can use this method to sample and blur data for all rows of pixels except for row D.
[0409] Based on the embodiments of this application, the electronic device can simultaneously modify the pixel values of pixels outside the first contour according to the pixel values of pixels within the first contour during the data sampling process of the D-th row of pixels, and blur the pixels within the first contour in the D-th row of pixels during the data sampling process.
[0410] In this way, electronic devices can improve the speed of fuzzy processing, which is beneficial to improving the fuzzy performance of electronic devices.
[0411] In some embodiments, the first image includes pixels in column E, where E is a positive integer. Modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes:
[0412] During the data sampling process of the E-th column pixels, the pixel values of the pixels in the E-th column pixels located outside the first contour are modified according to the pixel values of the pixels in the E-th column pixels located within the first contour;
[0413] Blurring is applied to the region within the first contour in the second image, including:
[0414] During the data sampling process of the E-th column pixels, the pixels located within the first contour in the E-th column pixels are blurred.
[0415] It should be understood that electronic devices can use this method to sample and blur data for all columns of pixels except for column E.
[0416] Based on the embodiments of this application, the electronic device can simultaneously modify the pixel values of pixels outside the first contour according to the pixel values of pixels within the first contour during the data sampling process of the E column pixels, and blur the pixels within the first contour in the E column pixels during the data sampling process.
[0417] This can improve the speed of fuzzy processing in electronic devices, which is beneficial for improving the fuzzy performance of electronic devices.
[0418] In some embodiments, blurring the region within the first contour in the second image includes:
[0419] When performing data sampling processing row by row for the rows containing pixels within the first contour, the pixels within the first contour are blurred row by row; and...
[0420] When performing data sampling processing on each column of pixels within the first contour, blurring processing is performed on each column of pixels within the first contour.
[0421] Based on the embodiments of this application, when the electronic device samples data row by row of the pixels within the first contour, it can perform blurring processing row by row; and when the electronic device samples data column by column of the pixels within the first contour, it can perform blurring processing column by column.
[0422] This allows the electronic device to perform blurring on pixels within the first contour while sampling data from row pixels, thereby improving the speed of blurring and enhancing the blurring performance of the electronic device.
[0423] In some embodiments, the electronic device includes a first processor and a second processor, and blurring a region within a first contour in a second image includes:
[0424] Using a first processor, when performing data sampling processing on a first target row among multiple rows containing pixels within a first contour, the pixels included in the first target row within the first contour are blurred; and using a second processor, when performing data sampling processing on a second target row among multiple rows containing pixels within a first contour, the pixels included in the second target row within the first contour are blurred.
[0425] or,
[0426] Using a first processor, when performing data sampling processing on a first target column among multiple columns containing pixels within a first contour, the pixels included in the first target column within the first contour are blurred; and using a second processor, when performing data sampling processing on a second target column among multiple columns containing pixels within a first contour, the pixels included in the second target column within the first contour are blurred.
[0427] For example, referring to Figure 3, the electronic device may include multiple CPUs that can process row pixels or column pixels in parallel.
[0428] Based on the embodiments of this application, the electronic device may include a first processor and a second processor, and the first processor and the second processor may process row pixels or column pixels in parallel, thereby improving the speed of blur processing of the electronic device and improving the blur performance of the electronic device.
[0429] In some embodiments, the electronic device modifies the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour, including:
[0430] When performing data sampling processing row by row for pixels outside the first contour, the pixel values of pixels outside the first contour are modified row by row based on the pixel values of pixels inside the first contour. Similarly, when performing data sampling processing column by column for pixels outside the first contour, the pixel values of pixels outside the first contour are modified column by column based on the pixel values of pixels inside the first contour.
[0431] Based on the embodiments of this application, the electronic device can modify the pixels outside the first contour while sampling the row pixels and column pixels, thereby improving the speed of blur processing and enhancing the blur performance of the electronic device.
[0432] In some embodiments, the electronic device includes a first processor and a second processor, and modifies the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour, including:
[0433] Using a first processor, when performing data sampling processing on a first target row among multiple rows containing pixels outside the first contour, the pixel values of the pixels included in the first target row outside the first contour are modified based on the pixel values of the pixels within the first contour; and using a second processor, when performing data sampling processing on a second target row among multiple rows containing pixels within the first contour, the pixel values of the pixels included in the second target row within the first contour are modified based on the pixel values of the pixels within the first contour; or...
[0434] Using a first processor, when performing data sampling processing on a first target column among multiple columns containing pixels within a first contour, the pixel values of the pixels included in the first target column within the first contour are modified based on the pixel values of the pixels within the first contour; and using a second processor, when performing data sampling processing on a second target column among multiple columns containing pixels within a first contour, the pixel values of the pixels included in the second target column within the first contour are modified based on the pixel values of the pixels within the first contour.
[0435] Based on the embodiments of this application, the electronic device may include a first processor and a second processor, and the first processor and the second processor may process row pixels or column pixels in parallel, thereby improving the speed of blur processing of the electronic device and improving the blur performance of the electronic device.
[0436] An electronic device provided in this application includes one or more processors; one or more memories; the one or more memories store one or more instructions, which, when executed by one or more processors, cause the image blurring method described in any of the possible implementations above to be executed.
[0437] This application also provides an electronic device, including a processor, a memory, and a communication interface, wherein the communication interface is used to receive signals, the memory is used to store signals, the communication interface is also used to transmit signals to the processor, and the processor processes the signals such that the image blurring method described in any of the possible implementations above is executed.
[0438] For example, the electronic device can be used to perform methods 200, 300, 400, 500 and 600 mentioned above.
[0439] For example, the electronic device may also be the electronic device 100a or electronic device 100b mentioned above.
[0440] This application also provides an image blurring device, including a processor and a communication interface. The communication interface is used to receive signals and transmit the signals to the processor. The processor processes the signals so that the image blurring method described in any of the possible implementations above is executed.
[0441] The device can be a chip. For example, the chip can be a chip system or a standalone chip.
[0442] This application also provides a readable storage medium storing instructions that, when executed on an electronic device, cause the electronic device to perform the aforementioned method steps to achieve the image blurring method described in the above embodiments.
[0443] This application also provides a program product that, when run on an electronic device, causes the electronic device to perform the aforementioned steps to achieve the image blurring method described in the above embodiments.
[0444] This application also provides an apparatus including a module for implementing the image blurring method as described in any of the preceding embodiments.
[0445] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component or module. The apparatus may include a connected processor and a memory; wherein the memory is used to store instructions, and when the apparatus is running, the processor may execute the instructions stored in the memory to cause the apparatus to perform the image blurring method in the above method embodiments.
[0446] In this embodiment, the device, readable storage medium, program product or apparatus are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding methods provided above, and will not be repeated here.
[0447] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0448] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0449] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0450] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0451] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0452] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory, random access memory, magnetic disks, or optical disks.
[0453] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for blurring an image, characterized in that, The method is applied to an electronic device, and the method includes: Obtain the first contour in the first image; The pixel values of the pixels outside the first contour are modified based on the pixel values of the pixels within the first contour to obtain the second image; The region within the first contour in the second image is blurred to obtain a first blurred image.
2. The method according to claim 1, characterized in that, For the Nth row of pixels in the first image, at least one pixel in the Nth row is located within the first contour, where N is a positive integer. The step of modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes: Obtain the pixel value of a first preset number of pixels that are close to the first contour in the Nth row of pixels; The pixel values of the pixels in the Nth row that are located outside the first contour are modified according to the pixel values of the first preset number of pixels.
3. The method according to claim 2, characterized in that, The first preset number of pixels are the pixels closest to the first side outside the first contour. The modification of the pixel values of the pixels in the Nth row located outside the first contour, based on the pixel values of the first preset number of pixels, includes: For the M1 pixels in the Nth row that are located on the first side outside the first contour, the pixel values of the M1 pixels are modified to the average of the pixel values of the first preset number of pixels, wherein the M1 pixels are adjacent pixels and M1 is a positive integer; and For each pixel Q1 in the Nth row of pixels located on the first side outside the first contour, excluding the M1 pixels, the pixel value of pixel Q1 is modified according to the average value and the pixel values of the M2 pixels that are close to or far from pixel Q1, wherein the M2 pixels are the pixels in the Nth row of pixels located on the first side outside the first contour, and M2 is a positive integer.
4. The method according to claim 2, characterized in that, The first preset number of pixels are pixels on the second side closest to the first contour, and the direction of the second side is opposite to that of the first side. The step of modifying the pixel values of the pixels in the Nth row that are located outside the first contour according to the pixel values of the first preset number of pixels includes: For each pixel G1 located on the second side outside the first contour in the Nth row of pixels, the pixel value of pixel G1 is modified according to the average pixel value of the first preset number of pixels and the pixel values of the M3 pixels closest to pixel G1, wherein the M3 pixels are the pixels in the Nth row of pixels, and M3 is a positive integer.
5. The method according to claim 2, characterized in that, The first preset number of pixels are pixels on the second side closest to the first contour, and the direction of the second side is opposite to that of the first side. The step of modifying the pixel values of the pixels in the Nth row that are located outside the first contour according to the pixel values of the first preset number of pixels includes: For the M1 pixels located on the second side outside the first contour in the Nth row of pixels, the pixel values of the M1 pixels are modified to the average of the pixel values of the first preset number of pixels, wherein the M1 pixels are adjacent pixels and M1 is a positive integer; and For each pixel G1 in the Nth row of pixels located on the second side outside the first contour, excluding the M1 pixels, the pixel value of pixel G1 is modified according to the average value and the pixel values of the M2 pixels that are close to or far from pixel G1, wherein the M2 pixels are the pixels in the Nth row of pixels located on the second side outside the first contour, and M2 is a positive integer.
6. The method according to any one of claims 2-5, characterized in that, For the Kth column of pixels in the first image, at least one pixel in the Kth column is located within the first contour, where K is a positive integer. The step of modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes: Obtain the pixel values of a second preset number of pixels within the first contour that are close to the first contour in the Kth column. The pixel values of the pixels in the Kth column that are located outside the first contour are modified according to the pixel values of the second preset number of pixels.
7. The method according to claim 6, characterized in that, The second preset number of pixels are the pixels on the third side closest to the outside of the first contour. The step of modifying the pixel values of the pixels in the Kth column that are located outside the first contour according to the pixel values of the second preset number of pixels includes: For the M4 pixels located on the third side outside the first contour in the Kth column, the pixel values of the M4 pixels are modified to the average of the pixel values of the second preset number of pixels, wherein the M4 pixels are adjacent pixels and M4 is a positive integer; and For each pixel Q2 in the Kth column of pixels located on the third side outside the first contour, excluding the M4 pixels, the pixel value of pixel Q2 is modified according to the average value and the pixel values of the M5 pixels that are close to or far from pixel Q2, wherein the M5 pixels are the pixels in the Kth column of pixels located on the third side outside the first contour, and M5 is a positive integer.
8. The method according to claim 6, characterized in that, The second preset number of pixels are pixels located on a fourth side near the outer edge of the first contour, and the direction of the fourth side is opposite to that of the third side. The step of modifying the pixel values of the pixels in the Kth column that are located outside the first contour according to the pixel values of the second preset number of pixels includes: For each pixel G2 located on the fourth side outside the first contour in the Kth column of pixels, the pixel value of pixel G2 is modified according to the average value of the pixel values of the second preset number of pixels and the pixel values of the M6 pixels closest to pixel G2, wherein the M6 pixels are the pixels in the Kth column of pixels, and M6 is a positive integer.
9. The method according to claim 6, characterized in that, The second preset number of pixels are pixels located on a fourth side near the outer edge of the first contour, and the direction of the fourth side is opposite to that of the third side. The step of modifying the pixel values of the pixels in the Kth column that are located outside the first contour according to the pixel values of the second preset number of pixels includes: For the M4 pixels in the Kth column that are located on the fourth side outside the first contour, the pixel values of the M4 pixels are modified to the average of the pixel values of the second preset number of pixels, wherein the M4 pixels are adjacent pixels and M4 is a positive integer; and For each pixel G2 in the Kth column of pixels located on the fourth side outside the first contour, excluding the M4 pixels, the pixel value of pixel G2 is modified according to the average value and the pixel values of the M5 pixels that are close to or far from pixel G2, wherein the M5 pixels are the pixels in the Kth column of pixels located on the fourth side outside the first contour, and M5 is a positive integer.
10. The method according to any one of claims 1-9, characterized in that, Before modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour to obtain the second image, the method further includes: The first image is subjected to data sampling processing to obtain the third image; The step of modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour to obtain the second image includes: The pixel values of pixels outside the first contour are modified based on the pixel values of pixels within the first contour in the third image to obtain the second image.
11. The method according to claim 10, characterized in that, The step of blurring the region within the first contour in the second image to obtain a first blurred image includes: The region within the first contour in the second image is blurred to obtain a second blurred image; The second blurred image is interpolated based on the information from the data sampling to obtain the first blurred image.
12. The method according to any one of claims 1-9, characterized in that, The first image includes pixels in row D, where D is a positive integer. Modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes: During the data sampling process of the D-th row of pixels, the pixel values of the pixels located outside the first contour in the D-th row of pixels are modified according to the pixel values of the pixels located within the first contour in the D-th row of pixels; The blurring process on the region within the first contour in the second image includes: During the data sampling process of the D-th row of pixels, the pixels located within the first contour in the D-th row of pixels are blurred.
13. The method according to claim 12, characterized in that, The first image includes pixels in column E, where E is a positive integer. The step of modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes: During the data sampling process of the Eth column pixels, the pixel values of the pixels in the Eth column pixels located outside the first contour are modified according to the pixel values of the pixels in the Eth column pixels located within the first contour; The blurring process on the region within the first contour in the second image includes: During the data sampling process of the Eth column pixels, the pixels located within the first contour in the Eth column pixels are blurred.
14. The method according to any one of claims 1-9, characterized in that, The blurring process on the region within the first contour in the second image includes: When performing data sampling processing on row by row for the pixels within the first contour, the pixels within the first contour are blurred row by row; and when performing data sampling processing on column by column for the pixels within the first contour, the pixels within the first contour are blurred column by column.
15. The method according to any one of claims 1-9, characterized in that, The electronic device includes a first processor and a second processor. The step of blurring the region within the first contour in the second image includes: Using the first processor, when performing data sampling processing on the first target row among multiple rows containing pixels within the first contour, the pixels included in the first target row within the first contour are blurred; and, Using the second processor, when performing data sampling processing on the second target row among the multiple rows containing the pixels in the first contour, the pixels included in the second target row within the first contour are blurred. or, Using the first processor, when performing data sampling processing on the first target column among multiple columns containing pixels within the first contour, the pixels included in the first target column within the first contour are blurred; and, Using the second processor, when performing data sampling processing on the second target column among the multiple columns containing pixels within the first contour, the pixels included in the second target column within the first contour are blurred.
16. The method according to any one of claims 1-9, characterized in that, The step of modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes: When performing data sampling processing row by row for the rows containing pixels outside the first contour, the pixel values of the pixels outside the first contour are modified row by row based on the pixel values of the pixels inside the first contour. Similarly, when performing data sampling processing column by column for the columns containing pixels outside the first contour, the pixel values of the pixels outside the first contour are modified column by column based on the pixel values of the pixels inside the first contour.
17. The method according to any one of claims 1-9, characterized in that, The electronic device includes a first processor and a second processor. The step of modifying the pixel values of pixels outside the first contour based on the pixel values of pixels within the first contour includes: Using the first processor, when performing data sampling processing on the first target row among multiple rows containing pixels outside the first contour, the pixel values of the pixels included in the first target row outside the first contour are modified according to the pixel values of the pixels within the first contour; and, Using the second processor, when performing data sampling processing on the second target row among the multiple rows containing pixels in the first contour, the pixel values of the pixels included in the second target row within the first contour are modified according to the pixel values of the pixels in the first contour. or, Using the first processor, when performing data sampling processing on the first target column among multiple columns containing pixels within the first contour, the pixel values of the pixels included in the first target column within the first contour are modified according to the pixel values of the pixels within the first contour; and, Using the second processor, when performing data sampling processing on the second target column among the multiple columns containing pixels within the first contour, the pixel values of the pixels included in the second target column within the first contour are modified according to the pixel values of the pixels within the first contour.
18. An electronic device, characterized in that, include: One or more processors; One or more memories; the one or more memories storing one or more programs that, when executed by one or more processors, cause the image blurring method as described in any one of claims 1-17 to be performed.
19. A chip, characterized in that, The chip includes a processor and a communication interface, the communication interface being used to receive signals and transmit the signals to the processor, the processor processing the signals such that the image blurring method as described in any one of claims 1-17 is executed.
20. A readable storage medium, characterized in that, The readable storage medium stores instructions that, when executed on an electronic device, cause the image blurring method as described in any one of claims 1-17 to be performed.
21. A program product, characterized in that, The program product includes program code that, when run on an electronic device, causes the image blurring method as described in any one of claims 1-17 to be executed.
Citation Information
Patent Citations
Image blurring method and system
CN102542533A
Method and system of sharpening image contour based on CMOS image sensor
CN104394336A
Image blurring method and device and electronic equipment
CN109727193A
Image processing method and device, electronic equipment and computer readable storage medium
CN116071222A
Determining contour edges for an image
US20230394647A1