Vitiligo area segmentation method based on pixel clustering and segmentation threshold
Technical Field
The invention belongs to the field of digital image processing, and relates to a vitiligo region segmentation method based on pixel clustering and a segmentation threshold.
Background
Vitiligo is a common skin depigmentation disease, and is mainly characterized in that white spot skin lesions with irregular sizes are formed on the body surface and are a disease which seriously influences the appearance and the beauty, the white spot area is an important evaluation index of clinical treatment effect, and the basis for measuring the white spot area is to accurately segment the white spot area.
With the development of image processing technology, traditional white spot area measurement methods, such as visual estimation, point estimation, and grid method, are gradually replaced by measurement methods based on image analysis due to their strong subjectivity and lack of objective measurement standards. The method can realize non-contact measurement, is objective and accurate, but due to the limitation of a plurality of factors such as picture shooting environment, shooting equipment, the self chromaticity of the skin of a patient and the like, the method can realize high-efficiency leucoderma area and accurate segmentation, for example, a K mean value clustering method based on a mixed color space adopts the method of converting an input RGB image into CIELAB, HSV and YCbCr spaces for K mean value clustering segmentation, but the method needs to cluster in three spaces at the same time, has large calculation amount, is difficult to effectively process the image with high resolution ratio, and takes pixel points as the minimum unit for segmentation; the method of manually dividing the vitiligo area and marking the edge by using tools such as Photoshop, Image J and the like has accurate effect but complicated operation; the method for extracting the vitiligo skin damage edge based on the snake model and by using the level set algorithm requires that the initial contour of the target area is given first, and the algorithm is sensitive to noise and has high equipment requirement. The method of combining the YCbCr color space with Fuzzy C-means (FCM) clustering is used, although good segmentation effect is achieved, the method cannot adapt to the situation of small picture contrast.
Therefore, according to some defects of the existing method, such as large calculation amount, complex operation, high requirements on shooting equipment, only being suitable for pictures with strong contrast and the like, the invention discloses a vitiligo region segmentation method which is efficient, simple, strong in robustness and not limited by the shooting equipment. The method comprises the steps of firstly carrying out clustering center segmentation on an image, and then manually setting a threshold value to realize the segmentation of the vitiligo area. In the present method, the cluster center is defined as: and the small region consists of the pixel points which are communicated in the digital image and have similar characteristics. These small regions retain significant information needed for further image segmentation and retain the boundary information of white spots in the image.
Disclosure of Invention
The purpose of the invention is as follows: the invention provides a vitiligo region segmentation method based on pixel clustering and a segmentation threshold value, which is used for segmenting a vitiligo region. The method can still perform efficient and accurate segmentation under the condition that the image has noise, high resolution and low contrast, and accurately segments the vitiligo area through an image processing technology.
The technical scheme is as follows: in order to realize the purpose of the invention, the technical scheme adopted by the invention is as follows: a vitiligo region segmentation method based on pixel clustering and segmentation threshold comprises the following steps:
(1) acquiring a face region image of a patient;
(2) carrying out Gaussian blur or median filtering on the image to remove noise;
(3) carrying out pixel clustering on the image obtained by the processing in the step (2);
(4) and determining a segmentation threshold, and segmenting the image based on pixel clustering to obtain a vitiligo region image.
Further, in step (2), if there is a highlight region in the image, highlight suppression processing is performed.
Further, in the step (3), the image clustering method is characterized by:
(3-1) when the collected RGB image is converted into a Lab color model, transition is carried out through an XYZ color model, and the formula is as follows:
wherein p isR,pB,pGRGB color components of pixel p, respectively;
(3-2) converting the input RGB image into Lab color space:
wherein, delta is a preset value, Xn,Yn,ZnAs a reference value for the white point in the XYZ color space;
(3-3) initializing the number of the clustering seed points according to the size of the input image, wherein the formula is as follows:
wherein N iscThe number of the clustering seed points is W and H are the width and the height of the image respectively,ρ is defined herein as the density of seed points, with a value range of [0, min (W, H)];
(3-4) setting the pixel with the coordinate of (rho ) as a first seed point, taking rho as a step length, initializing the rest seed points on the position of the intersection point in a checkerboard mode, and then combining the seed point set into a seed point set
Taking the seed point as an initialization clustering center and marking as C
k=[l
k,a
k,b
k,x
k,y
k],k=1,2,…,N
cWherein l is
k,a
k,b
kRespectively, the position coordinates of the image in Lab space are (x)
k,y
k) The L, a, b components of the corresponding pixel points are located;
(3-5) moving the seed point to a position where the gradient of the L channel is minimum in the Lab model in a field of a size of 3 x 3 with the seed point as a center so as to prevent the seed point from falling on the edge of the image or at a noise;
(3-6) the specific method of the image pixel clustering process is as follows:
(3-6-1) initializing the tag array l (i) ═ 1, the distance array d (i) ═ infinity, and the maximum number of iterations N for each pixel point iiter;
(3-6-2) with CkCentered on this, within a region of size 2 ρ × 2 ρ, the following operations are performed for each pixel i: calculating pixel i and cluster center CkA distance D of (D); if D is<D (i), let D (i) D, (i) k;
(3-6-3) judging whether all the clustering centers are traversed or not, if so, continuing; otherwise, returning to the step (3-6-2);
(3-6-4) updating all the clustering centers;
(3-6-5) judging whether the maximum iteration number N is reachediterIf yes, ending; otherwise, returning to the step (3-6-2).
Further, in step (3-6-2), the distance D between the pixel i and the pixel j is defined as a weighted sum of the spatial distance and the color distance:
wherein, the coordinates of the pixel point i and the pixel point j are respectively (x)i,yi),(xj,yj) In Lab space, the pixel values are (l)i,ai,bi),(lj,aj,bj),DsIs the spatial distance of two pixels, DcIs the distance of two pixels in Lab color space, Cs,CcRespectively, the normalized constant terms of the space distance and the color distance, and the pixel i and the clustering center C are calculated by adopting the methodkDistance D of (D).
Further, in the step (3-6-4), the method for updating all the cluster centers is as follows:
wherein N iskIs the number of pixels labeled k.
Further, the image pixel clustering in the step (3-6) further comprises the following steps:
(3-7-1) initializing label ═ 0, adjacent ═ 0, initializing empty queue Q, initializing array new
clusterAll initial values are set to-1, order
Initializing an array V, and recording the number of pixel points contained in the image as N
pLet i equal to 0;
(3-7-2) taking the label array l obtained in the step (3-6);
(3-7-3) if i<NpThen continuing the following steps; otherwise, ending;
(3-7-4) if new _ cluster [ i)]If the pixel i is equal to-1, the pixel i enters the queue Q, and four adjacent domain pixel points of the pixel i are traversed according to the left-up-right-down sequence, namely, four upper, lower, left and right pixel points adjacent to the pixel i in the image size range are marked as itIf t is 1,2,3,4, if new _ clusters [ it]If the value is more than or equal to 0, updating adjcent to new _ clusters [ i ≧ 0t];
(3-7-5) making count ═ 1;
(3-7-6) dequeuing the head pixel in the queue Q, marking as a pixel j, and storing the j to an array V;
(3-7-7) traversing pixel points of four neighborhoods of j, namely, in the image size range, four pixel points of upper, lower, left and right adjacent to the pixel j are marked as jtIf t is 1,2,3,4, if new _ clusters [ jt]Is ═ 1, and l [ i ═ 1]==l[jt]Then let jtEnter queue and let new _ cluster [ j ]t]Equal to label, count equal to count + 1; otherwise, entering (3-7-8);
(3-7-8) if the queue Q is empty, entering (3-7-9); otherwise, returning to the step (3-7-6);
(3-7-9) if count is less than or equal to TmThen, go through the point in the access array V, note the current access point as z, let new _ cluster [ z]After traversing is completed, clearing the array V;
(3-7-10) allowing label + 1;
(3-7-11) letting i ═ i +1, return to (3-7-3);
(3-7-12) taking the obtained new _ cluster as a new cluster label array, and recording n image sub-regions after re-clustering;
(3-7-13) recalculating the cluster center using the following formula:
is marked as
In (1)
As an abstract feature representation of all pixels in the region represented by it.
Further, in the step (4), a segmentation threshold is determined, and the image is segmented based on pixel clustering to obtain a vitiligo region image, wherein the method comprises the following steps:
(4-1) randomly sampling pixel points in the vitiligo area by using a cursor, and recording the total sampling NsPoint with sampling point of Si,i=1,2,…,NsThen the L, a, b components of the sampling point are SiL,Sia,SibThen the required threshold value T is dividedlowAnd ThighCan be determined by the following rules:
(4-2) traversing all the pixel cluster centers if
This cluster center is labeled as white spot skin lesion area, otherwise as normal skin.
Has the advantages that: compared with the prior art, the technical scheme of the invention has the following beneficial effects:
1. the operation is simple and convenient, and no special requirements are required for hardware equipment.
2. The method can be suitable for the situations that the white spot boundary is fuzzy and the image contrast is low.
3. Since the cluster center is introduced as a representative of a block of regions, rapid segmentation can be achieved even when a high-resolution image is processed.
4. The segmented image is not easy to generate holes and does not depend on later morphological processing.
Drawings
FIG. 1 is a flow chart of a vitiligo region segmentation method based on a clustering center and a threshold;
FIG. 2 is an example of a vitiligo region segmentation method based on a cluster center and a threshold;
fig. 3 shows two examples of the vitiligo region segmentation method based on the cluster center and the threshold.
Detailed Description
The technical solution of the present invention is further described below with reference to the accompanying drawings and examples.
(1) Picture acquisition
The affected part can be photographed by using a mobile phone, a camera and professional medical equipment, the skin occupies the main part of the picture, but the affected part still can contain irrelevant areas such as partial background, clothes, hair and the like, and the environment with soft light rays is selected as much as possible during photographing.
(2) Image pre-processing
According to specific conditions, carrying out Gaussian blur or median filtering on the image to remove noise; if there is a highlight region in an image, highlight suppression is performed. The purpose of this step is to remove noise and smooth sharp edges in the hair region to avoid excessive irregular shapes and holes when the cluster center is segmented. Because local highlight areas caused by oil on the surface of the skin are difficult to avoid when the photo is taken, color information is covered, the clustering center segmentation effect is poor, and the highlight areas are required to be inhibited firstly.
(3) Performing cluster centric segmentation
The cluster center segmentation can be performed on the denoised picture by using the SLIC algorithm or the VCell algorithm, which is described herein as the SLIC algorithm.
(3-1) converting the input RGB image into a Lab color space;
since the Lab space is a uniform color space, it is more advantageous than RGB when the contrast of skin color to white spot is low. In the Lab model, L is the brightness, and a, b are the color channels. L represents from black to white, a is green to red; when the collected RGB image is converted into a Lab color model, the conversion cannot be directly carried out, and the transition is carried out through an XYZ color model, wherein the formula is as follows:
wherein p isR,pB,pGRespectively RGB color components of the pixel p.
Wherein, δ is a preset value, δ is 0.008856, and X isn,Yn,ZnAs a reference value for the white point in the XYZ color space. Taking D65 as the reference white point here, there are:
Xn=95.047
Yn=100.000
Zn=108.883
(3-2) initializing the number of clustering seed points according to the size of the input image, wherein the following empirical formula can be adopted:
wherein N iscFor clustering the number of seed points, W and H are the width and height of the image, respectively, and ρ is defined as the density of seed points and has a value range of [0, min (W, H)]In the experiment, 20 is taken, and the value of ρ may be set as needed. The larger rho is, the more dense the seed points are, the smaller the area of each clustering center obtained in the later stage is, and the finer the segmentation is, but the excessive density increases the calculation amount and is easily interfered by image noise, so that the image segmentation effect is poor.
(3-3) setting the pixel with the coordinate of (rho ) as a first seed point, taking rho as a step length, initializing the rest seed points on the position of the intersection point in a checkerboard mode, and then combining the seed point set into a seed point set
Taking the seed point as an initialization clustering center and marking as C
k=[l
k,a
k,b
k,x
k,y
k],k=1,2,…,N
cWherein l is
k,a
k,b
kRespectively, the position coordinates of the image in Lab space are (x)
k,y
k) And the L, a and b components of the corresponding pixel points are processed.
(3-4) in the area with the seed point as the center and the size of 3 multiplied by 3, the seed point is moved to the position with the minimum L channel gradient in the Lab model so as to prevent the seed point from falling onto the edge of the image or the noise and influencing the subsequent clustering process.
(3-5) the specific algorithm of the clustering process is as follows:
(3-5-1) initializing the tag array l (i) ═ 1, the distance array d (i) ═ infinity, and the maximum number of iterations N for each pixel point iiter
(3-5-2) with CkCentered on this, within a region of size 2 ρ × 2 ρ, the following operations are performed for each pixel i: calculate i and CkA distance D of (D); if D is<D (i), let D (i) D, l (i) k
(3-5-3) judging whether all the clustering centers are traversed or not, if so, continuing; otherwise, returning to the step 3-5-2
(3-5-4) updating all the clustering centers
(3-5-5) judging whether the maximum iteration number N is reachediterIf yes, ending; otherwise, returning to the step 3-5-2
Wherein the distance D between pixel i and pixel j is defined as the weighted sum of the spatial distance and the color distance:
wherein C iss,CcNormalized constant terms for spatial distance and color distance, respectively. Here let Cs=25,Ccρ. During use, CcThe value range of (A) can be [1,40 ]]The larger the value, the larger DsThe smaller the weight occupied in the distance measurement is, the more irregular the shape of the clustering center obtained in the later period is, the long strip shape is formed, namely the correlation of the space is difficult to ensure, but the clustering center is sensitive to the edge of an object, has high fitting degree and is easy to receive the interference of noise; conversely, the smaller the value, the smaller DsThe larger the weight occupied in the distance measurement is, the more regular the shape of the clustering center obtained in the later stage is, the clustering center is similar to a square block, is not easily interfered by noise, but is less sensitive to the image edge.
The maximum iteration number in the experiment is 10, and the balance between the effect and the calculation cost can be achieved.
The update of the cluster center can be done using the following equation:
wherein N iskIs the number of pixels labeled k.
(3-6) after the clustering is carried out by the above steps, the problems of poor connectivity and some small regions which are not marked can occur, so that the connectivity of the image needs to be further enhanced, and the specific method is as follows:
(3-6-1) initializing label ═ 0, adjacent ═ 0, initializing empty queue Q, initializing array new
clusterAll initial values are set to-1, order
Initializing an array V, and recording the number of pixel points contained in the image as N
pLet i equal to 0;
(3-6-2) taking the label array l obtained in the step 3-5;
(3-6-3) if i<NpContinuing the following steps; otherwise, ending;
(3-6-4) if new _ cluster [ i)]If the pixel i is equal to-1, the pixel i enters the queue Q, four adjacent domain pixel points of the pixel i are traversed according to the sequence of the left, the top, the right, the left and the right, namely four pixel points which are adjacent to the pixel i in the image size range, the four pixel points are marked as itIf t is 1,2,3,4, if new _ clusters [ it]If the value is more than or equal to 0, let adjcent be new _ clusters [ i ≧ 0t];
(3-6-5) making count ═ 1;
(3-6-6) dequeuing the head pixel in the queue Q, marking as a pixel j, and storing the j to an array V;
(3-6-7) traversing the pixel points of the four neighborhoods of j, and marking as jtIf t is 1,2,3,4, if new _ clusters [ jt]Is ═ 1, and l [ i ═ 1]==l[jt]Then let jtEnter queue and let new _ cluster [ j ]t]Equal to label, count equal to count + 1; otherwise, entering (3-6-8);
(3-6-8) if the queue Q is empty, continuing; otherwise, returning to the step (3-6-6);
(3-6-9) if count is less than or equal to TmThen, go through the point in the access array V, note the current access point as z, let new _ cluster [ z]Setting the label as label-1, and emptying the array V;
(3-6-10) let label ═ label +1
(3-6-11) let i ═ i +1, return to (3-6-3).
The new _ cluster obtained by the algorithm is a new label array, the size of the new _ cluster is the number of pixels in the image, and the value of a certain position is the label corresponding to the pixel point of the position.
Thus, sub-regions of n well-segmented images can be obtained, wherein n is equal to the value of the label variable in the step (3-6), namely n clustering centers, and as shown in the second drawing (b), each minimum closed region formed by the blue line is a clustering center. Recalculating the Cluster center, note
In (1)
Can be regarded as an abstract feature representation of all pixel points in the represented area, and in the experiment, the features are extracted from Lab color space. The user can extract different features under different color spaces according to the needs of the user.
In (1)
What is obtained is a floating point number, which can be simply rounded to an integer for convenience of thresholding in step four.
(4) Manually determining a threshold value, and performing segmentation
The pixel values of the lesion area are manually measured and a segmentation threshold is determined, and then segmentation is performed. The method comprises the following specific steps:
(4-1) randomly sampling pixel points in the vitiligo area by using photoshop or drawing tools and the like, wherein the number of the sampling points is determined according to the image contrast of the vitiligo area (I.e. according to the brightness and the color difference visible to the naked eye), the sampling point needs to cover the areas with different brightness and color differences as much as possiblesPoint with sampling point of Si,i=1,2,…,NsThen the L, a, b components of the sampling point are SiL,Sia,SibThen the required threshold value T is dividedlowAnd ThighCan be determined by the following rules:
(4-2) traversing all cluster centers if
This cluster center is labeled as white spot skin lesion area, otherwise as normal skin, resulting in a result similar to that shown in panel two (c).
The Lab space is used for threshold segmentation, because the Lab space can separate the luminance component from the chrominance, so that only the color range can be limited, and the method is simple and effective for pictures with poor illumination conditions.
The technical means disclosed in the invention scheme are not limited to the technical means disclosed in the above embodiments, but also include the technical scheme formed by any combination of the above technical features. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present invention, and such improvements and modifications are also considered to be within the scope of the present invention. The results of the experimental comparison are shown in Table I
In table one test picture as shown in fig. two and fig. three, the running time is from step two-image preprocessing start timing to the completion of white spot region segmentation.