Description of the embodiments
Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to like or similar modules or modules having like or similar functions throughout. The embodiments described below by referring to the drawings are illustrative only and are not to be construed as limiting the invention. On the contrary, the embodiments of the invention include all alternatives, modifications and equivalents as may be included within the spirit and scope of the appended claims.
According to the embodiment of the invention, the damaged cell boundary is repaired according to the position information of the cell edge and the cell communication area information, so that the accuracy of cell counting when the cell boundary is damaged is improved.
Example 1
Fig. 1 is a flowchart of a cell boundary repairing method according to an embodiment of the invention. As shown in fig. 1, the method includes the following steps.
Step S101: a first cell image is acquired.
In the embodiment of the invention, the first cell image is a gradient binarized image, and after the gradient image is calculated according to the gray values of all pixels in the gray level diagram shown in fig. 2, the gradient image is compared with a set gradient threshold value to obtain the gradient binarized image shown in fig. 3.
As another embodiment of the present invention, the first cell image may be obtained by photographing a slide glass filled with a cell liquid under a microscope light path. The first cell image may be a color image or a gray image. If the image is a color image, the gray image shown in fig. 2 is obtained through conversion, and then the gray image is converted into a gradient binary image for the subsequent steps.
Step S102: a second cell image containing positional information of the cell edges is determined from the first cell image.
When the first cell image is a gradient binarized image, as an embodiment of the present invention, a process of extracting positional information of a cell edge is shown in fig. 4, and the method includes the following steps.
Step S401: and performing image erosion processing on the first cell image.
Step S402: and subtracting the first cell image before the corrosion treatment from the first cell image after the corrosion treatment to obtain a second cell image containing the position information of the cell edge.
In an embodiment of the invention, the first cell image is a gradient binarized image. As shown in fig. 3, the circle is a cell boundary covering several pixels. A circle and its enclosed area represent a cell. The ring connection indicates no break in the cell boundary and the ring disconnection indicates a break in the cell boundary. The erosion process narrows the ring, and the value of each pixel of the first cell image before the erosion process is subtracted from the value of each pixel of the first cell image after the erosion process to obtain a second cell image, as shown in fig. 5. For each cell, the edges inside and outside each ring are obtained, and the edges inside and outside the rings are the cell edges.
Step S103: a third cell image containing cell connected region information is determined from the first cell image.
When the first cell image is a gradient binarized image, as an embodiment of the present invention, a method of segmenting a cell communication region includes: and (3) marking the cell communication area information of the first cell image by using an eight-neighborhood marking algorithm to obtain a third cell image. In the third cell image, connected regions have the same region value, and unconnected regions have different region values. That is, a cell boundary (a circle) is a connected region, and several pixels covered by the connected region have the same region value; different cell boundaries are areas of non-connectivity that cover pixels with different area values.
Step S104: and repairing the cell boundary in the first cell image according to the position information of the cell edge and the cell communication area information to determine a fourth cell image.
Starting from the cell edge, if there is a connected region outside the preset distance, the pixels between the two regions are judged to belong to the same connected region. As one embodiment of the present invention, the process of repairing cell boundaries is shown in FIG. 6, and the method is as follows.
Step S601: and comparing the cell communication area information of the starting point and the end point by taking the pixel corresponding to the cell edge as the starting point and the pixel which is at a distance of a preset length in a preset direction as the end point.
Step S602: if the cell communication area information of the start point and the end point are the same, the pixel values of the pixels between the start point and the end point are set to be the same as the start point and the end point based on the first cell image.
In the embodiment of the invention, after the cell edge is extracted to obtain a second cell image, selecting a pixel covered by the cell edge in the second cell image, taking the pixel as a starting point, projecting in a preset direction, and projecting to a pixel with a preset length. As shown in fig. 7 and 8, for a single cell, the pixels covered by the cell edge are selected as P1, and projection is sequentially performed in eight preset directions of 0, 45, 90, 135, 180, 225, 270 and 315 degrees of P1, and the preset length of projection in each preset direction is five pixels P1, P2, P3, P4 and P5. The number of the preset directions and the preset length are selected according to actual needs, and the method is not limited to the above.
The cell communication region information of the starting point P1 and the ending point P5 is compared with the starting point P1 and the ending point P5. Cell communication region information of the start point P1 and the end point P5 is acquired from the corresponding pixel positions in the third cell image.
If the cell communication area information of the start point P1 and the end point P5 are the same, that is, the area values of the two are the same, the pixel values of the pixels P2, P3, and P4 between the start point P1 and the end point P5 are set to be the same as the start point P1 and the end point P5 based on the first cell image. In the embodiment of the invention, the first cell image is a gradient binarized image, and the pixel values of the corresponding pixels of the first cell image are binarized gradient values of the P1, P2, P3, P4 and P5. Visually, for a single cell, a line is drawn between pixels corresponding to the start point P1 and the end point P5 at positions corresponding to the first cell image, so that the ring is disconnected, and as shown in fig. 9, two arrows indicate that the cell communication areas at the start point P1 and the end point P5 are identical in information in the two predetermined directions, and a line is drawn. If the cell communication area information of the starting point P1 and the cell communication area information of the ending point P5 are different, namely the area values of the starting point P1 and the ending point P5 are not equal, the preset direction is not processed, and the next preset direction is reached.
Step S603: and traversing pixels corresponding to the cell edges in the second cell image to obtain a fourth cell image of the repaired cell boundary.
And traversing all pixels corresponding to the cell edges in the second cell image, and executing steps S601 and S602 to obtain a fourth cell image. As shown in fig. 10 and 11, when the part of the first cell image of the unrepaired cell boundary and the part of the fourth cell image of the repaired cell boundary are compared, it can be seen that the cell boundary has been repaired at the connection of the broken part of the circular ring.
Step S105: cell counting was performed according to the fourth cell image.
In the embodiment of the invention, cell counting is performed according to the fourth cell image after repairing the cell boundary, or cell counting is performed after filling the hole in the fourth cell image. Hole filling of individual cells is shown in fig. 12. FIG. 13 shows the effect of cell counting without repairing cell boundaries, two cells indicated by arrows being unclamped, i.e., not counted, with omission; FIG. 14 shows the effect of cell counting on repaired cell borders, with two cells indicated by arrows being circled, i.e. counted, avoiding missed detection.
According to the embodiment of the invention, the damaged cell boundary is repaired according to the position information of the cell edge and the cell communication area information, if a communication area exists outside the preset distance of the cell edge, the pixels between the two areas belong to the same communication area, the pixels are considered as the cell boundary, and the cell counting is performed after the repair, so that the accuracy of the cell counting is improved.
Example two
Fig. 15 is a block diagram of a cell boundary repairing apparatus according to a second embodiment of the present invention, as shown in fig. 15, the apparatus includes: an acquisition unit 1501, a first determination unit 1502, a second determination unit 1503, and a patching unit 1504.
The acquisition unit 1501 is used to acquire a first cell image.
The first determining unit 1502 is configured to determine a second cell image including positional information of cell edges from the first cell image.
The second determination unit 1503 is configured to determine a third cell image containing cell communication region information from the first cell image.
The patching unit 1504 is used for patching the cell boundaries in the first cell image according to the position information of the cell edges and the cell connected region information to determine a fourth cell image.
Preferably, the first cell image is a gradient binarized image, and the first determining unit 1502 includes an erosion subunit and a subtraction subunit.
The etching subunit is used for performing image etching processing on the first cell image.
The subtraction subunit is configured to subtract the first cell image before the erosion treatment from the first cell image after the erosion treatment to obtain a second cell image that includes positional information of a cell edge.
Preferably, the first cell image is a gradient binarized image and the second determining unit 1503 includes eight neighborhood subunits. The eight neighborhood sub-units are used for marking cell communication area information of the first cell image through an eight neighborhood marking algorithm to obtain a third cell image.
Preferably, the patching unit 1504 includes a comparing subunit, a setting subunit, and a looping subunit.
The comparing subunit is configured to compare the cell communication area information of the starting point and the ending point with the pixel corresponding to the cell edge as the starting point and the pixel having a distance of a preset length in the preset direction as the ending point.
The setting subunit is configured to set, if the cell communication area information of the start point and the end point are the same, pixel values of pixels between the start point and the end point to be the same as the start point and the end point based on the first cell image.
The circulation subunit is used for traversing pixels corresponding to the cell edges in the second cell image to obtain a fourth cell image of the repaired cell boundary.
Further, the cell boundary repair device further comprises a counting unit. The counting unit is used for counting cells according to the fourth cell image.
The cell boundary repairing method performed in the cell boundary repairing device corresponds to the method described in the first embodiment one by one, and will not be described herein.
According to the embodiment of the invention, the damaged cell boundary is repaired according to the position information of the cell edge and the cell communication area information, if a communication area exists outside the preset distance of the cell edge, the pixels between the two areas belong to the same communication area, the pixels are considered as the cell boundary, and the cell counting is performed after the repair, so that the accuracy of the cell counting is improved.
While embodiments of the present invention have been shown and described above, it will be understood that the above embodiments are illustrative and not to be construed as limiting the invention, and that variations, modifications, alternatives and variations may be made to the above embodiments by one of ordinary skill in the art within the scope of the invention.