A workpiece feature recognition method for a CNC machining center
By combining LAB value, gradient value and dynamic optical flow significance in the CNC machining center, and fusing multiple features to extract the workpiece edges, the problem of FT algorithm ignoring high-frequency details is solved, and the complete identification and precise processing of the workpiece profile is achieved.
Patent Information
- Application Number
- CN202510587950.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2045-05-08
AI Technical Summary
The FT significance detection algorithm of the existing CNC machining center is sensitive to significant areas in the image, and it is easy to ignore high-frequency details, resulting in broken or discontinuous workpiece edge profiles, affecting processing quality.
By obtaining the LAB value and gradient value of the workpiece image, setting multiple neighborhood windows, calculating the local significance of the pixel points, combining the entropy value of the grayscale symbiosis matrix and the significance of dynamic optical flow, filtering edge points, and using multiple feature fusion methods for edge detection to avoid errors caused by a single feature.
The complete extraction of the workpiece contour edge is achieved, the accuracy and machining accuracy of workpiece feature recognition are improved, and the problems of edge fracture and discontinuity are avoided.
Smart Images

Figure CN120107619B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing. More specifically, the present invention relates to a method for identifying workpiece features for a CNC machining center. Background Art
[0002] Computer Numerical Control (CNC) machining centers, as the core equipment of modern manufacturing, are highly efficient automated machine tools that precisely control the tool movement trajectory through computer programs. This equipment can achieve precision machining of workpieces such as metals, plastics, and composite materials. Its core machining functions cover various composite processes such as milling, drilling, boring, and tapping, and are suitable for batch production of workpieces with complex geometric shapes or high-precision single-piece machining.
[0003] Before starting the machining process, the features of the workpiece to be machined are first extracted and analyzed. This crucial step includes comprehensively obtaining parameters such as the geometric features of the workpiece (such as three-dimensional shape, key dimensions, etc.), material properties (including mechanical properties such as hardness and toughness), and machining part 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).
[0004] During the feature extraction process, the FT (Frequency-tuned) saliency detection algorithm can achieve automatic recognition of the machining area by performing specific processing on the image data. However, this algorithm tends to capture regions with significant features in the image, but is more sensitive to large significant regions. Moreover, the algorithm is prone to ignoring the high-frequency detail information of the image, resulting in the fracture or discontinuity of the extracted workpiece edge contour, which in turn has an adverse effect on the subsequent machining quality. Summary of the Invention
[0005] To solve the technical problem of the incomplete extraction of workpiece features leading to a decrease in its machining accuracy, the present invention provides the following technical solutions.
[0006] A method for identifying workpiece features for a CNC machining center, comprising:
[0007] Real-time collecting the image of the workpiece to be machined and preprocessing it;
[0008] 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;
[0009] All edge points of the workpiece image are screened based on the local saliency value to obtain a contour edge image;
[0010] Based on the contour image, matching is performed in the workpiece database to match the corresponding processing steps.
[0011] 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.
[0012] Preferably, the process of acquiring the pixel distribution complexity includes:
[0013] 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;
[0014] 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;
[0015] 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.
[0016] 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).
[0017] Preferably, the Euclidean distance between the LAB value of a pixel and the LAB mean value within the target window is used as the color difference between the pixel and other pixels within its target window.
[0018] Preferably, the square root of the difference between the gradient value of a pixel and the gradient mean value within its target window is used as the gradient difference between the pixel and other pixels within its target window.
[0019] Preferably, the screening of all edge points of the workpiece image based on the local saliency value includes:
[0020] Pixels with local saliency values greater than or equal to a preset saliency threshold are used as edge points.
[0021] Preferably, the matching is a Fourier descriptor matching algorithm or a scale-invariant feature transform matching algorithm.
[0022] Preferably, the acquisition process of the dynamic optical flow saliency includes:
[0023] Calculate the mean of the optical flow vectors of all pixels within each neighborhood window and the variance of the cosine similarity between the optical flow vectors of all other pixels within the neighborhood window and the optical flow vector of the center point of the neighborhood window; convert the variance of the cosine similarity using an exponential function, and use the product of the converted result and the mean of the optical flow vectors of all pixels within the neighborhood window as the dynamic optical flow saliency of the pixel neighborhood window.
[0024] By calculating the mean of the optical flow vectors of all pixels within the neighborhood window, the optical flow information within the neighborhood can be grasped as a whole, avoiding large errors caused by abnormal optical flow vectors of individual pixels; calculating the variance of the cosine similarity between the optical flow vectors of all other pixels within the neighborhood window and the optical flow vector of the center point of the neighborhood window can measure the consistency of the optical flow directions within the neighborhood. When the variance is small, it indicates that the optical flow directions within the neighborhood are more consistent and the saliency is higher, thus more accurately reflecting the true motion.
[0025] Preferably, the preset saliency threshold includes:
[0026] Preset multiple candidate saliency thresholds, perform initial segmentation based on each candidate saliency threshold, divide the pixels into edge points and non-edge points, calculate the between-class variance and continuity for the segmentation result of the current candidate saliency threshold, construct an objective function based on the between-class variance and continuity, and solve the objective function to obtain the optimal saliency threshold.
[0027] By presetting multiple candidate significant thresholds and performing initial segmentation based on each candidate threshold to divide pixels into edge points and non-edge points, each pixel in the image can be processed more meticulously, avoiding misjudgment that may be caused by a single threshold, and thus more accurately determining the edge of the image; after each segmentation, an objective function is constructed according to the between-class variance and continuity, and the optimal significant threshold is obtained by solving the objective function. The larger the between-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 result, avoiding fragmentation of the segmentation result caused by factors such as noise.
[0028] Preferably, the particle swarm optimization algorithm or the genetic algorithm is used to solve the objective function.
[0029] Preferably, the process of obtaining the dynamic optical flow saliency includes:
[0030] Calculate the direction distribution entropy of the optical flow vectors within the neighborhood window of the pixel point, and use the direction distribution entropy as the dynamic optical flow saliency of the pixel point neighborhood window.
[0031] As a measure of the dynamic optical flow saliency, the direction distribution entropy can effectively reduce misjudgment caused by noise or background interference. For example, in the case of complex background texture or small-scale random motion, this method can better distinguish these interferences and real moving targets.
[0032] The beneficial effects of the present invention are:
[0033] The present invention calculates the color difference and gradient difference between a pixel point and other pixel points within its target window, and uses the product of them and the window distribution complexity of the target window as the local saliency of the pixel point; by presetting multiple candidate significant thresholds and performing initial segmentation based on each candidate threshold, calculating the between-class variance and continuity, constructing an objective function and solving the optimal significant threshold, it can automatically select the optimal significant threshold according to the specific characteristics of the workpiece image, and then more accurately extract the contour edge of the workpiece, thereby improving the accuracy of workpiece feature recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 is a flowchart of the method from step S1 to step S4 in a workpiece feature recognition method for a CNC machining center according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0035] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention.
[0036] Refer to Figure 1, A workpiece feature recognition method for a CNC machining center includes steps S1 - S4, specifically as follows:
[0037] S1: Continuously collect the workpiece image to be machined in real - time and pre - process it.
[0038] In one embodiment, install a camera in the machining area of the CNC machining center. When the workpiece to be machined reaches the camera area, the camera starts to continuously collect the workpiece image to be machined.
[0039] Furthermore, use a 5×5 Gaussian kernel to smooth the collected workpiece image to be machined to remove high - frequency information in the image.
[0040] S2: Obtain the pixel values of the LAB three channels of each pixel point of the workpiece image to be machined and the gradient value of each pixel point. Set multiple neighborhood windows for the pixel point, traverse the pixel point distribution complexity of each neighborhood window, select the neighborhood window corresponding to the maximum pixel point distribution complexity as the target window of the pixel point, calculate the color difference and gradient difference between the pixel point and other pixel points in its target window, and take the product of the color difference, gradient difference, and the window distribution complexity of the target window as the local saliency of the pixel point.
[0041] The workpiece edge contour feature is an important basis for precision machining of a CNC machining center. When the traditional FT saliency algorithm extracts the workpiece edge contour feature, it tends to capture large significant regions and easily ignores small edges, resulting in discontinuous workpiece edge contours and loss of details extracted.
[0042] In the embodiment of the present invention, by combining the color information and gradient information of the image, the edge features are processed more finely to avoid the influence of global contrast on edge extraction.
[0043] In one embodiment, first convert the above - collected image from the RGB color space to the LAB color space to obtain the LAB three - channel values of each pixel point. In addition, convert the image into a grayscale image and use the Sobel operator to calculate the gradient value of each pixel point.
[0044] Furthermore, set multiple neighborhood windows of different sizes k×k for each pixel point, traverse these neighborhood windows, obtain the gray - level co - occurrence matrix of the corresponding neighborhood window, and calculate the entropy value of the gray - level co - occurrence matrix. The larger the entropy value, the more complex the gray - level distribution of pixel points in the window.
[0045] Exemplarily, 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 context information but may increase the computational complexity and introduce unnecessary noise. Therefore, choosing a compromise value range of k as [3, 15] can achieve a balance between capturing sufficient local information and controlling the computational complexity.
[0046] It should be noted that in a sequence of consecutive frame images, the foreground object (the workpiece to be processed) is usually in a moving state, and the positions of its pixel points change over time; while the background area is relatively stationary or has less movement. Therefore, by calculating the optical flow vectors of pixel points, the movement direction and speed magnitude of pixel points can be accurately described, which helps to further determine the size of the neighborhood window of pixel points.
[0047] In one embodiment, the optical flow vectors of each pixel point in the image are obtained by performing a difference operation between the current frame image and the previous frame image. Then, the mean value of the optical flow vectors of all pixel points within each neighborhood window and the variance of the cosine similarity between the optical flow vectors of all other pixel points within the neighborhood window and the optical flow vector of the center point of the neighborhood window are calculated. Further, the variance of the cosine similarity is transformed using an exponential function, and the product of the transformed result and the mean value of the optical flow vectors of all pixel points within the neighborhood window is used as the dynamic optical flow significance.
[0048] In another embodiment, the direction distribution entropy of the optical flow vectors within the neighborhood window of a pixel point is calculated and used as the dynamic optical flow significance of the neighborhood window of the pixel point. The larger the entropy value, the more dispersed the movement direction and the higher the significance.
[0049] Finally, the product of the entropy value of the gray-level co-occurrence matrix calculated above and the dynamic optical flow significance is used as the pixel point distribution complexity of the corresponding neighborhood window of the pixel point.
[0050] Traverse all neighborhood windows, and select the neighborhood window corresponding to the maximum pixel point distribution complexity as the target window of the pixel point.
[0051] Further, the Euclidean distance between the LAB value of the pixel point and the LAB mean value within the target window is used as the color difference between the pixel point and other pixel points within its target window, and the square root of the difference between the gradient value of the pixel point and the gradient mean value within its target window is used as the gradient difference between the pixel point and other pixel points within its target window.
[0052] Finally, the product of the color difference, gradient difference, and window distribution complexity of the target window calculated above is used as the local significance of the pixel point.
[0053] 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 terms of color, and its local saliency value is also greater; by considering the gradient difference, the saliency of edge points can be enhanced to strengthen the edge response; the higher the complexity, the more uneven the distribution of pixels in the window, and it may contain more detailed or structural information.
[0054] S3: Screen all edge points of the workpiece image based on the local saliency value to obtain a contour edge image.
[0055] In one embodiment, all edge points of the workpiece image are screened according to the local saliency of the pixel points calculated in 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 to divide the pixels into edge points and non-edge points. For the segmentation result of the current candidate significant threshold, calculate its between-class variance and continuity, construct an objective function based on the between-class variance and continuity, and dynamically adjust the candidate significant threshold through a swarm intelligence algorithm (such as particle swarm optimization algorithm, genetic algorithm, etc.). Repeat the two operations of initial segmentation and constructing the objective function to find the optimal significant threshold that maximizes the objective function value. The calculation of between-class variance and continuity is a prior art and will not be elaborated here.
[0056] Exemplarily, the above objective function is:
[0057]
[0058] In the formula, is the objective function value calculated after screening edge points using the candidate significant threshold ; is the between-class variance calculated after screening edge points using the candidate significant threshold ; is the continuity calculated after screening edge points using the candidate significant threshold .
[0059] Among them, stop searching when the objective function value converges.
[0060] Further use the optimal significant threshold to perform a final segmentation on the workpiece image to be processed to obtain all edge points, and then create a blank image with the same size as the original image, and draw all edge points on the blank image to generate a contour edge image.
[0061] S4: Perform matching in the workpiece database based on this contour image to match the corresponding processing procedures.
[0062] In one embodiment, the contour image of the workpiece to be processed is denoised, and the size, angle, etc. of the contour image are normalized so that it has the same scale and orientation as the images in the database.
[0063] The selected matching algorithm (such as Hu moment matching, Fourier descriptor matching, SIFT (Scale-Invariant Feature Transform) matching, etc.) is used to extract features from the contour image of the workpiece to be processed and each workpiece contour image in the database. According to the extracted features, the similarity between the image to be matched and each image in the database is calculated. The similarity calculation method can be determined according to different matching algorithms, such as Euclidean distance, cosine similarity, etc.
[0064] Then, the image with the highest similarity is selected as the matching result, and according to the matching result, the processing procedure information of the corresponding workpiece is obtained from the database.
[0065] It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, several deformations and improvements can still be made, and these all belong to the protection scope of the present invention. Therefore, the protection scope of this invention patent shall be subject to the appended claims.
Claims
1. A workpiece feature recognition method for a CNC machining center, characterized in that, Including: Collecting the image of the workpiece to be processed in real time and preprocessing it; Obtaining the pixel values of the three LAB channels of each pixel point in the image of the workpiece to be processed and the gradient value of each pixel point, setting multiple neighborhood windows for the pixel point, traversing the pixel point distribution complexity of each neighborhood window, selecting the neighborhood window corresponding to the maximum pixel point distribution complexity as the target window of the pixel point, calculating the color difference and gradient difference between the pixel point and other pixel points in its target window, and taking the product of the color difference, gradient difference and pixel point distribution complexity of the target window as the local saliency of the pixel point; Filtering all edge points of the workpiece image based on the local saliency value to obtain a contour edge image; Performing matching in the workpiece database based on the contour edge image to match the corresponding processing procedure; The obtaining process of the pixel point distribution complexity includes: Obtaining the gray-level co-occurrence matrix of each neighborhood window of the pixel point and calculating the entropy value of the gray-level co-occurrence matrix; Performing a difference operation between the current frame image and the previous frame image to obtain the optical flow vector of each pixel point in the image, and calculating the dynamic optical flow saliency of the pixel point neighborhood window based on the optical flow vector; Taking the product of the entropy value of the gray-level co-occurrence matrix and the dynamic optical flow saliency as the pixel point distribution complexity of the pixel point corresponding neighborhood window.
2. The workpiece feature recognition method for a CNC machining center according to claim 1, wherein, Taking the Euclidean distance between the LAB value of the pixel point and the LAB mean value in the target window as the color difference between the pixel point and other pixel points in its target window.
3. The workpiece feature recognition method for a CNC machining center according to claim 2, characterized in that, Taking the square root of the difference between the gradient value of the pixel point and the gradient mean value in its target window as the gradient difference between the pixel point and other pixel points in its target window.
4. A workpiece feature recognition method for a CNC machining center according to claim 3, characterized in that, The filtering of all edge points of the workpiece image based on the local saliency value includes: Taking the pixel points with local saliency values greater than or equal to the preset significant threshold as edge points.
5. A workpiece feature recognition method for a CNC machining center according to claim 4, characterized in that, The matching is a Fourier descriptor matching algorithm or a scale-invariant feature transform matching algorithm.
6. A workpiece feature recognition method for a CNC machining center according to claim 5, characterized in that, The obtaining process of the dynamic optical flow saliency includes: Calculating the mean value of the optical flow vectors of all pixel points in each neighborhood window and calculating the variance of the cosine similarity between the optical flow vectors of all other pixel points in the neighborhood window and the optical flow vector of the neighborhood window center point; converting the variance of the cosine similarity using an exponential function, and taking the product of the converted result and the mean value of the optical flow vectors of all pixel points in the neighborhood window as the dynamic optical flow saliency of the pixel point neighborhood window.
7. A workpiece feature recognition method for a CNC machining center according to claim 6, characterized in that, The preset significant threshold includes: Presetting multiple candidate significant thresholds, performing initial segmentation based on each candidate significant threshold, classifying pixels into edge points and non-edge points, calculating the between-class variance and continuity for the segmentation result of the current candidate significant threshold, constructing an objective function based on the between-class variance and continuity, and solving the objective function to obtain the optimal significant threshold.
8. A workpiece feature recognition method for a CNC machining center according to claim 7, characterized in that, The solution of the objective function uses a particle swarm optimization algorithm or a genetic algorithm.
9. A workpiece feature recognition method for a CNC machining center according to claim 1, characterized in that, The obtaining process of the dynamic optical flow saliency includes: Calculating the direction distribution entropy of the optical flow vectors in the pixel point neighborhood window, and taking the direction distribution entropy as the dynamic optical flow saliency of the pixel point 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