Summary of the invention
The object of the present invention is to provide a kind of lung dividing method, for improving the effect of lung segmentation.
In order to realize aforementioned invention object, the invention provides a kind of lung dividing method, comprising the following steps:
A kind of lung dividing method, comprises the following steps:
Step S1, input original image, carry out pre-service to original image;
The coarse segmentation in step S2, lung region; Step S2 comprises: step S201, setting threshold value, Threshold segmentation is used to carry out binary conversion treatment to pretreated image, extract lung areas and the part background close with lung areas gray-scale value (white in Fig. 4 outside lung, background all refers to all regions outside lung); Step S202, from image four corner edge obtained after step S201 process, backfill is carried out to part background; Step S203, find out the lung of maximum one deck of area from z direction down, the crown; Step S204, to be undertaken on z direction forward by the lung of maximum one deck and successively region growing backward, successively judge, prevent and background adhesion;
Step S3: the segmentation in lung region is cut, for extracting and removing tracheae and be separated pulmo.
Preferably, described threshold value is-500HU.
Preferably, the method successively judged is mark current layer is CurrentSlice, propagation layer is then SpreadSlice, obtain the ratio of the number summation of lung region point on the number summation of lung region point on SpreadSlice and CurrentSlice, if ratio is less than 0.4 or be greater than 2.25, then be judged as leaking to background, stop growth; If ratio is more than or equal to 0.4 and be less than or equal to 2.25, be then judged as not leaking to background, continued growth.
Preferably, step S204 also comprises and judging by asking for connected region to the lung of maximum one deck in two dimension: be that each point of 1 is as Seed Points using image intermediate value, then Seed Points is carried out region growing, if only obtain a connected region, just using the initial growth layer of this connected region as lung; If obtain multiple connected region, get maximum two connected regions as the initial growth layer of lung, remove other connected regions.
Preferably, when successively judging to start, setting current layer is initial growth layer.
Preferably, in step S202, the back-filled method of background carries out region growing inward from four frames of image, grows to chest area, and namely value is that 0 place stops, and the value assignment in the place simultaneously region growing crossed is 0.
Preferably, in step S202, the method for region growing is: first select one group of Seed Points, Seed Points can be four frames of image, then searches 8 neighborhoods of Seed Points, if the mark value of 8 neighborhoods is consistent with Seed Points, then the point of 8 neighborhoods is also joined Seed Points, ceaselessly grow, until run into the point of 8 neighborhoods and Seed Points inconsistent, then stop growth, be simultaneously 0 the local assignment grown, be background.
Preferably, be the number of 1 by successively accumulated value in step S203, choose the lung of the maximum one deck of number as maximum one deck.
Preferably, the method extracting tracheae in step S3 is: ask for two-dimentional connected region and three-dimensional communication region, traversal from the z direction initial layers down of the crown, the area circularity of two-dimentional connected region is greater than 0.5, three-dimensional communication region maximum as trachea-seed point, then with level set algorithm, tracheae is extracted.
Preferably, step S3 also comprises: generate lung mask needed for Lung neoplasm and the lung mask needed for workstation display and merge.
The present invention, by successively contrasting judgement, prevents and background adhesion, significantly improves the effect of lung segmentation, in addition, accelerates splitting speed.
Embodiment
Below in conjunction with the drawings and specific embodiments, the present invention is described in further detail.According to the following describes and claims, advantages and features of the invention will be clearer.It should be noted that, accompanying drawing all adopts the form that simplifies very much and all uses non-ratio accurately, only in order to object that is convenient, the aid illustration embodiment of the present invention lucidly.
Please refer to shown in Fig. 1, the lung dividing method in the embodiment of the present invention comprises the following steps:
Step S1: input original image, carries out pre-service to original image.
As shown in Figure 3, original image is the chest CT image meeting DICOM3.0 standard that CT device scan obtains.Pre-service adopt method be that noise reduction process is carried out to original image, such as carry out Gaussian smoothing, Gaussian smoothing be by Gaussian filter on x, y, z three directions respectively by following formula:
Generate the gaussian kernel of Gaussian filter (GaussianSmoothingFilter), and then be weighted summation with each pixel in original image.Weighted sum carries out convolution to the original gray value of each pixel in image and gaussian kernel, cumulative summation acquired results is as the gray-scale value of each pixel, and the effect reached eliminates artifact, removes noise, improve picture quality, avoid noise to cause adverse effect to follow-up segmentation.
σ in above-mentioned formula2for variance, determine the width of Gaussian function, namely determine smoothness, what x represented is the distance of current pixel point to corresponding pixel points.
Step S2: the coarse segmentation in lung region.
The object of coarse segmentation mainly comprises tracheae, lung.Pretreated image is three-dimensional data, and for ease of the process of coarse segmentation being described, random selecting one number of cases certificate, and intercept its image of the 121st layer, this image is two dimensional image.
Step S2 comprises the following steps:
Step S201: setting threshold value, Threshold segmentation is used to carry out binary conversion treatment to pretreated image, extract lung areas and part background, part background refers to the white in the part background close with lung areas gray-scale value and Fig. 4 outside lung, and whole background refers to all regions outside lung.
In the present embodiment, threshold value (Threshold) is chosen to be-500HU, the value (mark value) being greater than the region of threshold value is set to 0, the value (mark value) being less than the region of threshold value is set to 1, the value (mark value) of background is 0, the value (mark value) of lung is 1, thus by chest area, the major part comprising lung areas and background all extracts, specifically as shown in Figure 4.
Step S202: background backfill from image four corner edge, thus extract lung areas and a small amount of bed board, specifically as shown in Figure 5, lung areas is white bulk region, and bed board is the white short-term bar below lung areas.
The back-filled method of background carries out region growing inward from four frames of image, grow to chest area, namely value (mark value) is that 0 place stops, value (mark value) assignment in the place simultaneously region growing crossed is 0, then calculate two-dimentional connected region, remove little connected region and namely remove the region that connected domain number is less than 10.The computing method of two dimension connected region are identical with asking the method for two-dimentional connected region in step S204.
The method of region growing is: first select one group of Seed Points, Seed Points can be four frames of image, then 8 neighborhoods of Seed Points are searched, if the mark value of 8 neighborhoods is consistent with Seed Points, then the point of 8 neighborhoods is also joined Seed Points, ceaselessly grow, until run into the point of 8 neighborhoods and Seed Points inconsistent, then stop growth, be simultaneously 0 the value in the place grown (mark value) assignment, be background.
Step S203: adopt Area comparison method, in three-dimensional picture, finds the lung of maximum one deck of area from z direction down, the crown.
The method adopted is that on z direction, successively accumulated value (mark value) is the number of 1, and choose maximum, what the present embodiment was selected is the 141st layer, as shown in Figure 7.
Step S204: to be undertaken on z direction forward by the lung of maximum one deck and successively region growing backward, successively judge, prevent from leaking to background, namely prevent and background adhesion.
If the lung elected also comprises some noises, judgement removal can be carried out by asking for connected region in two dimension.If only obtain a connected region, Fig. 7 is exactly this situation, just using the initial growth layer of this connected region as lung, is labeled as LungLabel.If obtain multiple connected region, get maximum two connected regions as the initial growth layer of lung, be labeled as LungLabel simultaneously, remove other connected regions.
Ask the method for two-dimentional connected region: similar with region growing, difference is the selection of Seed Points, two dimension connected region is that each point of 1 is as Seed Points using image intermediate value (mark value), then by its region growing, will be classified as a class similar in image like this, Fig. 7 obtains a connected region.Fig. 8 obtains 3 connected regions, i.e. three pieces of white portions, extracts two largest connected regions.
Above step is exactly lung region on the initial layers (StartSlice) in order to look for lung (LungLabel, lung marks), then carries out forward successively region growing backward.Adopt multithreading, allow forward and carry out backward simultaneously.
Mark current layer is CurrentSlice, and propagation layer is then SpreadSlice.
When just starting, CurrentSlice=StartSlice;
Back-propagation, SpreadSlice=CurrentSlice+1;
Forward direction, SpreadSlice=CurrentSlice-1;
CurrentSlice will be labeled as the point of LungLabel as Seed Points, calculate its point on SpreadSlice, if this point value (mark value) is 1, then it can be used as the Seed Points on SpreadSlice.Then carry out region growing, be lunglabel by the some assignment grown simultaneously.
According to Rule of judgment, determine whether it leaks to background, concrete determination methods is the ratio of the number summation first obtaining LungLabel point on the number summation of LungLabel point on SpreadSlice and CurrentSlice.
Because lung is continually varying in a z-direction, therefore, background area can be grown to by ratio in judgement eliminating.If ratio is less than 0.4 or be greater than 2.25, be then judged as leaking to background, stop growth; If ratio is more than or equal to 0.4 and be less than or equal to 2.25, be then judged as not leaking to background, continued growth.
Continue after having judged to propagate (region growing) process, now
CurrentSlice=SpreadSlice;
Back-propagation, SpreadSlice=CurrentSlice+1;
Forward direction, SpreadSlice=CurrentSlice-1;
Continue ratio calculated, judge.
By successively judge compare, can Leakage prevention to background, also just save and leak to background many time spents, and adopt multithreading, can pick up speed.
Step S3: the segmentation in lung region is cut, and specifically comprises the steps:
Step S301: extract and remove tracheae.Ask for two-dimentional connected region and three-dimensional communication region, trachea-seed point is looked for according to the area circularity of two-dimentional connected region and the volume size in three-dimensional communication region, traversal from the z direction initial layers down of the crown, the area circularity of two dimension connected region is greater than 0.5, three-dimensional communication region maximum as trachea-seed point, then with level set algorithm, tracheae is extracted, and it is removed from lung mask.
Step S302: be separated pulmo, carry out morphology closed operation respectively, the cavity (blood vessel) in lung mask is tamped.Because the lung mask needed for Lung neoplasm requires different with the lung mask that workstation shows, need to be distinguished.Described pulmo refers to two lung tissues in left and right or pulmonary parenchyma part.
Step S3031: consider that the tubercle on lung wall may be undetected, so by lung Mask toward extending out a circle, need adopt morphological dilations method, thus the tubercle on guarantee lung wall is in lung mask, generates the lung mask needed for Lung neoplasm.
Step S3032: and for display mask, tracheae need be shown, so the tracheae extracted before being added by lung mask, generate the lung mask needed for workstation display, specifically can join Fig. 9.First tracheae being done morphology closed operation, for preventing tracheal wall from losing, carrying out morphological dilation.In order to make display more clear, lung mask is carried out morphological erosion operation.
So far, the lung mask needed for Lung neoplasm and the lung mask needed for workstation interface display all generate.
Step S304: in order to save internal memory, merges the lung mask needed for the lung mask needed for Lung neoplasm and display, draws final lung mask.Reach the effect of fusion in order to pick up speed, adopt with the following method:
First set lung mask (LungMask)=4, represent that background is 4, being changed to scale-of-two is then 0100.
Then allow the lung mask needed for lung mask and Lung neoplasm merge, carry out or operate with 1, being changed to scale-of-two is then 0001.
0100|0001=0101, also just represents the lung mask of 5 expressions needed for Lung neoplasm.
Most relief lung mask merges with the lung mask needed for display, and carry out with 2 or operate, being changed to scale-of-two is then 0010;
0100|0010=0110, also just represents that 6 represent the lung mask needed for showing;
0101|0010=0111,7 represent the lung mask be needed for Lung neoplasm, the lung mask again needed for display;
To sum up be summarized as follows: during LungMask=5 or 7, represent the lung mask needed for Lung neoplasm;
During LungMask=6 or 7, represent the lung mask needed for workstation interface display;
During LungMask=4, represent background;
So far only need a lung mask, just can represent the lung mask needed for Lung neoplasm and the lung mask needed for display respectively.
The lung dividing method of the above embodiment of the present invention can be implemented in the computer-readable medium of the such as combination of computer software, hardware or computer software and hardware.For hardware implementation, embodiment described in the present invention can at one or more special IC (ASIC), digital signal processor (DSP), digital signal processor (DAPD), programmable logic device (PLD) (PLD), field programmable gate array (FPGA), processor, controller, microcontroller, microprocessor, be implemented for the selection combination performing other electronic installation of above-mentioned functions or said apparatus.In some circumstances, this kind of embodiment can be implemented by controller.
For implement software, embodiment described in the present invention by such as program module (procedures) sum functions module (functions) etc. independently software module implemented, wherein each module performs one or more function described herein and operation.Software code is implemented by the application software of writing in suitable programming language, can be stored in internal memory, is performed by controller or processor.
Although the present invention describes with reference to current specific embodiment, but those of ordinary skill in the art will be appreciated that, above embodiment is only used to the present invention is described, change or the replacement of various equivalence also can be made when not departing from spirit of the present invention, therefore, as long as all will drop in the scope of claims of the application the change of above-described embodiment, modification in spirit of the present invention.