A pedestrian image accurate segmentation method based on contour attribute features
By using an image processing method based on contour attribute features, accurate segmentation of pedestrian images was achieved, solving the problems of data dependence and overfitting in deep learning methods, simplifying the segmentation process, and improving the segmentation effect.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN BROAD TECH CO LTD
- Filing Date
- 2023-04-06
- Publication Date
- 2026-05-05
AI Technical Summary
Existing deep learning-based pedestrian image segmentation methods require a large amount of data, are prone to overfitting, and have cumbersome decoding processes, making them difficult to generalize in practical applications.
A contour-based feature extraction method is adopted, which extracts contour features through image binarization, edge detection, local processing and fusion, and trains pedestrian and background contour classifiers to directly output the segmentation results.
It reduces the need for data labeling, lowers the risk of overfitting, simplifies the decoding process, and improves segmentation results.
Smart Images

Figure CN116416265B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision technology, and in particular to a method for accurate segmentation of pedestrian images based on contour attribute features. Background Technology
[0002] In the field of computer vision, image segmentation plays a vital technical support role in image processing, autonomous driving, robotics, and other fields.
[0003] Pedestrian image segmentation involves dividing a pedestrian from the background into different regions based on features such as grayscale, contour, and texture, thereby separating the pedestrian from the background. Current deep learning-based image segmentation methods are mainly divided into two categories: two-stage and one-stage. Two-stage methods, as the name suggests, consist of two stages: first, object detection methods locate the region containing the target (e.g., a pedestrian), and then semantic segmentation is performed within that region. Representative methods include Mask-RCNN, PANet, and FCIS. One-stage methods are similar to single-stage object detection methods, representing an end-to-end approach. The input is the image, and the output is the segmentation result for each instance. Representative methods include YOLACT, SOLO, and FCOS.
[0004] Current problems and challenges in image segmentation tasks include: 1. Deep learning-based methods require massive amounts of data. Deep learning is data-driven, and data labeling is costly. 2. Deep learning methods are prone to overfitting. While they can easily achieve good results on open-source datasets, in practical applications, the model's generalization performance declines due to variations in data distribution. 3. Post-processing of deep learning models is cumbersome. The model output is typically a high-dimensional matrix, not a direct segmentation result, making the decoding process complex. Summary of the Invention
[0005] This invention provides a method for accurate pedestrian image segmentation based on contour attribute features. It does not require a large amount of data to drive the process; it only requires collecting a small amount of data in a fixed scene to reduce model overfitting, improve segmentation performance, and directly output the segmentation results without a complex decoding process.
[0006] This invention provides a method for accurate pedestrian image segmentation based on contour attribute features, comprising:
[0007] Acquire an image containing pedestrians as the original image;
[0008] The original image is binarized to convert it into a binarized image.
[0009] The binarized image is subjected to edge detection, local edge processing and fusion in sequence to extract the image contour and obtain a contour image.
[0010] Contour features are extracted from the contour image to obtain a contour feature image;
[0011] Train pedestrian and background contour classifiers, and identify pedestrian contours based on the pedestrian and background contour classifiers to obtain pedestrian masks, so as to separate pedestrians and backgrounds based on the pedestrian masks.
[0012] Further, the step of binarizing the original image to convert the original image into a binary image includes:
[0013] The original image is converted from RGB to grayscale using the formula: Gray = (R*299 + G*587 + B*114) / 1000;
[0014] A histogram of image intensity is calculated based on the grayscale image; wherein, the X-axis of the histogram represents the pixel value, and the Y-axis represents the number of pixels in the grayscale image that have that pixel value;
[0015] A global threshold is determined based on the histogram of the image intensity to binarize the pixels of the grayscale image, mapping the pixels to [0, 255].
[0016] Further, in the step of sequentially performing edge detection, local edge processing, and fusion on the binarized image to extract the image contour and obtain a contour image, the edge detection on the binarized image includes:
[0017] A two-dimensional Gaussian function is used to smooth the image in a ring shape. The gradient information of the binarized image is calculated, and the edge intensity and direction at each point are estimated based on the gradient magnitude and direction of the binarized image. The input binarized image is represented by f(x,y), and the Gaussian smoothing function is represented by G(x,y).
[0018]
[0019] The Gaussian-smoothed image f is obtained through convolution filtering. s (x,y):
[0020]
[0021] Calculate the gradient value, gradient magnitude, and edge direction of the smoothed image:
[0022]
[0023]
[0024]
[0025] Among them, g x g y Let M(x,y) represent the horizontal and vertical gradients of the smoothed image, respectively, and let α(x,y) represent the magnitude of the gradient and α(x,y) represent the direction of the gradient.
[0026] Edges are thinned by non-maximum suppression, which is performed on the edge angle matrix α(x,y) of the image in a 3×3 local non-maximum suppression manner; where d1, d2, d3, d4 represent the four directions in the 3×3 region: 0 degrees, -45 degrees, 90 degrees and 45 degrees.
[0027] Non-maximum suppression is applied to a 3×3 region centered at each coordinate (x, y) of the edge angle matrix.
[0028] Furthermore, the step of performing non-maximum suppression on the 3×3 region centered at each coordinate (x, y) of the edge angle matrix includes:
[0029] Find the fundamental direction d that is closest to α(x,y). k ;
[0030] If the value of M(x,y) is at least less than along d k If one of the two adjacent magnitudes in the direction is g, then the gradient magnitude at that point is suppressed. N (x,y)=0, otherwise the amplitude remains unchanged; where, g N (x,y) is the magnitude matrix obtained by suppressing the magnitude non-maximum.
[0031] For g N Thresholding is applied to (x,y) to reduce false edge points, g N All retained magnitude points in (x,y) are assumed to be valid edge pixels.
[0032] Further, in the step of sequentially performing edge detection, local edge processing, and fusion on the binarized image to extract the image contour and obtain a contour image, the local edge processing and fusion of the binarized image includes:
[0033] Calculate the gradient magnitude matrix M(x,y) and gradient angle matrix α(x,y) of the input binarized image f(x,y);
[0034] Form a binary image g(x,y); where the value at any coordinate pair (x,y) is given by the following formula:
[0035]
[0036] Among them, T M Indicates the amplitude threshold, A represents the specified angle direction, ±T A Indicates the acceptable range of angles;
[0037] Iterate through the rows of g(x,y) and fill all gaps in each row that does not exceed the specified length;
[0038] In any direction Detect gaps, rotate g(x,y) by that angle, repeat the step of traversing rows of g(x,y) and filling all gaps in each row not exceeding a specified length, and then in the opposite direction - Rotate g(x,y);
[0039] Repeat the above steps to obtain the edge connectivity matrix.
[0040] Further, the step of extracting contour features from the contour image to obtain a contour feature image includes:
[0041] The formulas for calculating the centroid and central moment of the profile are as follows:
[0042]
[0043]
[0044] in, M represents the centroid coordinates of the contour. 00 M is the zeroth moment of the profile. 10 M 01 Let u be the first moment of the profile. pq Pix is the central moment. (x,y) These are the pixel values at the x and y coordinates of the outline.
[0045] Calculate the area of the outline region:
[0046]
[0047] Among them, Pix (x,y) These are the pixel values at the x and y coordinates of the outline.
[0048] Calculate the perimeter of the outline and the bounding rectangle of the outline, and determine the aspect ratio:
[0049]
[0050] Where Aspect Ratio is the aspect ratio of the bounding rectangle, Width is the width of the bounding rectangle, and Height is the height of the bounding rectangle;
[0051] Calculate the ratio of the contour area to the area of the circumscribed matrix:
[0052]
[0053] Wherein, Contour Area is the area of the contour, and Bounding Rectangle Area is the area of the bounding rectangle of the contour;
[0054] Calculate the ratio of the contour area to the protrusion area:
[0055]
[0056] Wherein, Convex Hull Area is the area of the protrusion.
[0057] Further, the step of training pedestrian and background contour classifiers, identifying pedestrian contours based on the pedestrian and background contour classifiers to obtain a pedestrian mask, and separating pedestrians and background based on the pedestrian mask includes:
[0058] Collect training sample data for pedestrians and backgrounds in different scenarios. i ∈R p The i = 1, ..., n and the sample label vector y ∈ {1, -1} n Where 1 indicates that the contour belongs to a pedestrian, and -1 indicates that the contour belongs to the background, the goal is to obtain a set of parameters w∈R p And b∈R, then substitute the contour features into the calculation: It can accurately distinguish the outlines of pedestrians;
[0059] Contour classification is achieved using the SVC algorithm:
[0060]
[0061] y i (w T φ(x i )+b)≥1-ζ i ,ζ i ≥0, i=1,...,n
[0062] Where w,b,ζ are the parameters of the w,b algorithm, ζ is the function interval, C is the regularization term, n is the number of sample data, and i is the sample index from 1 to n. i Let y be the functional interval of the i-th sample. i Let x be the sample label of the i-th sample. i This is the i-th sample data;
[0063] By maximizing the interval (||w||) 2 =wT w), to enable the classifier to predict the category of the contour as accurately as possible, while adding a regularization term C, the problem can be expressed as:
[0064]
[0065] Solving the above formula yields the optimal parameter: w * b * ;
[0066] Based on the pedestrian and background contour classifiers, the feature vector x of each contour is input, and the classification result is output. Filter the outlines of pedestrians, obtain the pedestrian mask based on the coordinates of the outlines, and separate the pedestrians from the background based on the mask.
[0067] The present invention also provides a pedestrian image accurate segmentation device based on contour attribute features, comprising:
[0068] The acquisition module is used to acquire images containing pedestrians as the original images;
[0069] The binarization module is used to binarize the original image to convert the original image into a binarized image;
[0070] The first extraction module is used to sequentially perform edge detection, local processing and fusion of the image edges on the binarized image to extract the image contour and obtain a contour image.
[0071] The second extraction module is used to extract contour features from the contour image to obtain a contour feature image;
[0072] A separation module is used to train pedestrian and background contour classifiers, and to identify pedestrian contours based on the pedestrian and background contour classifiers to obtain pedestrian masks, so as to separate pedestrians and backgrounds based on the pedestrian masks.
[0073] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method.
[0074] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the above-described method.
[0075] The beneficial effects of this invention are as follows:
[0076] This invention binarizes the original image containing pedestrians, then sequentially performs edge detection, local edge processing, and fusion on the binarized image to obtain a contour image. Contour features are extracted from the contour image, and pedestrian and background contour classifiers are trained to identify pedestrian contours, obtaining a pedestrian mask. Finally, pedestrians and background are separated based on the pedestrian mask. This invention eliminates the need for large amounts of segmentation label data, requiring only a small number of contour classification labels. The fewer and simpler model parameters reduce the risk of overfitting, and the segmentation mask result is directly output without a complex decoding process. Attached Figure Description
[0077] Figure 1 This is a schematic diagram of a method flow according to an embodiment of the present invention.
[0078] Figure 2 This is a schematic diagram of the original image binarization process in this invention.
[0079] Figure 3 This is a diagram showing the contour detection effect of the binarized image in this invention.
[0080] Figure 4 This is a diagram illustrating the effect of pedestrian background separation in this invention.
[0081] Figure 5 This is a schematic diagram of the device structure according to an embodiment of the present invention.
[0082] Figure 6 This is a schematic diagram of the internal structure of a computer device according to an embodiment of the present invention.
[0083] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0084] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0085] like Figure 1 As shown, this invention provides a method for accurate pedestrian image segmentation based on contour attribute features, including:
[0086] S1. Obtain an image containing pedestrians as the original image;
[0087] S2. The original image is binarized to convert it into a binarized image. First, the original image is converted into a grayscale image, and then the threshold for image binarization is determined by observing the pixel distribution histogram, and then binarization is performed.
[0088] like Figure 2 As shown, step S2 specifically includes:
[0089] S21. Convert the original image from RGB to grayscale using the following formula:
[0090] Gray=(R*299+G*587+B*114) / 1000
[0091] S22. Calculate the image intensity histogram based on the grayscale image; wherein, the X-axis of the histogram is the pixel value, and the Y-axis is the number of pixels in the grayscale image that have that pixel value; after converting from RGB pixel space to grayscale value, calculate the image histogram. The histogram can reveal the overall distribution of image pixel intensity. Its X-axis is the pixel value (generally ranging from 0 to 255), and the Y-axis is the number of pixels in the image that have that pixel value.
[0092] S23. Determine a global threshold based on the histogram of the image intensity to binarize the pixels of the grayscale image, mapping the pixels to [0, 255]:
[0093]
[0094] Where p is the pixel value and threshold is the pixel threshold (binarization).
[0095] S3. The binarized image is subjected to edge detection, local edge processing, and fusion sequentially to extract the image contour, resulting in a contour image. The image contour extraction mainly consists of two steps: 1. Edge detection; 2. Local edge processing and fusion.
[0096] In step S3, the edge detection algorithm has a low error rate, all edges can be detected, there are no false edges, the edges can be accurately located, the difference between the located edge points and the real edges is small, a single edge point response exists, there is only one single edge point position, and the detector will not point out multiple edge pixels.
[0097] Performing edge detection on the binarized image includes:
[0098] S301. A two-dimensional Gaussian function is used to smooth the image in a ring shape. The gradient information of the binarized image is calculated, and the edge intensity and direction at each point are estimated based on the gradient magnitude and direction of the binarized image. The input binarized image is represented by f(x,y), and the Gaussian smoothing function is represented by G(x,y).
[0099]
[0100] The Gaussian-smoothed image f is obtained through convolution filtering. s (x,y):
[0101]
[0102] Calculate the gradient value, gradient magnitude, and edge direction of the smoothed image:
[0103]
[0104]
[0105]
[0106] Among them, g x g y Let M(x,y) represent the horizontal and vertical gradients of the smoothed image, respectively, and let α(x,y) represent the magnitude of the gradient and α(x,y) represent the direction of the gradient.
[0107] S302. Edges are thinned by non-maximum suppression. 3×3 local non-maximum suppression is performed on the edge angle matrix α(x,y) of the image. Let d1, d2, d3, d4 represent the four directions in the 3×3 region: 0 degrees, -45 degrees, 90 degrees, and 45 degrees.
[0108] Non-maximum suppression is performed on a 3×3 region centered at each coordinate (x, y) of the edge angle matrix, specifically including:
[0109] T1. Find the fundamental direction d that is closest to α(x,y). k ;
[0110] T2. If the value of M(x,y) is at least less than that along d k If one of the two adjacent magnitudes in the direction is g, then the gradient magnitude at that point is suppressed. N (x,y)=0, otherwise the amplitude remains unchanged; where, g N (x,y) is the magnitude matrix obtained by suppressing the magnitude non-maximum.
[0111] T3, for g N Thresholding is applied to (x,y) to reduce false edge points, g N All retained magnitude points in (x,y) are assumed to be valid edge pixels.
[0112] In step S3, edge detection only finds the pixel set of the edge portion in the image. These pixel sets are discontinuous due to noise, lighting, and other factors, and therefore cannot be combined to form meaningful contour information. Therefore, post-processing of the edges is necessary to form a closed target contour. Edge connection involves analyzing the characteristics of pixels within the neighborhood of each edge point, and then connecting all edge points with similar characteristics according to certain rules.
[0113] The local processing and fusion of image edges in the binarized image includes:
[0114] S311. Calculate the gradient magnitude matrix M(x,y) and gradient angle matrix α(x,y) of the input binarized image f(x,y);
[0115] S312. Form a binary image g(x,y); where the value at any coordinate pair (x,y) is given by the following formula:
[0116]
[0117] Among them, T M Indicates the amplitude threshold, A represents the specified angle direction, ±T A Indicates the acceptable range of angles;
[0118] S313. Iterate through the rows of g(x,y) and fill all gaps in each row that does not exceed the specified length;
[0119] S314, in any direction Detect gaps, rotate g(x,y) by that angle, repeat the step of traversing rows of g(x,y), and fill all gaps in each row not exceeding a specified length, and then in the opposite direction. Rotate g(x,y);
[0120] Repeat steps S313-S314 above to obtain the edge connection matrix, as follows: Figure 3 The image shown is the contour detection result.
[0121] S4. Extract contour features from the contour image to obtain a contour feature image;
[0122] Step S4 specifically includes:
[0123] S41. Calculate the centroid and central moment of the profile. The calculation formula is as follows:
[0124] Outline centroid:
[0125]
[0126] Torque:
[0127]
[0128] in, M represents the centroid coordinates of the contour. 00 M is the zeroth moment of the profile. 10 M 01 Let u be the first moment of the profile. pq Pix is the central moment. (x,y) These are the pixel values at the x and y coordinates of the outline.
[0129] S42. Calculate the area of the contour region:
[0130]
[0131] Among them, Pix (x,y) These are the pixel values at the x and y coordinates of the outline.
[0132] S43. Calculate the perimeter of the outline and the circumscribed rectangle (perimeter and area of the circumscribed rectangle), and determine the aspect ratio. The perimeter of the outline is also called the arc length, which is the perimeter of the closed curve of the outline.
[0133] Aspect Ratio:
[0134]
[0135] Where Aspect Ratio is the aspect ratio of the bounding rectangle, Width is the width of the bounding rectangle, and Height is the height of the bounding rectangle;
[0136] S44. Calculate the ratio (range) of the contour area to the area of the circumscribed matrix:
[0137]
[0138] Where ContourArea is the area of the contour, and Bounding Rectangle Area is the area of the bounding rectangle of the contour;
[0139] S45. Calculate the ratio of the contour area to the protrusion area (robustness):
[0140]
[0141] Wherein, Convex Hull Area is the area of the protrusion.
[0142] S5. Train pedestrian and background contour classifiers, and identify pedestrian contours based on the pedestrian and background contour classifiers to obtain pedestrian masks, so as to separate pedestrians and backgrounds based on the pedestrian masks.
[0143] Step S5 specifically includes:
[0144] Collect training sample data for pedestrians and backgrounds in different scenarios. i ∈R p The i = 1, ..., n and the sample label vector y ∈ {1, -1} n Where 1 indicates that the contour belongs to a pedestrian, and -1 indicates that the contour belongs to the background, the goal is to obtain a set of parameters w∈R p And b∈R, then substitute the contour features into the calculation: It can accurately distinguish the outlines of pedestrians;
[0145] Contour classification is achieved using the SVC algorithm:
[0146]
[0147] y i (w T φ(x i )+b)≥1-ζ i ,ζ i ≥0, i=1,...,n
[0148] Where w,b,ζ are the parameters of the w,b algorithm, ζ is the function interval, C is the regularization term, n is the number of sample data, and i is the sample index from 1 to n. i Let y be the functional interval of the i-th sample. i Let x be the sample label of the i-th sample. i This is the i-th sample data;
[0149] By maximizing the interval (||w||) 2 =w T w), to enable the classifier to predict the category of the contour as accurately as possible, while adding a regularization term C, the problem can be expressed as:
[0150]
[0151] Solving the above formula yields the optimal parameter: w * b * ;
[0152] Based on the pedestrian and background contour classifiers, the feature vector x of each contour is input, and the classification result is output. Filter the outlines of pedestrians, obtain the pedestrian mask based on the coordinates of the outlines, and separate the pedestrians from the background based on the mask, such as... Figure 4 As shown.
[0153] The advantages of this invention are:
[0154] 1. No large amount of segmentation label data is required; only a small number of contour classification labels are needed.
[0155] 2. Fewer and simpler model parameters reduce the risk of overfitting.
[0156] 3. Directly output the segmentation mask result without a complex decoding process.
[0157] like Figure 5 As shown, the present invention provides a pedestrian image accurate segmentation device based on contour attribute features, comprising:
[0158] Module 1 is used to acquire images containing pedestrians as the original images;
[0159] Binarization module 2 is used to binarize the original image to convert the original image into a binarized image;
[0160] The first extraction module 3 is used to sequentially perform edge detection, local processing and fusion of the image edges on the binarized image to extract the image contour and obtain a contour image.
[0161] The second extraction module 4 is used to extract contour features from the contour image to obtain a contour feature image;
[0162] Separation module 5 is used to train pedestrian and background contour classifiers, and to identify pedestrian contours based on the pedestrian and background contour classifiers to obtain pedestrian masks, so as to separate pedestrians and backgrounds based on the pedestrian masks.
[0163] In one embodiment, binarization module 2 includes:
[0164] The conversion unit is used to convert the original image from RGB to grayscale image, and its formula is: Gray = (R*299+G*587+B*114) / 1000;
[0165] A histogram calculation unit is used to calculate a histogram of image intensity based on the grayscale image; wherein, the X-axis of the histogram is the pixel value, and the Y-axis is the number of pixels in the grayscale image that have that pixel value;
[0166] The mapping unit is used to determine a global threshold based on the histogram of the image intensity to binarize the pixels of the grayscale image, mapping the pixels to [0, 255].
[0167] In one embodiment, the first extraction module 3 performs edge detection on the binarized image, which includes:
[0168] The estimation unit is used to smooth the image using a circular two-dimensional Gaussian function, calculate the gradient information of the binarized image, and estimate the edge intensity and direction at each point based on the gradient magnitude and direction of the binarized image; wherein the input binarized image is represented by f(x,y), and the Gaussian smoothing function is represented by G(x,y):
[0169]
[0170] The Gaussian-smoothed image f is obtained through convolution filtering. s (x,y):
[0171]
[0172] Calculate the gradient value, gradient magnitude, and edge direction of the smoothed image:
[0173]
[0174]
[0175]
[0176] Among them, g x g y Let M(x,y) represent the horizontal and vertical gradients of the smoothed image, respectively, and let α(x,y) represent the magnitude of the gradient and α(x,y) represent the direction of the gradient.
[0177] The suppression unit is used to refine the edges through non-maximum suppression, performing 3×3 local non-maximum suppression on the edge angle matrix α(x,y) of the image; where d1, d2, d3, d4 represent the four directions in the 3×3 region: 0 degrees, -45 degrees, 90 degrees and 45 degrees.
[0178] Non-maximum suppression is applied to a 3×3 region centered at each coordinate (x, y) of the edge angle matrix.
[0179] In one embodiment, the suppression unit includes:
[0180] Finding sub-units to locate the fundamental direction d closest to α(x,y). k ;
[0181] Suppression subunit, used if the value of M(x,y) is at least less than along d k If one of the two adjacent magnitudes in the direction is g, then the gradient magnitude at that point is suppressed. N (x,y)=0, otherwise the amplitude remains unchanged; where, g N (x,y) is the magnitude matrix obtained by suppressing the magnitude non-maximum.
[0182] Processing subunit, used for g N Thresholding is applied to (x,y) to reduce false edge points, g N All retained magnitude points in (x,y) are assumed to be valid edge pixels.
[0183] In one embodiment, the first extraction module 3 performs local edge processing and fusion on the binarized image, including:
[0184] The matrix calculation unit is used to calculate the gradient magnitude matrix M(x,y) and gradient angle matrix α(x,y) of the input binary image f(x,y);
[0185] A forming unit is used to form a binary image g(x,y); where the value at any coordinate pair (x,y) is given by the following formula:
[0186]
[0187] Among them, T M Indicates the amplitude threshold, A represents the specified angle direction, ±T A Indicates the acceptable range of angles;
[0188] The traversal unit is used to traverse the rows of g(x,y) and fill all gaps in each row that does not exceed the specified length;
[0189] Detection unit, used in any direction Detect gaps, rotate g(x,y) by that angle, repeat the step of traversing rows of g(x,y), and fill all gaps in each row not exceeding a specified length, and then in the opposite direction. Rotate g(x,y);
[0190] Repeat the steps above to form the unit to obtain the edge connection matrix.
[0191] In one embodiment, the second extraction module 4 includes:
[0192] The first calculation unit is used to calculate the centroid and central moment of the profile. Its calculation formula is as follows:
[0193]
[0194]
[0195] The second calculation unit is used to calculate the area of the outline region:
[0196]
[0197] The third calculation unit is used to calculate the perimeter of the outline and the bounding rectangle of the outline, and to determine the aspect ratio:
[0198]
[0199] The fourth calculation unit is used to calculate the ratio of the contour area to the area of the circumscribed matrix:
[0200]
[0201] The fifth calculation unit is used to calculate the ratio of the contour area to the protrusion area:
[0202] In one embodiment, the separation module 5 includes:
[0203] The training unit is used to collect training sample data for two categories: pedestrians and backgrounds in different scenarios. i ∈R p The i = 1, ..., n and the sample label vector y ∈ {1, -1} n Where 1 indicates that the contour belongs to a pedestrian, and -1 indicates that the contour belongs to the background, the goal is to obtain a set of parameters w∈R p And b∈R, then substitute the contour features into the calculation: It can accurately distinguish the outlines of pedestrians;
[0204] Contour classification is achieved using the SVC algorithm:
[0205]
[0206] y i (w T φ(x i )+b)≥1-ζ i ,ζ i ≥0, i=1,...,n
[0207] By maximizing the interval (||w||) 2 =w T w), which enables the classifier to predict the category of the contour as accurately as possible, while adding a regularization term C;
[0208]
[0209] The problem can be represented as:
[0210]
[0211] Solving the above formula yields the optimal parameter: w * b * ;
[0212] The separation unit is used to take the feature vector x of each contour as input from the pedestrian and background contour classifiers and output the classification result. Filter the outlines of pedestrians, obtain the pedestrian mask based on the coordinates of the outlines, and separate the pedestrians from the background based on the mask.
[0213] Each of the above modules, units, and sub-units is used to perform the respective steps in the above-described method for accurate pedestrian image segmentation based on contour attribute features. The specific implementation methods are as described in the above-described method embodiments, and will not be repeated here.
[0214] like Figure 6 As shown, the present invention also provides a computer device, which may be a server, and its internal structure may be as follows: Figure 6As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores all data required for the process of a pedestrian image segmentation method based on contour attribute features. The network interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements the pedestrian image segmentation method based on contour attribute features.
[0215] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer equipment on which the present application is applied.
[0216] An embodiment of this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described methods for accurate pedestrian image segmentation based on contour attribute features.
[0217] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media provided in this application and in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual-speed SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0218] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, apparatus, article, or method. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.
[0219] The above description is merely a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A method for accurate pedestrian image segmentation based on contour attribute features, characterized in that, include: Acquire an image containing pedestrians as the original image; The original image is binarized to convert it into a binarized image. The binarized image is subjected to edge detection, local edge processing and fusion in sequence to extract the image contour and obtain a contour image. Contour feature extraction is performed on the contour image to obtain a contour feature image. The contour feature extraction includes calculating the contour centroid, central moment, contour region area, contour perimeter, contour circumscribed rectangle, the ratio of contour area to circumscribed rectangle area, and the ratio of contour area to convex area. Train pedestrian and background contour classifiers, and identify pedestrian contours based on the pedestrian and background contour classifiers to obtain pedestrian masks, so as to separate pedestrians and backgrounds based on the pedestrian masks; Specifically, it includes: Collect training sample data for two categories: pedestrians and backgrounds, in different scenarios. i ∈R p The i = 1, ..., n and the sample label vector y ∈ {1, -1} n Where 1 indicates that the contour belongs to a pedestrian, and -1 indicates that the contour belongs to the background, the goal is to obtain a set of parameters w∈R p And b∈R, then substitute the contour features into the calculation: It can accurately distinguish the outlines of pedestrians; Contour classification is achieved using the SVC algorithm: y i (w T φ(x i )+b)≥1-ζ i ,g i ≥0,i=1,...,n Where ζ is the functional interval, C is the regularization term, n is the number of sample data, and i is the sample index, from 1 to n. i Let y be the functional interval of the i-th sample. i Let x be the sample label of the i-th sample. i This is the i-th sample data; By maximizing the interval ||w|| 2 =w T w, to make the classifier predict the category of the contour as accurately as possible, while adding a regularization term C, the problem can be expressed as: Solving the above formula yields the optimal parameter: w * b * ; Based on the pedestrian and background contour classifiers, the feature vector x of each contour is input, and the classification result is output. Filter the outlines of pedestrians, obtain the pedestrian mask based on the coordinates of the outlines, and separate the pedestrians from the background based on the mask.
2. The method for accurate pedestrian image segmentation based on contour attribute features according to claim 1, characterized in that, The step of binarizing the original image to convert it into a binary image includes: The original image is converted from RGB to grayscale using the formula: Gray = (R*299 + G*587 + B*114) / 1000; A histogram of image intensity is calculated based on the grayscale image; wherein, the X-axis of the histogram represents the pixel value, and the Y-axis represents the number of pixels in the grayscale image that have that pixel value; A global threshold is determined based on the histogram of the image intensity to binarize the pixels of the grayscale image, mapping the pixels to [0, 255].
3. The method for accurate pedestrian image segmentation based on contour attribute features according to claim 1, characterized in that, The step of sequentially performing edge detection, local edge processing, and fusion on the binarized image to extract the image contour and obtain a contour image includes the following: A two-dimensional Gaussian function is used to smooth the image in a ring shape. The gradient information of the binarized image is calculated, and the edge intensity and direction at each point are estimated based on the gradient magnitude and direction of the binarized image. The input binarized image is represented by f(x,y), and the Gaussian smoothing function is represented by G(x,y). The Gaussian-smoothed image f is obtained through convolution filtering. s (x,y): Calculate the gradient value, gradient magnitude, and edge direction of the smoothed image: Among them, g x g y Let M(x,y) represent the horizontal and vertical gradients of the smoothed image, respectively, and let α(x,y) represent the magnitude of the gradient and α(x,y) represent the direction of the gradient. Edges are thinned by non-maximum suppression, which is performed on the edge angle matrix α(x,y) of the image in a 3×3 local non-maximum suppression manner; where d1, d2, d3, d4 represent the four directions in the 3×3 region: 0 degrees, -45 degrees, 90 degrees and 45 degrees. Non-maximum suppression is applied to a 3×3 region centered at each coordinate (x, y) of the edge angle matrix.
4. The method for accurate pedestrian image segmentation based on contour attribute features according to claim 3, characterized in that, The step of performing non-maximum suppression on a 3×3 region centered at each coordinate (x, y) of the edge angle matrix includes: Find the fundamental direction d that is closest to α(x,y). k d k It is one of the four directions {d1,d2,d3,d4}; If the value of M(x,y) is at least less than along d k If one of the two adjacent magnitudes in the direction is g, then the gradient magnitude at that point is suppressed. N (x,y)=0, otherwise the amplitude remains unchanged; where, g N (x,y) is the magnitude matrix obtained by suppressing the magnitude non-maximum. For g N Thresholding is applied to (x,y) to reduce false edge points, g N All retained magnitude points in (x,y) are assumed to be valid edge pixels.
5. The method for accurate pedestrian image segmentation based on contour attribute features according to claim 1, characterized in that, The step of sequentially performing edge detection, local edge processing, and fusion on the binarized image to extract the image contour and obtain a contour image includes the following steps: Calculate the gradient magnitude matrix M(x,y) and gradient angle matrix α(x,y) of the input binarized image f(x,y); Form a binary image g(x,y); where the value at any coordinate pair (x,y) is given by the following formula: Among them, T M Indicates the amplitude threshold, A represents the specified angle direction, ±T A Indicates the acceptable range of angles; Iterate through the rows of g(x,y) and fill all gaps in each row that does not exceed the specified length; In the preset direction Detect gaps above, in the direction Rotate the binary image g(x,y), repeat the steps of traversing the rows of the rotated binary image g(x,y) and filling all gaps in each row not exceeding a specified length, and then in the reverse direction... Rotate the binary image g(x,y); Repeat the above steps to obtain the edge connectivity matrix.
6. The method for accurate pedestrian image segmentation based on contour attribute features according to claim 1, characterized in that, The step of extracting contour features from the contour image to obtain a contour feature image includes: The formulas for calculating the centroid and central moment of the profile are as follows: in, M represents the centroid coordinates of the contour. 00 M is the zeroth moment of the profile. 10 M 01 Let u be the first moment of the profile. pq Pix is the central moment. (x,y) These are the pixel values at the x and y coordinates of the outline. Calculate the area of the outline region: Calculate the perimeter of the outline and the bounding rectangle of the outline, and determine the aspect ratio: Where Aspect Ratio is the aspect ratio of the bounding rectangle, Width is the width of the bounding rectangle, and Height is the height of the bounding rectangle; Calculate the ratio of the contour area to the area of the circumscribed matrix: Where ContourArea is the area of the contour, and Bounding Rectangle Area is the area of the bounding rectangle of the contour; Calculate the ratio of the contour area to the protrusion area: Wherein, Convex Hull Area is the area of the protrusion.
7. A pedestrian image precise segmentation device based on contour attribute features, based on the pedestrian image precise segmentation method based on contour attribute features according to any one of claims 1 to 6, characterized in that, include: The acquisition module is used to acquire images containing pedestrians as the original images; The binarization module is used to binarize the original image to convert the original image into a binarized image; The first extraction module is used to sequentially perform edge detection, local processing and fusion of the image edges on the binarized image to extract the image contour and obtain a contour image. The second extraction module is used to extract contour features from the contour image to obtain a contour feature image; A separation module is used to train pedestrian and background contour classifiers, and to identify pedestrian contours based on the pedestrian and background contour classifiers to obtain pedestrian masks, so as to separate pedestrians and backgrounds based on the pedestrian masks.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Pedestrian individual segmenting method and device
CN106778705A
Image processor, image processing method and program
JP2016122367A