The present application claims the priority of a Chinese patent application No. 201810208514.4 filed on Mar. 14, 2018. Herein, the content disclosed by the Chinese patent application is incorporated in full by reference as a part of the present application.
The present disclosure relates to an image processing method, apparatus, device and medium for locating a center of a target object region.
Tracking (such as eyeball tracking) for a region of interest is an important technique in a virtual reality or augmented reality (VR/AR) application. For example, more possible interactive modes can be provided for a user by eyeball tracking. Therefore, a technology for locating a region of interest which can realize simply and effectively is needed.
There is provided in an embodiment of the present disclosure an image processing method for locating a center of a target object region, comprising: acquiring a binary image including the target object region; extracting a boundary line of the target object region from the binary image, wherein the boundary line includes a plurality of boundary points; selecting one of the plurality of boundary points as an initiation point, and determining a first connected region, wherein a starting point of the first connected region is the initiation point; determining the center of the target object region based on the first connected region.
According to some embodiments of the present disclosure, selecting one of the plurality of boundary points as an initiation point, and determining a first connected region, wherein a starting point of the first connected region is the initiation point comprises: selecting one pixel having a pixel value which is a preset pixel value from the plurality of boundary points as a first initiation point; determining a first connected region by adopting an octuple connected region algorithm, wherein the starting point of the first connected region is the first initiation point, and storing coordinates of respective boundary points of the first connected region in a first boundary matrix.
According to some embodiments of the present disclosure, selecting one of the plurality of boundary points as an initiation point, and determining a first connected region, wherein a starting point of the first connected region is the initiation point further comprises: determining whether there are other pixels having pixel values which are the preset pixel value in the plurality of boundary points besides the respective boundary points of the first connected region; in case that there are other pixels having pixel values which are the preset pixel value, selecting one of the other points having pixel values of the preset pixel value as a second initiation point, determining a second connected region by adopting the octuple connected region algorithm, wherein a starting point of the second connected region is the second initiation point, and storing coordinates of respective boundary points of the second connected region in a second boundary matrix, determining a number M of boundary points included in the first connected region, and determining a number N of boundary points included in the second connected region, where M and N are positive integers; comparing M and N, and determining one of the first connected region and the second connected region that includes a greater number of boundary points as a target connected region; in case that there are no other pixel having a pixel value which is the preset pixel value, determining the first connected region as the target connected region.
According to some embodiments of the present disclosure, an octuple connected region of a pixel includes pixels adjacent to the pixel in directions of up, down, left, right, top left, bottom left, top right, bottom right, the octuple connected region algorithm comprises: among respective pixels within the octuple connected region of the pixel, looking up clockwise or counterclockwise by taking one of the respective pixels as a starting point, and determining a first looked-up pixel having a pixel value which is the preset pixel value as the boundary point of the connected region.
According to some embodiments of the present disclosure, the boundary line in the binary image is extracted by utilizing a four connected region algorithm, wherein a four connected region of one pixel includes pixels adjacent to the pixel in directions of up, down, left, and right, the four connected region algorithm comprising: for each pixel in the binary image having a pixel value which is the preset pixel value, in case that there is a pixel having a pixel value which is not the preset pixel value in the four connected region of the pixel, determining the pixel as the boundary point forming the boundary line.
According to some embodiments of the present disclosure, the image processing method further comprises allocating a storage region of the boundary line based on the boundary line: determining a left-most boundary point and a right-most boundary point of the boundary line based on the boundary line, determining a maximum horizontal length of the boundary line according to the left-most boundary point and the right-most boundary point; determining a top-most boundary point and a bottom-most boundary point of the boundary line based on the boundary line, determining a maximum vertical length of the boundary line according to the top-most boundary point and the bottom-most boundary point; calculating the storage region of the boundary line based on the maximum horizontal length and the maximum vertical length.
According to some embodiments of the present disclosure, determining a center of the target object region according to the target connected region comprises: performing a fitting algorithm on the boundary line of the target connected region, determining a coordinate of the center of the target connected region according to a fitted boundary line of the target connected region, and determining the center of the target connected region as the center of the target object region, or determining an average value of abscissa values of the left-most boundary point and the right-most boundary point in the target connected region as an abscissa value of the center of the target object region, and determining an average value of ordinate values of the top-most boundary point and the bottom-most boundary point in the target connected region as an ordinate value of the center of the target object region.
According to some embodiments of the present disclosure, the method further comprises: acquiring an input image before acquiring the binary image including the target object region; and acquiring the binary image including the target object region further comprises: determining a pixel value threshold, wherein the pixel value threshold is used to distinguish the target object region and a background region included in the input image; and performing binarization process on pixel values of respective pixels of the input image according to the pixel value threshold, to obtain the binary image of the target object region.
According to some embodiments of the present disclosure, the process of acquiring the binary image further comprises at least one of following process: performing at least one of grayscale conversion, brightness adjustment, and filtering process on the input image; and performing an open operation on the input image on which binarization process has been performed.
There is further provided in some embodiments of the present disclosure an image apparatus for locating a center of the target object region, comprising: a binarization module, configured to acquire a binary image including the target object region; an extraction module, configured to extract a boundary line of the target object region from the binary image, wherein the boundary line includes a plurality of boundary points; a connected region determination module, configured to select one of the plurality of boundary points as an initiation point, and determine a first connected region, wherein a starting point of the first connected region is the initiation point; and a center localization module, configured to determine the center of the target object region based on the first connected region.
According to some embodiments of the present disclosure, the connected region determination module is further configured to: select one pixel having a pixel value which is a preset pixel value from the plurality of boundary points as a first initiation point; and determine a first connected region by adopting an octuple connected region algorithm, wherein the starting point of the first connected region is the first initiation point, and store coordinates of respective boundary points of the first connected region in a first boundary matrix.
According to some embodiments of the present disclosure, the connected region determination module is further configured to determine whether there are other pixels having pixel values which are the preset pixel value in the plurality of boundary points besides the respective boundary points of the first connected region, and in case that there are other pixels having pixel values which are the preset pixel value, select one of the other points having pixel values of the preset pixel value as a second initiation point, determine a second connected region by adopting the octuple connected region algorithm, wherein a starting point of the second connected region is the second initiation point, and store coordinates of respective boundary points of the second connected region in a second boundary matrix, determine a number M of boundary points included in the first connected region, and determine a number N of boundary points included in the second connected region, where M and N are positive integers; compare M and N, and determine one of the first connected region and the second connected region that includes a greater number of boundary points as a target connected region; determine the first connected region as the target connected region in case that there are no other pixel having a pixel value which is the preset pixel value in case.
According to some embodiments of the present disclosure, an octuple connected region of a pixel includes pixels adjacent to the pixel in directions of up, down, left, right, top left, bottom left, top right, bottom right, the octuple connected region algorithm comprises: among respective pixels within the octuple connected region of the pixel, looking up clockwise or counterclockwise by taking one of the respective pixels as a starting point, and determining a first looked-up pixel having a pixel value which is the preset pixel value as the boundary point of the connected region.
According to some embodiments of the present disclosure, the extraction module is configured to extract the boundary line in the binary image by utilizing a four connected region algorithm, wherein a four connected region of one pixel includes pixels adjacent to the pixel in directions of up, down, left, and right, the four connected region algorithm comprises: for each pixel in the binary image having a pixel value which is the preset pixel value, in case that there is a pixel having a pixel value which is not the preset pixel value in the four connected region of the pixel, determining the pixel as the boundary point forming the boundary line.
According to some embodiments of the present disclosure, the image processing apparatus for locating a center of a target object region further comprises a storage region allocation module, configured to allocate a storage region of the boundary line based on the boundary line.
According to some embodiments of the present disclosure, the center localization module is configured to perform a fitting algorithm on the boundary line of the target connected region, determine a coordinate of the center of the target connected region according to a fitted boundary line of the target connected region, or determine an average value of abscissa values of a left-most boundary point and a right-most boundary point in the target connected region as an abscissa value of the center of the target object region, and determine an average value of ordinate values of a top-most boundary point and a bottom-most boundary point in the target connected region as an ordinate value of the center of the target object region.
According to some embodiments of the present disclosure, the binarization module is configured to acquire a pixel value threshold, wherein the pixel value threshold is used to distinguish the target object region and a background region included in the input image, and perform binarization process on pixel values of respective pixels of the input image according to the pixel value threshold, to obtain the binary image of the target object region.
According to some embodiments of the present disclosure, the binarization module is further configured to perform at least one of following process: performing at least one of grayscale conversion, brightness adjustment, and filtering process on the input image; and performing an open operation on the input image on which binarization process has been performed.
According to another aspect of the present disclosure, there is further provided an image processing device for locating a center of a target object region comprising at least a storage and a processor, wherein program instructions are stored in the storage, and when the program instructions are executed, the processor is configured to perform the image processing method described above.
According to another aspect of the present disclosure, there is further provided a compute readable storage medium, upon which program instructions are stored, and when the instructions are executed by a processor, the processor is configured to perform the image processing method described above.
Technical solutions in embodiments of the present disclosure will be described below clearly and completely by combining with accompanying figures in the embodiments of the present disclosure. Obviously, the embodiments described below are just a part of embodiments of the present disclosure, but not all the embodiments. Based on the embodiments in the present disclosure, all the other embodiments obtained by those ordinary skilled in the art without paying any inventive labor belong to the scope sought for protection in the present disclosure.
There is provided in some embodiments of the present disclosure a method for locating a center of a target object region. The center of the target object can be determined by calculating a connected region of a binary image. This method has an advantage of small amount of data storage. Furthermore, in the method provided in the present disclosure, a storage regions required in the process of calculation can be allocated, so as to become suitable for a hardware implementation.
The method for locating the center of the target object region is applicable to technologies of localization of pupil center and eyeball tracking and so on. The localization of pupil center is a key process of the eyeball tracking technology, and in a product applying the technology of eyeball tracking, hardware implementation of localization of pupil center is also particularly important. For example, in applications such as virtual reality or enhancement reality and so on, eyeball tracking can function as an important technical measure for interacting with the user. For example, in a process of using a virtual reality product by the user, the line-of-sight of the user is determined and tracked by obtaining a image of the user face and identifying an eyeball region, and locating the center of the eyeball, so as to make a corresponding response. Accurate eyeball tracking is capable of providing better user experience for the user. For example, the user can use his/her eyes to control a display content of a display.
Additionally, the eyeball tracking technology can also be applicable to other fields. In a physiological experiment, whether one person is lying can be monitored based on a change in pupil of the person; in the aspect of advertisement effect monitoring, preference of the person can be determined according to the movement of point of regard of eyes; in the aspect of human-machine interaction, the eyes can take the place of keyboard, cursor mouse and touch screen, for example, some mobile phones can pause the video playback when eyes of the person leave away.
The method for locating the center of the target object region is capable of satisfying the requirement for hardware implementation. The requirement for data storage is relatively low, and is easy to be implemented. The method for locating the center of the target object region provided in the present disclosure will be described in the following text by taking pupils of a person as an example. However, those skilled in the art can understand that the target object region may be any region of interest depending on different actual application scenarios.
Next, in step S102, the boundary line of the target object region is extracted from the binary image acquired in step S101. For example, the boundary line can be extracted by adopting a four connected region algorithm, but extraction of the boundary line is not limited thereto, and the boundary line can also be extracted by adopting other methods. The boundary line is composed of a series of boundary points, and forms an outline of the target object. It may be understood that the boundary line may be a line, or may be a line set composed of a plurality of lines.
Next, in step S103, one point is selected from the boundary line (i.e., the plurality of boundary points) as an initiation point, and a first connected region is determined, wherein a starting point of the first connected region is the initiation point. In the embodiments of the present disclosure, for example, the connected region can be determined by adopting an octuple connected region algorithm, but the method for determining a connected region is not limited thereto, and the connected region can also be determined by adopting other methods. The connected region is a set composed of pixels which are connected to each other and have a same grayscale value. One or more connected regions can be included in the binary image.
Finally, in step S104, a target connected region including the center of the target object region is determined according to the determined first connected region, and the center of the target object region is determined according to the target connected region. In case that the binary image includes one connected region, the center of the connected region can be determined as the center of the target object region. In case that the binary image includes a plurality of connected regions, a center of one connected region of the plurality of connected regions including a maximum amount of boundary points can be determined as the center of the target object region. Thus it can be known that the center of the target object region can be determined through the above steps.
The left side in
In the binary image, for example, the boundary line of the target object region in the binary image can be extracted through the four connected region algorithm. In one image, the four connected region of one pixel refers to pixels in the image which are adjacent to the pixel in directions of up, down, left and right. In
The four connected region algorithm comprises: looking up a pixel with a pixel value of 1 in the binary image of the target object region, and performing judgment for the pixel whose pixel value is 1.
If the pixel whose pixel value is 1 is located at the edge of the binary image, it can be determined directly as a boundary point of the target object region, and a pixel value of pixels outside the binary image in the four connected region of the pixel is defined as 0.
As for a pixel whose pixel value is 1 not located at the edge of the binary image, if the four connected region of the pixel comprises a pixel whose pixel value is 0, the pixel can be determined as the boundary point of the target object region. If all pixel values of the four connected region are 1, it is considered that the pixel whose pixel value is 1 is not the boundary point. Optionally, in case that a certain pixel is not the boundary point, its pixel value can be set as 0.
By utilizing the four connected region algorithm provided in the present disclosure, all boundary points of the target object region in the binary image are determined by determining the pixel values of the four connected regions of the pixels. These boundary points form the boundary line of the target object region. An image including the boundary line is called as a boundary diagram, as shown in the right of
In one embodiment of the present disclosure, the boundary diagram including the boundary line can be stored. In other embodiments of the present disclosure, coordinates of boundary points included in the boundary line can be stored directly, for the purpose of being used in the subsequent calculation process.
The first initiation point A0 can be used to determine a connected region including the first initiation point A0 and determine whether all the included boundary points have been looked up. A plurality of connected regions included in the boundary diagram can be distinguished by utilizing the method for determining the connected region based on the boundary line as shown in
Next, in step S302 of
In one image, the octuple connected region of one pixel includes pixels adjacent to the pixel in directions of up, down, left, right, top-left, bottom-left, top-right, and bottom-right by taking the pixel as a center. The octuple connected region algorithm can include determining the first pixel whose pixel value is 1 as the boundary point of the connected region clockwise or counterclockwise by taking one pixel as the starting point in the octuple connected region of the pixel.
In one embodiment according to the present disclosure, for example, the connected region can be determined by adopting the octuple connected template as shown in
It needs to be noted that in other embodiments according to the present disclosure, the connected region can also be determined by adopting other octuple connected templates, for example, looking up the first pixel whose pixel value is 1 in the octuple connected region clockwise by taking the pixel adjacent to Δ in the left as the starting point, or looking up counterclockwise by taking the pixel adjacent to Δ in the right as the starting point. This mode of looking up does not form a limitation to the present disclosure, and thus no further details are given herein.
Next, a next boundary point A′ is looked up by taking the current boundary point A as a center, and applying the octuple connected region algorithm to it, and a coordinate (x′, y′) of the point A′ is stored in the first boundary matrix. The octuple connected template is the same as the octuple connected template used for looing up the current boundary point A. Then, A′ is taken as the current boundary point A, and a next boundary point A′ is continuously looked up by utilizing the above octuple connected template. The connected region can be determined by looking up a next boundary point A′ step by step.
In particular,
All the boundary points of the connected region can be determined through the step of looking up the next boundary point A′ by applying the octuple connected template to the current boundary point A. Optionally, the pixel value of the first initiation point A0 can be set as 0 in the boundary diagram, or in case that the coordinates of the boundary points have been stored already, coordinates of the pixels are marked, so as to confirm that look-up of the boundary points in the first connected region is finished.
Thus it can be known that the connected region including the first initiation point can be determined through the above steps, the connected region can be referred to as a first connected region, and coordinates of boundary points included in the first connected region are stored in the first boundary matrix. In the embodiments of the present disclosure, a storage region can be allocated to the first boundary matrix based on the boundary line, and the process of calculating the storage region will be introduced below in details.
After it is judged that determination of the first connected region is finished, that is, after the next boundary point A′ returns back to the first initiation point A0, it can be determined whether there are other pixels whose pixel value are 1 besides the boundary point of the first connected region. In case that there are other pixels whose pixel values are 1, one of the other pixels whose pixel values are 1 is selected as the second initiation point A1.
The boundary diagram 2 in
In other embodiments of the present disclosure, other pixels whose pixel values are 1 can also be looked up in other ways. For example, since the coordinates of the boundary points included in the first connected region are stored in the process of determining the first connected region, it can be determined whether there are other pixels whose pixel values are 1 by determining whether the coordinate of the pixel whose pixel value is 1 is identical with the coordinate included in the first boundary matrix.
In case that there are other pixels whose pixel values are 1, one of the other pixels whose pixel values are 1 is selected as the second initiation point A1. The second initiation point A1 is selected in a way of determining the first initiation point A0. For example, when the process of determining the first initiation point includes looking up the pixel whose pixel value is 1 from left to right progressively, then in the process of selecting the second initiation point, by taking A0 as the starting point and by means of looking up from left to right progressively, the first pixel whose pixel value is 1 is determined as the second initiation point A1. In the boundary diagram 2 of
By taking the second initiation point A1 as the starting point, the second connected region is determined by adopting the octuple connected region algorithm, and coordinates of respective boundary points of the second connected region are stored in a second boundary matrix. The process of determining the second connected region is the same as the process of determining the first connected region, and thus no further details are given herein.
It needs to be noted that the octuple connected template used in the process of determining the second connected region shall be the same as the octuple connected template used in the process of determining the first connected region. In other words, when the octuple connected template used for determining the first connected region includes: in the octuple connected region of Δ, taking the pixel adjacent to Δ in the left as the starting point, performing look-up for the first pixel whose pixel value is 1 in the octuple connected region in a clockwise way, and determining the first pixel whose pixel value is 1 as the current boundary point A. Then, the octuple connected template used in the process of determining the second connected region shall also be: in the octuple connected region of Δ, taking the pixel adjacent to Δ in the left as the starting point, looking up for the first pixel whose pixel value is 1 in the octuple connected region in a clockwise way.
Thus it can be known that in the embodiments of the present disclosure, the coordinates of the boundary points included in the first connected region are stored in the first boundary matrix, and the coordinates of the boundary points included in the second connected region are stored in the second boundary matrix. In one embodiment of the present disclosure, for example, a size of the connected region can be determined by calculating the number of the boundary points included in the first connected region and the second connected region. For example, the connected region that includes a greater number of boundary points can be determined as a target connected region (for example, pupil). After the target connected region is determined, the boundary matrix that storing the coordinates of the boundary points included in the target connected region is reserved, and the boundary matrix of other connected regions is cleared up.
In particular, a number M of boundary points included in the first connected region can be determined, and a number N of boundary points included in the second connected region can be determined, where both M and N are positive integers. Id N is greater than M, the second connected region is determined as the target connected region. If N is smaller than M, the first target connected region is determine as the target connected region.
For the purpose of convenient description, the reserved boundary matrix is called as a first boundary matrix, and the cleared-up boundary matrix is called as a second boundary matrix. The cleared-up boundary matrix can be used to store coordinates of other boundary matrixes of other connected regions. In this way, the storage region needed in the process of locating the center of the target object region can be reduced as much as possible, so as to be applicable to hardware implementation.
After the target connected region is determined, it can be determined continuously whether there are other pixels whose pixel values are 1. In case that there are other pixels whose pixel values are 1, one of other pixels whose pixel values are 1 is selected as a third initiation point A2. By taking A2 as a starting point, the third connected region is determined by adopting the octuple connected template, and coordinates of respective boundary points of the third connected region are stored in the second boundary matrix. The above process is the same as the process of determining the second connected region, and thus no further details are given herein. It needs to be noted that the other pixels whose pixel values are 1 are the pixels whose pixel value is 1 other than the boundary points included in the first and second connected regions.
Based on the above steps, all connected regions in the boundary line can be determined, and finally a target connected region having the largest number of boundary points and the first boundary matrix that stores the coordinate of the boundary point of the target connected region are obtained. The boundary points of the target connected region can be considered as the boundary points of the target object region.
The center of the target object region can be determined based on the target connected region. For example, if there are a plurality of connected regions in the boundary diagram, the connected region having the largest number of boundary points is determined as the target connected region, and the center of the target connected region is determined as the center of the target object region; alternatively, if there is only one connected region in the boundary diagram, for example, the center of the connected region is directly considered as the center of the target object region.
In one embodiment of the present disclosure, the first boundary matrix stores the coordinates of the boundary points included in the target connected region. For example, fitting calculation according to the coordinates of the boundary points is performed so as to obtain the center of the first connected region and to be taken as the center of the target object region. For example, if the target object region is pupil, the outline of the boundary points of the target connected region is approximate to an ellipse, and ellipse fitting calculation can be performed on the coordinates of determined boundary points of the target connected region. The center of the ellipse is the center of the target connected region, i.e., the center of the target object region.
In other embodiments of the present disclosure, the center of the target object region can be determined in the following method: taking an average value of abscissa values of a left-most boundary point and a right-most boundary point in the target connected region as an abscissa value of the center of the target object region, and taking an average value of an top-most boundary point and a bottom-most boundary point in the target region as a ordinate value of the center of the target object region.
A maximum value and a minimum value of coordinates x of boundary points stored in the first boundary matrix are calculated, and are marked as X_right and X_left. Also, a maximum value and a minimum value of coordinates y of boundary points stored in the first boundary matrix are calculated, and are marked as Y_bottom and Y_top. Thus it can be known that the bounding box of the target connected region can be represented as:
BoundingBox[0]=X_left; BoundingBox[1]=Y_top;
BoundingBox[2]=X_right; BoundingBox[3]=Y_bottom;
If the center of the target object region is calculated in this way, a storage region can be allocated to a bounding box matrix, so as to store values of BoundingBox[0], BoundingBox[1], BoundingBox[2] and BoundingBox[3].
Based on this bounding box matrix, coordinates (X_C, Y_C) of the center point of the target connected region can be determined directly by BoundingBox:
X_C=(BoundingBox[0]+BoundingBox[2])/2
Y_C=(BoundingBox[1]+BoundingBox[3])/2
Thus, it can be known that the method for locating the center of the target object region is capable of simply determining the center of the target object through the connected region calculated based on the boundary line, and in the process of calculation, the storage region required for calculation of the above method can be allocated, and thus it is applicable to the hardware implementation. For example, the boundary line of the binary image of the pupil image is extracted, the first connected region is determined based on the boundary line, and the center of the first connected region is taken as the center of the pupils. In this way, the obtained information on the position of the pupil center can be applicable to a virtual reality product with the eyeball tracking technology.
In step S801, a left-most boundary point and a right-most boundary point in the boundary line are determined based on the boundary line. For example, a maximum horizontal length of the boundary line can be determined according to the left-most boundary point and the right-most boundary point.
In step S802, a top-most boundary point and a bottom-most boundary point in the boundary line are determined based on the boundary line. For example, a maximum vertical length of the boundary line can be determined according to the top-most boundary point and the bottom-most boundary point.
In step S803, the storage region of the boundary line is calculated based on the maximum horizontal length and the maximum vertical length.
The determined maximum horizontal and vertical length of the boundary line represents the maximum number of pixels included in the boundary line horizontally and vertically. Therefore, the storage region can be allocated based on the maximum number of pixels that are likely included in the boundary line. For example, if the maximum number of pixels included in the boundary line horizontally and vertically are m and n, respectively, then in case of assuming that the connected region is a matrix, the maximum number of boundary points that can be included in the connected region is 2*(m+n), then the first and second boundary matrixes need to store coordinates of 2*2*(m+n) boundary points in all, based on which the storage region can be allocated. In order to avoid the case of the storage region being not enough from occurring because the outline of the connected region is winding, a storage region can be added appropriately on such a basis in the process of allocating the storage region, for example, the storage region can be allocated on a basis of 4*2*(m+n) boundary points.
For example, if the target object region is a pupil, its boundary line is approximate to an ellipse, as shown in the boundary diagram in the right side of
Before a binary image is acquired, an input image is acquired in step S901, and a target object whose center needs to be determined is included in the input image.
Next, in step S902, a pixel value threshold is determined, wherein the pixel value threshold is used to distinguish the target object region and the background region included in the input image. For example, the threshold of the target object region in gray scale image data can be calculated by using an Otsu's method. The Ostu's method is an adaptive threshold determining method, which is also referred to as a maximum between-class variance method. In other embodiments of the present disclosure, a threshold of the eyeball image can be calculated by adopting other algorithms. For example, the threshold can be determined by making a statistics of an average value of pixel values of the pixels in the target object region.
Next, in step S903, the binarization process is performed on the input image including the target object region based on the determined threshold, so as to separate the target object region from the background region. For example, a pixel value of a pixel in the grayscale image whose pixel value is higher than the threshold can be set as 1, and a pixel value of a pixel whose pixel value is lower than the threshold can be set as 0. It needs to be noted that a pixel value of a pixel whose pixel value is higher than the threshold can also be set as 0, and a pixel value of a pixel whose pixel value is lower than the threshold can also be set as 1. In this way, the binary image of the target object region can be obtained.
The input image including the target object region can be obtained through an image acquisition device. For example, in an application of eyeball tracking, an image of eyeball can be obtained by utilizing a device such as a camera, etc., and the camera can obtain a colored image or can obtain a grayscale image, for example, adopting an infrared camera. If the image including the target object region is colored, it can be transformed by grayscale in the process of pre-process the image, and the image would be transformed into a grayscale image.
During the process of acquiring the image, brightness of pixel values of pixels at different positions of the image would become non-uniform due to the impact of factors such as light intensity, angle of light and so on. For example, the case that brightness in a certain region is too high or too low would occur in a photographed eyeball image, and also some image noises would exist. In order to perform the binarization processing of image segmentation by using the threshold on the image more accurately, brightness adjustment and filtering process can be performed in advance on the acquired image. For example, the grayscale value of the too-bright region in the image is correspondingly adjusted, and filtering process such as Gaussian filtering is performed on the image whose brightness has been adjusted, so as to eliminate the noises of image. Thus, a brightness-uniform grayscale image including the target object region can be obtained. On the basis of the grayscale image, the binary image can be obtained by performing the above binarization processing on the grayscale image.
In general, due to the impact of noise, the boundary of the image obtained after binarization process is performed in the image is not smooth. It is likely to have some noise holes in the target object region, and some small noise objects are distributed on the background region. Corrosion process in the image process can separate the sticky target objects, and expansion process can splice the disconnected target objects. Herein, the corrosion process is a process of eliminating the boundary points so that the boundary constricts to the inside, which can be used to remove small and insignificant objects; the expansion processing is a process of merging all background points contacting with the object into the object and making the boundary to expand to the outside, which can be used to fill holes in the object.
Therefore, after the binary image of the target object region is obtained, open operation processing can be performed on the obtained binary image. It comprises an image processing process of first corroding and then expanding, which is used to eliminate small objects, separate the object at a slender point, smoothen a boundary of a larger object while does not change its area evidently. The main function of the open operation is similar to that of corrosion. However, compared with the corrosion operation, the open operation has the advantage of basically maintaining the original size of the target object region unchanged, which is advantageous for accurately extracting the boundary line of the target object region and determining its center.
It needs to be noted that in the embodiments according to the present disclosure, in the process of acquiring the binary image, pre-process steps as shown in
There is further provided in some embodiments of the present disclosure an apparatus for locating a center of a target object region.
The binarization module 1002 is configured to acquire a binary image including the target object region. The extraction module 1004 is configured to extract a boundary line of the target object region from the binary image, wherein the boundary line includes a plurality of boundary points. The connected region determination module 1006 is configured to select one of the plurality of boundary points as an initiation point, and determine a first connected, wherein a starting point of the first connected region is the initiation point. The center localization module 1008 is configured to determine the center of the target object region based on the first connected region.
In one embodiment of the present disclosure, the extraction module can extract a boundary line in the binary image by utilizing the four connected region algorithm. The four connected region algorithm comprises: for each pixel whose pixel value is 1 in the binary image, when there is a pixel whose pixel value is not 1 in the four connected region of the pixel, determining the pixel as a boundary point, the boundary point forming the boundary line.
In one embodiment of the present disclosure, the connected region determination module can select one pixel whose pixel value is 1 from the plurality of boundary points as a first initiation point; and determining the first connected region for example by adopting the octuple connected region algorithm, wherein a starting point of the first connected region is the initiation point, and storing coordinates of respective boundary points of the first connected region in a first boundary matrix.
The connected region determination module is further configured to determine whether there are other pixels whose pixel values are 1, in the plurality of boundary points besides respective boundary points of the first connected region, and in case that there are other pixels whose pixel values are 1, select one of the other points whose pixel value is 1 as a second initiation point, determine a second connected region by adopting an octuple connected region algorithm, wherein the second initiation point is a starting point of the second connected region, and store coordinates of respective boundary points of the second connected region in a second boundary matrix. For example, one of the first connected region and the second connected region that includes a greater number of boundary points is determined as a first connected region.
An octuple connected region of one pixel is pixels adjacent to the pixel in directions of up, down, left, right, top left, bottom left, top right, bottom right. The octuple connected region algorithm comprises in respective pixels within the octuple connected region of the pixel, looking up clockwise or counterclockwise by taking one of the respective pixels as a starting point, and determining a first looked-up pixel whose pixel value is 1 as a boundary point of the connected region.
The apparatus for locating the center of the target object region can further comprise a storage region allocation module configured to allocate the storage region of the boundary line based on the boundary line.
In one embodiment of the present disclosure, the center localization module can perform a fitting algorithm on the boundary line of the target connected region, and determine a coordinate of the center of the target connected region according to a fitted boundary line of the target connected region.
In other embodiments of the present disclosure, the center localization module can further take an average value of abscissa values of a left-most boundary point and a right-most boundary point in the target connected region as an abscissa value of the center of the target object region, and take an average value of vertical axes of an top-most boundary point and a bottom-most boundary point in the target connected region as a vertical axis of the center of the target object region.
The binarization module can determine a pixel value threshold of the target object region in the acquired input image, and perform binarization process on pixel values of respective pixels of the input image according to the pixel value threshold, to obtain the binary image of the target object region.
The binarization module can further perform at least one of following processing: performing grayscale conversion, brightness adjustment and filtering process on the input image; and performing an open operation on the input image on which the binarization process has been performed.
There is provided in the embodiments of the present disclosure a method and apparatus for locating the center of the target object region. The method for locating the center of the target object region comprises: acquiring the binary image including the target object region; extracting the boundary line of the target object region in the binary image, the boundary line including a plurality of boundary points; determining the target connected region in the binary image based on the boundary line; determining the center of the target object region based on the target connected region. The method for locating the center of the target object region can further comprise the processes of allocating the storage region based on the boundary line, and pre-processing the image to acquire the binary image of the target object region. The apparatus for locating the center of the target object region comprises the binarization module, the extraction module, the connected region module and the center localization module. The center of the target object region is determined by calculating the connected region in the binary image of the target object region.
The method and apparatus for locating the center of the target object region is easy to be implemented, needs a relatively small storage space, and is easy to calculate the resources required for hardware realization. It can be applicable to technologies or products such as pupil location and eyeball tracking and so on. In addition, the method and apparatus further store boundary coordinates of boundary points of the connected region which is determined based on the boundary line. The connected region and its coordinates of the boundary points can also be applicable to other calculation processes. For example, the boundary of the connected region is determined so as to realize eye recognition based on the pupil boundary.
There is provided in the present disclosure the method and apparatus for locating the center of the target object region, which determines the boundary line based on the binary image of the target object, calculates the connected region based on the boundary line, and determines the center of the first connected region as the center of the target object region. Its data storage amount is small, and it is easy to be implemented, and is capable of satisfying the requirement for the hardware realization.
Those skilled in the art can understand that respective aspects of the present disclosure can be described and explained through several patentable types or scenarios, comprising combination of any new or usable processes, machines, products or substances, or any new or usable improvement to these processes, machines, products or substances. Correspondingly, respective aspects of the present disclosure may be executed completely by a hardware, or may be executed completely by a software (including a firmware, a resident software, a microcode, etc.), or may be executed by a combination of the hardware and the software. Both the hardware and the software can be referred to as “data block”, “module”, “engine”, “unit”, “component” or “system”. In addition, respective aspects of the present disclosure may be shown as a computer product located in one or more computer readable media. The computer product comprises computer readable program encoding.
The present disclosure uses specific expressions to describe the embodiments of the present disclosure. For example, “one embodiment”, “an embodiment”, and/or “some embodiments” means a certain feature, structure or characteristics relating to at least one embodiment of the present disclosure. Therefore, it shall be emphasized and noted that “an embodiment”, “one embodiment”, or “an alternative embodiment” mentioned for two or more times at different positions of the present specification does not necessarily refer to the same embodiment. In addition, some features, structures or characteristics in one or more embodiments of the present disclosure can be combined appropriately.
Unless otherwise defined, all terms (including technical and scientific terms) used herein have the meanings as the same as those meanings commonly understood by those ordinary skilled in the art. It shall be further understood that those terms such as defined in general dictionaries shall be explained as having meanings consistent with meanings in the context of related technology, but shall not be explained by idealized or formalized meanings, unless otherwise explicitly defined.
The above are descriptions of the present disclosure, but shall not be considered as limitations to the present disclosure. Although several exemplary embodiments of the present disclosure are described, it is easy for those skilled in the art to understand that various amendments can be made to the exemplary embodiments without departing from novel teachings and advantages of the present disclosure. Therefore, all these amendments intend to be included within the scope of the present disclosure as defined in the Claims. It shall be understood that the above are the descriptions of the present disclosure, but shall not be considered as being limited to specific disclosed embodiments. Furthermore, amendments made to the embodiments and other embodiments of the present disclosure shall intend to be included within the scope of the Claims. The present disclosure is defined by the Claims and equivalents thereof.
Number | Date | Country | Kind |
---|---|---|---|
201810208514.4 | Mar 2018 | CN | national |
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/CN2018/113989 | 11/5/2018 | WO | 00 |