Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. However, it will be appreciated by those of ordinary skill in the art that numerous technical details are set forth in order to provide a better understanding of the present application in various embodiments of the present invention. However, the technical solution claimed in the present application can be implemented without these technical details and various changes and modifications based on the following embodiments.
An embodiment of the present invention relates to a depth image restoration method, and as shown in fig. 1, the depth image restoration method provided in this embodiment includes the following steps.
Step 101: and obtaining a depth image containing the hole pixel points.
Specifically, the hole pixel points in this embodiment may be pixel points corresponding to holes in the original depth image determined based on a disparity map or the like, or may be hole pixel points in the depth image obtained by performing certain processing (such as noise reduction) on the original depth image. In this embodiment, the source of the depth image including the void pixel is not limited, and the pixel value of the void pixel may be set to 0 in order to describe the void pixel in the depth image.
Aiming at the acquired depth image containing the hole pixel points, the following preferential filling operation is carried out on the hole pixel points which are not filled in the depth image (steps 102-103).
Step 102: aiming at unfilled hole pixel points, determining a neighborhood by taking each hole pixel point as a center, and determining the filling priority of each hole pixel point according to the number and the pixel value of non-hole pixel points contained in the neighborhood; the higher the filling priority is, the better the image restoration effect after the corresponding hole pixel point is filled.
Specifically, the depth values in the depth image have area continuity, and the depth values in the same area do not change much, so the filling priority of the hole pixel point is necessarily related to the pixel value of the pixel point in the local area. Therefore, for unfilled hole pixels, a neighborhood can be determined in the region corresponding to 8 adjacent pixels by using each hole pixel as a center. And determining the filling priority of the hollow pixel point at the central position according to the number and the pixel value of the non-hollow pixel points (pixel points with the pixel value not being 0) contained in the neighborhood. The higher the filling priority is, the better the restoration effect of the depth image after the hole pixel point representing the central position is filled.
Wherein, to the understanding that the repair effect is good, after the hole pixel is filled, the degree of fusion of the filled hole pixel and other pixels in the neighborhood is higher, the overall pixel smoothness of the region is better, and the holes are less. And if the restoration effect is good, the image effect shown by the existing pixel points in the neighborhood before the hole pixel points are required to be restored, namely, the hole pixel points are filled is relatively good. The good effect is also expressed in that the fusion degree between the pixel points contained in the neighborhood is higher, the pixel smoothness of the whole area is better, and the holes are fewer. And the quality of the effects can be quantitatively evaluated through the number and the pixel value of the non-hole pixel points contained in the neighborhood. For example, the smaller the number of non-hole pixels, the smaller the overall variation range of the pixel values, the better the image effect is, and vice versa.
Based on this, in this embodiment, according to the number and the pixel value of the non-void pixel points included in the neighborhood, the quality of the image restoration effect after the void pixel points are filled is quantified, so that the filling priority of each void pixel point is determined. The higher the filling priority is, the better the image restoration effect after the corresponding hole pixel point is filled.
Step 103: and filling the specified number of hole pixel points with the highest filling priority.
Specifically, after the filling priority of each void pixel point is determined, filling can be performed on the specified number of void pixel points with the highest filling priority according to the principle that filling is preferentially performed when the filling priority is higher. When filling is performed for each hole pixel point, the filled pixel value may be a pixel average value of all non-hole pixel points in a neighborhood corresponding to the hole pixel point.
In an example, when filling is performed on a specified number of hole pixel points with the highest filling priority, filling may be performed on one hole pixel point with the highest filling priority among the hole pixel points.
Step 104: judging whether the depth image contains unfilled hole pixel points; if yes, jumping back to step 102, and continuing to execute the priority filling operation; if not, step 105 is performed.
After the one-time preferential filling operation is completed, unfilled void pixel points in the depth image are reduced, at this time, whether the depth image still contains unfilled void pixel points is judged, if yes, the step 102 needs to be skipped back, the preferential filling operation is continuously executed, and the process is circulated until the depth image does not contain unfilled void pixel points.
Step 105: and taking the depth image obtained after the preferential filling operation as the repaired depth image.
Specifically, when the depth image does not include unfilled hole pixel points, that is, no hole exists in the depth image, the depth image at this time can be used as a repaired depth image.
In addition, in order to further improve the repairing effect of the depth image, after step 104, if it is determined that the depth image does not include unfilled hole pixel points, the depth image obtained after the present preferential filling operation may be smoothed by using bilateral filtering, so as to obtain a final repaired depth image.
In particular, some frizz may appear in the depth image obtained after the filling of the cavity. Bilateral filtering is nonlinear filtering, and consists of two kernel functions, so that not only is the correlation in a spatial domain referred, but also the similarity of pixel values is referred. The bilateral filtering is adopted to carry out smoothing processing on the depth image, and the image edge information in the image information can be considered while filtering, so that the image edge is smoother.
Compared with the related art, in the embodiment, after the depth image containing the hole pixel points is obtained, the following preferential filling operation is performed on the hole pixel points which are not filled in the depth image: aiming at unfilled hole pixel points, determining a neighborhood by taking each hole pixel point as a center, and determining the filling priority of each hole pixel point according to the number and the pixel value of non-hole pixel points contained in the neighborhood; the higher the filling priority is, the better the image restoration effect after the corresponding hole pixel point is filled is; filling the specified number of hole pixel points with the highest filling priority; after the first preferential filling operation is executed, judging whether the depth image contains unfilled hole pixel points; if yes, continuing to execute the prior filling operation on unfilled hole pixel points; and if not, taking the depth image obtained after the priority filling operation as the repaired depth image. According to the scheme, the filling priority is set for the cavity points in the depth image, so that the higher part of the cavity pixel points with the filling priority can be filled preferentially each time, the filling priority of the unfilled cavity pixel points is updated after filling at each time, and the filling is continued preferentially until all the cavity pixel points are filled.
Another embodiment of the present invention relates to a depth image restoration method, as shown in fig. 2, which is an improvement of the method steps shown in fig. 1, and the improvement is to refine the process of obtaining a depth image containing hole pixel points. As shown in fig. 2, the above step 101 includes the following sub-steps.
Substep 1011: and obtaining a depth image containing the original hole pixel points.
Specifically, the original hole pixel points in this embodiment may be pixel points corresponding to holes in the original depth image determined based on a disparity map or the like, or may be hole pixel points in the depth image obtained by performing certain processing (such as noise reduction) on the original depth image. In this embodiment, the source of the depth image including the original hole pixel point is not limited, and the pixel value of the original hole pixel point may be 0 in order to describe the original hole pixel point in the depth image.
In one example, this step may be implemented as follows.
Step 1: an original depth image is acquired.
Specifically, the original depth image may be an original depth image determined based on a disparity map or the like.
Step 2: and dividing the original depth image into a plurality of regions according to the pixel value difference value of each pixel point and the adjacent pixel point in the original depth image.
Specifically, when the depth camera shoots a depth image, due to the reason of the depth camera and the influence of the surrounding environment, the collected depth information often contains a large amount of holes and noises, and if the holes and the noises are directly applied without being processed, the precision of subsequent work is directly influenced, and even failure is caused. Therefore, the depth image needs to be denoised before the hole repairing.
In this embodiment, a method of detecting a connected region is used to implement denoising processing. Firstly, setting a connected region detection threshold value; traversing each pixel point in the original depth image, and determining pixel difference values between all pixel points in a neighborhood formed by the current pixel point and 8 pixel points; and counting all pixel points with pixel difference values smaller than the detection threshold of the connected region in the same region until the original depth image is traversed and cut off. Finally, the original depth image is divided into several regions.
And step 3: and determining each pixel point in the region, in which the number of the included pixel points is less than the preset region pixel point threshold value, as an original hole pixel point.
Specifically, a region area size threshold is set, the number of pixels included in each region in the original depth image is compared with the region area size threshold, and the pixel values of the pixels in the regions smaller than the region area size threshold are assigned to 0, that is, the pixels are set as original hole pixels.
Substep 1012: and performing opening and closing operation on the depth image containing the original hole pixel points by adopting the circular structural elements to eliminate partial original hole pixel points to obtain the depth image containing the hole pixel points.
The morphological filtering is an image processing method which takes several basic operations in morphology as a core algorithm, and has better effect to a certain extent compared with the conventional linear filtering. The morphological filtering removes different types of noise signals contained in the target object using different structural elements. Most of the morphological processing is a binarized image and a grayscale image. The object processed in the binary operation is a set element, and the object processed in the grayscale image is an image function. The principle of processing depth images using morphology is similar to processing grayscale images.
The morphological filtering mainly includes dilation and erosion. The main effect of the expansion is to expand the edges of the target object, allowing an increased range of the object, so that isolated parts in contact with the object can be incorporated into the object itself. The erosion acts opposite to the expansion, which is mainly to shrink the edge of the target object inwards. The opening operation is to perform corrosion operation and then expansion operation, mainly remove single small points, burrs and small bridges in the image and smoothen the edge of the object. The closed operation is to perform expansion operation and then corrosion operation, mainly to fill the tiny holes existing in the target object, and to repair tiny cracks and smooth the edge of the object.
Specifically, in this embodiment, the round structural element is adopted to perform morphological processing of opening and closing operations on the denoised original depth image, so as to eliminate isolated and burred points in the depth image and repair a fine cavity region.
Compared with the related art, the depth image containing the original hole pixel points is obtained; and performing opening and closing operation on the depth image containing the original hole pixel points by adopting the circular structural elements to eliminate partial original hole pixel points to obtain the depth image containing the hole pixel points. By carrying out opening and closing operation morphological processing on the denoised depth image, isolated and burred points in the original depth image can be eliminated, and a fine cavity area can be repaired, so that the depth image after optimized processing is obtained, and the effect of the depth image after subsequent cavity filling is improved.
Another embodiment of the present invention relates to a depth image restoration method, as shown in fig. 3, which is an improvement of the method steps shown in fig. 1, and the improvement is to refine the determination process of the filling priority of each hole pixel point. As shown in fig. 3, the step 102 includes the following sub-steps.
Substep 1021: and aiming at unfilled hole pixel points, determining a neighborhood by taking each hole pixel point as a center respectively, and preferentially determining that the filling priority of the hole pixel points with less number of non-hole pixel points contained in the neighborhood is higher.
Specifically, as shown in fig. 4, there are 5 neighborhood images centered around a hole pixel (pixel value is 0). Aiming at the void pixel points positioned in the center position in the neighborhood images, the filling priority of the void pixel points with less number of non-void pixel points contained in the neighborhood can be preferentially determined to be higher. For example, in fig. 4, the number of non-hole pixels included in the neighborhoods (a) to (e) is 0, 2, 4, and 8 in order, and the filling priorities of the hole pixels corresponding to the center position in the drawing are (a), (b) > (c) > (d) > (e).
Substep 1022: and when the filling priorities of the void pixel points obtained based on the number of the non-void pixel points contained in the neighborhood are the same, determining that the filling priority of the void pixel points with smaller standard difference of the pixel values of the non-void pixel points contained in the neighborhood is higher.
Specifically, as shown in fig. 4, there are 5 neighborhood images centered around a hole pixel (pixel value is 0). For the void pixel points located in the center of the neighborhood images, when the filling priorities of the void pixel points obtained based on the number of the non-void pixel points included in the neighborhood are the same, for example, the filling priorities of (a) and (b) are the same, it can be continuously determined that the filling priority of the void pixel points included in the neighborhood and having a smaller standard deviation of the pixel values of the non-void pixel points is higher. For example, it can be known through calculation that the standard deviation of the pixel value of each pixel point in the field in (a) is smaller than the standard deviation of the pixel value of each pixel point in the field in (b), so that the filling priority ranking of the void pixel point at the center position in the corresponding graph can be determined to be (a) > (b), and the finally obtained filling priority ranking of the void pixel point at the center position in each corresponding graph is (a) > (b) > (c) > (d) > (e).
Compared with the related technology, the filling priority of the void pixel points with less number of non-void pixel points contained in the neighborhood is determined to be higher by priority; when the filling priorities of the void pixel points obtained based on the number of the non-void pixel points contained in the neighborhood are the same, the filling priority of the void pixel point with the smaller standard difference of the pixel values of the non-void pixel points contained in the neighborhood is determined to be higher, and therefore an implementation mode for determining the filling priority of each void pixel point is provided.
Another embodiment of the present invention relates to a depth image restoration method, as shown in fig. 5, which is an improvement of the method steps shown in fig. 1, and the improvement is that the determination process of the filling priority of each hole pixel point is refined. As shown in fig. 5, the step 102 includes the following sub-steps.
Substep 1023: aiming at unfilled hole pixel points, determining a neighborhood by taking each hole pixel point as a center, and determining a first filling priority of the hole pixel points based on the number of non-hole pixel points contained in the neighborhood; wherein, the smaller the number, the higher the corresponding padding priority.
The process executed in this step can refer to sub-step 1021, which is not described herein.
Substep 1024: aiming at unfilled hole pixel points, determining a neighborhood by taking each hole pixel point as a center, and determining a second filling priority of the hole pixel points based on the pixel value standard difference of non-hole pixel points contained in the neighborhood; wherein, the smaller the standard deviation of the pixel value, the higher the corresponding filling priority.
Specifically, as shown in fig. 4, there are 5 neighborhood images centered around a hole pixel (pixel value is 0). And respectively calculating the standard deviation of the pixel values of the non-hole pixel points contained in the neighborhood aiming at the hole pixel points positioned at the central position in the neighborhood images. For example, in fig. 4, the standard deviations of the pixel values of the non-hole pixels included in the neighborhoods (a) to (e) are 1.05, 41.14, 41.19, 0.5, and 0 in this order, and the second filling priorities of the hole pixels corresponding to the center positions in the drawing are (d) > (a), (b) > (c) > (e). The second shim priority for (e) is at a minimum by default in any case.
Sub-step 1025: and taking the average priority of the first filling priority and the second filling priority as the filling priority of the final hole pixel point.
For example, in fig. 4, the filling priority ranking of the void pixel point corresponding to the center position in the final map may be (a), (b) > (d) > (c) > (e). When the average priority is actually calculated, weights can be set for the first padding priority and the second padding priority respectively, and the weighted average priority is determined as the final padding priority.
Compared with the related art, the embodiment determines the first filling priority of the void pixel points based on the number of the non-void pixel points contained in the neighborhood; wherein, the smaller the number, the higher the corresponding filling priority; determining a second filling priority of the void pixel points based on the pixel value standard deviation of the non-void pixel points contained in the neighborhood; the smaller the standard deviation of the pixel value is, the higher the corresponding filling priority is; and taking the average priority of the first filling priority and the second filling priority as the filling priority of the final hole pixel point, thereby providing an implementation mode for determining the filling priority of each hole pixel point.
Another embodiment of the present invention relates to a depth image restoration method, as shown in fig. 6, which is an improvement of the method steps shown in fig. 1, and the improvement is to refine the determination process of the filling priority of each hole pixel point. As shown in fig. 6, the step 102 includes the following sub-steps.
Substep 1026: the filling priority of each hollow pixel point is calculated by adopting the following formula:
wherein the content of the first and second substances,
R(s)the fill-in priority for the void pixel points,
sthe light-emitting diode is a hollow pixel point,
n v (s)the number of non-void pixels in the neighborhood is determined by centering on the void pixel,
is the standard deviation of the pixel values of the non-hole pixel points in the neighborhood,
is a constant factor.
Can make it possible to
Normalized to [0,1 ]]In the meantime.
Specifically, the filling priority ranking of the void pixel point at the center position in each corresponding graph in fig. 4 determined by the formula (1) is (a) > (b) > (c) > (d) > (e).
Compared with the related art, the embodiment determines the final filling priority of the void pixel points through the formula (1), thereby providing an implementation mode for determining the filling priority of each void pixel point.
Another embodiment of the invention relates to an electronic device, as shown in FIG. 7, comprising at least one processor 202; and a memory 201 communicatively coupled to the at least one processor 202; wherein the memory 201 stores instructions executable by the at least one processor 202, the instructions being executable by the at least one processor 202 to enable the at least one processor 202 to perform any of the method embodiments described above.
Where the memory 201 and the processor 202 are coupled in a bus, the bus may comprise any number of interconnected buses and bridges that couple one or more of the various circuits of the processor 202 and the memory 201 together. The bus may also connect various other circuits such as peripherals, voltage regulators, power management circuits, and the like, which are well known in the art, and therefore, will not be described any further herein. A bus interface provides an interface between the bus and the transceiver. The transceiver may be one element or a plurality of elements, such as a plurality of receivers and transmitters, providing a means for communicating with various other apparatus over a transmission medium. The data processed by the processor 202 is transmitted over a wireless medium through an antenna, which further receives the data and transmits the data to the processor 202.
The processor 202 is responsible for managing the bus and general processing and may also provide various functions including timing, peripheral interfaces, voltage regulation, power management, and other control functions. And memory 201 may be used to store data used by processor 202 in performing operations.
Another embodiment of the present invention relates to a computer-readable storage medium storing a computer program. The computer program realizes any of the above-described method embodiments when executed by a processor.
That is, as can be understood by those skilled in the art, all or part of the steps in the method for implementing the embodiments described above may be implemented by a program instructing related hardware, where the program is stored in a storage medium and includes several instructions to enable a device (which may be a single chip, a chip, or the like) or a processor (processor) to execute all or part of the steps of the method described in the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
It will be understood by those of ordinary skill in the art that the foregoing embodiments are specific examples for carrying out the invention, and that various changes in form and details may be made therein without departing from the spirit and scope of the invention in practice.