Workpiece feature recognition method for CNC machining center
By real-time acquisition of images and calculating local saliency in the workpiece feature extraction of CNC machining centers, the problem of existing algorithms ignoring high-frequency details is solved, and the accuracy and processing quality of edge extraction are improved.
Patent Information
- Application Number
- CN202510587950.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2025-06-06
- Estimated Expiration
- 2045-05-08
AI Technical Summary
The workpiece feature extraction algorithm of the existing CNC machining center easily ignores the high-frequency details of the image, resulting in fracture or discontinuity of the workpiece edge contour, affecting the processing quality.
By collecting workpiece images in real time, obtaining the LAB channel values and gradient values of each pixel point, setting multiple neighborhood windows, calculating the local significance of the pixel point, filtering edge points, and generating outline edge images.
It realizes more accurate identification of workpiece edges, avoids edge fracture or discontinuity, and improves the accuracy and processing quality of workpiece feature recognition.
Smart Images

Figure CN120107619A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and more specifically, to a workpiece feature recognition method for a CNC machining center. Background Art
[0002] As the core equipment of modern manufacturing, the computer numerical control (CNC) machining center is a highly efficient automated machine tool that accurately controls the tool motion trajectory through computer programs. This equipment can realize the precision machining of workpieces such as metals, plastics and composite materials. Its core machining functions include milling, drilling, boring and tapping, etc. It is suitable for batch production of workpieces with complex geometric shapes or high-precision single-piece machining.
[0003] Before the machining process starts, the workpiece to be machined is firstly subjected to feature extraction and analysis. This key step includes comprehensive acquisition of parameters such as workpiece geometric features (such as three-dimensional shape, key dimensions, etc.), material properties (including mechanical properties such as hardness and toughness), and machining location information. Based on these feature data, the system will intelligently match the optimal machining process for the workpiece. Specifically, different workpiece features will directly affect the machining process planning, including the selection of machining methods, the configuration of tool types, and the optimization of key process parameters (such as cutting speed, feed rate, and cutting depth, etc.).
[0004] In the feature extraction process, the FT (Frequency-tuned) saliency detection algorithm can realize automatic identification of the processing area by performing specific processing on the image data. However, this algorithm tends to capture areas with salient features in the image, but is more sensitive to large salient areas. Moreover, the algorithm tends to ignore the high-frequency detail information of the image, resulting in fracture or discontinuity in the extracted edge contour of the workpiece, which in turn has an adverse effect on the subsequent processing quality. Summary of the invention
[0005] In order to solve the technical problem that the machining accuracy of the workpiece is reduced due to incomplete feature extraction, the present invention provides the following technical solution.
[0006] A workpiece feature recognition method for a CNC machining center, comprising: Collect the image of the workpiece to be processed in real time and pre-process it; Obtain the pixel values of the three LAB channels of each pixel point of the workpiece image to be processed and the gradient value of each pixel point, set multiple neighborhood windows for the pixel point, traverse the pixel distribution complexity of each neighborhood window, select the neighborhood window corresponding to the maximum pixel distribution complexity as the target window of the pixel point, calculate the color difference and gradient difference between the pixel point and other pixels in its target window, and take the product of the color difference, gradient difference and window distribution complexity of the target window as the local significance of the pixel point; All edge points of the workpiece image are screened based on the local saliency value to obtain a contour edge image; Based on the contour image, matching is performed in the workpiece database to match the corresponding processing steps.
[0007] The present invention first obtains the pixel values of the three LAB channels of each pixel point of the workpiece image and the gradient value of each pixel point, and then selects the optimal neighborhood window according to the complexity of pixel point distribution, thereby avoiding edge information loss or noise interference caused by a fixed window, and comprehensively considers color difference, gradient difference and the window distribution complexity of the target window to calculate the local significance of the pixel point, so that edge detection no longer relies solely on single grayscale information or gradient information, but integrates multiple features, thereby being able to more accurately identify edge points and effectively extract complete contours, avoiding the edge breakage or discontinuity problems that may exist in traditional edge detection algorithms, and making the obtained contour edge image clearer and more complete.
[0008] Preferably, the process of acquiring the pixel distribution complexity includes: Obtain the gray level co-occurrence matrix of each neighborhood window of the pixel point and calculate the entropy value of the gray level co-occurrence matrix; The optical flow vector of each pixel in the image is obtained by performing a difference operation between the current frame image and the previous frame image, and the dynamic optical flow saliency of the pixel neighborhood window is calculated based on the optical flow vector; The product of the entropy value of the gray-level co-occurrence matrix and the dynamic optical flow significance is taken as the pixel distribution complexity of the neighborhood window corresponding to the pixel.
[0009] The entropy value of the gray-level co-occurrence matrix reflects the randomness and texture complexity of the gray-level distribution in the neighborhood of the pixel point, while the dynamic optical flow saliency captures the differences in motion patterns in the neighborhood of the pixel point. It also takes into account the spatial texture features and motion features, making the complexity representation more comprehensive, avoiding the limitations brought by a single feature, and enhancing the distinction between complex areas (such as areas with rich textures and intense motion) and simple areas (such as uniform areas or static areas).
[0010] Preferably, the Euclidean distance between the LAB value of the pixel point and the LAB mean value in the target window is taken as the color difference between the pixel point and other pixels in the target window.
[0011] Preferably, the square root of the difference between the gradient value of the pixel point and the gradient mean value in the target window is taken as the gradient difference between the pixel point and other pixels in the target window.
[0012] Preferably, screening all edge points of the workpiece image based on the local saliency value comprises: Pixels whose local significance values are greater than or equal to a preset significance threshold are regarded as edge points.
[0013] Preferably, the matching is a Fourier descriptor matching algorithm or a scale-invariant feature transform matching algorithm.
[0014] Preferably, the process of acquiring the dynamic optical flow saliency includes: Calculate the mean of the optical flow vectors of all pixels in each neighborhood window and the variance of the cosine similarity between the optical flow vectors of all other pixels in the neighborhood window and the optical flow vector of the center point of the neighborhood window; transform the variance of the cosine similarity using an exponential function, and take the product of the transformed result and the mean of the optical flow vectors of all pixels in the neighborhood window as the dynamic optical flow saliency of the pixel neighborhood window.
[0015] By calculating the mean of the optical flow vectors of all pixels in the neighborhood window, the optical flow information in the neighborhood can be grasped as a whole to avoid large errors caused by abnormal optical flow vectors of single pixels. By calculating the variance of the cosine similarity between the optical flow vectors of all other pixels in the neighborhood window and the optical flow vector of the center point of the neighborhood window, the consistency of the optical flow direction in the neighborhood can be measured. When the variance is small, it means that the optical flow direction in the neighborhood is more consistent and more significant, thereby more accurately reflecting the real movement.
[0016] Preferably, the preset significant threshold includes: Multiple candidate saliency thresholds are preset, and initial segmentation is performed based on each candidate saliency threshold to divide pixels into edge points and non-edge points. The inter-class variance and continuity of the segmentation result of the current candidate saliency threshold are calculated, and the objective function is constructed based on the inter-class variance and continuity. The objective function is solved to obtain the optimal saliency threshold.
[0017] By presetting multiple candidate saliency thresholds and performing initial segmentation based on each candidate threshold, pixels are divided into edge points and non-edge points, which can process each pixel in the image more carefully, avoiding misjudgment that may be caused by a single threshold, and thus more accurately determining the edge of the image; after each segmentation, the objective function is constructed based on the inter-class variance and continuity, and the objective function is solved to obtain the optimal saliency threshold. The larger the inter-class variance, the greater the difference between the foreground and the background, and the better the segmentation effect; continuity ensures the smoothness and coherence of the segmentation results, avoiding the fragmentation of the segmentation results caused by factors such as noise.
[0018] Preferably, the objective function is solved using a particle swarm optimization algorithm or a genetic algorithm.
[0019] Preferably, the process of acquiring the dynamic optical flow saliency includes: The directional distribution entropy of the optical flow vector in the pixel neighborhood window is calculated, and the directional distribution entropy is used as the dynamic optical flow saliency of the pixel neighborhood window.
[0020] Directional distribution entropy, as a measure of dynamic optical flow saliency, can effectively reduce misjudgments caused by noise or background interference. For example, in the case of complex background textures or small random motions, this method can better distinguish these interferences from real moving targets.
[0021] The beneficial effects of the present invention are: The present invention calculates the color difference and gradient difference between a pixel and other pixels in its target window, and takes the product of the color difference and gradient difference and the window distribution complexity of the target window as the local significance of the pixel; by presetting multiple candidate significant thresholds, performing initial segmentation based on each candidate threshold, calculating the inter-class variance and continuity, constructing an objective function and solving the optimal significant threshold, the optimal significant threshold can be automatically selected according to the specific features of the workpiece image, and the contour edge of the workpiece can be extracted more accurately, thereby improving the accuracy of workpiece feature recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a method flow chart of steps S1 to S4 in a method for workpiece feature recognition for a CNC machining center according to an embodiment of the present invention. DETAILED DESCRIPTION
[0023] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments.
[0024] Reference Figure 1 A method for identifying workpiece features for a CNC machining center includes steps S1 to S4, which are specifically as follows: S1: Real-time acquisition of the image of the workpiece to be processed and preprocessing of it.
[0025] In one embodiment, a camera is installed in the processing area of the CNC machining center. When the workpiece to be processed reaches the camera area, the camera starts to continuously capture images of the workpiece to be processed.
[0026] Furthermore, the collected image of the workpiece to be processed is smoothed using a 5×5 Gaussian kernel to remove high-frequency information in the image.
[0027] S2: Obtain the pixel values of the three LAB channels of each pixel point of the workpiece image to be processed and the gradient value of each pixel point, set multiple neighborhood windows for the pixel point, traverse the pixel distribution complexity of each neighborhood window, select the neighborhood window corresponding to the maximum pixel distribution complexity as the target window of the pixel point, calculate the color difference and gradient difference between the pixel point and other pixels in its target window, and take the product of the color difference, gradient difference and window distribution complexity of the target window as the local significance of the pixel point.
[0028] The edge contour features of workpieces are an important basis for precision machining in CNC machining centers. When extracting the edge contour features of workpieces, the traditional FT saliency algorithm tends to capture large salient areas and easily ignores small edges, resulting in discontinuity in the extracted edge contours of workpieces and loss of details.
[0029] In the embodiment of the present invention, the color information and gradient information of the image are combined to process the edge features more finely, thereby avoiding the influence of global contrast on edge extraction.
[0030] In one embodiment, the collected image is first converted from the RGB color space to the LAB color space to obtain the LAB three-channel value of each pixel point. In addition, the image is converted into a grayscale image, and the gradient value of each pixel point is calculated using the Sobel operator.
[0031] Furthermore, multiple neighborhood windows k×k of different sizes are set for each pixel point, and these neighborhood windows are traversed to obtain the gray-level co-occurrence matrix of the corresponding neighborhood window, and the entropy value of the gray-level co-occurrence matrix is calculated. The larger the entropy value, the more complex the gray-level distribution of the pixel point in the window.
[0032] For example, a smaller neighborhood window (such as 3×3) can better capture local features and details in the image and is suitable for detecting fine structures or edges in the image. A larger window (such as 7×7) can capture more contextual information, but may increase computational complexity and introduce unnecessary noise. Therefore, a compromise k value range [3, 15] can be selected to strike a balance between capturing sufficient local information and controlling computational complexity.
[0033] It should be noted that in a sequence of continuous frame images, the foreground target (the workpiece to be processed) is usually in motion, and the position of its pixel points will change over time; while the background area is relatively static or has little movement. Therefore, by calculating the optical flow vector of the pixel point, the movement direction and speed of the pixel point can be accurately described, which helps to further determine the size of the neighborhood window of the pixel point.
[0034] In one embodiment, a difference operation is performed between the current frame image and the previous frame image to obtain the optical flow vector of each pixel in the image, and then the mean of the optical flow vectors of all pixels in each neighborhood window and the variance of the cosine similarity between the optical flow vectors of all other pixels in the neighborhood window and the optical flow vector of the center point of the neighborhood window are calculated. The variance of the cosine similarity is further transformed using an exponential function, and the product of the transformed result and the mean of the optical flow vectors of all pixels in the neighborhood window is used as the dynamic optical flow saliency.
[0035] In another embodiment, the directional distribution entropy of the optical flow vector in the pixel neighborhood window is calculated and used as the dynamic optical flow saliency of the pixel neighborhood window. The larger the entropy value, the more dispersed the motion direction is and the higher the saliency is.
[0036] Finally, the product of the entropy value of the gray-level co-occurrence matrix calculated above and the dynamic optical flow significance is taken as the pixel distribution complexity of the neighborhood window corresponding to the pixel.
[0037] Traverse all neighborhood windows and select the neighborhood window with the largest pixel distribution complexity as the target window of the pixel.
[0038] The Euclidean distance between the LAB value of the pixel and the LAB mean in the target window is taken as the color difference between the pixel and other pixels in its target window, and the square root of the difference between the gradient value of the pixel and the gradient mean in its target window is taken as the gradient difference between the pixel and other pixels in its target window.
[0039] Finally, the product of the color difference, gradient difference and window distribution complexity of the target window calculated above is taken as the local saliency of the pixel.
[0040] Among them, the greater the color difference, the greater the difference in color between the pixel and other pixels in its neighborhood, which means that the pixel is more prominent in color and its local significance value is larger; by considering the gradient difference, the significance of the edge point can be enhanced and the edge response can be strengthened; the higher the complexity, the more uneven the distribution of pixels in the window, which may contain more details or structural information.
[0041] S3: Filter all edge points of the workpiece image based on the local saliency value to obtain a contour edge image.
[0042] In one embodiment, all edge points of the workpiece image are screened according to the local significance of the pixel points calculated by S2 above. However, in order to obtain a better segmentation effect, multiple candidate significant thresholds are preset, and initial segmentation is performed based on each candidate significant threshold, and the pixels are divided into edge points and non-edge points. The inter-class variance and continuity of the segmentation result of the current candidate significant threshold are calculated, and the objective function is constructed according to the inter-class variance and continuity. The candidate significant threshold is dynamically adjusted through a swarm intelligence algorithm (such as a particle swarm optimization algorithm, a genetic algorithm, etc.), and the two operations of initial segmentation and constructing the objective function are repeated to find the optimal significant threshold that maximizes the objective function value. The calculation of inter-class variance and continuity is a prior art and will not be described in detail here.
[0043] Exemplarily, the above objective function is:
[0044] In the formula, To use the candidate saliency threshold The objective function value calculated after filtering the edge points, To use the candidate saliency threshold The inter-class variance calculated after filtering edge points, To use the candidate saliency threshold Continuity calculated after filtering edge points.
[0045] Among them, the search is stopped when the objective function value converges.
[0046] The image of the workpiece to be processed is further segmented using the optimal saliency threshold to obtain all edge points, and then a blank image with the same size as the original image is created, all edge points are drawn on the blank image to generate a contour edge image.
[0047] S4: Matching is performed in a workpiece database based on the contour image to match a corresponding processing procedure.
[0048] In one embodiment, the contour image of the workpiece to be processed is subjected to denoising, and the size, angle, etc. of the contour image are normalized so that the image has the same scale and direction as the image in the database.
[0049] Use the selected matching algorithm (such as Hu moment matching, Fourier descriptor matching, SIFT (Scale Invariant Feature Transform) matching, etc.) to extract features from the contour image of the workpiece to be processed and each workpiece contour image in the database, and calculate the similarity between the image to be matched and each image in the database based on the extracted features. The similarity calculation method can be determined according to different matching algorithms, such as Euclidean distance, cosine similarity, etc.
[0050] Then the image with the highest similarity is selected as the matching result, and the processing process information of the corresponding workpiece is obtained from the database based on the matching result.
[0051] It should be noted that, for those skilled in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these modifications and improvements all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A workpiece feature recognition method for a CNC machining center, characterized in that: include: Collect the image of the workpiece to be processed in real time and pre-process it; Obtain the pixel values of the three LAB channels of each pixel point of the workpiece image to be processed and the gradient value of each pixel point, set multiple neighborhood windows for the pixel point, traverse the pixel distribution complexity of each neighborhood window, select the neighborhood window corresponding to the maximum pixel distribution complexity as the target window of the pixel point, calculate the color difference and gradient difference between the pixel point and other pixels in its target window, and take the product of the color difference, gradient difference and window distribution complexity of the target window as the local significance of the pixel point; All edge points of the workpiece image are screened based on the local saliency value to obtain a contour edge image; Based on the contour image, matching is performed in the workpiece database to match the corresponding processing steps.
2. A method for identifying workpiece features for a CNC machining center according to claim 1, characterized in that: The process of obtaining the pixel distribution complexity includes: Obtain the gray level co-occurrence matrix of each neighborhood window of the pixel point and calculate the entropy value of the gray level co-occurrence matrix; The optical flow vector of each pixel in the image is obtained by performing a difference operation between the current frame image and the previous frame image, and the dynamic optical flow saliency of the pixel neighborhood window is calculated based on the optical flow vector; The product of the entropy value of the gray-level co-occurrence matrix and the dynamic optical flow significance is taken as the pixel distribution complexity of the neighborhood window corresponding to the pixel.
3. A method for identifying workpiece features for a CNC machining center according to claim 2, characterized in that: The Euclidean distance between the LAB value of the pixel and the LAB mean in the target window is taken as the color difference between the pixel and other pixels in its target window.
4. A method for identifying workpiece features for a CNC machining center according to claim 3, characterized in that: The square root of the difference between the gradient value of the pixel point and the mean gradient value in its target window is taken as the gradient difference between the pixel point and other pixels in its target window.
5. A method for identifying workpiece features for a CNC machining center according to claim 4, characterized in that: The screening of all edge points of the workpiece image based on the local saliency value includes: Pixels whose local significance values are greater than or equal to a preset significance threshold are regarded as edge points.
6. A method for identifying workpiece features for a CNC machining center according to claim 5, characterized in that: The matching is a Fourier descriptor matching algorithm or a scale-invariant feature transformation matching algorithm.
7. A method for identifying workpiece features for a CNC machining center according to claim 6, characterized in that: The process of acquiring the dynamic optical flow saliency includes: Calculate the mean of the optical flow vectors of all pixels in each neighborhood window and the variance of the cosine similarity between the optical flow vectors of all other pixels in the neighborhood window and the optical flow vector of the center point of the neighborhood window; transform the variance of the cosine similarity using an exponential function, and take the product of the transformed result and the mean of the optical flow vectors of all pixels in the neighborhood window as the dynamic optical flow saliency of the pixel neighborhood window.
8. A method for identifying workpiece features for a CNC machining center according to claim 7, characterized in that: The preset significant thresholds include: Multiple candidate saliency thresholds are preset, and initial segmentation is performed based on each candidate saliency threshold to divide pixels into edge points and non-edge points. The inter-class variance and continuity of the segmentation result of the current candidate saliency threshold are calculated, and the objective function is constructed based on the inter-class variance and continuity. The objective function is solved to obtain the optimal saliency threshold.
9. A method for identifying workpiece features for a CNC machining center according to claim 8, characterized in that: The objective function is solved using a particle swarm optimization algorithm or a genetic algorithm.
10. A method for identifying workpiece features for a CNC machining center according to claim 2, characterized in that: The process of acquiring the dynamic optical flow saliency includes: The directional distribution entropy of the optical flow vector in the pixel neighborhood window is calculated, and the directional distribution entropy is used as the dynamic optical flow saliency of the pixel neighborhood window.
Citation Information
Patent Citations
Smoke image segmentation and recognition method based on dictionary and BP neural network
CN110415260A
Fire smoke detection method and device based on LK optical flow method and storage medium
CN115564710A
Fabric tensile property quality detection method
CN118967552A
Part machining detection method and system
CN119941740A
Cited By
Dam displacement monitoring method based on image processing
CN121053607A
A dam displacement monitoring method based on image processing
CN121053607B