#### Abstract

In the development of modern tools, the flute (or profiling flute) after design optimization is often obtained by grooving with a forming grinding wheel. At present, the main method of reverse forming wheel profile is the analytical method, which needs to solve the contact line equation according to the contact conditions. It is difficult to solve the equation. The solution value is unstable, which leads to the design error of the grinding wheel profile. In order to solve this problem, this paper proposes a new algorithm, called the pixel matrix method for short. This method is based on the spiral motion envelope method and mathematical morphology. First, the cross-section of the flute is discretized into a point cloud, and then, the envelope motion is carried out in the grinding wheel coordinate system. Second, the point cloud of the grinding wheel radial section is collected and converted into a binary image of pixel points. Finally, the profile of the binary image is extracted by erosion and dilation. The optimized profile of the formed grinding wheel reaches the accuracy requirements of the design and processing in the actual machining verification. This method can accurately reverse the profile of the forming grinding wheel. The calculation process is intuitive, avoiding the solution of the contact line equation, and the solution value is stable. It provides a new way to reverse the profile of the machining tool for cylindrical spiral products.

#### 1. Introduction

As the “teeth” of industrial manufacturing, cutting tools play an important role in the processing quality and effectiveness of products. The performance of a tool depends mainly on the design of the spiral groove and grinding process. To obtain a good cutting effect and tool life, the flute needs to meet the specific structural requirements related to the rake angle, core radius, spiral angle, chip breaking, and chip removal [1]. A forming grinding wheel is often used to perform grooving in the design and optimization of a spiral groove. Therefore, it becomes particularly important to apply the reverse method of calculating the section of the forming grinding wheel based on the designed flute. It is also the key to realize high-precision grinding of the flute.

Based on the meshing relationship between the grinding wheel and the spiral groove, Litvin and Fuentes [2] proposed an analytical solution, which focused on the meshing principle and considered the common normal direction at the contact point between the grinding wheel and flute as perpendicular to the direction of speed of relative motion; the solution determined the contact point between the rotating surface of the grinding wheel and helical surface processed by the grinding wheel. According to the condition that the contact point lies on both the rotating surface and spiral surface of the grinding wheel, the contact point is rotated around the axis of the grinding wheel, and the grinding wheel contour equation is obtained after fitting. Uhlman et al. [3] optimized the grinding wheel design for flute grinding processes by using the numerical analysis of complex contact conditions. Wasif et al. [4] used a five-axis NC grinding process combined with contact conditions to generate a simplified grinding wheel geometry for grinding end mills. Jianmin et al. [5] based on the principle of form grinding, combined with the meshing principle and the numerical method of piecewise accumulative chord length parameters, gave the basic calculation process of the profile of the form grinding wheel. Ren et al. [6], combined with contact conditions, gave a general and effective method for grinding cylindrical milling cutter with five-axis NC tools. Wei et al. [7] established a mathematical model for the cross-section profile design of a precision-grinding helical grinding wheel based on the gear meshing theory. By using the profile design method of forming tools based on the meshing principle and spline interpolation method, Tang et al. [8] combined the contact line shape generated by the coordinated movement of the machine tool, screw, and tool with the spatial position parameters and proposed the form position geometry method (FPGM), which avoids the task of solving the first derivative of each discrete point in the traditional contact line method. Shen et al. [9] introduced the parametric design method of grinding wheel with an arbitrary groove on the spiral rake face of the tool. Li [10] introduced a grinding wheel contour calculation algorithm based on the envelope and analytic geometry theory.

The above methods are all based on complex mathematical equations, and their constraints are also described by mathematical models, which are called analytical methods. It has high accuracy and does not need too many iterative operations. During the process of solving, the analytical method established according to the surface conjugate theory often suffers from problems such as complex numerical solution, nonlinearity, and instability due to the complexity of the contact line equation. Especially, a solution cannot be obtained when there is no normal at a point on the contour of the grinding wheel. In addition, if the grinding wheel contour has a conic curve such as a circular arc, the transcendental equation needs to be solved, and the exact analytical solution cannot be obtained.

With the rapid development of computer speed, researchers have proposed a new method, called the graphical method, which can obtain an accurate profile by using the envelope boundary. It avoids the use of the traditional complex surface meshing equation by simulating the envelope motion process of the helical surface and replacing the traditional conjugate principle. Chong and Ibrahim [11] developed computer vision measurement for end mill and realized cutter parameter measurement by image recognition. Karasawa et al. [12] used image processing technology to analyze the wear condition of the grinding wheel. Wu et al. [13] proposed the radial ray shooting method to segment the envelope curve cluster. They used the radial ray method to scan the approximate arc center position to extract the grinding wheel section profile. Chen et al. [14] introduced an image processing method for checking the accuracy of the grinding wheel profile in microdrill groove processing. Yang et al. [15–17] solved the formed grinding wheel of the screw compressor rotor based on the graphical edge detection method, avoiding the difficulty of solving the complex nonlinear contact line equation when using the analytical method. It can effectively obtain point cloud data to remove singular points, with high accuracy, and can extract relatively ideal edges. This method has reference value in the design of the grinding wheel profile for forming a grinding screw rotor. Shen et al. [18] proposed the digital graphic scanning method (DSG) to obtain the contour data of the rotor by scanning the pixels of the envelope surface in the tool cutting path on the screen.

The above graphical methods need to scan point by point to obtain the boundary of the envelope profile and judge the validity of the boundary points point by point, which makes it difficult to remove the singular points of the point cloud data in the process of extracting the boundary, and the processing efficiency is relatively low. Because the accuracy of the image boundary depends on the trajectory planning, the number of pixels, and the fitting accuracy of the curve, there is still a large error between the boundary extraction and the theoretical curve. Therefore, the identification or extraction of the profile boundary of the formed grinding wheel has become a new difficulty and research topic. Many scholars have developed a variety of graphical methods, which enable the algorithm more efficient and accurate in identifying or extracting the theoretical profile boundary of the grinding wheel.

Similarly, in order to avoid the analytic solution, this paper proposes a binary image processing algorithm, which combines the meshing motion envelope method and mathematical morphology, called the pixel matrix method for short. This method tries to use the idea of mathematical morphology to view the point cloud pixels as a set to extract the point cloud boundary, which eliminates the process of scanning and one-by-one boundary judgment. At the same time, the pixel matrix method, like other graphical methods, avoids the solution of the contact line equation. The calculation process is intuitive, and the solution value is stable. The pixel matrix method is another innovative research and application of the graphic method to obtain the profile of the shaped grinding wheel. This method is also suitable for the reverse calculation of forming tools. It provides a new way to obtain the section profile of spiral groove forming tools that meet the requirements of design and machining accuracy in theory.

The remainder of this paper is organized as follows: in Section 2, the basis of point cloud generation is derived by using the envelope principle of the flute. Section 3 presents the method and steps of extracting the profile of the formed grinding wheel based on mathematical morphology; in Section 4, simulation examples and actual machining are provided. Finally, Section 5 summarizes the study.

#### 2. Envelope Principle of Known Flute End Cross-Section for Determining Grinding Wheel Section Profile

In this paper, according to the envelope model proposed by Kang et al. [19, 20], Figure 1 shows the tool end cross-section curve . Its vector equation can be expressed as follows:where is a parameter variable. Furthermore, can also be expressed as follows:

Equation (3) for the spiral surface of the flute can be obtained using the spiral motion of the profile curve around the tool axis.where *θ* is a parameter variable, which indicates the angle at which the section curve at the tool end rotates around the *z*-axis from the beginning; is a helix parameter, which indicates the distance covered along the axial direction when the section curve at the tool end turns around the -axis by a unit angle.

The relative positions of the tool workpieces machined with the forming grinding wheels are shown in Figure 2. The tool workpiece coordinate system was fixed on the tool workpiece such that the -axis coincided with the workpiece axis. The grinding wheel coordinate system was fixed on the grinding wheel, and its origin was located at the center of the front face of the grinding wheel. The angle between the tool axis and workpiece axis was , and the distance between the origins of the two coordinate systems along the *y*-axis direction was denoted as *a* (called the center distance); the distance along the -axis direction was *e* (called the eccentricity), and the distance along the -axis direction was *d* (distance before the end).

According to the principle of coordinate transformation, the transformation matrix between the workpiece coordinate system and grinding wheel coordinate system can be expressed as follows:

The coordinates of the helical surface in the grinding wheel coordinate system can be expressed as follows:

Then, the point cloud of the spiral surface is rotated around the axis of the grinding wheel, and the rotating surface of the sand wheel in its axial plane is expressed as shown in equation (6). The profile of the grinding wheel is shown in Figure 3.where is the thickness direction, and is the radial direction of the grinding wheel.

#### 3. Algorithm for Extracting the Profile of Shaped Grinding Wheel Based on Mathematical Morphology

The proposed algorithm for extracting the profile of the shaped grinding wheel based on mathematical morphology is called the pixel matrix method. It is intended to quickly obtain the boundary of the point cloud after converting a large number of point cloud data into pixels based on the principle of combining computer image processing with the mathematical morphology. The specific algorithm for obtaining the profile of the shaped grinding wheel can be divided into the following steps:(1)The discrete data points of the cross-section profile of the flute are interpolated and densified.(2)The dense data points are used to generate the helicoid, and then, the data points of the grinding wheel section are enveloped to generate the data points. The boundary conditions are set to obtain the coordinates of the target point cloud of the grinding wheel section.(3)The target point cloud is binarized, and the boundary of the binary image is extracted using mathematical morphology.(4)The extracted wheel cross-section profile is optimized using the slope method to obtain the pixel points that are closer to the theoretical profile, and the actual wheel cross-section profile is obtained by restoring the wheel coordinates through the coordinate mapping relationship.

##### 3.1. Densification of the Cross-Section Profile Point of the Flute

The cross-section profile point of the flute, indicated by the discrete points of the flute under the workpiece coordinates, is , as shown in Figure 4, in which *r* is the radius of the tool.

Two types of mathematical models are used for the end cross-section of the flute: the first is the vector model, which is given in the form of equation (1). The profile of the end cross-section of the flute can be obtained by discretizing the parameter . The other model describes the section shape of the flute in the form of discrete points according to the following equation:

In this case, because the number of points is limited, the profile of the end cross section of the flute can be interpolated and densified by the cubic spline curve.

According to the definition of the spline curve, let be the cubic spline interpolation function of . Then, we can know that each segment of is a cubic polynomial function curve, which can pass through fixed points , . The specific expression for each curve can be obtained by calculating the coefficients in each spline curve equation. Each segment expression can be set as follows:where , , , are undetermined coefficients.

Obviously, the differential equation of the spline curve can be expressed as follows:

According to the definition, a unit *s* of , i.e., , needs to meet two conditions.(1)Interpolation and continuity conditions are as follows:where .(2)Differential continuity condition is as follows:where .

Then, the data nodes and the specified first endpoint conditions are brought into the matrix equation, and the pursuit method is used to solve the tridiagonal matrix equation to obtain the coefficients of each section of the spline curve, as shown in the following equation:where , , and is the step size.

Finally, the interpolated is examined in the subinterval of [,], through which the function is used to calculate the corresponding interpolation . The cubic spline interpolation points of each interval are drawn to obtain the densification point cloud of the flute, as shown in Figure 5.

##### 3.2. Acquisition of Target Point Cloud under Point Cloud Envelope and Boundary Conditions

In the workpiece coordinate system , the point cloud of the end face profile of the tool flute after densification is spirally moved according to the screw parameter ; the point cloud on the cross-section of the grinding wheel is generated after enveloping the point cloud of the spiral surface formed according to the envelope principle, as shown in Figure 6. The cloud equation for generating the discrete space point set of the tool flute surface is as follows:where , .

According to the transformation matrix **M** of the workpiece coordinates and grinding wheel coordinates in equation (4), the calculation formula for calculating the conversion of the helicoid point cloud to the grinding wheel coordinates is as follows:where .

The helicoid point cloud is converted to the grinding wheel coordinate around the grinding wheel axis. Then, all the point clouds on the grinding wheel section are obtained according to equation (16), as shown in Figure 7.where .

According to the envelope principle and processing conditions, the target point cloud can be determined through the following boundary conditions:(1) of the target point cloud is less than the set center distance *a*.(2)The target point clouds are between the points and . The target point cloud is in the direction, and the coordinates are in the interval , as shown in Figure 8.

According to the above boundary conditions, the matrix form of the point cloud of the target grinding wheel section is expressed as equation (17), and the target point cloud satisfying the boundary conditions is shown in Figure 9.

##### 3.3. Boundary Extraction Algorithm of Mathematical Morphology

Mathematical morphology is a widely used technology in image processing. It is mainly used to extract meaningful image components to express or describe the shape of a region from an image. Based on the geometry, it focuses on the collection structure of the images [19].

The research object of this paper is the grinding wheel. The key feature of the point cloud binary image of its cross-section is that each pixel in the binary image is 8-connected; that is, the connected features form the internal composition as shown in Figure 10.

Finally, the binary image boundary is extracted through the dilation and erosion operations of mathematical morphology [20], and the final image boundary is marked as shown in Figure 11.

Let **A** be the original image, and **B** be the “structural element.” Mathematical morphology erosion is expressed as equation (18), and the schematic is shown in Figure 12.

Similarly, the dilation operation process is shown in Figure 13, and the operation is expressed as follows:

The operation on the boundary is shown in Figure 14 and is expressed as follows:

To realize the conversion between the data points and pixels, the point cloud data should be prepared for binary processing such as scaling, translation, and rounding operations to ensure that the pixel coordinates are positive integers. The point cloud is converted from the point cloud coordinates of the grinding wheel section profile plane, shown in equation (21), into the pixel coordinates . The converted image is shown in Figure 15.where , ; indicates a rounding operation, and is the zoom factor.

Here, , , .

Then, binarization is performed to generate a binarized image.

The maximum values , and minimum values , are extracted to construct a matrix. The matrix element at the position is “1” in equation (22). The other element in the matrix is “0.” The point cloud of the flute is established using the binary matrix, which binarizes the coordinates of the point clouds, and then, the binary image is generated according to the binarization matrix.

The binary point cloud image can be processed using the dilation and erosion algorithm of the mathematical morphology, and the profile curve of the forming wheel can be extracted. The resulting image after the dilation operation is shown in Figure 16. The image obtained after the edge erosion operation using the erosion algorithm is shown in Figure 17.

##### 3.4. Boundary Extraction and Optimization Processing of Binary Image of Grinding Wheel Section Profile

The basic morphological operations of the binary images in the mathematical morphology include dilation, erosion, opening, and closing. As some nonexistent pixels are added or filled in the filling process of the dilation operation, as shown in Figure 18, a stepped contour pixel boundary appears.

In this study, the slope method was used to optimize the boundary extracted through mathematical morphology. The slope method can reduce the deviation caused by the dilation operation.

The algorithm of the slope method calculates the slope between the characteristic pixels. To extract the pixels closer to the real contour, it calculates the interpolated pixels when the pixels change in the *x* or *y* direction (the pixels are called the characteristic pixels), instead of the pixels between the two characteristic pixels.

As shown in Figure 19, according to the change in the profile curvature, the computation begins at the starting pixel point (the pixel point with the smallest coordinate value *Y*) in a pixel unit (composed of a column of pixel points) and proceeds point-by-point with the comparison of the calculation results.

Set the starting pixel point of the first-pixel unit as the starting point, and the given starting point coordinate is . The starting pixel coordinate of the nth pixel unit is , where ; *i* denotes the pixel point, where , and *i* = 1 is the starting point of the nth pixel unit. Then, the slope between any pixel point *P*11 and the nth pixel unit can be defined as equation (23).

The position is taken with the minimum slope in each pixel unit, as follows:

Thus, only the pixel point with the smallest slope is reserved for extracting the pixel unit on the same vertical axis. On the contrary, after the curvature of the pixel points is reversed, the position pixel with the largest slope can be reserved, and the filtered pixel points can be regarded as the characteristic pixel points.

Assume that the coordinates of the starting pixel of the nth pixel unit are , and the coordinates of the starting pixel of the -th pixel unit are . The spline interpolation function is established through the interpolation method. Taking the *y* value of the pixel points as the independent variable, various pixel coordinate values *x* are obtained as the compensated pixel points to increase the number of pixel points. Thus, an approximate contour line is obtained, as shown in Figure 20. The interpolated pixel points can be expressed as follows:

Finally, the grinding wheel profile coordinates are restored, and the theoretical contour is mapped to the pixel coordinates through the zoom and translation operations to obtain the corresponding grinding wheel profile coordinates . The transformation is expressed as follows:

#### 4. Example Analysis

##### 4.1. Theoretical Calculation and Analysis

The 4-edge end mill (tool radius: *r* = 6 mm; helix angle: = 30°) was selected for replication and manufacturing. The end mill was cut vertically along the axis, and the end cross-section profile of the tool was obtained. The measurement data were obtained by placing it on the projector (Table 1). The measurement error was within the range of 0.001 mm.

The cross-section profile of the end mill was obtained after copying and rotating the profile points measured in Table 1, as shown in Figure 21.

The grinding wheel installation parameters are shown in Table 2. The zoom factor *N* selected in the pixel matrix method operation is 1000 times. The pixel matrix method can be used to reverse the profile of the formed grinding wheel by equation (26), as shown in Figure 22.

Analytical method is the most commonly used and traditional method to reverse the profile of forming the grinding wheel in actual production activities. Therefore, this paper chooses the pixel matrix method to reverse the profile curve of the grinding wheel and the analytical method to reverse the profile curve of the grinding wheel for comparative analysis.

Under the same parameters as in the above example of the pixel matrix method (Table 2), the analytical method was used to solve the grinding wheel cross-section profile. The obtained cross-section profile point coordinate data are shown in Table 3, and the data points of the grinding wheel cross-section profile drawn from the table data are shown in Figure 23.

The error evaluation method for the profile of the forming grinding wheel measures the distance between the corresponding points of the sand profile obtained with the pixel matrix method and analytical method in the normal direction of the profile points as the comparison error.(1)The section profile curve of the grinding wheel reverse calculated by the pixel matrix method with the zoom factor *N* of 1000 times is compared with the section profile curve of the grinding wheel reverse calculated by the analytical method. The error of the two profiles is ≤1.2695 *μ*m, as shown in Figure 24. It can be seen from the comparison results that the profile error is within the range of (−3 *μ*m, 3 *μ*m), which can meet the accuracy requirements of actual machining.(2)When the zoom factor *N* is 500 times, the pixel matrix method is used to reverse the profile of the forming wheel. The error distance of the profile point solved by the analytical method is less than 3.0044 *μ*m. The comparison result is shown in Figure 25. It is found that the reverse profile cannot meet the accuracy requirements of actual processing. It can be seen from the comparison results that the profile error is beyond the range of (−3 *μ*m, 3 *μ*m), and the reverse grinding wheel profile cannot meet the accuracy requirements of actual machining. It can be seen from this that with the increase of scaling factor *N*, the profile error of the grinding wheel inversely obtained by the pixel matrix method is smaller than that obtained by the analytical method, which indicates that the prediction model of the grinding wheel profile inversely obtained by pixel matrix method is more accurate.

##### 4.2. Actual Processing Verification

In order to verify the effectiveness of the algorithm in the actual tool grinding, the grinding wheel was shaped based on the grinding wheel section profile inversely solved by the pixel matrix, and the slotting was processed by a C818 five-axis CNC tool grinder manufactured by the Narita Intelligent Technology (Zhejiang) Co., Ltd., shown in Figure 26.

*Step 1. *Select the shaped grinding wheel with the profile of the grinding wheel section as shown in Figure 22 for slotting. The installation parameters of the grinding wheel are shown in Table 2. Processing parameters are shown in Table 4. The 4-edge cutting tool (only slotting) obtained by slotting is shown in Figure 27.

*Step 2. *Extract the section profile of the actually processed flute, and the VMS-2010 image measuring instrument was selected as the detection equipment. The detection process is shown in Figure 28.

The cross-section of the tool end after machining was extracted by the detection equipment, as shown in Figure 29.

Figure 30 shows the result after gray processing, and the extraction boundary is shown in Figure 31.

*Step 3. *Compare the section profile of the flute. First, 200 discrete points of the single-edge flute profile are extracted from Figure 31 and then compare it with the original given flute end face profile points in Table 1. The distances between the corresponding points of the two profiles along the normal direction were calculated as comparison errors. The error is ≤2.9733 *μ*m, and the error distribution is shown in Figure 32. These errors were within the range of (−3 *μ*m, 3 *μ*m). Therefore, the pixel matrix method can meet the accuracy requirements of design or processing in actual production.

The results of theoretical calculation and actual machining show that the grinding wheel based on the inverse solution of mathematical morphology can meet the accuracy requirements of grooving, and the prediction model is stable, accurate, and reliable.

#### 5. Conclusions

In order to accurately and stably obtain the section profile of the grooved forming grinding wheel, a new digital graphic solution algorithm is proposed. It only needs to make a rotary motion around the *z*-axis of the grinding wheel through the discrete point cloud of the spiral surface of the cutting groove of the tool, collect the envelope point cloud, intercept the target point cloud of the condition boundary on the grinding wheel section, and extract the boundary profile curve of the grinding wheel section by using the concept of morphological binary image operation. The main conclusions about this new method are as follows:(1)This algorithm is based on the principle of spiral motion, and it is not only applicable to reverse grinding wheel engineering of flute in end mill but also applicable to reverse engineering of machining tool profile in all cylindrical spiral products.(2)This algorithm does not need to solve contact line and nonlinear equation, so the solution value of this method is stable and has no singular solution problem.(3)The algorithm is intuitive in the calculation process and has the ability to simulate and calculate the profile of the formed grinding wheel section. It could be used as a theoretical inspection tool before grooving and be directly used to develop CAD/CAM computer software and automatically generate the profile of the grinding wheel section.(4)This algorithm is a powerful calculation of actual tool slotting processing. It can guide the profiling production of formed grinding wheels, and its calculating accuracy can also meet the requirements of processing and design. However, the compensation problem after wear of formed grinding wheels needs to be further studied in combination with wheel position and attitude.(5)This method is based on the mathematical morphology of pixel images. The numerical solution accuracy of the calculation is directly related to the number of point clouds. The more point clouds, the higher the calculation accuracy, and the greater amount of calculation, which often affects the efficiency of calculation. With the improvement of computer performance and optimization of calculating methods, this problem should be solved better.

#### Data Availability

The data used to support the findings of this study are included within the article.

#### Conflicts of Interest

The authors declare that there are no conflicts of interest regarding the publication of this paper.

#### Acknowledgments

The authors would like to acknowledge financial support from the Guizhou Science and Technology Planning Project ([2020] 1y231).