Disclosure of Invention
The invention provides a blood cell morphology contour obtaining method and a blood cell morphology contour obtaining system based on microscopic images, which aim to solve the problem that when in threshold segmentation, the blood cells contain red blood cells, white blood cells and platelets, and the characteristics of the blood cells have large differences, so that the threshold segmentation effect is poor for a specific area, and the whole blood cell contour edge cannot be segmented.
The blood cell morphology contour obtaining method and system based on microscopic images adopt the following technical scheme:
one embodiment of the present invention provides a microscopic image-based blood cell morphology profile acquisition method comprising the steps of:
Obtaining a blood cell gray level image;
Equally dividing the blood cell gray level image into a plurality of small windows, acquiring an optimal threshold value of the blood cell gray level image and an optimal threshold value of each small window, and acquiring the fitness of each small window according to the optimal threshold value of the blood cell gray level image and the optimal threshold value of each small window;
Dividing the foreground region of each target window into a plurality of chain code segments, and obtaining the probability that each chain code segment of the foreground region of each target window meets the arc-shaped characteristic according to the difference of pixel point position relations in each chain code segment of the foreground region of each target window;
Obtaining the definition of each target window after threshold segmentation according to the probability that each chain code segment of the foreground region of each target window of the blood cell gray level image meets the arc-shaped characteristic and the number of the chain code segments;
And obtaining a threshold segmentation result of each target window according to the rationality of threshold segmentation of the foreground region of each target window, and obtaining the shape profile of the blood cell wheel through the threshold segmentation result of each target window.
Preferably, the obtaining the fitness of each small window according to the optimal threshold of the blood cell gray level image and the optimal threshold of each small window comprises the following specific steps:
combining the optimal threshold of the blood cell gray level image with the first blood cell gray level image The inverse proportion normalized value of the absolute value of the difference value of the optimal threshold values of the small windows is recorded as the first blood cell gray level imageFitness of the individual portlets.
Preferably, the step of obtaining all the small windows to be adjusted according to the fitness of each small window includes the following specific steps:
When the blood cell gray level image is the first The fitness of each small window is smaller than a preset threshold valueWhen the blood cells are in the gray level image, the first stepThe small window is the small window which needs to be adjusted.
Preferably, the method for obtaining a plurality of target windows according to all the small windows to be adjusted comprises the following specific steps:
And merging adjacent small windows needing to be adjusted in the blood cell gray level image to obtain a target window.
Preferably, the dividing the foreground region of each target window into a plurality of chain code segments, and obtaining the probability that each chain code segment of the foreground region of each target window meets the arc-shaped characteristic according to the difference of the pixel point location relations in each chain code segment of the foreground region of each target window comprises the following specific steps:
In the blood cell gray level image On the edge of the foreground region of the target window, the first isAnd the first and secondThe absolute value of the difference value of the code values of the chains of the edge pixel points is recorded as the firstChain code differential characteristic values of the edge pixel points;
When the blood cell gray level image is the first On the edge of the foreground region of the target window, the firstThe difference characteristic value of the chain codes of the edge pixel points is larger than a preset threshold valueWhen then the firstThe edge pixel points are dividing points, and the edges of the foreground region are divided into a plurality of chain code segments by using all the dividing points;
When the blood cell gray level image is the first Foreground region of each target windowOn the code segment of the chainThe difference characteristic value of the chain codes of the edge pixel points is equal to a preset threshold valueWhen then the firstThe edge pixel points are new partition points, and the first partition point is used for all the new partition pointsThe individual chain code segments are divided into a plurality of chain code sequences;
the first of the blood cell gray scale image Foreground region of each target windowThe calculation formula of the probability that each chain code segment meets the arc-shaped characteristic is as follows:
In the formula, First image representing gray level of blood cellsForeground region of each target windowProbability that each chain code segment meets an arc-shaped characteristic; First image representing gray level of blood cells Foreground region of each target windowThe number of all edge pixel points on each chain code segment; First image representing gray level of blood cells Foreground region of each target windowOn the code segment of the chainChain code values of the edge pixel points; First image representing gray level of blood cells Foreground region of each target windowOn the code segment of the chainChain code values of the edge pixel points; First image representing gray level of blood cells Foreground region of each target windowVariance of all chain code sequence lengths in the individual chain code segments; Is an exponential function with a natural constant as a base; as a function of absolute value.
Preferably, the specific formula is as follows, where the definition after threshold segmentation of the foreground region of each target window is obtained according to the probability that each chain code segment of the foreground region of each target window of the blood cell gray level image meets the arc feature and the number of chain code segments:
In the formula, First image representing gray level of blood cellsDefinition after threshold segmentation of foreground regions of the target windows; First image representing gray level of blood cells Foreground region of each target windowProbability that each chain code segment meets an arc-shaped characteristic; First image representing gray level of blood cells The number of all chain code segments of the foreground region of the target window; Is a normalization function.
Preferably, the obtaining the rationality of the threshold segmentation of the foreground region of each target window according to the definition of the threshold segmentation of the foreground region of each target window and the fitness of all the small windows in the foreground region of each target window includes the following specific steps:
Calculating the first blood cell gray level image Inverse of variance of fitness of all small windows in foreground region of each target window and the first blood cell gray level imageThe product of the threshold-divided definition of the foreground region of each target window is recorded as the first blood cell gray level imageThe threshold segmentation of the foreground region of the individual target window is reasonable.
Preferably, the threshold segmentation result of each target window is obtained according to the rationality of threshold segmentation of the foreground region of each target window, and the specific steps include:
acquisition of the blood cell gray level image A secondarily divided foreground region and background region of the target window;
obtaining the rationality of the threshold segmentation of the foreground region of each segmentation according to the rationality obtaining mode of the threshold segmentation of the foreground region of each target window;
When the blood cell gray level image is the first The threshold segmentation of the secondarily segmented foreground region of the background region of the target window is less than or equal to the first thresholdWhen the threshold value of the foreground region of each target window is segmented reasonably, the first step isThe foreground region and the background region divided by the target window are taken as the firstThreshold segmentation result of each target window, when the first blood cell gray level imageThe threshold segmentation of the secondarily segmented foreground region of the background region of the target window is more reasonable than that of the firstAcquiring the first threshold value of the foreground region of each target window when the threshold value of the foreground region is partitioned reasonablyStopping segmentation when the rationality of threshold segmentation of the foreground region of any one time is greater than that of the foreground region of any one time later, and taking the background region of any one time and the foreground regions of any one time and all previous times as a first timeThreshold segmentation results for each target window.
Preferably, the blood cell wheel shape profile is obtained through the threshold segmentation result of each target window, and the specific steps are as follows:
Dividing each small window which is not a target window into a foreground area and a background area, acquiring a threshold segmentation result of each small window which is not a target window, combining the threshold segmentation result of each target window, enabling the gray value of a pixel point in the foreground area in the blood cell gray level image to be 0, enabling the gray value of the pixel point in the background area to be 1, obtaining a final blood cell binary image, and extracting the edge of the final blood cell binary image to be the blood cell wheel shape outline.
The invention also provides a blood cell morphology contour obtaining system based on the microscopic image, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the computer program stored in the memory so as to realize the steps of the blood cell morphology contour obtaining method based on the microscopic image.
The technical scheme of the invention has the beneficial effects that all small windows needing to be adjusted are obtained according to the fitness of each small window, and each small part of the blood cell gray level image can be analyzed, so that the accuracy of extracting the blood cell morphological outline is improved. The method comprises the steps of obtaining the reasonable degree of threshold segmentation of the foreground region of each target window according to the reasonable degree of threshold segmentation of the foreground region of each target window, obtaining the threshold segmentation result of each target window according to the reasonable degree of threshold segmentation of the foreground region of each target window and the reasonable degree of threshold segmentation of the foreground region of each background region, and accurately judging whether each target window needs to be adjusted or not. The threshold segmentation result of each target window is used for obtaining the shape outline of the blood cell wheel, so that the complete blood cell outline can be accurately segmented.
Detailed Description
In order to further describe the technical means and effects adopted by the present invention to achieve the preset purpose, the following detailed description refers to the specific implementation, structure, characteristics and effects of the method and system for acquiring blood cell morphology profile based on microscopic image according to the present invention with reference to the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" means that the embodiments are not necessarily the same. Furthermore, the particular features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
The following specifically describes a detailed scheme of the blood cell morphology contour obtaining method and system based on microscopic image provided by the invention with reference to the accompanying drawings.
Referring to fig. 1, a flowchart illustrating a method for acquiring a blood cell morphology contour based on microscopic images according to an embodiment of the invention is shown, the method includes the following steps:
and S001, obtaining a blood cell gray level image.
The blood cell image is collected by a microscope, the schematic diagram of the collected blood cells is shown in fig. 2, the collected blood cells comprise red blood cells, white blood cells and platelets, the image is cut and graying processed, and the gray level image of the blood cells is shown in fig. 3.
It should be noted that, because blood cells are divided into red blood cells, white blood cells and platelets, the blood cells are different in morphology and the interference of factors such as uneven cell staining is caused, so that the blood cells of each type cannot be well divided by using global threshold segmentation; the result of dividing the blood cell gray image by the oxford algorithm is shown in fig. 4, and the maximum inter-class variance is 366.5021 when the gray is 169. Therefore, in order to obtain the whole cell outline, the local threshold value of the image is adjusted, so that a relatively accurate segmentation result is ensured to be achieved locally.
The method of the Sedrin algorithm is a well-known technique, and the specific method is not described here.
Step S002, equally dividing the blood cell gray level image into a plurality of small windows, obtaining an optimal threshold value of the blood cell gray level image and an optimal threshold value of each small window, obtaining the fitness of each small window according to the optimal threshold value of the blood cell gray level image and the optimal threshold value of each small window, and obtaining all small windows to be adjusted according to the fitness of each small window.
The image is first divided into grid-like small windows, and the division of the image in a local area is evaluated. The local segmentation condition is judged specifically by the difference between the local optimal threshold and the overall optimal threshold, when the optimal threshold of a certain small window is close to the optimal threshold of the overall image, the separation of the background and the target object in the small window can be generally clear, and when the difference is large, the local segmentation effect is poor, and the small window size may need to be adjusted.
Preset valueFor 7, set up oneEqually dividing the blood cell gray level image into a plurality of small windows;
Obtaining an optimal threshold value of the blood cell gray level image and an optimal threshold value of each small window of the blood cell gray level image by adopting an Ojin algorithm;
combining the optimal threshold of the blood cell gray level image with the first blood cell gray level image The inverse proportion normalized value of the absolute value of the difference value of the optimal threshold values of the small windows is recorded as the first blood cell gray level imageFitness of the individual portlets;
the first of the blood cell gray scale image The method for calculating the fitness of each small window comprises the following steps:
In the formula, First image representing gray level of blood cellsFitness of the individual portlets; an optimal threshold value representing a gray level image of blood cells; First image representing gray level of blood cells Optimal threshold for each portlet; As a function of absolute value; Is an exponential function with a base of natural constant. The embodiment is to To present inverse proportion relation and normalization processing, and the implementer can set inverse proportion function and normalization function according to actual situation.
It is to be noted that,First image representing gray level of blood cellsThe difference between the optimal threshold of the small window and the optimal threshold of the whole image is larger, the larger the difference is, the first isThe more unsuitable the size selection of the small window, the firstThe lower the fitness of the small window, the more appropriate the window is to the firstThe size of the small window is adjusted.
According to the mode, calculating the fitness of each small window of the blood cell gray level image;
Preset threshold value 0.9, When the blood cell gray level image is the firstThe fitness of each small window is smaller than a preset threshold valueWhen the blood cells are in the gray level image, the first stepThe small window is the small window which needs to be adjusted.
So far, all small windows of the blood cell gray level image which need to be adjusted are obtained.
Step S003, obtaining a plurality of target windows according to all small windows to be adjusted, dividing the foreground area and the background area of each target window, dividing the foreground area of each target window into a plurality of chain code segments, and obtaining the probability that each chain code segment of the foreground area of each target window meets the arc-shaped characteristic according to the difference of pixel point position relations in each chain code segment of the foreground area of each target window.
When the small window is adjusted, the adjacent small windows to be adjusted may be the same area, so that the adjacent small windows to be adjusted are combined together, and the size of the combined windows is adjusted to obtain the final window suitable for segmentation.
And merging adjacent small windows needing to be adjusted in the blood cell gray level image to obtain a target window. Thereby obtaining a number of target windows.
The target window is obtained by using the oxford algorithm, the suspected blood cell area is obtained by using the target window, and the rationality of the segmentation in the window is judged by the target window characteristics and the suspected blood cell characteristics. The definition of the segmentation rationality comprises the rationality of the window and the definition of the segmented image, wherein the more reasonable the window is combined, the larger the segmentation rationality is, and the clearer the segmented image is, the larger the segmentation rationality is. For the calculation of window rationality, when the adaptability difference of a plurality of small windows contained in the window is smaller, the combined window is more rational.
It should be noted that, for the calculation of the sharpness of the segmented image, since the outer contours of normal blood cells each have a circular shape or an oval shape, if the segmentation result is approximately circular or if the segmentation result is locally approximately circular (locally smooth) due to cell adhesion, the segmentation is considered to be clearer. When blood cells are adhered, the chain codes of the cell images are mutated at the adhesion points of the cells, the whole area chain codes are split into multiple sections of chain codes according to the cell adhesion points, and then each section of chain code meets the uniform change of gradients.
It should be noted that when a mutation occurs in a cell chain code, the current mutation pixel may be an adhesion point, so that the whole chain code is segmented. And after the chain code difference characteristic value of the edge pixel point is 1, splitting the chain code, wherein the length of each small segment of the chain code is approximately equal, and the smaller the change of the length of each small segment of the chain code is, the more the arc characteristic of the gradient change is met. When the number of chain codes satisfying the arc is larger, the possibility that the region is blood cells is proved to be larger, and the definition of the segmented image is larger.
Image of blood cell gray scaleThe target windows are segmented into the first blood cell gray level images by adopting the Ojin algorithmForeground and background regions of the respective target windows;
it is noted that the pixel gray values in the foreground region are smaller than the pixel gray values in the background region.
The region expansion algorithm and the oxford algorithm are known techniques, and specific methods are not described herein.
Calculating the first blood cell gray level image by adopting 8-communication chain code algorithmObtaining the chain code value of each edge pixel point of the foreground region of each target window to obtain the firstA chain code sequence of foreground regions of the respective target windows;
it should be noted that the calculation of the first The edge chain codes of the foreground region of each target window are specifically 8-chain codes, and are marked as 0 in the horizontal right direction and are marked as clockwise in sequenceThe interval of (1) is respectively recorded as 1 to 7, and the edge chain code of the whole connected domain is extracted clockwise by taking any point on the edge of the connected domain as a starting point. And finding out pixel points with the chain code difference characteristic value larger than 2, wherein the pixel points corresponding to the difference chain codes are cell adhesion points, and segmenting the edge according to the pixel points.
In the blood cell gray level imageOn the edge of the foreground region of the target window, the first isAnd the first and secondThe absolute value of the difference value of the code values of the chains of the edge pixel points is recorded as the firstChain code differential characteristic values of the edge pixel points;
the chain code differential characteristic value of the last edge pixel point is the absolute value of the difference value of the chain code value of the last edge pixel point and the first edge pixel point.
Preset threshold value2, Preset threshold value1 Is shown in the specification;
When the blood cell gray level image is the first On the edge of the foreground region of the target window, the firstThe difference characteristic value of the chain codes of the edge pixel points is larger than a preset threshold valueWhen then the firstThe edge pixel points are dividing points, and the edges of the foreground region are divided into a plurality of chain code segments by using all the dividing points;
according to the mode, a plurality of chain code segments of the foreground region of each target window are obtained;
When the blood cell gray level image is the first Foreground region of each target windowOn the code segment of the chainThe difference characteristic value of the chain codes of the edge pixel points is equal to a preset threshold valueWhen then the firstThe edge pixel points are new partition points, and the first partition point is used for all the new partition pointsThe individual chain code segments are divided into a plurality of chain code sequences;
According to the mode, a plurality of chain code sequences of each chain code segment of the foreground region of each target window are obtained;
the first of the blood cell gray scale image Foreground region of each target windowThe calculation method of the probability that each chain code segment meets the arc-shaped characteristic is as follows:
In the formula, First image representing gray level of blood cellsForeground region of each target windowProbability that each chain code segment meets an arc-shaped characteristic; First image representing gray level of blood cells Foreground region of each target windowThe number of all edge pixel points on each chain code segment; First image representing gray level of blood cells Foreground region of each target windowOn the code segment of the chainChain code values of the edge pixel points; First image representing gray level of blood cells Foreground region of each target windowOn the code segment of the chainChain code values of the edge pixel points; First image representing gray level of blood cells Foreground region of each target windowVariance of all chain code sequence lengths in the individual chain code segments; Is an exponential function with a natural constant as a base; as a function of absolute value.
It is to be noted that,First image representing gray level of blood cellsForeground region of each target windowChain code differential characteristic values of edge pixel points corresponding to the chain code segments; First image representing gray level of blood cells Foreground region of each target windowThe average value of the chain code difference characteristic values of all edge pixel points corresponding to each chain code segment is smaller, and the first is representedThe average change degree of each chain code segment is lower, namely the change is more uniform, and the probability of meeting the arc-shaped characteristic is larger.First image representing gray level of blood cellsForeground region of each target windowThe smaller the variance of the lengths of all the chain code sequences in each chain code segment, the more the arc-shaped characteristic of gradient change is satisfied.
So far, the probability that each chain code segment of the foreground region of each target window of the blood cell gray level image meets the arc-shaped characteristic is obtained.
Step S004, obtaining the definition of the foreground region threshold of each target window according to the probability that each chain code segment of the foreground region of each target window of the blood cell gray level image meets the arc-shaped characteristic and the number of the chain code segments, and obtaining the reasonable definition of the foreground region threshold segmentation of each target window according to the definition of the foreground region threshold segmentation of each target window and the adaptability of all small windows in the foreground region of each target window.
The first of the blood cell gray scale imageThe method for calculating the definition of the foreground region threshold of each target window after segmentation is as follows:
In the formula, First image representing gray level of blood cellsDefinition after threshold segmentation of foreground regions of the target windows; First image representing gray level of blood cells Foreground region of each target windowProbability that each chain code segment meets an arc-shaped characteristic; First image representing gray level of blood cells The number of all chain code segments of the foreground region of the target window; Is a normalization function.
It is to be noted that,First image representing gray level of blood cellsThe larger the average value of probabilities that all chain code segments of the foreground region of the target window meet the arc-shaped characteristics is, the more the segmented image meets the morphological characteristics of blood cells, and the higher the segmented definition is; First image representing gray level of blood cells The more the number of all the chain code segments of the foreground region of each target window is, the more finely divided the segmentation is proved, the more the edge change of the chain code sequence is proved to be frequent, and the less the obtained connected domain meets the characteristics of blood cells, the lower the segmentation rationality is.
The method is that the first blood cell gray level image is calculatedThe fitness of each widget in the foreground region of the individual target window.
Calculating the first blood cell gray level imageInverse of variance of fitness of all small windows in foreground region of each target window and the first blood cell gray level imageThe product of the threshold-divided definition of the foreground region of each target window is recorded as the first blood cell gray level imageThe threshold segmentation rationality of foreground regions of the target windows;
the first of the blood cell gray scale image The method for calculating the rationality of threshold segmentation of the foreground region of each target window comprises the following steps:
In the formula, First image representing gray level of blood cellsThe threshold segmentation rationality of foreground regions of the target windows; First image representing gray level of blood cells Definition after threshold segmentation of foreground regions of the target windows; First image representing gray level of blood cells Variance of fitness of all portlets in a foreground region of a target window; Is a normalization function.
It is to be noted that,First image representing gray level of blood cellsThe smaller the variance of fitness of all the portlets in the foreground area of the target window, the smaller the variance, indicating that the fitness of the portlets differ less, indicating the first of the blood cell gray imageThe more reasonable the foreground region merging of the target windows, the more rational theThe greater the rationality of the foreground region threshold segmentation of the individual target windows.First image representing gray level of blood cellsThe greater the definition of the foreground region threshold of each target window, the greater the rationality of threshold segmentation. If a part of a small window is in the foreground area of the target window, the small window also belongs to the foreground area.
So far, the rationality of threshold segmentation of the foreground region of each target window of the blood cell gray level image is obtained.
It should be noted that, the rationality of the division in the window is primarily calculated according to the basic morphology of the blood cells, however, in the process of dividing the white blood cells, since the white blood cells have nuclei, and the outlines of the nuclei of the white blood cells are similar to the morphology of the adherent cells, the local smooth characteristics are satisfied, so that the area divided in the target window in the previous step may be the nucleus area of the white blood cells, rather than the outline of the morphology of the outer edge of the blood cells. It is therefore necessary to further judge whether the threshold setting is reasonable.
Step S005, obtaining a threshold segmentation result of each target window according to the rationality of threshold segmentation of the foreground region of each target window, and obtaining the shape profile of the blood cell wheel through the threshold segmentation result of each target window.
The white blood cell image includes a nucleus, a cytoplasm and a background area, and the judgment of whether the segmented area is the white blood cell nucleus area can be performed by re-segmenting the background area of the segmented image, and when the rationality after re-segmentation is higher than the previously calculated segmentation rationality, the image obtained by the previous segmentation is proved to be possibly the nucleus of the white blood cell. For the calculation of the rationality of the background area re-segmentation, the calculation mode is identical to the mode.
Image of blood cell gray scaleThe background area of each target window is divided into the first blood cell gray level image by adopting the Ojin algorithmA secondarily divided foreground region and background region of the target window;
according to the above mode, calculating to obtain the first blood cell gray level image Threshold segmentation rationality of the secondarily segmented foreground regions of the background regions of the target windows;
When the blood cell gray level image is the first The threshold segmentation of the secondarily segmented foreground region of the background region of the target window is less than or equal to the first thresholdWhen the threshold value of the foreground region of each target window is segmented reasonably, the first step isThe foreground region and the background region divided by the target window are taken as the firstThreshold segmentation results for each target window. When the blood cell gray level image is the firstThe threshold segmentation of the secondarily segmented foreground region of the background region of the target window is more reasonable than that of the firstAcquiring the first threshold value of the foreground region of each target window when the threshold value of the foreground region is partitioned reasonablyStopping segmentation when the rationality of threshold segmentation of the foreground region of any one time is greater than that of the foreground region of any one time later, and taking the background region of any one time and all the foreground regions of any time and the previous time as a first timeThreshold segmentation results for each target window.
According to the mode, the threshold segmentation result of each target window is obtained.
Dividing each small window which is not a target window into a foreground area and a background area by using an Ojin algorithm, acquiring a threshold segmentation result of each small window which is not a target window, combining the threshold segmentation result of each target window to enable the gray value of a pixel point in the foreground area to be 0 and the gray value of the pixel point in the background area to be 1 in the gray image of the blood cell, obtaining a final binary image of the blood cell, and extracting the edge of the final binary image of the blood cell to be the contour of the shape of the blood cell wheel.
The final binary blood cell image is subjected to morphological open operation to remove isolated points.
In this embodiment, when the denominator in the formula is 0, the denominator is 1, and the formula is ensured to be established, which is described as an example.
The embodiment of the invention also provides a blood cell morphology contour acquisition system based on microscopic images, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the steps S001 to S005 are realized when the processor executes the computer program.
This embodiment is completed.
The above description is only of the preferred embodiments of the present invention and is not intended to limit the invention, but any modifications, equivalent substitutions, improvements, etc. within the principles of the present invention should be included in the scope of the present invention.