Image Processing Method, Related Device and Computer-Readable Storage Medium
By obtaining edge information of the original image and adjusting the cutout image using the erosion algorithm, the problem of edge error after image scaling in the cutout technology is solved, and the accuracy and user experience of the cutout image are improved.
Patent Information
- Application Number
- CN202211642161.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-20
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2042-12-20
AI Technical Summary
The existing keying technology can easily lead to edge errors during image scaling, especially when the background is black, which will affect the user's visual experience.
By acquiring edge information of the original image, the maximum edge intensity is obtained using erosion algorithm and edge detection, and the cutout image is adjusted to solve edge errors.
Improves the accuracy of cutout images, reduces the edge error after image scaling, and improves the user experience.
Smart Images

Figure CN116468745B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular, to an image processing method, related devices, and computer-readable storage media. Background Art
[0002] Existing keying technologies have the problem of blurred edges. For example, human keying has a wide range of applications in fields such as live video. Its purpose is to separate the foreground human figure from the background environment, and on this basis, add specific special effects to achieve better display and entertainment effects. Existing human keying systems are difficult to solve the problem of blurred object edges, resulting in a relatively poor visual experience for users. Summary of the Invention
[0003] Embodiments of this application provide an image processing method, related devices, and computer-readable storage media. By using the edge information of the original image to adjust the keying image, the edge error caused by the keying image generated by the deep learning model after image scaling can be solved.
[0004] In a first aspect, embodiments of this application provide an image processing method, which includes:
[0005] Obtain an original image and the Alpha image corresponding to the original image; wherein, the Alpha image corresponding to the original image has the same size as the original image;
[0006] Perform edge detection on the original image to obtain the edge information corresponding to the original image;
[0007] Obtain the edge intensity of the Alpha image, and use the erosion algorithm and the edge information corresponding to the original image to obtain the maximum edge intensity;
[0008] Adjust the Alpha image according to the maximum edge intensity.
[0009] Implementing the embodiments of this application can use the erosion algorithm and the edge information corresponding to the original image to obtain the maximum edge intensity, and then can adjust the keying image based on the maximum edge intensity. In this way, the edge error caused by the keying image generated by the deep learning model after image scaling can be solved.
[0010] In a possible implementation, the obtaining of the original image includes:
[0011] Obtain a keying video;
[0012] Perform video decoding on the keying video to obtain the video picture frames of the keying video;
[0013] Obtain the original image in the video picture frames at a set time interval or according to the change amount of the picture content of the video picture frames.
[0014] In a possible implementation manner, obtaining the Alpha image corresponding to the original image includes:
[0015] Obtain a trained keying model, where the trained keying model is associated with a model input size;
[0016] Adjust the original image through the model input size to obtain an adjusted original image;
[0017] Process the adjusted original image by using the trained keying model to obtain the Alpha image.
[0018] Since the size of the original image input to the trained keying model is the same as the image size required by the keying model, in this way, the accuracy of extracting the keying image can be guaranteed.
[0019] In a possible implementation manner, the trained keying model is a model trained based on at least one sample image, where each sample image is associated with annotation data, and the annotation data is used to indicate the edge position of the keying object in the sample image. Exemplarily, the above keying model can be implemented by using a neural network.
[0020] In a possible implementation manner, performing edge detection on the original image to obtain edge information corresponding to the original image includes:
[0021] Perform Gaussian blur calculation on the original image to obtain a blurred image;
[0022] Perform edge detection on the blurred image to obtain the edge information.
[0023] In a second aspect, an embodiment of the present application provides an image processing apparatus, including:
[0024] An image acquisition unit, configured to acquire an original image and the Alpha image corresponding to the original image; where the Alpha image corresponding to the original image has the same size as the original image;
[0025] An edge detection unit, configured to perform edge detection on the original image to obtain edge information corresponding to the original image;
[0026] An edge intensity acquisition unit, configured to acquire the edge intensity of the Alpha image, and use an erosion algorithm and the edge information corresponding to the original image to obtain the maximum edge intensity;
[0027] A processing unit for adjusting the Alpha image according to the maximum edge intensity.
[0028] In a possible implementation, the image acquisition unit is specifically configured to:
[0029] Acquire a keying video;
[0030] Perform video decoding on the keying video to obtain video picture frames of the keying video;
[0031] Obtain the original image from the video picture frames at a set time interval or according to the change amount of the picture content of the video picture frames.
[0032] In a possible implementation, the image acquisition unit is specifically configured to:
[0033] Obtain a trained keying model, where the trained keying model is associated with a model input size;
[0034] Adjust the original image according to the model input size to obtain an adjusted original image;
[0035] Process the adjusted original image using the trained keying model to obtain the Alpha image.
[0036] In a possible implementation, the trained keying model is a model trained based on at least one sample image, where each sample image is associated with annotation data, and the annotation data is used to indicate the edge position of the keying object in the sample image.
[0037] In a possible implementation, the edge detection unit is specifically configured to:
[0038] Perform Gaussian blur calculation on the original image to obtain a blurred image;
[0039] Perform edge detection on the blurred image to obtain the edge information.
[0040] In a third aspect, an embodiment of the present application provides an electronic device, including a processor and a memory, the processor and the memory are connected to each other, where the memory is used to store a computer program that supports the electronic device to execute the above method, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method of the first aspect above.
[0041] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, the computer-readable storage medium stores a computer program, the computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to execute the method of the first aspect above.
[0042] In a fifth aspect, an embodiment of the present application further provides a computer program, which includes program instructions that, when executed by a processor, cause the processor to execute the method of the first aspect above.
[0043] The embodiments of the present application bring the following beneficial effects:
[0044] In the existing matting technology, the neural network algorithm will first scale the original input image to the input size of the neural network model, obtain the Alpha prediction result of the matted image based on the neural network model, and then scale the prediction result of the matted image to the size of the original image. Such a scaling process will cause errors on the edges. If the background is black, obvious white edges will appear. This implementation method is likely to bring a bad visual experience to users. The image processing method proposed in the present application can use the erosion algorithm and the edge information corresponding to the original image to obtain the maximum edge intensity, and then can adjust the matted image based on the maximum edge intensity. In this way, the edge error caused by the matted image generated by the deep learning model after image scaling can be solved, and the accuracy can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] To more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments.
[0046] Figure 1a is a schematic diagram of the process of an image processing provided by an embodiment of the present application;
[0047] Figure 1b is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application;
[0048] Figure 2 is a flowchart of a method for training a keying model provided by an embodiment of the present application;
[0049] Figure 3a is a schematic diagram of the process of an image processing method provided by an embodiment of the present application;
[0050] Figure 3b Another schematic diagram of the process of an image processing provided by an embodiment of the present application;
[0051] Figure 4 is a schematic diagram of the structure of an image processing device provided by an embodiment of the present application;
[0052] Figure 5 is a schematic diagram of the structure of another electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0053] Next, the technical solutions in the embodiments of the present application will be described with reference to the accompanying drawings in the embodiments of the present application.
[0054] The terms "first", "second", "third", "fourth", etc. in the specification and claims of the present application and the accompanying drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, products, or devices.
[0055] Referring to "embodiments" herein means that a particular feature, structure, or characteristic described in connection with the embodiments can be included in at least one embodiment of the present application. The phrase appears in various places in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.
[0056] The terms "component", "module", "system", etc. used in this specification are used to represent computer-related entities, hardware, firmware, combinations of hardware and software, software, or software in execution. For example, a component can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, an execution thread, a program, and / or a computer. By way of illustration, an application running on a computing device and the computing device can both be components. One or more components can reside in a process and / or an execution thread, and the components can be located on one computer and / or distributed between two or more computers. In addition, these components can execute from various computer-readable media on which various data structures are stored. Components can communicate, for example, according to signals having one or more data packets (such as data from two components interacting with each other from a local system, a distributed system, and / or a network, such as the Internet interacting with other systems through signals) through local and / or remote processes.
[0057] Overview of the application
[0058] Video keying processing is an operation to separate the foreground and background in a video image, which belongs to the inverse process of image synthesis. With the development of keying technology, the requirements for the speed and accuracy of keying are getting higher and higher, and the requirements are also getting more and more detailed. Because artificial intelligence technology can use a digital computer or a machine controlled by a digital computer to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to obtain results, it is widely used in the field of keying technology. As an important branch of artificial intelligence, the neural network (Neural Network, NN) is a network structure that mimics the behavioral characteristics of animal neural networks for information processing. The structure of a neural network is composed of a large number of nodes (or neurons) connected to each other. Based on a specific operation model, it processes information by learning and training the input information. A neural network includes an input layer, a hidden layer, and an output layer. The input layer is responsible for receiving input signals, the output layer is responsible for outputting the calculation results of the neural network, and the hidden layer is responsible for calculation processes such as learning and training. It is the memory unit of the network. The memory function of the hidden layer is characterized by a weight matrix. Usually, each neuron corresponds to a weight coefficient. However, the applicant found that in the existing keying technology, the neural network algorithm will first scale the original input image to the input size of the neural network model, obtain the Alpha prediction result of the keying image based on the neural network model, and then scale the prediction result of the keying image to the size of the original image. Such a scaling process will cause errors on the edges. If the background is black, obvious white edges will appear (as Figure 1a shown). This implementation method is likely to bring a bad visual experience to users.
[0059] Based on this, the present application proposes an image processing method, related devices, and a computer-readable storage medium. This method can use the erosion algorithm and the edge information corresponding to the original image to obtain the maximum edge intensity, and then can adjust the keying image based on the maximum edge intensity. In this way, the edge error caused by the keying image generated by the deep learning model after image scaling can be solved.
[0060] First, refer to Figure 1b to describe the exemplary electronic device 100 for implementing the keying model training method and device or the image processing method and device according to the embodiments of the present application. As Figure 1b shown, the electronic device 100 includes one or more processors 102, one or more storage devices 104, an input device 106, and an output device 108. The electronic device 100 may also include a data acquisition device 110 and / or an image acquisition device 112. These components are interconnected through a bus system 114 and / or other forms of connection mechanisms (not shown). It should be noted that Figure 1a the components and structure of the electronic device 100 shown are only exemplary, not restrictive. According to needs, the electronic device may also have other components and structures.
[0061] The processor 102 may be a central processing unit (CPU) or other forms of processing units with data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 100 to perform desired functions.
[0062] The storage device 104 may include one or more computer program products, and the computer program products may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory, etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage media, and the processor 102 may run the program instructions to implement the client functions (implemented by the processor) in the embodiments of the present application described below and / or other desired functions. Various application programs and various data may also be stored in the computer-readable storage media, such as various data used and / or generated by the application programs, etc.
[0063] The input device 106 may be a device used by a user to input instructions, and may include one or more of a keyboard, a mouse, a microphone, a touch screen, etc.
[0064] The output device 108 may output various information (such as images and / or sounds) to the outside (such as a user), and may include one or more of a display, a speaker, etc.
[0065] When the electronic device 100 is used to implement the matte model training method and apparatus and the image processing method and apparatus according to the embodiments of the present application, the electronic device 100 may include a data acquisition device 110. The data acquisition device 110 may acquire sample images (including video frames) and corresponding annotation data, and store the acquired sample images and annotation data in the storage device 104 for use by other components. For example, the data acquisition device 110 may include one or more of a wired or wireless network interface, a universal serial bus (USB) interface, an optical disc drive, etc.
[0066] When the electronic device 100 is used to implement the image processing method and apparatus according to the embodiments of the present application, the electronic device 100 may include an image acquisition device 112. The image acquisition device 112 may acquire images (including video frames), and store the acquired images in the storage device 104 for use by other components. The image acquisition device 112 may be a camera. It should be understood that the image acquisition device 112 is only an example, and the electronic device 100 may not include the image acquisition device 112. In this case, other devices with image acquisition capabilities may be used to acquire the image to be processed and send the acquired image to the electronic device 100.
[0067] Exemplarily, the exemplary electronic device for implementing the matte model training method and apparatus and the image processing method and apparatus according to the embodiments of the present application may be implemented on devices such as personal computers or remote servers.
[0068] The following will introduce Figure 2 in detail the matte model training method proposed by the present application, as Figure 2 shown, the method may include but is not limited to the following steps:
[0069] In step S201, obtain a sample image and corresponding annotation data, where the annotation data is used to indicate the edge position of the matte object in the sample image.
[0070] The matte object may be any object, such as a person, a car, a building, etc. In the following description, the human-shaped matte will be used as an example to describe the present application. However, this is not a limitation of the present application, and the present application may be applicable to matte applications of other objects.
[0071] The sample image may be the original image acquired by the electronic device 100, or the image obtained after preprocessing the original image. Image matting generally includes predicting the position of the matte object and its category. The annotation data (ground truth) may be manually annotated. For example, the annotation data may indicate the category of each pixel in the sample image, and pixels belonging to different objects may be represented by different colors for distinction.
[0072] The sample image and the annotation data may be sent from a remote device (such as a server storing a training data set) to the electronic device 100 for the processor 102 of the electronic device 100 to train the matte model, or may be acquired by the data acquisition device 110 included in the electronic device 100 and transmitted to the processor 102 for matte model training.
[0073] In step S202, use the loss function, the sample image, and the corresponding annotation data to train the matte model to obtain a trained matte model.
[0074] During the training of the matting model based on the loss function, the backpropagation algorithm can be used to adjust the parameters (or weights) adopted in the matting model until the training converges, so as to obtain a trained matting model. Exemplarily, the matting model training method according to the embodiments of the present application can be implemented in a device, apparatus or system having a memory and a processor. The matting model training method according to the embodiments of the present application can be independently deployed at the client or the server. Alternatively, the matting model training method according to the embodiments of the present application can also be distributively deployed at the server side (or cloud) and the client side. For example, sample images and annotation data can be obtained at the client, and the obtained images are transmitted by the client to the server side (or cloud), and the matting model is trained by the server side (or cloud).
[0075] According to the embodiments of the present application, the matting model can be implemented using a neural network. Of course, the present application is not limited to neural networks, and any model based on parameter learning can be applied to the present application. A neural network is a network that can learn autonomously and has powerful image processing capabilities, which is a very good model choice.
[0076] The matting model training method provided by the embodiments of the present application mainly takes effect during the training process and does not affect the deployment and use of the matting model.
[0077] According to another aspect of the present application, an image processing method is provided. Figure 3a The schematic flowchart showing the image processing method according to an embodiment of the present application may include but is not limited to the following steps:
[0078] Step S301, obtain an original image and an Alpha image corresponding to the original image; wherein, the Alpha image corresponding to the original image has the same size as the original image.
[0079] The original image can be any suitable image that needs to be matted. The original image can be an image collected by an image acquisition device, or an image obtained after preprocessing the original image. The original image can be a static image or a video picture frame in a video stream.
[0080] The original image can be sent by a client device (such as a mobile terminal including a camera) to the electronic device 100 for image matting by the processor 102 of the electronic device 100, or can be collected by the image acquisition device 112 included in the electronic device 100 and transmitted to the processor 102 for image matting.
[0081] In step S301, the electronic device 100 can use a video conversion tool such as ffmpeg to convert the keying video that needs to perform video keying actions into video frames. Each video frame can correspond to a video picture frame with picture pixels. According to a set time interval, obtain the original image from the video picture frames; or, obtain the original image from the video picture frames according to the change amount of the picture content of the video picture frames.
[0082] In step S301, obtain the trained keying model. Among them, the trained keying model manages the model input size; adjust the original image according to the model input size to obtain the adjusted original image, and use the keying model trained by the above keying model training method to perform keying processing on the adjusted original image to obtain the Alpha image.
[0083] As mentioned above, the keying model trained by the above keying model training method can well predict the object edge. Therefore, using such a keying model for image keying can well improve the edge blur phenomenon and greatly enhance the user experience. This image processing method can be well applied to keying applications in fields such as live video.
[0084] Step S302: Perform edge detection on the original image to obtain the edge information corresponding to the original image.
[0085] Exemplarily, Gaussian blur calculation can be performed through a Gaussian filter. Among them, the size of the Gaussian filter is 3*3, and the coordinates of the center point are (0,0). Its calculation formula can be expressed as:
[0086]
[0087] After Gaussian blur calculation, a blurred image can be obtained. After that, perform edge detection on the blurred image to obtain the edge information. For the specific implementation of edge detection on the blurred image, please refer to the prior art and will not be elaborated here.
[0088] Step S303: Obtain the edge intensity of the Alpha image, and use the erosion algorithm and the edge information corresponding to the original image to obtain the maximum edge intensity.
[0089] Exemplarily, the erosion algorithm can be described as:
[0090] dst(x,y)=min(x′,y′):element(x′,y′)≠0src(x+x′,y+y′)
[0091] Among them,
[0092] In the process of using the erosion algorithm and the edge information corresponding to the original image, within the set number of iterations, the maximum edge strength (which can also be referred to as the maximum number of edges) can be calculated for the inner contraction at which time, and the position information of the inner contraction is recorded, so that the maximum edge strength can be determined based on the position information of the inner contraction.
[0093] Step S304. Adjust the Alpha image according to the maximum edge strength.
[0094] Exemplarily, adjust the edge strength of the Alpha image to the maximum edge strength. Exemplarily, the adjustment result can be as Figure 3b shown.
[0095] It can be understood that the image processing method proposed in this application can use the erosion algorithm and the edge information corresponding to the original image to obtain the maximum edge strength, and then the matte image can be adjusted based on the maximum edge strength. In this way, the edge error caused by the matte image generated by the deep learning model after image scaling can be solved, and the accuracy can be improved.
[0096] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that this disclosure is not limited by the described order of actions, because according to this disclosure, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this disclosure.
[0097] Furthermore, it should be noted that although Figure 3a the steps in the flowchart of Figure 3a are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover,
[0098] at least a part of the steps in Figure 1a - Figure 3a may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or sub-steps or stages of other steps.
[0098] The above has described in detail the image processing method of the embodiments of the present application. In order to facilitate better implementation of the above solutions of the embodiments of the present application, correspondingly, related devices and equipment for cooperating with the implementation of the above solutions are also provided below.
[0099] See Figure 4, which is a schematic structural diagram of an image processing device 40 provided by an embodiment of the present application, may include:
[0100] An image acquisition unit 400, configured to acquire an original image and an Alpha image corresponding to the original image; wherein, the Alpha image corresponding to the original image has the same size as the original image;
[0101] An edge detection unit 402, configured to perform edge detection on the original image to obtain edge information corresponding to the original image;
[0102] An edge intensity acquisition unit 404, configured to acquire the edge intensity of the Alpha image, and use an erosion algorithm and the edge information corresponding to the original image to obtain the maximum edge intensity;
[0103] A processing unit 406, configured to adjust the Alpha image according to the maximum edge intensity.
[0104] In a possible implementation manner, the image acquisition unit 400 is specifically configured to:
[0105] Acquire a keying video;
[0106] Perform video decoding on the keying video to obtain video picture frames of the keying video;
[0107] Acquire the original image in the video picture frames at a set time interval or according to the change amount of the picture content of the video picture frames.
[0108] In a possible implementation manner, the image acquisition unit 400 is specifically configured to:
[0109] Acquire a trained keying model, wherein the trained keying model is associated with a model input size;
[0110] Adjust the original image through the model input size to obtain an adjusted original image;
[0111] Process the adjusted original image by using the trained keying model to obtain the Alpha image.
[0112] In a possible implementation manner, the trained keying model is a model trained based on at least one sample image, wherein each sample image is associated with annotation data, and the annotation data is used to indicate the edge position of the keying object in the sample image.
[0113] In a possible implementation manner, the edge detection unit 402 is specifically configured to:
[0114] Perform Gaussian blur calculation on the original image to obtain a blurred image;
[0115] Perform edge detection on the blurred image to obtain the edge information.
[0116] It should be noted that each device in the above system may further include other units. For the specific implementation of each device and unit, reference may be made to the relevant descriptions in the above method embodiments, which will not be elaborated here.
[0117] To facilitate better implementation of the above solutions of the embodiments of the present application, the present application also correspondingly provides an electronic device 50, which will be described in detail below with reference to the accompanying drawings:
[0118] As Figure 5 The structural schematic diagram of the electronic device provided by the embodiment of the present application is shown. The electronic device 500 may include a processor 501, a memory 504, and a communication module 505. The processor 501, the memory 504, and the communication module 505 may be interconnected through a bus 506. The memory 504 may be a high-speed random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory 504 may further be at least one storage system located far from the aforementioned processor 501. The memory 504 is used to store application program codes, which may include an operating system, a network communication module, a user interface module, and a data processing program. The communication module 505 is used for information interaction with external devices; the processor 501 is configured to call the program code to execute the following steps:
[0119] Obtain an original image and the Alpha image corresponding to the original image; wherein, the Alpha image corresponding to the original image has the same size as the original image;
[0120] Perform edge detection on the original image to obtain the edge information corresponding to the original image;
[0121] Obtain the edge intensity of the Alpha image, and use the erosion algorithm and the edge information corresponding to the original image to obtain the maximum edge intensity;
[0122] Adjust the Alpha image according to the maximum edge intensity.
[0123] Among them, the processor 501 obtains the original image, including:
[0124] Obtain a keying video;
[0125] Perform video decoding on the keying video to obtain the video picture frames of the keying video;
[0126] Obtain the original image in the video picture frame according to a set time interval or according to the change amount of the picture content of the video picture frame.
[0127] Among them, the processor 501 obtains the Alpha image corresponding to the original image, including:
[0128] Obtain a trained matte extraction model, where the trained matte extraction model is associated with a model input size;
[0129] Adjust the original image through the model input size to obtain an adjusted original image;
[0130] Process the adjusted original image by using the trained matte extraction model to obtain the Alpha image.
[0131] Among them, the trained matte extraction model is a model trained based on at least one sample image, and each sample image is associated with annotation data, and the annotation data is used to indicate the edge position of the matte extraction object in the sample image.
[0132] Among them, the processor 501 performs edge detection on the original image to obtain the edge information corresponding to the original image, including:
[0133] Perform Gaussian blur calculation on the original image to obtain a blurred image;
[0134] Perform edge detection on the blurred image to obtain the edge information.
[0135] The embodiment of the present application also provides a computer storage medium. Instructions are stored in the computer-readable storage medium. When it runs on a computer or a processor, it causes the computer or the processor to execute one or more steps in the method described in any one of the above embodiments. If each component module of the above device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in the computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product, and the computer product is stored in the computer-readable storage medium.
[0136] The above computer-readable storage medium may be an internal storage unit of the device described in the foregoing embodiments, such as a hard disk or memory. The above computer-readable storage medium may also be an external storage device of the above device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. Further, the above computer-readable storage medium may also include both the internal storage unit and the external storage device of the above device. The above computer-readable storage medium is used to store the above computer program and other programs and data required by the above device. The above computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0137] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The program of this computer can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. The foregoing storage medium includes: various media such as ROM, RAM, magnetic disk, or optical disc that can store program codes.
[0138] The steps in the method of the embodiments of this application can be adjusted, combined, and deleted according to actual needs.
[0139] The modules in the device of the embodiments of this application can be combined, divided, and deleted according to actual needs.
[0140] It can be understood that those of ordinary skill in the art can realize that, combining the units and algorithm steps of the examples described in the embodiments disclosed in each embodiment of this application, can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered to exceed the scope of this application.
[0141] Those skilled in the art can appreciate that the functions described in connection with the various illustrative logical blocks, modules, and algorithmic steps disclosed in the embodiments of the present application can be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions described in the various illustrative logical blocks, modules, and steps can be stored or transmitted as one or more instructions or codes on a computer-readable medium and executed by a hardware-based processing unit. The computer-readable medium can include a computer-readable storage medium corresponding to a tangible medium, such as a data storage medium, or a communication medium including any medium that facilitates the transfer of a computer program from one place to another (e.g., according to a communication protocol). In this way, the computer-readable medium generally can correspond to (1) a non-transitory tangible computer-readable storage medium, or (2) a communication medium, such as a signal or a carrier wave. The data storage medium can be any available medium that can be accessed by one or more computers or one or more processors to retrieve instructions, codes, and / or data structures for implementing the techniques described in the present application. A computer program product can include a computer-readable medium.
[0142] Those skilled in the art can clearly understand that for the sake of convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.
[0143] In several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical functional division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the couplings, direct couplings, or communication connections shown or discussed among each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.
[0144] The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0145] In addition, the functional units in the various embodiments of the present application can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit.
[0146] When the above-mentioned functions are implemented in the form of 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 part of this 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 for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks, or optical discs.
[0147] As described above, the above are only specific implementation manners of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art within the technical scope disclosed by this application can easily think of changes or substitutions, which should all be covered within the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.
Claims
1. An image processing method, characterized in that, including: obtaining an original image and an Alpha image corresponding to the original image; wherein, the Alpha image corresponding to the original image has the same size as the original image; performing edge detection on the original image to obtain edge information corresponding to the original image; obtaining the edge intensity of the Alpha image, and obtaining the maximum edge intensity by using an erosion algorithm and the edge information corresponding to the original image; adjusting the Alpha image according to the maximum edge intensity.
2. The method according to claim 1, characterized in that The obtaining of the original image includes: obtaining a keying video; performing video decoding on the keying video to obtain video picture frames of the keying video; obtaining the original image from the video picture frames at a set time interval or according to the change amount of the picture content of the video picture frames.
3. The method according to claim 1, wherein The obtaining of the Alpha image corresponding to the original image includes: obtaining a trained keying model, wherein the trained keying model is associated with a model input size; adjusting the original image through the model input size to obtain an adjusted original image; processing the adjusted original image by using the trained keying model to obtain the Alpha image.
4. The method according to claim 3, characterized in that The trained keying model is a model trained based on at least one sample image, wherein each sample image is associated with annotation data, and the annotation data is used to indicate the edge position of the keying object in the sample image.
5. The method according to claim 1, wherein The performing of edge detection on the original image to obtain edge information corresponding to the original image includes: performing Gaussian blur calculation on the original image to obtain a blurred image; performing edge detection on the blurred image to obtain the edge information.
6. An image processing apparatus, characterized in that, including: an image acquisition unit, configured to obtain an original image and an Alpha image corresponding to the original image; wherein, the Alpha image corresponding to the original image has the same size as the original image; an edge detection unit, configured to perform edge detection on the original image to obtain edge information corresponding to the original image; an edge intensity acquisition unit, configured to obtain the edge intensity of the Alpha image, and obtain the maximum edge intensity by using an erosion algorithm and the edge information corresponding to the original image; a processing unit, configured to adjust the Alpha image according to the maximum edge intensity.
7. The device according to claim 6, characterized in that, The image acquisition unit is specifically configured to: obtain a keying video; perform video decoding on the keying video to obtain video picture frames of the keying video; obtain the original image from the video picture frames at a set time interval or according to the change amount of the picture content of the video picture frames.
8. The device according to claim 6, characterized in that, The image acquisition unit is specifically configured to: obtain a trained keying model, wherein the trained keying model is associated with a model input size; adjust the original image through the model input size to obtain an adjusted original image; process the adjusted original image by using the trained keying model to obtain the Alpha image.
9. An electronic device, characterized in that, including: A memory and a processor, the memory is used to store and support a program for the processor to execute the method according to any one of claims 1 to 5, and the processor is configured to execute the program stored in the memory.
10. A computer-readable medium having non-volatile program code executable by a processor, characterized in that, The program code causes the processor to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Object contour extraction method based on mask-RCNN
CN108898610A
Image processing method, electronic equipment and storage medium
CN112990331A