Disclosure of Invention
In order to solve the technical problem that image edge blurring can be caused by image enhancement by adopting a traditional linear interpolation algorithm, the invention aims to provide a glomerular pathological image enhancement method based on a kidney biopsy slice, and the adopted technical scheme is as follows:
acquiring a glomerular image area in a tissue slice image of a renal biopsy;
Classifying the pixel points of the glomerular image area to obtain at least two categories, and obtaining a category image corresponding to each category; obtaining a gray level change trend sequence of two categories corresponding to the shared edge points according to the change rate of the gray level values of the pixel points in the neighborhood of the shared edge points along the gradient direction of each shared edge point;
the method comprises the steps of inserting blank pixel points into a glomerular image area, obtaining correction necessity according to the category of glomerular image pixel points in the neighborhood of the blank pixel points, screening out blank pixel points to be corrected based on the correction necessity, correcting the pixel values of the blank pixel points to be corrected according to the gray level change trend sequence of the glomerular image pixel points in the neighborhood of the blank pixel points to be corrected, and obtaining an enhanced glomerular enhanced image.
Preferably, the obtaining a gray scale variation trend sequence of two categories corresponding to the shared edge point according to the change rate of the gray scale value of the pixel point in the neighborhood of the shared edge point along the gradient direction of each shared edge point includes:
for each shared edge point, gray value sequences are formed by gray values of pixel points adjacent to the left and right of the shared edge point along the gradient direction of each shared edge point;
Selecting any pixel point in a gray value matrix as a target pixel point, and calculating the difference value of gray values of adjacent pixel points on the right side of the target pixel point and the target pixel point to be used as a first difference value;
And forming two kinds of gray scale change trend sequences corresponding to the shared edge points by the gray scale change trends corresponding to the pixel points of all columns in the gray scale value matrix.
Preferably, the correcting the pixel value of the blank pixel to be corrected according to the gray scale variation trend sequence of the glomerulus image pixel in the neighborhood of the blank pixel to be corrected includes:
When the blank pixel points to be corrected are positioned on a connecting line formed by two glomerular image pixel points in the adjacent area, the blank pixel points to be corrected between the two glomerular image pixel points are constructed into a spacing pixel point sequence according to the position sequence; the method comprises the steps of obtaining the position number of a blank pixel point to be corrected in a space pixel point sequence, obtaining the average value of gray level change rates in a gray level change rate sequence corresponding to the class of a pixel point with smaller gray level value in two glomerular image pixel points as a gray level change rate average value, taking the product of the position number of the blank pixel point to be corrected and the average value of gray level change rates corresponding to the pixel point with smaller gray level value in the two glomerular image pixel points as an adjustment gray level value, taking the sum value of the adjustment gray level value and the smaller gray level value corresponding to the two glomerular image pixel points as a target gray level value, and taking the target gray level value as the corrected gray level value of the blank pixel point to be corrected;
When the blank pixel points to be corrected are positioned on a plurality of connecting lines formed by two glomerular image pixel points in the adjacent area, respectively calculating target gray values corresponding to the blank pixel points to be corrected when the blank pixel points to be corrected are positioned on each connecting line;
and obtaining the gray value of the blank pixel to be corrected by linear interpolation for the blank pixel to be corrected which is not positioned on the connecting line of the two glomerular image pixel points in the adjacent region.
Preferably, the obtaining the correction necessity according to the category of the glomerular image pixel in the neighborhood of the blank pixel includes:
Upwards rounding one half of the number of blank pixel points inserted between adjacent rows and columns, taking two times of the obtained result value as an initial neighborhood side length, and adding one obtained value to the initial neighborhood side length to be taken as the neighborhood side length of the blank pixel points;
Based on the neighborhood side length, the category number of the categories to which the glomerular image pixels in the neighborhood of the blank pixels belong is used as the correction necessity corresponding to the blank pixels.
Preferably, the obtaining a category image corresponding to each category includes:
And multiplying the corresponding mask image with the glomerular image area for each category to obtain a category image corresponding to the category.
Preferably, the screening the blank pixel point to be corrected based on the correction necessity includes:
When the correction necessity is larger than a preset correction threshold, the corresponding blank pixel point is used as the blank pixel point to be corrected.
Preferably, the inserting blank pixels in the glomerular image region includes:
blank pixel points are inserted into adjacent rows and columns of the glomerular image region.
Preferably, the constructing a corresponding gray value matrix according to the gray value sequences of all the shared edge points corresponding to the two categories includes:
And taking the elements in the gray value sequences corresponding to the shared edge points in the two categories as the elements of each row in the gray value matrix to form a corresponding gray value matrix.
Preferably, the classifying the pixels of the glomerular image area to obtain at least two categories includes:
And clustering the pixel points of the glomerular image area by using a k-means algorithm to obtain at least two categories.
Preferably, the acquiring the glomerular image area in the image of the kidney biopsy tissue section comprises:
Semantic segmentation techniques are employed to identify glomerular image regions in images of kidney biopsy tissue sections.
The embodiment of the invention has at least the following beneficial effects:
The method comprises the steps of firstly obtaining a glomerular image area, obtaining a gray level change trend sequence between different types after segmentation, wherein the gray level change trend sequence reflects gray level change trends of two types, combining the gray level change trend sequence to adjust gray level values of blank pixel points to be added between two types of pixel points, adding the blank pixel points in the glomerular image area to improve resolution of the glomerular image area, obtaining correction necessity of the blank pixel points according to the number of the types of the glomerular image pixel points in the neighborhood of the blank pixel points, reflecting the positions of the blank pixel points, reflecting the boundary positions of the blank pixel points when the number of the types of the glomerular image pixel points in the neighborhood is more, reflecting the necessity of the blank pixel points to be corrected in the corresponding type area when the number of the types of the glomerular image pixel points in the neighborhood is more, screening the blank pixel points to be corrected based on the correction necessity, carrying out subsequent correction operation on the blank pixel points to be corrected according to the correction necessity, and carrying out calculation on the obtained blank pixel points to be corrected according to the gray level change trend, and carrying out the correction on the blank pixel points. According to the invention, the resolution of the glomerular image and the definition of the edge are improved by correcting the pixel value of the blank pixel point to be corrected.
Detailed Description
In order to further describe the technical means and effects adopted by the invention to achieve the preset aim, the following description refers to the specific implementation, structure, characteristics and effects of the glomerular pathology image enhancement method based on the kidney biopsy according to the invention by combining the accompanying drawings and the preferred embodiment. 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 embodiment of the invention provides a specific implementation method of a glomerular pathology image enhancement method based on a renal biopsy slice, which is suitable for a glomerular case image enhancement scene. The method aims to solve the technical problem that image edge blurring is caused by image enhancement by adopting a traditional linear interpolation algorithm. The method comprises the steps of firstly obtaining a glomerular image area, obtaining a gray level change trend sequence among different types after segmentation, then adding blank pixel points to improve the resolution of the glomerular image area, obtaining correction necessity of the blank pixel points according to the category number of the glomerular image pixel points in the neighborhood of the blank pixel points, obtaining a pixel gray level value of the blank pixel points by using linear interpolation for the blank pixel points with the correction necessity equal to 1, obtaining the pixel gray level value of the correction blank pixel points according to the gray level change trend sequence for the blank pixel points to be corrected with the correction necessity greater than 1, and further obtaining the reinforced glomerular image after the enhancement.
The specific scheme of the glomerular pathological image enhancement method based on the kidney biopsy slice provided by the invention is specifically described below with reference to the accompanying drawings.
Referring to fig. 1, a flowchart of a method for enhancing glomerular pathology image based on a biopsy of a kidney according to an embodiment of the present invention is shown, the method comprises the following steps:
Step S100, acquiring a glomerular image area in a renal biopsy tissue slice image.
Obtaining a kidney biopsy tissue slice image, and identifying a glomerulus image area in the kidney biopsy tissue slice image by adopting a semantic segmentation technology. Specific:
The used data is a kidney biopsy tissue slice image data set obtained in the acquisition process of the invention, pixels to be segmented in the kidney biopsy tissue slice image are divided into two types, namely, the corresponding label labeling process of the training set is a single-channel semantic label, the pixels corresponding to the positions are labeled 0, the pixels belonging to the non-glomerular image are labeled 1, and the task of the network is classification, so that the used loss function is a cross entropy loss function.
And inputting the obtained to-be-processed renal biopsy tissue slice image into a neural network after training, and obtaining a glomerulus image area in the renal biopsy tissue slice image.
Step S200, classifying the pixel points of the glomerular image area to obtain at least two categories, acquiring category images corresponding to each category, obtaining shared edge points overlapped in any two category images based on the edge points in each category image, and obtaining gray scale change trend sequences of the two categories corresponding to the shared edge points according to the change rate of gray scale values of the pixel points in the neighborhood of the shared edge points along the gradient direction of each shared edge point.
The colors of the parts in the glomerulus image area are obviously different after being dyed by the dyeing agent, the glomerulus image area can be segmented by using a k-means algorithm, and the k-means is a very classical clustering algorithm and can be used for image segmentation in image processing. And obtaining the gray scale variation trend of the pixels at the boundary edges of various pixels. After inserting blank pixel points among different types of pixels, if linear interpolation is used, even gray level change among the different types of pixel points can cause blurring and unobvious edges in the enhanced image, but if gray level values of the blank pixel points are determined by the gray level change trend, gray level change of the blank pixel points accords with gray level change condition of an original image, and the edge definition of the enhanced image is obviously improved.
Firstly, dividing an obtained glomerular image area by using a k-means algorithm, classifying the pixels in the glomerular image area into N categories, and classifying the pixels in the glomerular image area by using the k-means algorithm to obtain at least two categories.
And obtaining a class image corresponding to each class after obtaining a plurality of classes, specifically obtaining a mask image corresponding to each class, and multiplying the corresponding mask image and the glomerular image area for each class to obtain a class image corresponding to the class. The mask image is a class image of the i-th class pixel obtained by multiplying the i-th class pixel by the glomerular image region point by point, wherein the pixel value of the mask image is assigned to 1, and the gray value of the rest pixels is assigned to 0 for the pixels classified as i (i=1, 2,., N).
Further, edge detection is carried out on the class images corresponding to the classes by using a canny operator, so that edge points of the classes are obtained, and the edge points in the class images are obtained. And obtaining the coincident shared edge points in any two category images based on the edge points in each category image.
And obtaining a shared edge point at the junction of any two types of pixels, namely obtaining the coincident shared edge point in the two types of images. Adjacent pixels of different classes share a boundary, and edge detection is performed on the pixels of the two classes, and edge detection results are coincident at the boundary. The coincident edge points detected by the edges in the two categories are the shared edge points.
Further, along the gradient direction of each shared edge point, according to the change rate of the gray value of the pixel point in the neighborhood of the shared edge point, two types of gray change trend sequences corresponding to the shared edge point are obtained. The two kinds of gray scale change trend sequences can also be said to be the gray scale change trend sequences of glomerular image pixels in the two kinds of glomerular images. The gray level change trend sequence is obtained, and specifically:
and for each shared edge point, forming a gray value sequence by gray values of pixel points adjacent to the left and right of the shared edge point along the gradient direction of each shared edge point, and constructing a corresponding gray value matrix according to all the shared edge points corresponding to the two categories. And taking the elements in the gray value sequences corresponding to the shared edge points in the two categories as the elements of each row in the gray value matrix to form a corresponding gray value matrix. The elements in the gray value matrix are the gray values of the pixel points at the corresponding positions. It should be noted that, when the direction in which the shared edge points appear is the transverse direction, the sequence of each row of gray value sequences in the gray value matrix is ordered according to the sequence of the shared edge points in the transverse direction, the preset direction may be left to right or right to left at this time, when the direction in which the shared edge points appear is the longitudinal direction, the sequence of each row of gray value sequences in the gray value matrix is ordered according to the sequence of the shared edge points in the longitudinal direction, the preset direction may be top to bottom or bottom to top at this time, and when the shared edge points form an arc, the sequence of each row of gray value sequences in the gray value matrix is ordered according to the sequence of the shared edge points in the direction in which the arc appears, with the end point of the arc as the starting point, that is, the sequence of each row of gray value sequences in the gray value matrix is ordered according to the sequence of the shared edge points in the direction in which the arc appears, that is the sequence of the shared edge points in the gray value matrix is ordered according to the extending sequence of the shared edge points.
In the embodiment of the invention, gray values of 7 pixel points are respectively taken from the left side and the right side of the shared edge point along the gradient direction of the shared edge point to form a gray value sequence, for one shared edge point, the gray values of the shared edge point are added, 15 gray values are shared in the gray value sequence corresponding to the shared edge point, and in other embodiments, the number of the gray values in the gray value sequence corresponding to each shared edge point can be adjusted by an implementer according to actual conditions. The gray value sequence corresponding to each shared edge point reflects gray fluctuation conditions of the adjacent areas of the shared edge points.
Selecting any pixel point in a gray value matrix as a target pixel point, calculating the difference value of gray values of adjacent pixel points on the right side of the target pixel point and the target pixel point to be used as a first difference value, taking the ratio of the first difference value to the gray value of the target pixel point as the gray change rate corresponding to the target pixel point, calculating the average value of the gray change rates corresponding to each column of pixel points in the gray value matrix to be used as the gray change trend corresponding to the column, and forming a gray change trend sequence by the gray change trend corresponding to all columns of pixel points in the gray value matrix. The number of gray level change trends in the gray level change trend sequence is the same as the number of columns of the gray level value matrix. The gray scale change trend sequence reflects gray scale change trends between two categories corresponding to the corresponding gray scale value matrix. The first difference value is the gray level difference of the target pixel point and the adjacent pixel points on the right side of the target pixel point, the gray level difference reflects the gray level value similarity condition of the two pixel points, and the blank pixel points which are subsequently inserted into the glomerular image area are adjusted based on the gray level value similarity condition of the two pixel points, so that the blank pixel points can be more in line with the change trend of the two adjacent categories after the blank pixel values are inserted, and the condition that the edges of the enhanced image are blurred is reduced.
Step S300, inserting blank pixel points into the glomerulus image area, obtaining correction necessity according to the category of glomerulus image pixel points in the neighborhood of the blank pixel points, screening out blank pixel points to be corrected based on the correction necessity, and correcting the pixel values of the blank pixel points to be corrected according to the gray scale change trend sequence of the glomerulus image pixel points in the neighborhood of the blank pixel points to be corrected, so as to obtain the enhanced glomerulus enhanced image.
Blank pixel points are inserted in adjacent rows and columns of the glomerular image area so as to enlarge the size of the glomerular image area and improve the resolution. And then obtaining the correction necessity of the blank pixel according to the category number of the glomerular image pixel in the neighborhood of the blank pixel. If the glomerulus image pixel point in the neighborhood of a certain blank pixel point belongs to one category, the fact that the blank pixel point is in a region corresponding to the category is indicated that linear interpolation is used, the edge definition is not affected, and correction is not needed, and if the glomerulus image pixel point in the neighborhood of the blank pixel point belongs to two categories and more, the fact that the blank pixel point is located at the boundary of edges corresponding to a plurality of categories is indicated that linear interpolation can affect the edge definition, interpolation is needed according to the gray level change trend of the glomerulus image region, so that edges with higher definition are obtained, and enhancement of the glomerulus image region is achieved through more accurate interpolation.
B-1 blank pixel points are inserted between adjacent rows of pixel points of the glomerular image area, and b-1 blank pixel points are inserted between adjacent columns of pixel points, so that the glomerular image area is enlarged b times. Note that, the blank pixel is a pixel having a gray value of 0. In the embodiment of the present invention, the value of b is 4, and in other embodiments, the practitioner may adjust the value according to the actual situation. For example, 1 blank pixel is inserted between adjacent rows of pixels in the glomerular image region, 1 blank pixel is inserted between adjacent columns of pixels to expand the glomerular image region by 2 times, 3 blank pixels are inserted between adjacent rows of pixels in the glomerular image region, and 3 blank pixels are inserted between adjacent columns of pixels to expand the glomerular image region by 4 times.
And obtaining the correction necessity according to the category of the glomerular image pixel points in the neighborhood of the blank pixel points.
And (3) carrying out upward rounding on one half of the number of the blank pixel points inserted between the adjacent rows and columns, and taking the double of the result value obtained by the upward rounding as the initial neighborhood side length. The result value obtained by adding one to the initial neighborhood side length is taken as the neighborhood side length of the blank pixel pointI.e. according to blank pixelsThe correction necessity is obtained by the number of categories to which the glomerular image pixels in the neighborhood belong, specifically, the blank pixels are subjected to The number of categories of the categories to which the glomerular image pixels in the neighborhood belong is used as the correction necessity corresponding to the blank pixels.
Further, blank pixel points to be corrected are screened out based on the correction necessity. When the correction necessity is larger than a preset correction threshold, the corresponding blank pixel point is used as the blank pixel point to be corrected. In the embodiment of the present invention, the preset correction threshold value is 1, and in other embodiments, the practitioner may adjust the value according to the actual situation. When the correction necessity corresponding to the blank pixel point is greater than 1, reflecting that the blank pixel point is positioned at the junction of the two types of glomerular image pixel points, the gray value of the blank pixel point is determined by the gray change trend between the two types of glomerular image pixel points and the linear interpolation is not directly used, and when the correction necessity corresponding to the blank pixel point is equal to a preset correction threshold value, the gray value of the blank pixel point is directly obtained by linear interpolation based on the gray value of the glomerular image pixel point in the neighborhood of the blank pixel point. That is, when the correction necessity corresponding to the blank pixel point is 1, the gray value of the blank pixel point can be directly obtained by linear interpolation, reflecting the inside of the glomerular image pixel point of a certain type. As another embodiment of the present invention, the gray value average value of the pixels in the glomerular image region may be used as the gray value of the blank pixels having the correction necessity of 1.
After the blank pixel point to be corrected is obtained, correcting the pixel value of the blank pixel point to be corrected according to the gray scale change trend sequence of the glomerular image pixel point in the neighborhood of the blank pixel point to be corrected, and specifically:
When the blank pixel point to be corrected is positioned on a connecting line formed by two glomerular image pixel points in the adjacent area. The method comprises the steps of constructing a space pixel point sequence by using blank pixels to be corrected between two glomerular image pixels according to a position sequence, obtaining the position number of the blank pixels to be corrected in the space pixel point sequence, taking the product of the position number of the blank pixels to be corrected and the average value of gray change rates corresponding to pixels with smaller gray values in the two glomerular image pixels as an adjustment gray value, taking the sum value of the adjustment gray value and the smaller gray values corresponding to the two glomerular image pixels as a target gray value, and taking the target gray value as the gray value of the corrected blank pixels. The method is characterized in that the glomerular image pixel points related to the blank pixel points to be corrected are used for correcting the blank pixel points to be corrected, and compared with a method directly utilizing linear interpolation, the method reduces the occurrence of the condition of edge blurring when the gray value of the blank pixel points to be corrected is determined.
When the blank pixel points to be corrected are positioned on a plurality of connecting lines formed by two glomerular image pixel points in the neighborhood, respectively calculating target gray values corresponding to the blank pixel points to be corrected when the blank pixel points to be corrected are positioned on each connecting line, and taking the average value of the target gray values corresponding to the blank pixel points to be corrected as the gray values of the blank pixel points to be corrected after correction. When the blank pixel points to be corrected are positioned on a plurality of connecting lines formed by two glomerular image pixel points in the neighborhood, the blank pixel points to be corrected are adjusted by taking the average value, so that the blank pixel points to be corrected are determined according to the multi-directional gray change trend.
And obtaining the gray value of the blank pixel point to be corrected by linear interpolation for the blank pixel point to be corrected which is not positioned on the connecting line of the two glomerular image pixel points in the adjacent region, namely directly obtaining the gray value corresponding to the blank pixel point to be corrected by linear interpolation. The probability that the blank pixel point to be corrected is positioned between two categories is smaller when the blank pixel point to be corrected is not positioned on the connecting line of the two glomerular image pixel points in the adjacent area, and the gray value of the blank pixel point to be corrected is obtained by using a linear interpolation method, so that the condition that the glomerular image has blurred edges can not occur.
And (3) performing the operations of the steps S100-S300 on each glomerulus image area in the kidney biopsy tissue slice image, mapping the enhanced glomerulus image area into a blank image, obtaining an enhanced glomerulus enhancement image, and enhancing the glomerulus image area.
In summary, the present invention relates to the field of image processing technology. The method comprises the steps of firstly obtaining a glomerular image area, obtaining a gray level change trend sequence among different types after segmentation, then adding blank pixel points to improve the resolution of the glomerular image area, obtaining correction necessity of the blank pixel points according to the category number of the glomerular image pixel points in the neighborhood of the blank pixel points, obtaining a pixel gray level value of the point by using linear interpolation for the blank pixel points with the correction necessity equal to 1, obtaining the pixel gray level value of the correction blank pixel points according to the gray level change trend sequence for the blank pixel points to be corrected with the correction necessity greater than 1, and further obtaining the reinforced glomerular image by accurately interpolating.
It should be noted that the sequence of the embodiments of the present invention is only for description, and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments.