Two-dimensional part outline rasterization feature representation method

文档序号:8545 发布日期:2021-09-17 浏览:32次 中文

1. A method for representing the rasterized features of the outline of a two-dimensional part is characterized by comprising the following steps:

step 1: storing the two-dimensional graph into a file format capable of reading graph information;

step 2: reading the file information in the step 1;

and step 3: according to the degree of dispersion xdRasterizing the outline of the part, and recording the direction sequence number of the discrete points;

and 4, step 4: constructing a direction chain code according to the direction serial number recorded in the step 3, and describing the concave-convex characteristic of the two-dimensional profile by using the code value;

and 5: and constructing a profile concave-convex characteristic curve.

2. The method for rasterizing feature representation of the outline of a two-dimensional part as recited in claim 1, wherein in step 1, the AutoCAD is used to save the two-dimensional graph into DXF file format;

in step 2, reading the graph in step 1 by using a DXF reading program, specifically: and (3) extracting the data information of the LINE, CIRCLE, POLYLINE and ARC in the segments of the ENTITIES of the DXF file in the step (1) by using a DXF reading program.

3. A two-dimensional part profile rasterization feature representation method as claimed in claim 1, wherein said step 3 comprises:

step 3.1: for all coordinate information A (X, Y), the X-coordinate and the Y-coordinate are divided by the degree X to be discretized, respectivelydFurther rounding up to obtain a discrete coordinate set B (X)1,Y1) (ii) a Further removing discrete coordinate set B (X)1,Y1) The repeated points result in a discrete coordinate set C (X)2,Y2);

Step 3.2: there are 8 adjacent pixel points around the central pixel point in the pixel graph, and 8 search directions are constructed as (1, 2, 3, 4, 5, 6, 7, 8);

step 3.3: taking a discrete coordinate set C (X)2,Y2) And further searching and storing the searched first discrete point Q and recording the direction serial number I of the first discrete point Q according to the sequence of (2, 3, 4, 5, 6, 7, 8, 1), and searching the next pixel point of the contour in the clockwise direction according to the direction serial number I of the first discrete point Q and the direction serial number I of the first discrete point Q relative to the symmetrical position of the central pixel point until the next pixel point is the initial pixel point.

4. A method as claimed in claim 3, wherein the method is characterized byIn step 4, the direction serial number I recorded by the next pixel point is usednMinus the direction index I of the pointn-1The difference J obtainedn-1As a chain code;

in obtaining In-In-1Judging when the code value is obtained, wherein the judgment conditions are as follows:

when I isn-In-1>4 hour Jn-1=In-In-1-8;

When I isn-In-1<-4 th time Jn-1J=In-In-1+8;

The obtained differential chain code Jn-1Is in the code value of [ -3,3 [)]Within the interval;

the code value is that the direction of the next pixel point is positively represented and is clockwise compared with the direction of the previous pixel point of the pixel point;

the code value is negative, and the direction of the next pixel point is anticlockwise compared with the direction of the previous pixel point by the pixel point;

-3 indicates that the direction of the next pixel point is 135 ° counterclockwise compared to the direction of the previous pixel point of the present pixel point;

-2 indicates that the direction of the next pixel point is 90 ° counterclockwise compared to the direction of the previous pixel point of the present pixel point;

-1 indicates that the direction of the next pixel point is 45 ° counterclockwise compared to the direction of the previous pixel point of the present pixel point;

0 represents that the direction of the next pixel point is unchanged compared with the direction of the previous pixel point of the current pixel point; (ii) a

1 represents that the direction of the next pixel point is 45 degrees clockwise compared with the direction of the previous pixel point of the current pixel point;

2, the direction of the next pixel point is 90 degrees clockwise compared with the direction of the previous pixel point of the current pixel point;

3 indicates that the direction of the next pixel point is 135 ° clockwise compared to the previous pixel point of the current pixel point.

5. A method as claimed in claim 1, wherein in step 4, the positive code value indicates that the feature is convex compared with the next point, the negative code value indicates that the feature is concave compared with the next point, and the absolute value of the code value indicates the obvious degree of the concave-convex characteristic.

6. The method for representing rasterized features of two-dimensional part profile according to claim 1, wherein in the step 4, assuming that the direction from point a to point b represents the position of the pixel point in the direction of the previous pixel point, then:

when the code value is-3, point-3 is shifted counterclockwise by 135 ° with respect to point 0, and point a to point b to point-3 form a reentrant angle of 45 °.

When the code value is-2, the-2 point is shifted counterclockwise by 90 ° with respect to the 0 point, and the a point to the b point to the-2 point form a reentrant angle of 90 °.

When the code value is-1, point-1 is shifted counterclockwise by 45 ° with respect to point 0, and point a to point b to point-1 form a reentrant angle of 135 °.

When the code value is 0, the 0 point is shifted counterclockwise by 0 ° with respect to the 0 point, and the a point to the b point to the 0 point constitute a straight line.

When the code value is 1, point 1 is shifted clockwise by 45 ° with respect to point 0, and a point a to a point b to point 1 form a lobe having an angle of 135 °.

When the code value is 2, point 2 is shifted counterclockwise by 90 ° with respect to point 0, and point a to point b form a lobe having an angle of 90 ° to point 2.

When the code value is 3, point 3 is shifted counterclockwise by 135 ° with respect to point 0, and point a to point b to point 3 form a lobe having an angle of 45 °.

7. A method for rasterizing features of the outline of a two-dimensional part as recited in claim 1, wherein in said step 5, convex angles in the concave-convex characteristic diagram, that is, points greater than 0, indicate that the outline is convex here; the re-entrant angle, i.e. the point less than 0, indicates that the profile is concave here; the concave-convex characteristic points are represented by 0 to show the concave-convex characteristic;

the degree of the conspicuousness of the contour concave-convex characteristic is judged by the sum of the magnitude of the absolute value of the numerical value and the superposition of the adjacent points smaller than or larger than 0.

8. The method for representing rasterized features of a two-dimensional part outline according to claim 1, characterized in that in step 5, the directional chain code constructed in step 4 is denoised, pixels which are complementary to salient points and recesses in the range of three adjacent pixels in the whole outline are removed, the pixels are replaced by straight line features, and the values of the concave-convex feature points are amplified to be more prominent.

Background

The part contour information is one of the most important blanking information of the part and is the basis for calculating the area of the part, judging the concavity and convexity, enveloping the rectangle of the part, splicing the part and interactively stock arranging. The acquisition of the contour information of the part is used as a primary stage of the optimized blanking process, and a reasonable extraction scheme has important influence on the quality of the blanking. The contour information of the part can be described by manually inputting the regular shape, and the contour characteristics of the part with the irregular shape are complex and changeable, so that the accurate input of various geometric information of the part is very difficult. The invention provides a discrete mode for solving the problems of extraction of a two-dimensional contour and identification of concave-convex characteristics, aiming at the problems of inconvenient expression of two-dimensional contour characteristics in a stock layout process, difficult characteristic extraction and identification and the like.

Disclosure of Invention

The technical problem to be solved by the present invention is to provide a method for representing a two-dimensional part contour rasterization feature in view of the above-mentioned shortcomings of the prior art.

In order to achieve the technical purpose, the technical scheme adopted by the invention is as follows:

a two-dimensional part contour rasterization feature representation method comprises the following steps:

step 1: storing the two-dimensional graph into a file format capable of reading graph information;

step 2: reading the file information in the step 1;

and step 3: according to the degree of dispersion xdRasterizing the outline of the part, and recording the direction sequence number of the discrete points;

and 4, step 4: constructing a direction chain code according to the direction serial number recorded in the step 3, and describing the concave-convex characteristic of the two-dimensional profile by using the code value;

and 5: and constructing a profile concave-convex characteristic curve.

In order to optimize the technical scheme, the specific measures adopted further comprise:

in the step 1, the two-dimensional graph is saved into a DXF file format by using AutoCAD;

in step 2, reading the graph in step 1 by using a DXF reading program, specifically: and (3) extracting the data information of the LINE, CIRCLE, POLYLINE and ARC in the segments of the ENTITIES of the DXF file in the step (1) by using a DXF reading program.

The step 3 includes:

step 3.1: for all coordinate information A (X, Y), the X-coordinate and the Y-coordinate are divided by the degree X to be discretized, respectivelydFurther rounding up to obtain a discrete coordinate set B (X)1,Y1) (ii) a Further removing discrete coordinate set B (X)1,Y1) The repeated points result in a discrete coordinate set C (X)2,Y2);

Step 3.2: there are 8 adjacent pixel points around the central pixel point in the pixel graph, and 8 search directions are constructed as (1, 2, 3, 4, 5, 6, 7, 8);

step 3.3: taking a discrete coordinate set C (X)2,Y2) And further searching and storing the searched first discrete point Q and recording the direction serial number I of the first discrete point Q according to the sequence of (2, 3, 4, 5, 6, 7, 8, 1), and searching the next pixel point of the contour in the clockwise direction according to the direction serial number I of the first discrete point Q and the direction serial number I of the first discrete point Q relative to the symmetrical position of the central pixel point until the next pixel point is the initial pixel point.

In the above step 4, the direction sequence number I recorded by the next pixel point is usednMinus the direction index I of the pointn-1The difference J obtainedn-1As a chain code;

in obtaining In-In-1Judging when the code value is obtained, wherein the judgment conditions are as follows:

when I isn-In-1>4 hour Jn-1=In-In-1-8;

When I isn-In-1<-4 th time Jn-1J=In-In-1+8;

The obtained differential chain code Jn-1Is in the code value of [ -3,3 [)]Within the interval;

the code value is that the direction of the next pixel point is positively represented and is clockwise compared with the direction of the previous pixel point of the pixel point;

the code value is negative, and the direction of the next pixel point is anticlockwise compared with the direction of the previous pixel point by the pixel point;

-3 indicates that the direction of the next pixel point is 135 ° counterclockwise compared to the direction of the previous pixel point of the present pixel point;

-2 indicates that the direction of the next pixel point is 90 ° counterclockwise compared to the direction of the previous pixel point of the present pixel point;

-1 indicates that the direction of the next pixel point is 45 ° counterclockwise compared to the direction of the previous pixel point of the present pixel point;

0 represents that the direction of the next pixel point is unchanged compared with the direction of the previous pixel point of the current pixel point; (ii) a

1 represents that the direction of the next pixel point is 45 degrees clockwise compared with the direction of the previous pixel point of the current pixel point;

2, the direction of the next pixel point is 90 degrees clockwise compared with the direction of the previous pixel point of the current pixel point;

3 indicates that the direction of the next pixel point is 135 ° clockwise compared to the previous pixel point of the current pixel point.

In step 4, a positive code value indicates that the image is convex compared to the previous and next points, a negative code value indicates that the image is concave compared to the previous and next points, and the absolute value of the code value indicates the degree of significance of the concave-convex characteristic.

In the above step 4, assuming that the direction from the point a to the point b represents the position of the pixel point in the direction of the previous pixel point, then:

when the code value is-3, point-3 is shifted counterclockwise by 135 ° with respect to point 0, and point a to point b to point-3 form a reentrant angle of 45 °.

When the code value is-2, the-2 point is shifted counterclockwise by 90 ° with respect to the 0 point, and the a point to the b point to the-2 point form a reentrant angle of 90 °.

When the code value is-1, point-1 is shifted counterclockwise by 45 ° with respect to point 0, and point a to point b to point-1 form a reentrant angle of 135 °.

When the code value is 0, the 0 point is shifted counterclockwise by 0 ° with respect to the 0 point, and the a point to the b point to the 0 point constitute a straight line.

When the code value is 1, point 1 is shifted clockwise by 45 ° with respect to point 0, and a point a to a point b to point 1 form a lobe having an angle of 135 °.

When the code value is 2, point 2 is shifted counterclockwise by 90 ° with respect to point 0, and point a to point b form a lobe having an angle of 90 ° to point 2.

When the code value is 3, point 3 is shifted counterclockwise by 135 ° with respect to point 0, and point a to point b to point 3 form a lobe having an angle of 45 °.

In step 5 above, a convex corner, i.e., a point greater than 0, in the concave-convex characteristic diagram indicates that the contour is convex here; the re-entrant angle, i.e. the point less than 0, indicates that the profile is concave here; the concave-convex characteristic points are represented by 0 to show the concave-convex characteristic;

the degree of the conspicuousness of the contour concave-convex characteristic is judged by the sum of the magnitude of the absolute value of the numerical value and the superposition of the adjacent points smaller than or larger than 0.

In the step 5, the direction chain code constructed in the step 4 is subjected to noise reduction treatment, pixels which are within the range of three adjacent pixels in the whole outline and can be complemented with the salient points are removed, the pixels are replaced by the characteristics of straight lines, and the numerical values of the concave-convex characteristic points are amplified to be more prominent.

The invention has the following beneficial effects:

the invention relates to a technology for extracting contour features of continuous graphs in a rasterization mode, which can accurately describe the contour features of the continuous graphs when searching contour pixel points of the continuous graphs, and aims to further improve the quality of stock layout; the difference of Freeman chain codes is improved to be used as a direction chain code, so that the magnitude and the positive and negative of the numerical value can be used as a basis for judging the concave-convex degree, a contour concave-convex characteristic curve is provided to represent the concave-convex characteristic of the contour, the direction chain code is used for constructing, the concave-convex characteristic change of the contour is reflected by the concave-convex characteristic change of continuous discrete points, and the concave-convex characteristic change of the contour can be accurately represented.

Drawings

FIG. 1 is a flow chart of the present invention;

FIG. 2 is a flow chart illustrating a process for reading a DXF file according to the present invention;

FIG. 3 is a sequence number diagram of the present invention;

FIG. 4 is a flow chart of the contour pixel searching process of the present invention;

FIG. 5 is a chain code difference pattern of the present invention;

FIG. 6 is a schematic view of the profile configuration of the present invention;

FIG. 7 is a flow chart of the directional chain code denoising method of the present invention.

Detailed Description

Embodiments of the present invention are described in further detail below with reference to the accompanying drawings.

Referring to fig. 1, the invention relates to a method for representing two-dimensional part contour rasterization features, which comprises the following steps:

step 1: the invention uses AutoCAD to store the two-dimensional graph into DXF file format;

step 2: reading the graph in the step 1 by utilizing a DXF reading program;

because the invention relates to the two-dimensional graph, when the graph is saved as a DXF format file, the primitive information of the DXF format file is generally stored in the segments, and therefore, the DXF reading program is used for extracting the data information of the LINEs, cirle, POLYLINE and ARC in the segments of the DXF file in the step 1.

DXF file read flow diagram referring to fig. 2, the DXF reference manual is referenced by the group code and description corresponding to the DXF file source code.

And step 3: according to the degree of dispersion xdRasterizing the outline of the part, and recording the direction sequence number of the discrete points;

to ensure that the two-dimensional contour lines are contained within the pixel frame, for all coordinate information A (X, Y) in step 2, the X-coordinate and the Y-coordinate are divided by the degree X to be discretized, respectivelydFurther rounding up to obtain a discrete coordinate set B (X)1,Y1) (ii) a Further removing discrete coordinate set B (X)1,Y1) The repeated points result in a discrete coordinate set C (X)2,Y2);

There are 8 adjacent pixels around the center pixel in the pixel pattern, and 8 search directions (1, 2, 3, 4, 5, 6, 7, 8) are constructed as shown in fig. 3. To align the resulting set of discrete coordinates C (X)2,Y2) Has continuity and guarantees 8 neighbors outside the central pixelIn the domain range, at most 3 pixel points are provided, and the invention takes a discrete coordinate set C (X)2,Y2) And further searching and storing the searched first discrete point Q and recording the direction serial number I of the first discrete point Q according to the sequence of (2, 3, 4, 5, 6, 7, 8, 1), and searching the next pixel point of the contour in the clockwise direction according to the direction serial number I of the first discrete point Q and the direction serial number I of the first discrete point Q relative to the symmetrical position of the central pixel point until the next pixel point is the initial pixel point. The contour pixel searching flow chart is shown in FIG. 4.

And 4, step 4: constructing a direction chain code according to the direction serial number recorded in the step 4, and describing the concave-convex characteristic of the two-dimensional profile by using the code value;

the invention describes the two-dimensional outline by using continuous pixel points, so the invention uses the direction serial number I recorded by the next pixel point to extract the concave-convex characteristic of the outlinenMinus the direction index I of the pointn-1The difference J obtainedn-1As a chain code. Because the invention refers to the previous direction serial number to describe the pixel point in the two-dimensional profile scanning sequence, the possibility of returning to the previous pixel point is eliminated, so that 4 or-4 code values cannot appear in the difference, if the direction serial numbers 1 and 8 are continuous in angle, the angle interval is overlarge in angle judgment if the difference (5, -5, 6, -6, 7, -7) is adopted. When the code value of (5, -5, 6, -6, 7, -7) is obtained, the judgment is made:

when I isn-In-1>4 hour Jn-1=In-In-1-8;

When I isn-In-1<-4 th time Jn-1J=In-In-1+8;

Therefore, the differential chain code obtained by the invention only comprises (-3, -2, -1, 0, 1, 2, 3);

the code value is positive indicating that the direction of the next pixel point is clockwise compared with the direction of the previous pixel point.

The code value is negative, which indicates that the direction of the next pixel point is counterclockwise compared with the direction of the previous pixel point.

-3 represents that the direction of the next pixel point is rotated by 135 degrees counterclockwise compared with the direction of the previous pixel point of the current pixel point

-2 represents that the direction of the next pixel point is 90 degrees counterclockwise compared to the direction of the previous pixel point of the current pixel point

-1 represents that the direction of the next pixel point is 45 degrees counterclockwise compared to the direction of the previous pixel point of the current pixel point

0 represents that the direction of the next pixel point is unchanged compared with the direction of the previous pixel point of the current pixel point;

1 indicates that the direction of the next pixel point is 45 degrees clockwise compared with the previous pixel point of the current pixel point

2 indicates that the direction of the next pixel point is 90 degrees clockwise compared with the previous pixel point of the current pixel point

3 represents that the direction of the next pixel point is clockwise 135 degrees compared with the direction of the previous pixel point of the current pixel point

Further, since the profile scanning direction of the present invention is clockwise as the same as the chain code arrangement direction, a positive code value also means a convex shape compared to the next point, and a negative code value means a concave shape compared to the next point. The magnitude of the absolute value of the code value indicates the degree of significance of the concave-convex characteristic.

As shown in fig. 5, the direction from point a to point b represents the position of the current pixel point in the direction of the previous pixel point.

When the code value is-3, point-3 is shifted counterclockwise by 135 ° with respect to point 0, and point a to point b to point-3 form a reentrant angle of 45 °.

When the code value is-2, the-2 point is shifted counterclockwise by 90 ° with respect to the 0 point, and the a point to the b point to the-2 point form a reentrant angle of 90 °.

When the code value is-1, point-1 is shifted counterclockwise by 45 ° with respect to point 0, and point a to point b to point-1 form a reentrant angle of 135 °.

When the code value is 0, the 0 point is shifted counterclockwise by 0 ° with respect to the 0 point, and the a point to the b point to the 0 point constitute a straight line.

When the code value is 1, point 1 is shifted clockwise by 45 ° with respect to point 0, and a point a to a point b to point 1 form a lobe having an angle of 135 °.

When the code value is 2, point 2 is shifted counterclockwise by 90 ° with respect to point 0, and point a to point b form a lobe having an angle of 90 ° to point 2.

When the code value is 3, point 3 is shifted counterclockwise by 135 ° with respect to point 0, and point a to point b to point 3 form a lobe having an angle of 45 °.

And 5: and constructing a profile concave-convex characteristic curve.

In order to visually represent the concave-convex characteristic of the contour, the invention provides a concave-convex characteristic curve chart. A convex corner (a point larger than 0) in the concave-convex characteristic diagram indicates that the profile is convex here; the re-entrant angle (point less than 0) indicates that the profile is concave here; and the concave-convex characteristic points are represented by 0 to show the concave-convex characteristic. The degree of the conspicuousness of the contour concave-convex characteristic is judged by the sum of the magnitude of the absolute value of the numerical value and the superposition of the adjacent points smaller than or larger than 0.

Referring to fig. 6, in the part, the lower left corner of the pixel point of the pattern is taken as the starting point of the concave-convex characteristic curve to describe the pattern profile clockwise, and the convex angle further comprises a straight line, a concave angle, a straight line, a convex angle, a straight line, a concave angle, a straight line, a convex angle, a straight line, a concave angle and a straight line, and then the straight line returns to the starting point of the lower left corner. The change of the concave-convex characteristic of the whole contour can be accurately depicted in the concave-convex characteristic curve.

Since the direction chain code in step 4 includes the concave-convex characteristic of the contour, the present invention uses the direction chain code to construct a concave-convex characteristic graph.

However, the direction chain code represents the change of two adjacent pixels, the change of the angle of the direction chain code in the whole outline range cannot visually reflect the curve characteristic of the outline in the concave-convex characteristic curve, but if the chain code reflects the linear characteristic, the sum of the code value neighborhoods of any pixel of the section of the straight line is always close to 0; therefore, the invention carries out noise reduction treatment on the direction chain code constructed in the step 4, removes the pixels which can be complemented by the concave points and the convex points in the range of three adjacent pixels in the whole outline, replaces the pixels by the characteristics of straight lines, and amplifies the numerical values of the concave-convex characteristic points to make the values more prominent.

The chain code is marked as I ═ I1,i2……in-1,in](ii) a Let J be [ i ]2……in-1,in,i1],L=[i3……in,i1,i2](ii) a M is less than 0 in I J, namely the adjacent pixel symbols are opposite, N is less than 0 in I L, namely the two pixel symbols at one interval are opposite, the length of the chain code is more than 2, so that the next pixel of some indexes less than 0 in M is not provided with a complementary pixel with the index, and the paired pixel is removed in the circulating process. However, in the complementary pixel points, the point actually represents the concave-convex characteristic point when one side of the left and right neighborhoods can be complementary but the other side conforms to the same condition. Therefore, the unique point is removed from the M set, and the characteristic point is ensured not to be processed; because the condition that the code values of adjacent pixels are opposite is removed in the processing process, the noise reduction of the outline is finished under the condition that the code values of two pixels which are separated by one pixel are opposite in sign. The process of direction chain code denoising is shown in fig. 7.

The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above-mentioned embodiments, and all technical solutions belonging to the idea of the present invention belong to the protection scope of the present invention. It should be noted that modifications and embellishments within the scope of the invention may be made by those skilled in the art without departing from the principle of the invention.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:基于改进K-邻域算法的配网电力线点云提取方法及系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!