A defect synthesis method, system, equipment and medium based on good grey cloth
By positioning the eye area in the grey cloth image, constructing the target yarn contour point set and performing visual transformation, the problem of defect texture and new cloth tissue texture in the prior art is solved, and efficient defect data generation and model migration accuracy are achieved.
Patent Information
- Application Number
- CN202310215877.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-07
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2043-03-07
AI Technical Summary
When generating grey cloth defect data, it is difficult to achieve alignment between the defect texture and the new cloth tissue texture, resulting in obvious defect boundaries, unnatural synthetic marks, and large differences in defect morphology of different tissue cloth types, affecting the migration accuracy of the model.
By positioning the eyelet area in the good-quality grey cloth image, expanding connection and screening based on adjacent eyelet areas, the target yarn contour point set is constructed, and visual transformation is performed using the moving least squares method to generate naturally aligned defects.
It realizes that a large number of effective defect data can be generated without physical defect creation, ensuring that the defect shape is aligned with the new cloth tissue texture, and improving the migration accuracy of the model in the new cloth.
Smart Images

Figure CN116228805B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image synthesis, and more specifically, to a defect synthesis method, system, equipment and medium based on good grey cloth. Background Art
[0002] Deep neural networks have the ability to automatically extract image features, and are gradually replacing traditional visual feature extraction methods that use handcrafted features in computer vision fields such as image recognition and target detection. They are also increasingly used in industrial quality inspection. Fabric defect detection is an important task in the textile industry. With the advancement of the national strategy of digital industry upgrading, the use of automated grey fabric defect detection by machines and equipment to replace manual detection is a business requirement, and deep learning has become the mainstream method for industrial visual defect detection.
[0003] However, the supervised training of deep learning models requires a large amount of manually annotated data, and there are many types of grey fabric defects in actual production scenarios. Some defects occur very rarely, and it is very difficult to collect defect data. In addition, for pre-trained models, faced with ever-changing fabric texture changes, if all new fabric types are required to collect defect data, it will consume huge manpower, material and financial resources, which will greatly hinder the commercialization of algorithm models. Therefore, the technology of using software to create defects based on the pictures of good new fabric types has become an important part of the implementation process.
[0004] The current data synthesis methods used for grey fabric defect target detection either rely on partial defect images or are based on texture misalignment fusion methods of good grey fabric. Color or geometric transformations such as brightness adjustment and image flipping, as well as local image transformations based on target frame annotation information, all rely on defect image data and require data collection in the loom environment, which is not conducive to low-cost migration of the model to new fabric types. The synthesis method that uses defect data of existing fabric types and fuses it into good images of new fabric types is a coarse-grained defect synthesis method. This solution does not align the defect texture with the texture of the new fabric type, resulting in obvious defect boundaries and very obvious synthesis marks. In addition, the defect morphology of different fabric types is quite different, and the improvement of migration accuracy is relatively limited. Summary of the invention
[0005] In view of the shortcomings of the prior art, the object of the present invention is to provide a defect synthesis method, system, equipment, and medium based on good grey cloth, which has the advantage of being able to generate a large amount of effective defect data without creating defects on good grey cloth.
[0006] The above technical objectives of the present invention are achieved through the following technical solutions: A defect synthesis method based on good grey cloth, comprising:
[0007] Locate all the eyelet areas in the good grey fabric image;
[0008] Adjacent hole regions in all hole regions are expanded and connected according to preset structural elements to obtain a number of candidate gap regions;
[0009] Screening all candidate gap regions to obtain a number of first gap regions;
[0010] Setting a target contour index value corresponding to each first gap region, and obtaining an adjacent contour index value of the corresponding first gap region according to the target contour index value;
[0011] Constructing a target yarn contour point set of the corresponding first gap area according to the target contour index value and the corresponding adjacent contour index value;
[0012] The moving least square method is used to perform visual transformation on the target yarn contour point set to generate corresponding defects.
[0013] Optionally, the locating all the eyelet areas in the good grey cloth image includes:
[0014] Performing grayscale processing on the good grey cloth image to obtain a corresponding grayscale image;
[0015] The pixel values of the grayscale image are inverted and then adaptively binarized to obtain the corresponding hole area.
[0016] Optionally, the adjacent hole areas in all the hole areas are expanded and connected according to the preset structural element to obtain a number of candidate gap areas, including:
[0017] Performing expansion operations on adjacent hole areas in all hole areas according to preset structural elements, so as to connect adjacent hole areas and generate corresponding gap areas;
[0018] The erosion operation is performed on each gap region according to the preset structural element to generate the corresponding candidate gap region.
[0019] Optionally, the screening of all candidate gap regions to obtain a plurality of first gap regions includes:
[0020] Obtain a sparse outer contour coordinate point set of each candidate gap area;
[0021] Calculate the line segment length of the corresponding candidate gap area according to each sparse outer contour coordinate point set;
[0022] The line segment length of each candidate gap region is compared with a preset threshold, and the candidate gap region whose line segment length is greater than the preset threshold is taken as the first gap region.
[0023] Optionally, setting a target contour index value corresponding to each first gap region, and obtaining an adjacent contour index value of the corresponding first gap region according to the target contour index value, includes:
[0024] Obtaining a sparse outer contour coordinate point set corresponding to each first gap area;
[0025] According to the sparse outer contour coordinate point set corresponding to each first gap region, a corresponding contour index value is set and used as a target contour index value corresponding to each first gap region;
[0026] A sparse outer contour coordinate point set of candidate gap regions adjacent to each first gap region on both sides is obtained, and an adjacent contour index value corresponding to each first gap region is constructed.
[0027] Optionally, constructing a target yarn contour point set of the corresponding first gap area according to the target contour index value and the corresponding adjacent contour index value comprises:
[0028] According to the target contour index value, a sparse outer contour coordinate point set of the corresponding first gap area is obtained as a target contour point set;
[0029] Acquire, according to the adjacent contour index values, a sparse outer contour coordinate point set of the candidate gap regions adjacent to both sides of the corresponding first gap region as a corresponding adjacent contour point set;
[0030] Performing linear difference calculation based on the target contour point set and one of the adjacent contour point sets to obtain a first yarn centerline between the corresponding first gap region and a candidate gap region adjacent to one side thereof;
[0031] Performing linear difference calculation based on the target contour point set and another adjacent contour point set to obtain a second yarn centerline between the first gap region and the candidate gap region adjacent to the other side thereof;
[0032] A corresponding target yarn contour point set is constructed according to the first yarn centerline and the second yarn centerline.
[0033] Optionally, the step of using the moving least squares method to perform visual transformation on the target yarn contour point set to generate corresponding defects includes:
[0034] Construct corresponding eyelet contour point sets according to all eyelet areas;
[0035] Taking any point in the eyelet contour point set as a control point, determine whether the control point is within the target yarn contour point set. If so, the first yarn center line and the second yarn center line in the target yarn contour point set are controlled to move away from each other based on the moving least squares method to generate a corresponding defect; if not, the first yarn center line and the second yarn center line in the target yarn contour point set are controlled to move closer to each other based on the moving least squares method to generate a corresponding defect.
[0036] A defect synthesis system based on good grey cloth, comprising: a hole positioning module, used to locate all hole areas in a good grey cloth image;
[0037] A gap generation module is used to expand and connect adjacent hole areas in all hole areas according to preset structural elements to obtain a number of candidate gap areas;
[0038] A gap screening module, used for screening all candidate gap regions to obtain a plurality of first gap regions;
[0039] An index determination module, used to set a target contour index value corresponding to each first gap region, and obtain an adjacent contour index value of the corresponding first gap region according to the target contour index value;
[0040] A point set obtaining module, used for constructing a target yarn contour point set of the corresponding first gap area according to the target contour index value and the corresponding adjacent contour index value;
[0041] The defect generation module is used to perform visual transformation on the target yarn contour point set by using the moving least square method to generate corresponding defects.
[0042] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
[0043] A computer-readable storage medium stores a computer program, which implements the steps of the above method when executed by a processor.
[0044] In summary, the present invention has the following beneficial effects: by targeting the characteristics of the grey cloth defect detection scene, firstly, the "grid eyelet" area formed by the interweaving of the warp and weft yarns of the good cloth is located, and then the yarn area is obtained based on the fitting of the adjacent eyelet area; finally, some local pixel value perturbations, local area deformations, local connected domain translation and replication, local image scaling and other color and geometric change operations are performed in the yarn area to realize the defect morphology synthesis based on the texture-level alignment of the good cloth. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1It is a schematic diagram of the process of the present invention;
[0046] Figure 2 It is a structural block diagram of the present invention when assembled;
[0047] Figure 3 1 is a diagram showing the internal structure of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION
[0048] In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings. Several embodiments of the present invention are shown in the accompanying drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein.
[0049] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal connection of two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to the specific circumstances. The terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features.
[0050] In the present invention, unless otherwise clearly specified and limited, the first feature being "above" or "below" the second feature may include the first and second features being in direct contact, or may include the first and second features being in contact not directly but through another feature between them. Moreover, the first feature being "above", "above" and "above" the second feature includes the first feature being directly above and obliquely above the second feature, or simply indicates that the first feature is higher in level than the second feature. The first feature being "below", "below" and "below" the second feature includes the first feature being directly below and obliquely below the second feature, or simply indicates that the first feature is lower in level than the second feature. The terms "vertical", "horizontal", "left", "right", "above", "below" and similar expressions are for illustrative purposes only, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.
[0051] The present invention is described in detail below in conjunction with the accompanying drawings and embodiments.
[0052] The present invention provides a defect synthesis method based on good grey cloth, such as Figure 1As shown, including:
[0053] Step 100, locating all the eyelet areas in the good grey cloth image;
[0054] Step 200: expanding and connecting adjacent hole areas in all hole areas according to preset structural elements to obtain a number of candidate gap areas;
[0055] Step 300: Screen all candidate gap regions to obtain a number of first gap regions;
[0056] Step 400: Set a target contour index value corresponding to each first gap region, and obtain an adjacent contour index value of the corresponding first gap region according to the target contour index value;
[0057] Step 500, constructing a target yarn contour point set corresponding to the first gap area according to the target contour index value and the corresponding adjacent contour index value;
[0058] Step 600: Use the moving least square method to perform visual transformation on the target yarn contour point set to generate corresponding defects.
[0059] In practical applications, grey cloth is woven from warp yarns and weft yarns, so there are several mesh holes formed by the interweaving of warp yarns and weft yarns on the good grey cloth. Therefore, the mesh holes in the good grey cloth image are first identified and located to obtain the corresponding hole areas with coordinate values; then a structural element suitable for the mesh holes is set in digital image processing, and the adjacent hole areas are expanded through the structural element to connect the adjacent holes, and the structural element is used to identify the mesh holes. The value of ze is correspondingly expanded in the warp direction and the weft direction, thereby generating radial gaps and weft gaps, and a number of candidate gap areas can be obtained; since the generated gaps are of different lengths, it is necessary to screen the candidate gap areas, eliminate the candidate gap areas whose lengths do not meet the requirements, and obtain a number of first gap areas that meet the requirements, and then set the target contour index value of each first gap area and the adjacent contour index values of its two adjacent candidate gap areas, and obtain the corresponding target contour point set and adjacent contour point set according to the target contour index value and the adjacent contour index values of its two adjacent candidate gap areas, and obtain the target yarn contour point set; then use the local deformation technology of the moving least squares method, local pixel value perturbation, local connected domain translation and replication, local graphic scaling and other visual transformation operations to process the target yarn contour point set, and different types and shapes of defects can be generated. Generally speaking, the warp and weft defect morphologies are realized by the local deformation technology based on the moving least squares method, and the defect morphology can be changed by changing the position and movement direction of the control point set.
[0060] In an application example, 100 hole areas are located in an image of good grey cloth, and a preset structural element is used to take any one of the 100 hole areas as the starting point. The hole areas adjacent to the hole area are expanded in the warp direction and the weft direction according to the value of the structural element ks i ze. Then, each hole area can generate at most 4 candidate gap areas; therefore, 400 candidate gap areas can be generated. Subsequently, the 400 candidate gap areas are screened, and the candidate gap areas whose lengths do not meet the requirements are eliminated to obtain 50 first gap areas that meet the requirements. Then, target contour index values and adjacent contour index values of two adjacent candidate gap areas are set for the 50 first gap areas, respectively, and according to the target contour index value and adjacent contour index values of two adjacent candidate gap areas, the target contour index value and adjacent contour index values of two adjacent candidate gap areas are selected. The corresponding target contour point set and adjacent contour point set are obtained, and the target yarn contour point set is obtained, and a total of 50 target yarn contour point sets are obtained. Then, the 50 target yarn contour point sets are subjected to equal visual transformation operations through the moving least squares method. Each target yarn contour point set is subjected to visual transformation operations such as local deformation technology of the moving least squares method, local pixel value perturbation, local connected domain translation and replication, and local graphics scaling. Five different types and forms of defects can be generated. Therefore, 250 defect images can be generated from 50 target yarn contour point sets, thereby generating a large amount of effective defect data.
[0061] Furthermore, the positioning of all the eyelet areas in the good grey cloth image includes:
[0062] Performing grayscale processing on the good grey cloth image to obtain a corresponding grayscale image;
[0063] The pixel values of the grayscale image are inverted and then adaptively binarized to obtain the corresponding hole area.
[0064] In practical applications, the grayscale mode is first used to read the image of good grey fabric, and then the pixel value of the grayscale image is inverted, that is, 255 minus the value of each pixel in the image matrix. Then, the adaptive binarization of image processing is used to convert the grayscale image into a position map with only two distribution values of 0 and 255. The dotted area with a value of 255 is the hole area. Among them, the adaptive method, threshold type, block size and other parameters need to be appropriately adjusted according to different imaging schemes for different fabrics. If the brightness distribution of the good fabric image is uneven, the image can be divided into multiple blocks based on the actual distribution, and then each block is adaptively binarized with specific parameters and then merged into one image.
[0065] Optionally, the adjacent hole areas in all the hole areas are expanded and connected according to the preset structural element to obtain a number of candidate gap areas, including:
[0066] Performing expansion operations on adjacent hole areas in all hole areas according to preset structural elements, so as to connect adjacent hole areas and generate corresponding gap areas;
[0067] The erosion operation is performed on each gap region according to the preset structural element to generate the corresponding candidate gap region.
[0068] In practical applications, there are certain gaps between warp yarns and between weft yarns. A structural element of a specific size and shape is constructed through image processing technology, and then this structural element is used for dilation operation. The number of dilation iterations is 10, and the direction of corrosion depends on the value of the structural element ks i ze. Generally, when the x-axis value of ks i ze is 10 and the y-axis value is 1, the dilation direction is horizontal, and the adjacent eyelets are connected by dilation. The solid line segment finally obtained is the weft gap area; similarly, when the x-axis value of ks i ze is 1 and the y-axis value is 10, the dilation direction is vertical, and the adjacent eyelets are connected by dilation. The solid line segment finally obtained is the warp gap area. In addition, the dilation operation is prone to bring some noise segments, and the noise is further removed by 11 rounds of iterative corrosion operation. The ks i ze used is the same as the dilation operation.
[0069] Optionally, the screening of all candidate gap regions to obtain a plurality of first gap regions includes:
[0070] Obtain a sparse outer contour coordinate point set of each candidate gap area;
[0071] Calculate the line segment length of the corresponding candidate gap area according to each sparse outer contour coordinate point set;
[0072] The line segment length of each candidate gap region is compared with a preset threshold, and the candidate gap region whose line segment length is greater than the preset threshold is taken as the first gap region.
[0073] In practical applications, the contour search interface of image processing is used to obtain the sparse outer contour coordinate point set of each gap segment. The search mode is RETR_EXTERNAL, and the search method is CHAIN_APPROX_SIMPLE. After obtaining the sparse outer contour coordinate point set, for the meridian segment, the maximum value of the y coordinate in the contour point set minus the minimum value is used to approximate the length of the segment; for the latitude segment, the maximum value of the x coordinate in the contour point set minus the minimum value is used to approximate the length of the segment, and the length of the corresponding candidate gap area can be obtained. The contour index value of the segment whose length is greater than the preset threshold is stored for subsequent random screening of target segments and adjacent segments. Generally, the preset threshold value is 180.
[0074] Further, the setting of the target contour index value corresponding to each first gap region and obtaining the adjacent contour index value of the corresponding first gap region according to the target contour index value includes:
[0075] Obtaining a sparse outer contour coordinate point set corresponding to each first gap area;
[0076] According to the sparse outer contour coordinate point set corresponding to each first gap region, a corresponding contour index value is set and used as a target contour index value corresponding to each first gap region;
[0077] A sparse outer contour coordinate point set of candidate gap regions adjacent to each first gap region on both sides is obtained, and an adjacent contour index value corresponding to each first gap region is constructed.
[0078] In practical applications, a contour index value i dx of a candidate gap area is randomly selected and compared with its sparse outer contour coordinate point set, thereby obtaining the contour index (i dx-1) of the candidate gap area on one side adjacent to the target contour and the contour index (i dx+1) of the candidate gap area on the other side adjacent to the target contour.
[0079] Further, constructing a target yarn contour point set of the corresponding first gap area according to the target contour index value and the corresponding adjacent contour index value comprises:
[0080] According to the target contour index value, a sparse outer contour coordinate point set of the corresponding first gap area is obtained as a target contour point set;
[0081] Acquire, according to the adjacent contour index values, a sparse outer contour coordinate point set of the candidate gap regions adjacent to both sides of the corresponding first gap region as a corresponding adjacent contour point set;
[0082] Performing linear difference calculation based on the target contour point set and one of the adjacent contour point sets to obtain a first yarn centerline between the corresponding first gap region and a candidate gap region adjacent to one side thereof;
[0083] Performing linear difference calculation based on the target contour point set and another adjacent contour point set to obtain a second yarn centerline between the first gap region and the candidate gap region adjacent to the other side thereof;
[0084] A corresponding target yarn contour point set is constructed according to the first yarn centerline and the second yarn centerline.
[0085] In practical applications, the center point of the yarn between the two gap areas is obtained by the linear difference method as the contour point set of the yarn to achieve the positioning of the target yarn area and the positioning of the adjacent yarn area.
[0086] Furthermore, the moving least square method is used to perform visual transformation on the target yarn contour point set to generate corresponding defects, including:
[0087] Construct corresponding eyelet contour point sets according to all eyelet areas;
[0088] Taking any point in the eyelet contour point set as a control point, determine whether the control point is within the target yarn contour point set. If so, the first yarn center line and the second yarn center line in the target yarn contour point set are controlled to move away from each other based on the moving least squares method to generate a corresponding defect; if not, the first yarn center line and the second yarn center line in the target yarn contour point set are controlled to move closer to each other based on the moving least squares method to generate a corresponding defect.
[0089] In practical applications, based on the coordinate information of the contour point sets of the above-mentioned yarns and eyelets, defects of different types and shapes are realized through visual transformation operations such as local deformation technology based on the moving least squares method, local pixel value perturbation, local connected domain translation and copying, and local graphic scaling. Generally, the "warp direction" defect morphology can be realized through local deformation technology based on the moving least squares method, and the defect morphology can be changed by changing the position and movement direction of the control point set. When the control points are taken from the contour point set of the eyelets on the outside of two adjacent warps, and the movement direction is set to move closer to the inside, the effect of the two warps sticking together can be achieved; when the control points are taken from the contour point set of the center points of two adjacent warps, and the movement direction is set to pull up to the outside, the gaps between the yarns can be enlarged, similar to the effect of missing warps.
[0090] The present invention is based on good pictures of different types of fabrics, and through image processing technology, first locates the warp and weft areas in the good pictures, and then realizes texture-level aligned defect synthesis through local deformation, local color and optical transformation methods, so that customized software can synthesize image data of different defect forms for different tissues without physically creating defects. The defect data of different texture surfaces can be synthesized by software methods, providing a large amount of effective defect data for deep learning training models; according to the characteristics of the grey cloth defect detection scene, first locate the "grid eyelet" area formed by the interweaving of the warp and weft yarns of the good fabric, and then fit the yarn area based on the adjacent eyelet area. Finally, some local pixel value perturbations, local area deformations, local connected domain translation replication, local image scaling and other specific area color and geometric change operations are performed in the yarn area to realize defect morphology synthesis based on texture-level alignment of good fabrics.
[0091] like Figure 2 As shown, the present invention also provides a defect synthesis system based on good grey cloth, comprising:
[0092] The hole positioning module 10 is used to locate all the hole areas in the good grey cloth image;
[0093] A gap generation module 20 is used to expand and connect adjacent hole areas in all hole areas according to a preset structural element to obtain a number of candidate gap areas;
[0094] A gap screening module 30 is used to screen all candidate gap regions to obtain a plurality of first gap regions;
[0095] An index determination module 40 is used to set a target contour index value corresponding to each first gap region, and obtain an adjacent contour index value of the corresponding first gap region according to the target contour index value;
[0096] A point set obtaining module 50, for constructing a target yarn contour point set of the corresponding first gap region according to the target contour index value and the corresponding adjacent contour index value;
[0097] The defect generating module 60 is used to perform visual transformation on the target yarn contour point set by using the moving least square method to generate corresponding defects.
[0098] For the specific definition of a defect synthesis system based on good grey fabric, please refer to the definition of a defect synthesis method based on good grey fabric above, which will not be repeated here. Each module in the above-mentioned defect synthesis system based on good grey fabric can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0099] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 3 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. When the computer program is executed by the processor, a defect synthesis method based on good grey cloth is implemented.
[0100] Those skilled in the art will understand that Figure 3The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0101] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the following steps when executing the computer program: locating all eyelet areas in an image of a good grey cloth;
[0102] Adjacent hole regions in all hole regions are expanded and connected according to preset structural elements to obtain a number of candidate gap regions;
[0103] Screening all candidate gap regions to obtain a number of first gap regions;
[0104] Setting a target contour index value corresponding to each first gap region, and obtaining an adjacent contour index value of the corresponding first gap region according to the target contour index value;
[0105] Constructing a target yarn contour point set of the corresponding first gap area according to the target contour index value and the corresponding adjacent contour index value;
[0106] The moving least square method is used to perform visual transformation on the target yarn contour point set to generate corresponding defects.
[0107] In one embodiment, the locating all the eyelet areas in the good grey cloth image includes:
[0108] Performing grayscale processing on the good grey cloth image to obtain a corresponding grayscale image;
[0109] The pixel values of the grayscale image are inverted and then adaptively binarized to obtain the corresponding hole area.
[0110] In one embodiment, the adjacent hole areas in all the hole areas are expanded and connected according to the preset structural element to obtain a number of candidate gap areas, including:
[0111] Performing expansion operations on adjacent hole areas in all hole areas according to preset structural elements, so as to connect adjacent hole areas and generate corresponding gap areas;
[0112] The erosion operation is performed on each gap region according to the preset structural element to generate the corresponding candidate gap region.
[0113] In one embodiment, the screening of all candidate gap regions to obtain a plurality of first gap regions includes:
[0114] Obtain a sparse outer contour coordinate point set of each candidate gap area;
[0115] Calculate the line segment length of the corresponding candidate gap area according to each sparse outer contour coordinate point set;
[0116] The line segment length of each candidate gap region is compared with a preset threshold, and the candidate gap region whose line segment length is greater than the preset threshold is taken as the first gap region.
[0117] In one embodiment, setting a target contour index value corresponding to each first gap region, and obtaining an adjacent contour index value of the corresponding first gap region according to the target contour index value, includes:
[0118] Obtaining a sparse outer contour coordinate point set corresponding to each first gap area;
[0119] According to the sparse outer contour coordinate point set corresponding to each first gap region, a corresponding contour index value is set and used as a target contour index value corresponding to each first gap region;
[0120] A sparse outer contour coordinate point set of candidate gap regions adjacent to each first gap region on both sides is obtained, and an adjacent contour index value corresponding to each first gap region is constructed.
[0121] In one embodiment, constructing a target yarn contour point set of the corresponding first gap area according to the target contour index value and the corresponding adjacent contour index value comprises:
[0122] According to the target contour index value, a sparse outer contour coordinate point set of the corresponding first gap area is obtained as a target contour point set;
[0123] Acquire, according to the adjacent contour index values, a sparse outer contour coordinate point set of the candidate gap regions adjacent to both sides of the corresponding first gap region as a corresponding adjacent contour point set;
[0124] Performing linear difference calculation based on the target contour point set and one of the adjacent contour point sets to obtain a first yarn centerline between the corresponding first gap region and a candidate gap region adjacent to one side thereof;
[0125] Performing linear difference calculation based on the target contour point set and another adjacent contour point set to obtain a second yarn centerline between the first gap region and the candidate gap region adjacent to the other side thereof;
[0126] A corresponding target yarn contour point set is constructed according to the first yarn centerline and the second yarn centerline.
[0127] In one embodiment, the step of using the moving least squares method to perform visual transformation on the target yarn contour point set to generate corresponding defects includes:
[0128] Construct corresponding eyelet contour point sets according to all eyelet areas;
[0129] Taking any point in the eyelet contour point set as a control point, determine whether the control point is within the target yarn contour point set. If so, the first yarn center line and the second yarn center line in the target yarn contour point set are controlled to move away from each other based on the moving least squares method to generate a corresponding defect; if not, the first yarn center line and the second yarn center line in the target yarn contour point set are controlled to move closer to each other based on the moving least squares method to generate a corresponding defect.
[0130] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing related hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct RAMbus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0131] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0132] 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 embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.
Claims
1. A defect synthesis method based on good grey cloth, characterized in that: include: Locate all the eyelet areas in the good grey fabric image; Adjacent hole regions in all hole regions are expanded and connected according to preset structural elements to obtain a number of candidate gap regions; Screening all candidate gap regions to obtain a number of first gap regions; Setting a target contour index value corresponding to each first gap region, and obtaining an adjacent contour index value of the corresponding first gap region according to the target contour index value; Constructing a target yarn contour point set of the corresponding first gap area according to the target contour index value and the corresponding adjacent contour index value; The moving least square method is used to perform visual transformation on the target yarn contour point set to generate corresponding defects.
2. The method according to claim 1, characterized in that The positioning of all the eyelet areas in the good grey cloth image includes: Performing grayscale processing on the good grey cloth image to obtain a corresponding grayscale image; The pixel values of the grayscale image are inverted and then adaptively binarized to obtain the corresponding hole area.
3. The method according to claim 1, characterized in that The adjacent hole areas in all the hole areas are expanded and connected according to the preset structural elements to obtain a number of candidate gap areas, including: Performing expansion operations on adjacent hole areas in all hole areas according to preset structural elements, so as to connect adjacent hole areas and generate corresponding gap areas; The erosion operation is performed on each gap region according to the preset structural element to generate the corresponding candidate gap region.
4. The method according to claim 1, characterized in that The step of screening all candidate gap regions to obtain a plurality of first gap regions includes: Obtain a sparse outer contour coordinate point set of each candidate gap area; Calculate the line segment length of the corresponding candidate gap area according to each sparse outer contour coordinate point set; The line segment length of each candidate gap region is compared with a preset threshold, and the candidate gap region whose line segment length is greater than the preset threshold is taken as the first gap region.
5. The method according to claim 4, characterized in that The step of setting a target contour index value corresponding to each first gap region and obtaining an adjacent contour index value of the corresponding first gap region according to the target contour index value comprises: Obtaining a sparse outer contour coordinate point set corresponding to each first gap area; According to the sparse outer contour coordinate point set corresponding to each first gap region, a corresponding contour index value is set and used as a target contour index value corresponding to each first gap region; A sparse outer contour coordinate point set of candidate gap regions adjacent to each first gap region on both sides is obtained, and an adjacent contour index value corresponding to each first gap region is constructed.
6. The method according to claim 5, characterized in that The step of constructing a target yarn contour point set of the corresponding first gap area according to the target contour index value and the corresponding adjacent contour index value comprises: According to the target contour index value, a sparse outer contour coordinate point set of the corresponding first gap area is obtained as a target contour point set; Acquire, according to the adjacent contour index values, a sparse outer contour coordinate point set of the candidate gap regions adjacent to both sides of the corresponding first gap region as a corresponding adjacent contour point set; Performing linear difference calculation based on the target contour point set and one of the adjacent contour point sets to obtain a first yarn centerline between the corresponding first gap region and a candidate gap region adjacent to one side thereof; Performing linear difference calculation based on the target contour point set and another adjacent contour point set to obtain a second yarn centerline between the first gap region and the candidate gap region adjacent to the other side thereof; A corresponding target yarn contour point set is constructed according to the first yarn centerline and the second yarn centerline.
7. The method according to claim 6, wherein the step of using the moving least squares method to perform visual transformation on the target yarn contour point set to generate corresponding defects comprises: Construct corresponding eyelet contour point sets according to all eyelet areas; Taking any point in the eyelet contour point set as a control point, determine whether the control point is within the target yarn contour point set. If so, the first yarn center line and the second yarn center line in the target yarn contour point set are controlled to move away from each other based on the moving least squares method to generate a corresponding defect; if not, the first yarn center line and the second yarn center line in the target yarn contour point set are controlled to move closer to each other based on the moving least squares method to generate a corresponding defect.
8. A defect synthesis system based on good grey cloth, characterized in that: include: The hole positioning module is used to locate all the hole areas in the good grey cloth image; A gap generation module is used to expand and connect adjacent hole areas in all hole areas according to preset structural elements to obtain a number of candidate gap areas; A gap screening module, used for screening all candidate gap regions to obtain a plurality of first gap regions; An index determination module, used to set a target contour index value corresponding to each first gap region, and obtain an adjacent contour index value of the corresponding first gap region according to the target contour index value; A point set obtaining module, used for constructing a target yarn contour point set of the corresponding first gap area according to the target contour index value and the corresponding adjacent contour index value; The defect generation module is used to perform visual transformation on the target yarn contour point set by using the moving least square method to generate corresponding defects.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method and device for generating dent defect sample in industrial detection
CN115578477A
Gray fabric defect form generation method, system and equipment and storage medium
CN115689870A