Image Processing Method, Apparatus, System, Electronic Device and Storage Medium
By directly performing Gaussian blur processing and cropping of the to-process area in image processing, the high resource consumption and lag problems caused by the generation of new layers in the prior art are solved, and a smoother image display is achieved.
Patent Information
- Application Number
- CN202111326700.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-10
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2041-11-10
AI Technical Summary
The prior art requires the generation of new layers and synthesis with the original image in image blur processing, which leads to excessive consumption of system resources and processing time, especially in scenarios where interface switching is frequent and image refresh is frequent, resulting in lag.
By performing Gaussian blurring on the image to be processed, determining the area to be processed and obtaining the location information, cropping the Gaussian blurring image and directly covering the area to be processed, avoiding the generation of new layers.
It greatly reduces the system resource consumption and processing time consumption of image drawing, avoids lag caused by frame skipping of image display, and improves the fluency of display interface refresh.
Smart Images

Figure CN114119394B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of image processing, and particularly relates to an image processing method, apparatus, system, electronic device, and storage medium. Background Art
[0002] In modern society where various electronic devices such as mobile phones, tablets, and laptops are becoming increasingly popular, the operating speed of electronic devices and the smoothness of transitional images during interface conversion have become an important evaluation criterion for consumers when choosing products.
[0003] To achieve the dual effects of smooth transitional screens and operating speed, the current mainstream solution is to blur the transitional animation, which requires image blurring processing on the image. However, in the existing technical solutions, the generation process of the blurred image is to first generate a new layer for the target area in the image, then blur the layer, and finally synthesize the processed layer with the original image to generate a new image with a blurred effect. However, this series of operations consumes a great deal of time and system resources for image processing.
[0004] In scenarios where the interface is switched frequently and the image refresh frequency is high, the number of generated transitional images will also be very large. As a result, the consumption of system resources and image processing time will increase significantly, leading to frame skipping during the refresh of transitional images, making the electronic device appear very laggy. Summary of the Invention
[0005] In view of the above problems, this application proposes an image processing method, apparatus, system, electronic device, and storage medium to improve the above problems.
[0006] In a first aspect, an embodiment of this application provides an image processing method, which includes: in response to an image acquisition request, acquiring an image to be processed; performing Gaussian blur processing on the image to be processed to obtain a target image, where the target image is the image to be processed after Gaussian blur processing; determining a region to be processed in the image to be processed, and acquiring position information corresponding to the region to be processed; based on the position information, cropping the target image to obtain a Gaussian blurred image corresponding to the region to be processed; and covering the Gaussian blurred image on the region to be processed of the image to be processed.
[0007] Second aspect, an embodiment of the present application provides an image processing method, the method comprising: an effect service thread obtains a to-be-processed image in response to an image acquisition request sent by a main thread; the effect service thread performs Gaussian blur processing on the to-be-processed image to obtain a target image, where the target image is the to-be-processed image after Gaussian blur processing; the effect service thread determines a to-be-processed area in the to-be-processed image and obtains position information corresponding to the to-be-processed area; the effect service thread crops the target image based on the position information to obtain a Gaussian blurred image corresponding to the to-be-processed area; the main thread covers the Gaussian blurred image on the to-be-processed area of the to-be-processed image.
[0008] Third aspect, an embodiment of the present application provides an image processing apparatus, the apparatus comprising: an image acquisition unit configured to obtain a to-be-processed image in response to an image acquisition instruction; a blur processing unit configured to perform Gaussian blur processing on the to-be-processed image to obtain a target image, where the target image is the to-be-processed image after Gaussian blur processing; an information acquisition unit configured to determine a to-be-processed area in the to-be-processed image and obtain position information corresponding to the to-be-processed area; a cropping unit configured to crop the target image based on the position information to obtain a Gaussian blurred image corresponding to the to-be-processed area; a covering unit configured to cover the Gaussian blurred image on the to-be-processed area of the to-be-processed image.
[0009] Fourth aspect, an embodiment of the present application provides an image processing system, the system comprising an effect service thread and a main thread; the effect service thread is configured to obtain a to-be-processed image in response to an image acquisition request sent by the main thread; the effect service thread is configured to perform Gaussian blur processing on the to-be-processed image to obtain a target image, where the target image is the to-be-processed image after Gaussian blur processing; the effect service thread is configured to determine a to-be-processed area in the to-be-processed image and obtain position information corresponding to the to-be-processed area; the effect service thread is configured to crop the target image based on the position information to obtain a Gaussian blurred image corresponding to the to-be-processed area; the main thread is configured to cover the Gaussian blurred image on the to-be-processed area of the to-be-processed image.
[0010] Fifth aspect, an embodiment of the present application provides an electronic device, comprising one or more processors and a memory; one or more programs, where the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method described above.
[0011] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium storing program code, where the above-mentioned method is executed when the program code runs.
[0012] In a seventh aspect, an embodiment of the present application provides a computer program product including a computer program / instructions, and the steps of the above-mentioned method are implemented when the computer program / instructions are executed by a processor.
[0013] An embodiment of the present application provides an image processing method, apparatus, system, electronic device, and storage medium. First, in response to an image acquisition request, an image to be processed is acquired, then the image to be processed is subjected to Gaussian blur processing to obtain a target image, a region to be processed is determined in the image to be processed, and position information corresponding to the region to be processed is acquired. Then, based on the position information, the target image is cropped to obtain a Gaussian blur image corresponding to the region to be processed. Finally, the Gaussian blur image is overlaid on the region to be processed of the image to be processed. Through the above method, the image to be processed is subjected to Gaussian blur processing as a whole, then the target image corresponding to the specified region is cropped, and the target image is overlaid on the specified region of the image to be processed, so that drawing can be performed on the original image without the need to generate a new layer, thereby greatly reducing the consumption of system resources and processing time for image drawing, and avoiding the phenomenon of frame skipping and stuttering in image display, and improving the smoothness of the display interface refresh. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] To more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for description in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and those skilled in the art can obtain other drawings without creative efforts based on these drawings.
[0015] Figure 1 FIG. shows a schematic diagram of an application environment of an image processing method proposed in an embodiment of the present application;
[0016] Figure 2 FIG. shows a flowchart of an image processing method proposed in an embodiment of the present application;
[0017] Figure 3 FIG. shows a flowchart of an image processing method proposed in another embodiment of the present application;
[0018] Figure 4 FIG. shows a flowchart of an image processing method proposed in yet another embodiment of the present application;
[0019] Figure 5 FIG. shows a flowchart of an image processing method proposed in still another embodiment of the present application;
[0020] Figure 6 The block diagram of an image processing device proposed by an embodiment of the present application is shown;
[0021] Figure 7 The block diagram of an image processing system proposed by an embodiment of the present application is shown;
[0022] Figure 8 The block diagram of an electronic device for executing an image processing method according to an embodiment of the present application in real time is shown;
[0023] Figure 9 The storage unit for storing or carrying program codes for implementing the image processing method according to an embodiment of the present application in real time is shown. Detailed implementation manners
[0024] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0025] Gaussian blur, also known as Gaussian smoothing, is a processing effect widely used in image processing software such as Adobe Photoshop and Paint.NET. It is usually used to reduce image noise and lower the detail level. Since Gaussian blur can enhance the effect of highlighting the theme and enrich the aesthetics of the human-computer interaction interface of mobile devices, it is meaningful to implement an efficient and real-time Gaussian blur effect.
[0026] The Gaussian blur effect can be applied to multiple fields, including: image blur in real-time video calls, Gaussian blur filter effects in image processing, and video coding complexity simplification methods combined with the Gaussian blur effect, etc. In these fields, through the Gaussian blur effect, effects such as beautifying images, reducing video coding complexity, and bit rate can be achieved.
[0027] The inventors found in the research on related image processing methods that during the process of blurring an image, it is necessary to blur a specific area in the image to generate a new layer, and then combine the newly generated layer with the layer of the original image, which in turn leads to extremely serious consumption of system resources and processing time.
[0028] Therefore, the inventor has proposed an image processing method, apparatus, system, electronic device, and storage medium in this application. First, in response to an image acquisition request, an image to be processed is acquired. Then, the image to be processed is subjected to Gaussian blur processing to obtain a target image. A region to be processed is determined in the image to be processed, and the position information corresponding to the region to be processed is acquired. Then, based on the position information, the target image is cropped to obtain a Gaussian blur image corresponding to the region to be processed. Finally, the Gaussian blur image is overlaid on the region to be processed of the image to be processed. Through the above method, the image to be processed is subjected to Gaussian blur processing as a whole, and then the target image corresponding to the specified region is cropped and overlaid on the specified region of the image to be processed, so that drawing can be performed on the original image without the need to generate a new layer, thereby greatly reducing the consumption of system resources and processing time for image drawing, and avoiding the phenomenon of frame skipping and jitter during image display, and improving the smoothness of the display interface refresh.
[0029] Before further elaborating on the embodiments of the present application, an application environment involved in the embodiments of the present application is introduced.
[0030] Figure 1 FIG. shows a schematic diagram of a system 100 in which the various methods and apparatuses described in the present application can be implemented according to an embodiment of the present application. Refer to Figure 1 , the system 100 includes one or more electronic devices 110, a server 120, and one or more communication networks 130 that couple the one or more electronic devices to the server 120.
[0031] In the embodiments of the present application, the server 120 can run one or more services or software applications that enable the execution of an image processing method. In some embodiments, the server 120 can be a server of a distributed system. The server 120 can also be a cloud server, or an intelligent cloud computing server or an intelligent cloud host with artificial intelligence technology.
[0032] A user can use the electronic device 110 to acquire an image to be processed. The electronic device 110 can provide an interface that enables a user of the electronic device to interact with the electronic device 110. The electronic device 110 can also output information to the user via the interface. For example, the electronic device 110 can input audio data through the interface.
[0033] The electronic device 110 can be various types of computer devices, such as portable handheld devices, general-purpose computers (such as personal computers and laptop computers), and wearable devices, etc. Among them, the portable handheld devices can include cellular phones, smart phones, tablet computers, personal digital assistants (PDAs), etc.; the wearable devices can include head-mounted displays and other devices. The electronic device 110 is capable of executing various different application programs, such as various Internet-related application programs, communication application programs (such as email application programs), short message service (SMS) application programs, and can use various communication protocols.
[0034] The network 130 can be any type of network, which can support data communication using any one of a variety of available protocols (including but not limited to TCP / IP, SNA, IPX, etc.). By way of example only, one or more networks 130 can be a local area network (LAN), an Ethernet-based network, a token ring, a wide area network (WAN), the Internet, a virtual network, a virtual private network (VPN), an intranet, an extranet, a public switched telephone network (PSTN), an infrared network, a wireless network (such as Bluetooth, WIFI), and / or any combination of these and / or other networks.
[0035] The system 100 may also include one or more databases 140. In certain embodiments, these databases can be used to store images to be processed. The database 140 can reside in various locations. For example, the database used by the server 120 can be local to the server 120, or can be remote from the server 120 and can communicate with the server 120 via a network-based or dedicated connection. The database 140 can be of different types. In certain embodiments, the database used by the server 120 can be a relational database. One or more of these databases can store, update, and retrieve data to and from the database in response to commands.
[0036] The embodiments of the present application will be specifically described below in conjunction with the accompanying drawings.
[0037] Please refer to Figure 2 , an image processing method provided by an embodiment of the present application, which is applied to an electronic device, and the method includes:
[0038] Step S110: In response to an image acquisition request, acquire an image to be processed.
[0039] In an embodiment of the present application, the image acquisition request may be triggered when a specified application in the electronic device is detected to be started or a specified touch operation on the electronic device is detected. Among them, the specified application may be an application for loading pictures, and the specified touch operation may be a pre-set touch operation, such as a double-tap operation on the touch display screen. Of course, the image acquisition request may also be triggered after detecting a touch operation on the display interface corresponding to the specified application in the electronic device after detecting that the specified application in the electronic device is started. Optionally, the image acquisition request may also be sent by other electronic devices that need to acquire the image to be processed. No specific limitation is made here.
[0040] As a way, the image to be processed is an image that needs to be subjected to Gaussian blur processing. Among them, the image to be processed may be stored in the local storage area of the electronic device or in a server that establishes a communication connection with the electronic device. When receiving an image acquisition request sent by other electronic devices or detecting that the image acquisition request is triggered, the electronic device responds to the image acquisition request and acquires the image to be processed from the local storage area or the server of the electronic device.
[0041] Optionally, the number of images stored in the local storage area or the server of the electronic device may be more than one. Therefore, when responding to the image acquisition request, the images stored in the local storage area or the server of the electronic device can be displayed, and then the user can select the image to be processed according to the needs.
[0042] Furthermore, the link address of the image to be processed may be carried in the image acquisition request. Then, when the electronic device responds to the image acquisition request, the corresponding image to be processed can be directly found from the local storage area or the server of the electronic device through this link address.
[0043] As another way, the image to be processed may also be the display interface image corresponding to the running application. During the running of some applications, when displaying some information, some areas in the corresponding display interface need to be blurred. Then, when responding to the image acquisition request, the display interface image corresponding to the running application can be used as the image to be processed. Here, the application may be an image processing application, such as PS software, etc.
[0044] Step S120: Perform Gaussian blur processing on the image to be processed to obtain a target image, where the target image is the image to be processed after Gaussian blur processing.
[0045] In an embodiment of the present application, after acquiring the image to be processed, the Gaussian blur function can be used to perform Gaussian blur processing on the image to be processed to obtain the image after Gaussian blur processing.
[0046] Step S130: Determine a region to be processed in the image to be processed, and obtain the position information corresponding to the region to be processed.
[0047] In the embodiments of the present application, the region to be processed may be a specified region that needs to be subjected to Gaussian blur processing and is set in advance, or the region to be processed may also be a region determined in real time according to the position of a control. Among them, the position of the control may be the position of a virtual control in an electronic device, and the position of the virtual control in the electronic device will move as the user operates. Therefore, the region to be processed can be determined in real time according to the position of the virtual control.
[0048] As a way, it can be known that when an electronic device runs certain application programs, corresponding virtual controls can pop up in the corresponding display interface. Then, in the corresponding display interface, the background image at the position where the virtual control is located is often desired to be hidden, and the part of the image other than the position where the virtual control is located does not need to be hidden. Therefore, it is necessary to perform Gaussian blur processing on the background image at the position where the virtual control is located, and the background image other than the position where the virtual control is located does not need to be subjected to Gaussian blur processing.
[0049] In the above case, when it is detected that the image to be processed is the display interface corresponding to the application program running in the electronic device, the region to be processed of the image to be processed can be determined in real time according to the position of the virtual control, and then the position information corresponding to the region to be processed can be obtained in real time.
[0050] Step S140: Based on the position information, crop the target image to obtain a Gaussian blur image corresponding to the region to be processed.
[0051] In the embodiments of the present application, since the target image is the image to be processed after Gaussian blur processing, the size and dimensions of the target image and the image to be processed are the same. Furthermore, based on the position information of the region to be processed obtained above, the Gaussian blur processed image obtained by cropping the target image is an image with the same size and dimensions as the region to be processed.
[0052] As a way, before cropping the target image based on the position information, it can be first detected whether the image to be processed has been subjected to Gaussian blur processing to obtain the target image. If so, the target image is cropped based on the position information; if not, after waiting for the Gaussian blur processing of the image to be processed to end, the target image is cropped based on the position information.
[0053] Step S150: Cover the Gaussian blur image on the region to be processed of the image to be processed.
[0054] In an embodiment of the present application, the Gaussian blurred image corresponding to the to-be-processed area obtained after cropping is overlaid on the corresponding area of the to-be-processed image, thereby completing the Gaussian blurring process for the specific area of the to-be-processed image.
[0055] An image processing method provided by the present application first obtains a to-be-processed image in response to an image acquisition request, then performs Gaussian blurring processing on the to-be-processed image to obtain a target image, determines a to-be-processed area in the to-be-processed image, and obtains the corresponding position information of the to-be-processed area. Then, based on the position information, the target image is cropped to obtain a Gaussian blurred image corresponding to the to-be-processed area. Finally, the Gaussian blurred image is overlaid on the to-be-processed area of the to-be-processed image. Through the above method, the to-be-processed image is subjected to Gaussian blurring processing as a whole, and then the target image corresponding to the specified area is cropped and overlaid on the specified area of the to-be-processed image, so that drawing can be performed on the original image without the need to generate a new layer, thereby greatly reducing the consumption of system resources and processing time for image drawing, and avoiding the phenomenon of frame skipping and jamming in image display, and improving the smoothness of the display interface refresh.
[0056] Please refer to Figure 3 , an image processing method provided by an embodiment of the present application is applied to an electronic device, and the method includes:
[0057] Step S210: Obtain a to-be-processed image in response to an image acquisition request.
[0058] In an embodiment of the present application, step S210 can specifically refer to the detailed explanation in the above embodiment, so it will not be elaborated here.
[0059] Step S220: Obtain the attribute information of the to-be-processed image.
[0060] In an embodiment of the present application, the attribute information of the to-be-processed image may include the encoding method and decoding method of the to-be-processed image, the byte data of the to-be-processed image, the width and height of the to-be-processed image, etc. Among them, the encoding method of the image may include YUV encoding method, RGB encoding method, etc., which are not specifically limited here.
[0061] As a way, when storing the to-be-processed image, the corresponding attribute information of the to-be-processed image can be stored at the same time. Then, when obtaining the to-be-processed image, the attribute information of the to-be-processed image can be obtained at the same time, and then corresponding processing can be performed on the to-be-processed image according to the attribute information of the to-be-processed image, such as cropping processing, magnifying processing or shrinking processing, etc.
[0062] Step S230: Perform a decoding operation on the to-be-processed image according to the attribute information to obtain a drawable image after decoding.
[0063] In an embodiment of the present application, after obtaining the attribute information of the image to be processed, the image to be processed can be decoded according to the decoding method of the image to be processed in the attribute information to obtain a drawable image after decoding.
[0064] Step S240: Perform Gaussian blur processing on the drawable image to obtain a target image.
[0065] In an embodiment of the present application, after obtaining the drawable image in the above manner, perform Gaussian blur processing on the drawable image through a preset Gaussian blur algorithm to obtain a target image.
[0066] Step S250: Determine a region to be processed in the image to be processed, and obtain the offset of the region to be processed relative to the image to be processed, and the position of the region to be processed in the image to be processed.
[0067] In an embodiment of the present application, the offset of the region to be processed relative to the image to be processed and the position of the region to be processed in the image to be processed can be calculated according to the coordinates of each pixel point in the image to be processed.
[0068] When the image to be processed is the display interface corresponding to an application program running on an electronic device and there are virtual controls in the display interface, since the positions of the virtual controls are changed in real time according to the user's touch operations, it is necessary to calculate the offset of the region where the virtual controls are located relative to the image to be processed before and after the virtual controls move.
[0069] When calculating the offset of the region to be processed relative to the image to be processed according to the coordinates of each pixel point in the image to be processed, it can be calculated according to the coordinates of the pixel points on the boundary line of the region to be processed, or it can be calculated according to the coordinates of the specified pixel points among the pixel points included in the region to be processed.
[0070] Step S260: Based on the position information, crop the target image to obtain a Gaussian blurred image corresponding to the region to be processed.
[0071] Step S270: Cover the Gaussian blurred image on the region to be processed of the image to be processed.
[0072] In an embodiment of the present application, for the specific implementation of step S260 and step S270, reference can be made to the detailed explanations in the above embodiments, so they will not be elaborated here.
[0073] An image processing method provided by this application first responds to an image acquisition request to acquire an image to be processed and the attribute information of the image to be processed, then performs a decoding operation on the image to be processed according to the attribute information to obtain a drawable image after decoding, performs Gaussian blur processing on the drawable image to obtain a target image, then determines a region to be processed in the image to be processed, and acquires the offset of the region to be processed relative to the image to be processed and the position of the region to be processed in the image to be processed. Finally, based on the position information, the target image is cropped to obtain a Gaussian blurred image corresponding to the region to be processed, and the Gaussian blurred image is overlaid on the region to be processed of the image to be processed. Through the above method, the image to be processed is subjected to Gaussian blur processing as a whole, then the target image corresponding to the specified region is cropped, and the target image is overlaid on the specified region of the image to be processed, so that drawing can be performed on the original image without the need to generate a new layer, thereby greatly reducing the consumption of system resources and processing time for image drawing, and avoiding the phenomenon of frame skipping and jamming in image display, and improving the smoothness of the display interface refresh.
[0074] Please refer to Figure 4 , an image processing method provided by an embodiment of this application is applied to an electronic device, and the method includes:
[0075] Step S310: In response to an image acquisition request, detect the state of the image to be processed.
[0076] In an embodiment of this application, the state of the image to be processed may include one of a cached state, an uncached completed state, and a non-existent state.
[0077] As a way, the state of the image to be processed can be represented by different identifiers. For example, if the state of the image to be processed is the cached state, the identifier of the image to be processed is set to "Y"; if the state of the image to be processed is the uncached completed state, the identifier of the image to be processed is set to "W"; if the state of the image to be processed is the non-existent state, the identifier of the image to be processed is set to "B", etc. Thus, the state of the image to be processed can be determined through the identifier corresponding to the image to be processed.
[0078] In an embodiment of this application, when an image acquisition request is received, in response to the image acquisition request, the identifier of the image to be recognized is acquired to determine the state of the image to be processed.
[0079] Step S320: If the state of the image to be processed is the cached state, acquire the image to be processed.
[0080] In an embodiment of this application, when it is determined through the identifier of the image to be processed that the state of the image to be processed is the cached state, the image to be processed is acquired.
[0081] As another approach, if the status of the image to be processed is non-existent or not cached completely, the status of the image to be processed is obtained at specified time intervals until the status of the image to be processed is cached, and then the image to be processed is obtained.
[0082] When it is determined that the status of the image to be processed is non-existent or not cached completely through the identifier of the image to be processed, the status of the image to be processed is obtained at specified time intervals until it is detected that the status of the image to be processed is cached, and then the acquisition of the status of the image to be processed is stopped. At this time, the image to be processed is obtained. Herein, the specified time may be the time interval between the first receipt of the image acquisition instruction and the second receipt of the image acquisition instruction. Of course, the specified time may also be a preset time length, which is not specifically limited herein.
[0083] Step S330: Perform Gaussian blur processing on the image to be processed to obtain a target image, where the target image is the image to be processed after Gaussian blur processing.
[0084] Step S340: Determine a region to be processed in the image to be processed and obtain the position information corresponding to the region to be processed.
[0085] Step S350: Crop the target image based on the position information to obtain a Gaussian blur image corresponding to the region to be processed.
[0086] Step S360: Cover the Gaussian blur image on the region to be processed of the image to be processed.
[0087] In the embodiments of the present application, steps S330, S340, S350, and S360 may specifically refer to the detailed explanations in the above embodiments, and thus will not be elaborated herein.
[0088] An image processing method provided by this application first responds to an image acquisition request, detects the status of the image to be processed. If the status of the image to be processed is already the cached status, the image to be processed is acquired, and the image to be processed is subjected to Gaussian blur processing to obtain a target image. Then, a region to be processed is determined in the image to be processed, and the corresponding position information of the region to be processed is obtained. Based on the position information, the target image is cropped to obtain a Gaussian blur image corresponding to the region to be processed. Finally, the Gaussian blur image is overlaid on the region to be processed of the image to be processed. Through the above method, the image to be processed is subjected to Gaussian blur processing as a whole, and then the target image corresponding to the specified region is cropped, and the target image is overlaid on the specified region of the image to be processed, so that drawing can be performed on the original image without the need to generate a new layer, thereby greatly reducing the consumption of system resources and processing time for image drawing, and further avoiding the phenomenon of frame skipping and freezing in image display, and improving the smoothness of the display interface refresh.
[0089] Please refer to Figure 5 , an image processing method provided by an embodiment of this application is applied to an image processing system, and the method includes:
[0090] Step S410: The effect service thread responds to the image acquisition request sent by the main thread and acquires the image to be processed.
[0091] In Flutter, tasks are defaultly processed by a single thread. If a new thread is not started, tasks are defaultly processed in the main thread. If there are many tasks to be processed, the burden on the main thread will increase.
[0092] To reduce the burden on the main thread for processing tasks, a new thread can be created to perform the Gaussian blur processing task through this new thread. In an embodiment of this application, the effect service thread is the newly created thread, and this effect service thread is a new processing thread generated by using the Isolate.spawnUri function and is used to perform Gaussian blur processing on the image to be processed.
[0093] As a way, the effect service thread can provide a cached image interface. The effect service thread receives the signal sent by the main thread through this cached image interface, decodes the blurred processed image based on the signal, and caches it. Optionally, the effect service thread can also detect whether the image has been cached and processed through this cached image interface to prevent repeated caching operations.
[0094] Step S420: The effect service thread performs Gaussian blur processing on the image to be processed to obtain a target image, and the target image is the image to be processed after Gaussian blur processing.
[0095] In the embodiment of the present application, the effect server thread calls the cached image interface to perform Gaussian blur processing and caching on the image to be processed, obtains the target image, and records the basic information of the target image in the local storage area. The basic information of the target image may include the link of the target image, the original byte data of the target image, the width and height of the target image, etc.
[0096] Step S430: The effect service thread determines the area to be processed in the image to be processed and obtains the position information corresponding to the area to be processed.
[0097] In the embodiment of the present application, before determining the area to be processed, the effect service thread will first detect the historical loading data, that is, the basic information recorded above. After detecting the basic information of the target image, the image to be processed is asynchronously and parallelly loaded in advance. After the main thread is started, the effect service thread is started. The main thread is responsible for graphics drawing, and the relatively time-consuming operations are processed using the effect service thread to prevent blocking the main thread when performing time-consuming operations.
[0098] Here, the relatively time-consuming operation is to determine the area to be processed in the image to be processed. The effect service thread calculates the position information of the area to be processed to obtain the position information corresponding to the area to be processed.
[0099] Step S440: The effect service thread crops the target image based on the position information to obtain a Gaussian blur image corresponding to the area to be processed.
[0100] In the embodiment of the present application, the effect service thread crops the target image according to the calculated position information to obtain a Gaussian blur image with the same size as the area to be processed.
[0101] As a way, the effect service thread can provide an interface for obtaining the Gaussian blur picture. This Gaussian blur picture interface refers to the interface for the main thread to obtain the drawable image that has been blurred and cached by the effect service thread. This interface can input the size and offset relative to the cached picture to notify the effect service thread to return a Gaussian blur image of the corresponding size to the main thread.
[0102] Step S450: The main thread covers the Gaussian blur image on the area to be processed of the image to be processed.
[0103] In the embodiment of the present application, after cropping the Gaussian blur image corresponding to the area to be processed, the main thread covers the cropped Gaussian blur image corresponding to the area to be processed on the image to be processed to complete the Gaussian blur processing of the specific area.
[0104] An image processing method provided by this application. First, an effect service thread responds to an image acquisition request sent by the main thread, acquires the image to be processed. Then, the effect service thread performs Gaussian blur processing on the image to be processed to obtain a target image. Determine the area to be processed in the image to be processed, and obtain the corresponding position information of the area to be processed. Then, based on the position information, crop the target image to obtain a Gaussian blurred image corresponding to the area to be processed. Finally, the main thread covers the Gaussian blurred image on the area to be processed of the image to be processed. Through the above method, perform Gaussian blur processing on the entire image to be processed, then crop the target image corresponding to the specified area, and cover the target image on the specified area of the image to be processed, so that drawing can be performed on the original image without the need to generate a new layer, thereby greatly reducing the consumption of system resources and processing time for image drawing, and further avoiding the phenomenon of frame skipping and jamming in image display, and improving the smoothness of the display interface refresh.
[0105] Please refer to Figure 6 , an image processing apparatus 500 provided by an embodiment of this application. The apparatus 500 includes:
[0106] An image acquisition unit 510, configured to acquire an image to be processed in response to an image acquisition instruction.
[0107] As a mode, the image acquisition unit 510 is configured to detect the state of the image to be processed in response to an image acquisition request; if the state of the image to be processed is a cached state, acquire the image to be processed.
[0108] Optionally, the image acquisition unit 510 is further configured to, if the state of the image to be processed is non-existent or not cached completely, acquire the state of the image to be processed at intervals of a specified time length until the state of the image to be processed is a cached state, and acquire the image to be processed.
[0109] A blur processing unit 520, configured to perform Gaussian blur processing on the image to be processed to obtain a target image, where the target image is the image to be processed after Gaussian blur processing.
[0110] As a mode, the blur processing unit 520 is further configured to acquire the attribute information of the image to be processed; perform a decoding operation on the image to be processed according to the attribute information to obtain a drawable image after decoding; perform Gaussian blur processing on the drawable image to obtain a target image.
[0111] An information acquisition unit 530, configured to determine an area to be processed in the image to be processed, and acquire the corresponding position information of the area to be processed.
[0112] As a way, the information acquisition unit 530 is configured to acquire the offset of the area to be processed relative to the image to be processed, and the position of the area to be processed in the image to be processed.
[0113] The cropping unit 540 is configured to crop the target image based on the position information to obtain a Gaussian blurred image corresponding to the area to be processed.
[0114] The covering unit 550 is configured to cover the Gaussian blurred image on the area to be processed of the image to be processed.
[0115] Please refer to Figure 7 , an image processing system 600 provided by an embodiment of the present application, the system 600 includes an effect service thread 610 and a main thread 620;
[0116] The effect service thread 610 is configured to acquire an image to be processed in response to an image acquisition request sent by the main thread 620.
[0117] The effect service thread 610 is configured to perform Gaussian blur processing on the image to be processed to obtain a target image, and the target image is the image to be processed after Gaussian blur processing.
[0118] The effect service thread 610 is configured to determine an area to be processed in the image to be processed and acquire position information corresponding to the area to be processed.
[0119] The effect service thread 610 is configured to crop the target image based on the position information to obtain a Gaussian blurred image corresponding to the area to be processed.
[0120] The main thread 620 is configured to cover the Gaussian blurred image on the area to be processed of the image to be processed.
[0121] It should be noted that the device embodiments in the present application correspond to the foregoing method embodiments. The specific principles in the device embodiments can be referred to the content in the foregoing method embodiments, and will not be elaborated here.
[0122] Next, an electronic device provided by the present application will be described in conjunction with Figure 8 Please refer to
[0123] Please refer to Figure 8, based on the above image processing method and apparatus, another electronic device 800 capable of executing the foregoing image processing method is further provided in an embodiment of the present application. The electronic device 800 includes one or more (only one is shown in the figure) processors 802, a memory 804, an image processor 806, and a network module 808 that are coupled to each other. Among them, the memory 804 stores a program that can execute the content in the foregoing embodiments, and the processor 802 can execute the program stored in the memory 804.
[0124] Among them, the processor 802 may include one or more processing cores. The processor 802 connects various parts within the entire electronic device 800 through various interfaces and lines, and executes various functions of the electronic device 800 and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 804, and by calling data stored in the memory 804. Optionally, the processor 802 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 802 may integrate a combination of one or more of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, application programs, etc.; the GPU is responsible for rendering and drawing display content; the modem is used to process wireless communication. It can be understood that the above modem may not be integrated into the processor 802 and may be implemented separately through a communication chip.
[0125] The memory 804 may include a random access memory (RAM) and may also include a read-only memory (ROM). The memory 804 can be used to store instructions, programs, codes, code sets, or instruction sets. The memory 804 may include a program storage area and a data storage area. Among them, the program storage area may store instructions for implementing the operating system, instructions for implementing at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data created during the use of the terminal 800 (such as phone book, audio and video data, chat record data, etc.).
[0126] The image processor 806 is used to perform Gaussian blur processing on the image to be processed to obtain a target image; determine a position to be processed in the image to be processed, and obtain the position information corresponding to the image to be processed; based on the position information, crop the target image to obtain a Gaussian blur image corresponding to the area to be processed; and cover the Gaussian blur image on the area to be processed of the image to be processed.
[0127] The network module 808 is used to receive and send electromagnetic waves, realize the mutual conversion between electromagnetic waves and electrical signals, so as to communicate with a communication network or other devices, such as communicating with an audio playback device. The network module 808 may include various existing circuit elements for performing these functions, such as antennas, radio frequency transceivers, digital signal processors, encryption / decryption chips, subscriber identity module (SIM) cards, memories, and the like. The network module 808 can communicate with various networks such as the Internet, enterprise intranets, wireless networks or communicate with other devices through a wireless network. The above-mentioned wireless network may include a cellular phone network, a wireless local area network or a metropolitan area network. For example, the network module 808 can interact with a base station.
[0128] Please refer to Figure 9 , which shows a structural block diagram of a computer-readable storage medium provided by an embodiment of the present application. Program code is stored in the computer-readable storage medium 900, and the program code can be called by a processor to execute the method described in the above method embodiment.
[0129] The computer-readable storage medium 900 can be an electronic memory such as a flash memory, EEPROM (electrically erasable programmable read-only memory), EPROM, hard disk or ROM. Optionally, the computer-readable storage medium 900 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 900 has a storage space for the program code 910 for executing any method step in the above method. These program codes can be read out from or written into one or more computer program products. The program code 910 can be compressed in an appropriate form, for example.
[0130] An image processing method, apparatus, system, electronic device, and storage medium provided by the present application first obtain a to-be-processed image in response to an image acquisition request, then perform Gaussian blur processing on the to-be-processed image to obtain a target image, determine a to-be-processed area in the to-be-processed image, and obtain position information corresponding to the to-be-processed area. Then, based on the position information, the target image is cropped to obtain a Gaussian blur image corresponding to the to-be-processed area. Finally, the Gaussian blur image is overlaid on the to-be-processed area of the to-be-processed image. Through the above method, Gaussian blur processing is performed on the entire to-be-processed image, and then the target image corresponding to the specified area is cropped, and the target image is overlaid on the specified area of the to-be-processed image, so that drawing can be performed on the original image without the need to generate a new layer, thereby greatly reducing the consumption of system resources and processing time for image drawing, and avoiding the phenomenon of frame skipping and freezing during image display, and improving the smoothness of the display interface refresh.
[0131] The embodiments of the present invention have been described above in conjunction with the accompanying drawings. However, the present invention is not limited to the above specific embodiments. The above specific embodiments are merely illustrative and not restrictive. Under the inspiration of the present invention, those of ordinary skill in the art can also make many forms without departing from the spirit and scope protected by the claims of the present invention, and all of them belong to the protection scope of the present invention.
Claims
1. An image processing method, characterized in that, The method includes: In response to an image acquisition request, acquire the image to be processed; Acquire the attribute information of the image to be processed; According to the attribute information, perform a decoding operation on the image to be processed to obtain a drawable image after decoding; Perform Gaussian blur processing on the drawable image to obtain a target image; Determine a region to be processed in the image to be processed, and acquire the corresponding position information of the region to be processed. The region to be processed is a region determined in real time according to the control position, and the control position is the position of a virtual control in an electronic device, and the position of the virtual control will move with the user's operation; Based on the position information, crop the target image to obtain a Gaussian blur image corresponding to the region to be processed; Overlay the Gaussian blur image on the region to be processed of the image to be processed.
2. The method according to claim 1, characterized in that, The acquiring the corresponding position information of the region to be processed includes: Acquire the offset of the region to be processed relative to the image to be processed, and the position of the region to be processed in the image to be processed.
3. The method according to claim 1, characterized in that, The in response to an image acquisition request, acquiring the image to be processed includes: In response to an image acquisition request, detect the state of the image to be processed; If the state of the image to be processed is the cached state, acquire the image to be processed.
4. The method according to claim 3, wherein The method further includes: If the state of the image to be processed is non - existent or not cached completely, acquire the state of the image to be processed at intervals of a specified time length until the state of the image to be processed is the cached state, and acquire the image to be processed.
5. An image processing method, characterized in that, The method includes: The effect service thread acquires the image to be processed in response to an image acquisition request sent by the main thread; The effect service thread acquires the attribute information of the image to be processed; according to the attribute information, performs a decoding operation on the image to be processed to obtain a drawable image after decoding; performs Gaussian blur processing on the drawable image to obtain a target image; The effect service thread determines a region to be processed in the image to be processed, and acquires the corresponding position information of the region to be processed. The region to be processed is a region determined in real time according to the control position, and the control position is the position of a virtual control in an electronic device, and the position of the virtual control will move with the user's operation; The effect service thread crops the target image based on the position information to obtain a Gaussian blur image corresponding to the region to be processed; The main thread overlays the Gaussian blur image on the region to be processed of the image to be processed.
6. An image processing apparatus, characterized in that, The device includes: An image acquisition unit, configured to acquire an image to be processed in response to an image acquisition instruction; A blur processing unit, configured to acquire the attribute information of the image to be processed; according to the attribute information, perform a decoding operation on the image to be processed to obtain a drawable image after decoding; perform Gaussian blur processing on the drawable image to obtain a target image; An information acquisition unit, configured to determine a region to be processed in the image to be processed, and acquire position information corresponding to the region to be processed, where the region to be processed is a region determined in real time according to the position of a control, the position of the control is the position of a virtual control in an electronic device, and the position of the virtual control moves along with the user's operation; A clipping unit, configured to clip the target image based on the position information to obtain a Gaussian blurred image corresponding to the region to be processed; An overlay unit, configured to overlay the Gaussian blurred image on the region to be processed of the image to be processed.
7. An image processing system, characterized in that, The system includes an effect service thread and a main thread; The effect service thread is configured to acquire an image to be processed in response to an image acquisition request sent by the main thread; The effect service thread is configured to acquire attribute information of the image to be processed; perform a decoding operation on the image to be processed according to the attribute information to obtain a drawable image after decoding; Perform Gaussian blur processing on the drawable image to obtain a target image; The effect service thread is configured to determine a region to be processed in the image to be processed, and acquire position information corresponding to the region to be processed, where the region to be processed is a region determined in real time according to the position of a control, the position of the control is the position of a virtual control in an electronic device, and the position of the virtual control moves along with the user's operation; The effect service thread is configured to clip the target image based on the position information to obtain a Gaussian blurred image corresponding to the region to be processed; The main thread is configured to overlay the Gaussian blurred image on the region to be processed of the image to be processed.
8. An electronic device, characterized in that, Comprising one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors to perform the method according to any one of claims 1-4 or claim 5.
9. A computer-readable storage medium, characterized in that, Program code is stored in the computer-readable storage medium, where the method according to any one of claims 1-4 or claim 5 is executed when the program code is run by a processor.
Citation Information
Patent Citations
Display control method, display control device, terminal equipment and electronic equipment
CN111045576A
Data display method and device, computer equipment and storage medium
CN112631698A