Method, apparatus, computing device, and storage medium for identifying paint type
By using image processing technology to perform threshold segmentation and connected component analysis on oil pipe paint, the problems of low paint recognition efficiency and high false positive rate in oil pipe repair shops are solved, and efficient and accurate paint type recognition is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- QINGDAO UNIV OF SCI & TECH
- Filing Date
- 2022-10-27
- Publication Date
- 2026-04-28
AI Technical Summary
In oil pipeline maintenance workshops, paint identification is inefficient and prone to misjudgment, resulting in wasted manpower and increased worker burden. Existing technologies are insufficient to effectively address the problems of irregular and sticky paint on oil pipelines.
Image processing technology is used to acquire pipeline images, perform threshold segmentation and color recognition to determine the painted area, and identify the paint type based on the number of pixels and distance in the painted connected region. Combined with HSV color space and background modeling method, false positives are reduced.
It improves the efficiency of paint identification, reduces manpower waste, minimizes misjudgments, and ensures the accuracy and reliability of paint type identification.
Smart Images

Figure CN115937238B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a method, apparatus, computing device and storage medium for identifying paint types. Background Technology
[0002] Oil tubing is a fundamental piece of equipment used extensively in oilfield production operations. Due to prolonged exposure to harsh operating environments, oil tubing frequently suffers from wear and corrosion, causing significant losses to oil production. Therefore, oilfields periodically remove old oil tubing from wells and transport it to tubing repair shops for inspection and repair. During tubing repair, some repair shops use different colored paints on the outer walls of the tubing to indicate the type of defect and the tubing's grade. Based on the paint application, the tubing is then sorted into different production workshops for further processing. For example, tubing with thread defects is painted green and sent to the machining workshop for threading, while tubing that fails pressure testing is painted red and sent to the discard rack for scrapping.
[0003] Currently, oil pipe maintenance plants often rely on manual visual inspection to identify the paint on oil pipes, which is inefficient and wastes a lot of manpower. In addition, because oil pipes are very heavy, if a sorting error occurs, workers usually need to manually move the oil pipe from the pipe rack back to the maintenance line, which places a heavy workload on the workers. Summary of the Invention
[0004] In view of this, this application provides a method, apparatus, computing device, and storage medium for identifying paint types, which can improve the efficiency of paint identification. The technical solution is as follows:
[0005] Firstly, a method for identifying paint type is provided, the method comprising:
[0006] Obtain the image of the oil pipe to be identified;
[0007] The image to be identified is subjected to threshold segmentation to determine multiple painted areas in the image to be identified, and color recognition is performed on each painted area.
[0008] Based on the color of each painted area and the distance between painted pixels in multiple painted areas, multiple painted connected components are determined.
[0009] The coating type of the oil pipe is determined based on the total number of coated pixels contained in each coated connected region.
[0010] Optionally, determining the paint type of the oil pipe based on the total number of painted pixels in each painted connected region includes:
[0011] If the plurality of painted connected regions includes a first painted connected region, it is determined that the paint type of the oil pipe is normal paint, wherein the first painted connected region is a painted connected region whose total number of pixels is greater than a first number threshold.
[0012] Optionally, determining the paint type of the oil pipe based on the number of paint pixels contained in each paint connected region includes:
[0013] If the first painted connected region is not included in the plurality of painted connected regions, determine the distance between the second painted connected region and the third painted connected region, wherein the second painted connected region and the third painted connected region are any two different painted connected regions among the plurality of painted connected regions;
[0014] Based on the distance between the second painted connected region and the third painted connected region, determine whether to merge the second painted connected region and the third painted connected region;
[0015] If so, the coating type of the oil pipe is determined based on the total number of pixels contained in the merged coating connected region.
[0016] Optionally, after determining whether to merge the second painted connected region with the third painted connected region, the process further includes:
[0017] If not, determine that the coating type of the oil pipe is adhesive coating.
[0018] Optionally, after determining the distance between the second painted connected region and the third painted connected region, the method further includes:
[0019] Based on the center coordinates of the second painted connected domain and the center coordinates of the third painted connected domain, determine the distance between the center of the second painted connected domain and the center of the third painted connected domain in the horizontal direction.
[0020] Accordingly, determining whether to merge the second painted connected region and the third painted connected region based on the distance between them includes:
[0021] Based on the distance between the second painted connected region and the third painted connected region, and the distance between the regional centers of the second painted connected region and the third painted connected region in the horizontal axis direction, it is determined whether to merge the second painted connected region and the third painted connected region.
[0022] Optionally, determining multiple painted connected components based on the color of each painted area and the distance between painted pixels in multiple painted areas includes:
[0023] Based on the color of each painted area, the painted areas with the same color are identified as the target painted areas;
[0024] For a first painted pixel in the target painted area, if multiple neighborhoods of the first painted pixel include other painted pixels, it is determined that the first painted pixel and the other painted pixels belong to the same painted connected region, wherein the first painted pixel is any painted pixel in the target painted area.
[0025] Optionally, the step of performing threshold segmentation processing on the image to be identified to determine multiple painted areas in the image to be identified includes:
[0026] Threshold segmentation is performed on the image to be identified in the three channels of hue, saturation and brightness to obtain the painted area in each channel;
[0027] The intersection of the painted areas of the three channels is used to obtain multiple painted areas in the image to be identified.
[0028] Optionally, before performing threshold segmentation on the image to be identified, the method further includes:
[0029] The image to be identified is subjected to contrast enhancement and sharpening processing to obtain the processed image to be identified;
[0030] Accordingly, threshold segmentation processing is performed on the image to be identified, including:
[0031] The processed image to be identified is then subjected to threshold segmentation.
[0032] Secondly, a paint type identification device is provided, the device comprising:
[0033] The acquisition module is configured to acquire the image of the oil pipe to be identified;
[0034] The first determining module is configured to perform threshold segmentation processing on the image to be identified, determine multiple painted areas in the image to be identified, and perform color recognition on each painted area.
[0035] The second determining module is configured to determine multiple painted connected components based on the color of each painted area and the distance between painted pixels in multiple painted areas.
[0036] The third determining module is configured to determine the coating type of the oil pipe based on the total number of coating pixels contained in each coating connected region.
[0037] Thirdly, a computing device is provided, comprising:
[0038] processor;
[0039] Memory for storing the executable instructions of the processor;
[0040] The processor is configured to execute instructions stored in the memory to implement the paint type identification method according to any of the first aspects.
[0041] Fourthly, a computer storage medium is provided, wherein instructions are stored therein, which, when executed on a processing component, cause the processing component to perform a paint type identification method as described in any of the first aspects.
[0042] The technical solutions provided by the embodiments of this application may include the following beneficial effects:
[0043] The paint type identification method provided in this application involves acquiring an image of an oil pipe to be identified; performing threshold segmentation on the image to be identified to determine multiple painted areas, and identifying the color of each painted area; determining multiple painted connected regions based on the color of each painted area and the distance between painted pixels in the multiple painted areas; and determining the paint type of the oil pipe based on the total number of painted pixels contained in each painted connected region. This method improves identification efficiency, reduces manpower waste, and, by determining painted connected regions for paint type identification, avoids misjudgments caused by irregular paint application due to adhesion or other reasons, thus improving the accuracy of paint type identification.
[0044] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this application. Attached Figure Description
[0045] Figure 1 This is a framework diagram of a paint type identification system provided in an embodiment of this application;
[0046] Figure 2 This is a flowchart of a method for identifying paint type provided in an embodiment of this application;
[0047] Figure 3 This is a schematic diagram of a process for foreground and background detection of an image to be recognized, provided in an embodiment of this application;
[0048] Figure 4 This is a schematic diagram illustrating threshold segmentation of an image to be recognized, provided in an embodiment of this application.
[0049] Figure 5 This is a schematic diagram of a painted connected region provided in this application;
[0050] Figure 6This is a flowchart of another method for identifying paint types provided in an embodiment of this application;
[0051] Figure 7 This is a schematic diagram of a painted connected region provided in this application;
[0052] Figure 8 This is a flowchart illustrating another method for identifying paint types provided in this application embodiment;
[0053] Figure 9 This is a block diagram of a paint type identification device provided in an embodiment of this application;
[0054] Figure 10 This is a schematic diagram of the structure of a computing device provided in an embodiment of this application. Detailed Implementation
[0055] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0056] First, the implementation environment of the paint type identification method provided in this application will be introduced.
[0057] See Figure 1 , Figure 1 This is a framework diagram of a paint type identification system provided in an embodiment of this application.
[0058] The paint type identification system mainly includes a vision acquisition device 101 and a sorting control device 102. The vision acquisition device 101 includes a CCD (Charge Coupled Device) camera and a ring light source installed in the detection box, with openings on both sides of the detection box for oil supply pipes to pass through. The sorting control device 102 includes an industrial computer and a PLC (Programmable Logic Controller). The industrial computer is used to carry paint identification software and identification algorithms, and the PLC is used to receive the identification result signals sent by the industrial computer and output sorting signals.
[0059] The workflow of the paint type identification method in this system is as follows: When the oil pipe is conveyed to the proximity sensor position by the conveyor roller, the proximity sensor is triggered, sending an oil pipe arrival signal. The area array CCD camera fixed on the top of the detection box and its matching ring light source turn on after receiving the oil pipe arrival signal. The area array CCD camera transmits the real-time acquired image of the oil pipe to the industrial control computer, where the identification algorithm built into the industrial control computer identifies the paint on the oil pipe. When the tail of the oil pipe leaves the proximity sensor, the sensor trigger signal disappears. After the identification algorithm determines that the oil pipe has left the detection box, the system stops acquiring oil pipe images. Finally, the industrial control computer comprehensively judges the paint identification results (paint type) of the entire oil pipe, determines the oil pipe information, determines the sorting signal, and sends the sorting signal to the PLC for sorting operation.
[0060] Next, the application scenarios of the paint type identification method provided in the embodiments of this application will be introduced.
[0061] When using a paint type recognition system to identify paint types, the following problems may occur:
[0062] (1) Problem of false triggering of proximity sensor leading to incorrect output signal: Sometimes the oil pipe proximity sensor may be falsely triggered by electromagnetic interference. At this time, there is no oil pipe in the image to be identified. If the image to be identified is identified, the output will be "no color ring", that is, the oil pipe is unpainted. This will lead to the output of incorrect sorting signal, which will bring safety hazards.
[0063] (2) Oil pipe reflection problem caused by oil stains on the pipe wall: Even after cleaning, there are still some oil stains on the surface of the oil pipe. After being illuminated by a light source, the strip-shaped light spots produced by the oil stains will sometimes divide the normal paint into two parts, affecting the paint identification.
[0064] (3) Paint adhesion problem on the pipe wall: The pipe is driven in the production line by the conveyor roller. Since the conveyor roller is in direct contact with the pipe wall, paint is very easy to stick to the conveyor roller. The paint on the surface of the conveyor roller will then stick to the outer wall of other pipes. Sometimes the area of the sticky paint is large, which can easily cause misidentification.
[0065] (4) Rusting of oil pipes: Some oil pipes have a lot of dark yellow or dark red rust on their surface. This rust is very similar to the yellow and red areas in the darker parts of the oil pipe image, which greatly interferes with the identification.
[0066] (5) Oil pipe coating quality issues: In some parts of the oil pipe maintenance line, workers use manual brushing to mark information, which often results in the coating not forming a ring, making it difficult to identify the coating.
[0067] (6) Oil pipe paint peeling phenomenon: When the oil pipe production line is stopped for a period of time, the paint on the oil pipe will be attached to the outer wall of the oil pipe after drying. The dried paint is easy to peel off from the pipe wall, affecting the paint ring formation and affecting paint identification.
[0068] Therefore, this application provides a method for identifying paint type, which can solve the above-mentioned technical problems. The specific implementation can be found in the following embodiments.
[0069] In the embodiments of this application, please refer to Figure 2 , Figure 2 This is a flowchart of a method for identifying paint type according to an embodiment of this application. The method may include the following steps:
[0070] Step 201: Obtain the image of the oil pipe to be identified.
[0071] The paint type identification method provided in this application embodiment can be applied to any device capable of image processing. For example, the device could be... Figure 1 The industrial control computer in the paint recognition system shown.
[0072] As an example, the camera in the detection box can capture the image of the oil pipe to be identified and send the image to the industrial control computer, so that the industrial control computer can obtain the image of the oil pipe to be identified.
[0073] Furthermore, to prevent the proximity sensor from malfunctioning and causing the acquired image to be identified to exclude the oil pipe, which would lead to the direct identification of the background and the resulting incorrect paint type, thus outputting an incorrect sorting signal, this application requires the detection of the foreground (oil pipe) and background (detection box) of the acquired image to be identified, and the identification is achieved by using a background modeling method.
[0074] In some embodiments, background modeling methods are commonly used in moving target detection. Background modeling-based moving target detection methods compare the current frame with a background model, then use a thresholding method to determine whether each pixel belongs to the moving foreground, and finally segment the detected moving foreground to obtain the detected object. Background modeling-based target detection methods generally include steps such as background model initialization, foreground detection, and segmentation.
[0075] In one or more embodiments of this application, since the detection box structure in the paint recognition system is relatively enclosed, the background image may vary slightly throughout the day due to different ambient lighting conditions. Therefore, a frame of the image taken at regular intervals when the proximity sensor is not triggered can be used as the background image. During the recognition process, the acquired image to be recognized and the background image are converted into grayscale images and the difference is calculated to obtain a difference image. The number of pixels of interest in the difference image is calculated based on a preset effective difference threshold. When a large number of pixels of interest appear, it is considered that the image to be recognized contains a moving target (oil pipe), and paint recognition can be performed on the image to be recognized.
[0076] For example, the difference image can be determined by the following formula (1):
[0077]
[0078] In the formula, Represents a difference image. This represents the image to be identified. Represents the background image. This represents the position coordinates of a pixel.
[0079] See Figure 3 , Figure 3 This is a schematic diagram of a process for foreground and background detection of an image to be identified, provided in an embodiment of this application. The camera can acquire multiple frames of images of an oil pipe to be identified. Before performing paint recognition on the current frame of the image to be identified, the current frame of the image to be identified is differentially processed with the background image to obtain a difference image. Then, the difference image is thresholded to obtain a thresholding result. If the difference image is determined to contain an oil pipe based on the thresholding result, then the current frame of the image to be identified is determined to contain an oil pipe, and subsequent processing can be performed on the current frame image.
[0080] In this embodiment of the application, after obtaining the image of the oil pipe to be identified, the background and foreground of the image to be identified are first identified to determine that the image to be identified includes the oil pipe. This avoids the situation where the proximity sensor is accidentally triggered, resulting in the acquisition of an image that does not include the oil pipe. This avoids the situation where the paint type is incorrectly determined when identifying an image that does not include the oil pipe. This not only improves the accuracy of determining the paint type, but also reduces the workload of paint identification.
[0081] Step 202: Perform threshold segmentation on the image to be identified to determine multiple painted areas in the image to be identified, and perform color recognition on each painted area.
[0082] In other words, after acquiring the image to be identified, it is necessary to first determine the areas in the image that are painted, i.e., the painted areas. Then, since different colors of paint represent different meanings, when identifying the type of paint, painted areas of the same color can be merged. Therefore, it is necessary to perform color recognition on each painted area to determine the color of each painted area.
[0083] In one or more embodiments of this application, since the image to be identified captured by the CCD camera is a color image belonging to the RGB (Red-Green-Blue) color space, but the RGB color space is a non-uniform color space, processing the three components separately will lead to the loss and disorder of color information, making it unsuitable for color image segmentation. In contrast, the HSV (Hue-Saturation-Value) color space is a uniform color space with a more compact information structure, strong independence of each component, and less loss of color information, making it suitable for color image segmentation. Therefore, the HSV color space is chosen for threshold segmentation of the image to be identified to determine the painted areas.
[0084] Therefore, the specific implementation of threshold segmentation of the image to be identified to determine the painted area in the image to be identified may include: performing threshold segmentation on the image to be identified in the three channels of hue, saturation and brightness respectively to obtain the painted area of each channel; and taking the intersection of the painted areas of the three channels to obtain the painted area in the image to be identified.
[0085] In other words, pixels can be segmented based on the threshold of each channel of hue, saturation, and brightness to obtain the segmentation results of the three channels H, S, and V respectively. The intersection of the segmentation results of the three channels can be used to obtain the painted region.
[0086] As an example, the painted area can be determined using the following formula (2):
[0087] (2)
[0088] In formula (2), region represents the painted area, region_h represents the segmentation result of threshold segmentation of the image to be recognized in the H channel, region_s represents the segmentation result of threshold segmentation of the image to be recognized in the S channel, and region_v represents the segmentation result of threshold segmentation of the image to be recognized in the V channel.
[0089] See Figure 4 , Figure 4This is a schematic diagram of threshold segmentation of an image to be identified provided in an embodiment of this application. The diagram includes the image to be identified, the H-channel segmentation result, the S-channel segmentation result, the V-channel segmentation result, and the comprehensive segmentation result (i.e., the painted area) after combining the segmentation results of the three channels.
[0090] In some embodiments, by acquiring a large number of oil pipe coating images, analyzing the H, S, and V thresholds of the coating area, obtaining common knowledge of coating colors, and determining the threshold range of different coatings.
[0091] Furthermore, ambient lighting is a crucial factor affecting the performance of machine vision inspection. Images acquired at different times will exhibit lighting variations, impacting the recognition results. For instance, oil stains on oil pipes reflect light, affecting the accuracy of the recognition. Therefore, image preprocessing can be performed before paint recognition to improve image quality and thus enhance the accuracy of the recognition results.
[0092] Therefore, in one or more embodiments of this application, before performing threshold segmentation processing on the image to be identified, the method further includes:
[0093] The image to be identified is subjected to contrast enhancement and sharpening processing to obtain the processed image to be identified;
[0094] Accordingly, the specific implementation of threshold segmentation processing on the image to be identified may include:
[0095] The processed image to be identified is then subjected to threshold segmentation.
[0096] In other words, before performing threshold segmentation on the image to be recognized, contrast enhancement and sharpening can be performed on the image to be recognized to make the boundary between the painted and unpainted parts more obvious. Then, the threshold segmentation is performed based on the image to be recognized after this processing, which can improve the accuracy of the segmentation process.
[0097] As an example, contrast enhancement of an image to be recognized is essentially contrast enhancement of the pixels within that image. For any given pixel, the enhanced pixel value can be determined based on its original pixel value and the average pixel value of its N neighboring pixels. Here, N is a positive integer greater than 1; for example, N can be 8.
[0098] For example, the image to be recognized can be contrast-enhanced using the following formula (3):
[0099] (3)
[0100] In formula (3), Represents pixels pixel values, Indicates the pixel after contrast enhancement processing pixel values, Indicates the gain factor. Represented by pixels The average pixel value is calculated by taking N neighborhoods around the center.
[0101] As an example, sharpening an image to be recognized is essentially sharpening the pixels within that image. For any given pixel, the pixel value after contrast enhancement can be determined based on the pixel value itself and the average pixel value of its N neighboring pixels. Here, N is a positive integer greater than 1; for example, N can be 8.
[0102] For example, the image to be recognized can be sharpened using the following formula (4):
[0103] (4)
[0104] In formula (4), Represents pixels pixel values, Indicates the pixel after contrast enhancement processing pixel values, Indicates the gain factor. Represented by pixels The average pixel value is calculated by taking N neighborhoods around the center.
[0105] Furthermore, since the oil pipe's position within the detection chamber is essentially fixed, identification can be performed only on the central region of the image. This means that before contrast enhancement and sharpening, the image is cropped, specifically the central region, which is then processed further to identify the type of paint coating on the oil pipe. This reduces the workload of paint coating identification and lowers the processing load on the equipment.
[0106] In this embodiment, after obtaining the image to be identified, the middle area is first cropped from the image to reduce the workload of paint identification. Then, the cropped image is subjected to contrast enhancement and sharpening processing, which increases the brightness of the darker parts of the image and decreases the brightness of the brighter parts, making the boundary between the painted area and the unpainted area more significant. Finally, the painted area is determined by HSV threshold segmentation, which can improve the efficiency and accuracy of determining the painted area.
[0107] Step 203: Based on the color of each painted area and the distance between painted pixels in multiple painted areas, determine multiple painted connected components.
[0108] Among them, the painted pixels are the pixels in the painted area.
[0109] In this embodiment, after determining the painted areas and their colors, the paint type can be determined by judging the number of pixels in each painted area. However, oil pipe paint formed due to special reasons such as adhesion is often irregular and discontinuous. If the paint type is directly judged based on the number of pixels contained in the painted area, misjudgment will occur. Therefore, further processing of the painted areas is required, merging painted areas of the same color.
[0110] In some embodiments of this application, for a first painted pixel in a painted area, if there exists a second painted pixel whose distance to the first painted pixel is less than a preset distance, then it is determined that the second painted pixel and the first painted pixel belong to the same painted connected region.
[0111] In other embodiments of this application, the specific implementation of determining multiple painted connected regions based on the color of each painted region and the distance between painted pixels in multiple painted regions may include: determining painted regions with the same color as target painted regions according to the color of each painted region; for a first painted pixel in the target painted region, if the multiple neighborhoods of the first painted pixel include other painted pixels, determining that the first painted pixel and the other painted pixels belong to the same painted connected region, wherein the first painted pixel is any painted pixel in the target painted region.
[0112] In other words, the painted areas can be classified according to their colors. Painted areas with the same color are collectively referred to as target painted areas. For the first painted pixel in the target painted area, the distance between the first painted pixel and other pixels in the image to be identified is used to determine the neighborhood of the first painted pixel. If there are second painted pixels in multiple neighborhoods of the first painted pixel, then the first painted pixel and the second painted pixel belong to the same painted connected region. The second painted pixel is a painted pixel in the target painted area.
[0113] For example, if there are other painted pixels in the 8-neighborhood of a painted pixel, then these two painted pixels belong to the same painted connected region.
[0114] Furthermore, before determining the painted connected region, an opening operation can be performed on the painted region, that is, the painted region is first eroded and then expanded, which is used to separate objects at thin points and smooth the boundaries of larger objects without significantly changing their area. Then, the painted connected region is determined on the painted region after the opening operation, and the painted connected region is selected as a whole for processing.
[0115] Furthermore, since the total number of painted pixels contained in painted connected regions is less than the second threshold (i.e., smaller area), painted connected regions do not greatly help in paint type identification and will increase the computational load of paint type identification. Therefore, painted connected regions with smaller area can be discarded, and only other painted connected regions that have a greater impact on paint identification can be retained.
[0116] In this embodiment, an opening operation is first performed on the painted area, and then the painted connected components are determined based on the distance between pixels in the painted area after the opening operation, which can improve the accuracy of paint recognition.
[0117] Step 204: Determine the coating type of the oil pipe based on the total number of coated pixels contained in each coated connected region.
[0118] In one or more embodiments of this application, the specific implementation of determining the paint type of the oil pipe based on the total number of paint pixels contained in each paint connected region may include: if the plurality of paint connected regions include a first paint connected region, determining that the paint type of the oil pipe is normal paint, wherein the first paint connected region is a paint connected region whose total number of pixels is greater than a first number threshold.
[0119] In other words, if the total number of pixels in multiple painted connected regions is greater than the first number threshold of the first painted connected region, then other painted connected regions can be discarded directly, and the painting type of the oil pipe can be determined to be normal painting.
[0120] For example, see Figure 5 , Figure 5 This is a schematic diagram of a painted connected region provided in this application. The white part in the figure represents the painted connected region. Figures (a) and (c) include the first painted connected region. The area of this type of painted connected region is several times larger than the area of the smaller painted connected regions in the same image. Therefore, the smaller painted connected regions can be directly discarded, and the painting type of the first painted connected region is considered to be normal painting.
[0121] Furthermore, the type of oil pipe can be determined based on the color of the paint in the connected region. For example, red indicates an oil pipe used in scene A, and green indicates an oil pipe used in scene B. It should be noted that the correspondence between color and oil pipe type can be set by the user according to actual needs.
[0122] In one or more embodiments of this application, the specific implementation of determining the paint type of the oil pipe based on the total number of paint pixels contained in each paint connected region may include:
[0123] If the first painted connected region is not included among the plurality of painted connected regions, the distance between the second painted connected region and the third painted connected region is determined, wherein the second painted connected region and the third painted connected region are any two different painted connected regions among the plurality of painted connected regions; based on the distance between the second painted connected region and the third painted connected region, it is determined whether to merge the second painted connected region and the third painted connected region; if so, the paint type of the oil pipe is determined based on the total number of pixels contained in the merged painted connected region.
[0124] In other words, if there is no first painted connected region with a large area among multiple painted connected regions, it can be determined whether to merge these smaller painted connected regions, and then the paint type of the oil pipe can be determined based on the total number of pixels in the merged painted connected regions.
[0125] As an example, a specific implementation of determining the distance between the second painted connected component and the third painted connected component may include: determining the center coordinates of the second painted connected component based on the coordinates of the pixels in the second painted connected component; determining the center coordinates of the third painted connected component based on the coordinates of the pixels in the third painted connected component; and determining the distance between the second painted connected component and the third painted connected component based on the center coordinates of the second painted connected component and the center coordinates of the third painted connected component.
[0126] The center coordinates of the second painted connected domain are the coordinates of the region center of the second painted connected domain.
[0127] For example, the center coordinates of the painted connected domain can be determined by the following formula (5):
[0128] (5)
[0129] In formula (5), This represents the i-th pixel. Represents the x-coordinate of a pixel within the painted connected region. Represents the ordinate of a pixel within the painted connected region. This represents the average value.
[0130] The average of the horizontal and vertical coordinates of all pixels in the painted connected region can be calculated using formula (5), and used as the horizontal and vertical coordinates of the region center, thus obtaining the center coordinates of the painted connected region.
[0131] In some embodiments, if the distance between the second and third painted connected regions is less than a distance threshold, the second and third painted connected regions are considered to be close, and they can be merged. The painting type is determined based on the number of pixels contained in the merged painted connected region. If the number of pixels contained in the merged painted connected region is greater than a first number threshold, the painting type of the oil pipe is determined to be normal painting; if the number of pixels contained in the merged painted connected region is less than the first number threshold, the painting type of the oil pipe is determined to be adhesive painting.
[0132] For example, see Figure 5 , Figure 5 In the middle (b) and (d), the painted connected regions are smaller in area and can be merged.
[0133] In other embodiments, after determining whether to merge the second painted connected region with the third painted connected region, the method further includes:
[0134] If not, determine that the coating type of the oil pipe is adhesive coating.
[0135] In other words, if the distance between multiple painted connected regions is relatively far and they cannot be merged, and the number of pixels contained in each painted connected region is less than the first number threshold, then the paint type of the oil pipe can be determined to be adhesive paint.
[0136] Furthermore, after determining the distance between the second and third painted connected regions, the process also includes:
[0137] Based on the center coordinates of the second painted connected domain and the center coordinates of the third painted connected domain, determine the distance between the center of the second painted connected domain and the center of the third painted connected domain in the horizontal direction.
[0138] Accordingly, determining whether to merge the second painted connected region and the third painted connected region based on the distance between them includes:
[0139] Based on the distance between the second painted connected region and the third painted connected region, and the distance between the regional centers of the second painted connected region and the third painted connected region in the horizontal axis direction, it is determined whether to merge the second painted connected region and the third painted connected region.
[0140] In other words, since paint with a long distance in the horizontal axis direction is generally formed by adhesion, when determining whether to merge two painted connected regions, we must consider not only the absolute distance between the two painted connected regions, but also the distance between the regional centers of the two painted connected regions in the horizontal axis direction. If both of these distances meet the conditions, then we determine to merge the second painted connected region with the third painted connected region.
[0141] As an example, if the distance between the second painted connected region and the third painted connected region, as well as the distance between the regional centers of the second painted connected region and the third painted connected region in the horizontal direction, are both less than a distance threshold, then it is determined that the second painted connected region and the third painted connected region will be merged.
[0142] This can further improve the accuracy of identifying the paint type.
[0143] Furthermore, after determining the paint type of the oil pipe, the oil pipe is classified according to the paint color. For example, red normal paint is used in scene A, yellow normal paint is used in scene B, and adhesive paint (no paint color) is used in scene C.
[0144] In summary, the paint type identification method provided in this application acquires an image of an oil pipe to be identified; performs threshold segmentation on the image to be identified to determine multiple painted areas in the image, and identifies the color of each painted area; determines multiple painted connected regions based on the color of each painted area and the distance between painted pixels in the multiple painted areas; and determines the paint type of the oil pipe based on the total number of painted pixels contained in each painted connected region. Using the above method for paint type identification can improve identification efficiency, reduce manpower waste, and, by determining painted connected regions for paint type identification, avoid misjudgment caused by irregular paint on the oil pipe due to adhesion or other reasons, thus improving the accuracy of paint type identification.
[0145] Please refer to Figure 6 , Figure 6This is a flowchart of a paint type identification method provided in this application embodiment, which is divided into three modules: background detection, threshold segmentation, and comprehensive judgment. The background detection module is used to determine whether the acquired image to be identified is an image containing only a background. If so, the image acquisition is returned; otherwise, subsequent steps are performed to ensure that the paint identification is processed on the oil pipe image. The threshold segmentation module first preprocesses the image to be identified to make the boundary between the painted area and the unpainted area in the image to be identified more obvious. Then, the image to be identified is converted to the HSV color gamut space and threshold segmented according to the threshold of each channel to obtain the painted area of the image to be identified. The comprehensive judgment module is used to further judge the painted area. First, the painted connected components are determined, and it is determined whether the number of pixels contained in the painted connected components is greater than the number threshold. If so, the paint type is determined to be normal paint. If not, it is determined whether to merge the painted connected components based on the distance between them. If so, the paint type is determined based on the number of pixels contained in the merged painted connected components.
[0146] Next, the paint recognition method provided in this application will be verified using experimental data.
[0147] First, the algorithm was validated using six sets of typical irregular paint images, such as... Figure 7 , Figure 7 This is a schematic diagram of a painted connected region provided in this application. Figure 7 In Figure (a), the painting was done by manual spraying. Due to uneven painting and reflection, the paint did not form a ring. Figures (c), (e), (g), and (i) show large areas of adhesive painting. Based on the area alone, it is easy to mistakenly judge it as normal painting. Figure (k) shows hand-brushed painting. The paint color is light and does not form a ring.
[0148] Following the processing method of the comprehensive judgment module for small-area painted connected regions, the number of pixels contained in the painted connected region, the distance between painted connected regions, and the distance of the region center of the painted connected region in the horizontal direction are calculated. As shown in Table 1, based on the distance judgment, the painted connected regions in (a) and (k) are relatively close, and can be merged for processing. Finally, based on the number of pixels, they are judged as normal painting; the painted connected regions in (c), (e), (g), and (i) are relatively far apart and are not processed as painted connected regions, but are identified as sticky painting.
[0149] Table 1 Test Results
[0150] Serial Number Number of connected components per pixel Number of connected components in 2 pixels center distance Horizontal distance 1 16650 17136 147.02 17.29 2 9886 16362 288.60 271.92 3 7277 6915 348.21 346.561 4 11353 12127 527.14 526.98 5 10523 5218 759.14 758.48 6 10032 13158 198.934 36.95
[0151] Next, real samples collected on-site by the system were used for experimental testing. Table 2 shows the recognition results of two sets of collected images saved by the paint recognition system. Normal paint was classified into categories based on manual visual inspection, resulting in paint classification results (paint type). Then, the recognition algorithm was used to identify the collected images. The results show that the recognition method has high accuracy, proving the effectiveness of the system. The processing time for oil pipe images was also recorded, and the average processing speed per image was calculated to be approximately 42ms, which meets the requirements of industrial field operations.
[0152] Table 2 Experimental Results
[0153] Serial Number Correct identification Identification error total accuracy 1 22511 23 22534 99.89% 2 4240 15 4255 99.64%
[0154] This application addresses the problems of low detection efficiency and high manpower consumption in current oil pipe paint identification methods by providing a paint identification method. This method utilizes machine vision technology to achieve high-precision identification of oil pipe paint, with simple hardware structure, high detection efficiency, and strong algorithm robustness. It effectively solves the problem of paint identification in irregular small connected regions, meets the requirements of industrial field use, and provides a simple and effective approach for similar identification tasks.
[0155] Please refer to Figure 8 , Figure 8 This is a flowchart of another method for identifying paint types provided in this application embodiment. The method includes the following steps:
[0156] Step 801: Obtain the image to be recognized.
[0157] Step 802: Perform background and foreground detection on the image to be identified to determine whether the image to be identified is a background image.
[0158] If yes, return to step 801; otherwise, proceed to step 803.
[0159] Step 803: Perform contrast enhancement and sharpening processing on the image to be recognized to obtain the processed image to be recognized.
[0160] Step 804: Perform threshold segmentation on the image to be recognized in the three channels of hue, saturation and brightness to obtain the painted area of each channel.
[0161] Step 805: Intersect the painted areas of the three channels to obtain the painted areas in the image to be identified, and identify the color of each painted area.
[0162] Step 806: Perform an opening operation on the painted areas in the image to be identified.
[0163] Step 807: Determine multiple painted connected components based on the colors of each painted area after the opening operation and the distances between painted pixels in multiple painted areas.
[0164] Step 808: If the first painted connected region is included in multiple painted connected regions, determine that the paint type of the oil pipe is normal paint.
[0165] The first painted connected region is a painted connected region whose total number of pixels is greater than a first quantity threshold.
[0166] Step 809: If the first painted connected domain is not included in the multiple painted connected domains, determine the center coordinates of the region center of the second painted connected domain and the center coordinates of the region center of the third painted connected domain.
[0167] Step 810: Based on the center coordinates of the regional center of the second painted connected domain and the center coordinates of the regional center of the third painted connected domain, determine the absolute distance between the second painted connected domain and the third painted connected domain, as well as the distance between the regional centers of the second painted connected domain and the third painted connected domain in the horizontal direction.
[0168] Step 811: If the distance between the second painted connected region and the third painted connected region, and the distance between the regional centers of the second painted connected region and the third painted connected region in the horizontal axis direction are both less than the distance threshold, then determine to merge the second painted connected region and the third painted connected region.
[0169] Step 812: Determine the paint type of the oil pipe based on the total number of pixels contained in the merged paint connected region.
[0170] Step 813: Classify the oil pipes according to their paint type and paint color.
[0171] The paint identification method provided in this application effectively solves the problems of paint adhesion and peeling in oil pipe paint identification, and has strong robustness, fast identification speed and high identification accuracy.
[0172] It should be noted that the order of the steps provided in the embodiments of this application can be adjusted appropriately, and the steps can also be added or removed as appropriate. Any variation methods that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application, and therefore will not be elaborated further.
[0173] The above text combines Figures 1 to 8 This application describes in detail the method for identifying paint types provided in its embodiments. The following will combine... Figure 9 This describes the paint type identification device provided in the embodiments of this application. Please refer to... Figure 9 , Figure 9 This is a block diagram of a paint type identification device provided in an embodiment of this application. The device includes:
[0174] The acquisition module 901 is configured to acquire the image of the oil pipe to be identified;
[0175] The first determining module 902 is configured to perform threshold segmentation processing on the image to be identified, determine multiple painted areas in the image to be identified, and perform color recognition on each painted area.
[0176] The second determining module 903 is configured to determine multiple painted connected regions based on the color of each painted region and the distance between painted pixels in multiple painted regions.
[0177] The third determining module 904 is configured to determine the coating type of the oil pipe based on the total number of coating pixels contained in each coating connected region.
[0178] In one or more embodiments of this application, the third determining module 904 is further configured to:
[0179] If the plurality of painted connected regions includes a first painted connected region, it is determined that the paint type of the oil pipe is normal paint, wherein the first painted connected region is a painted connected region whose total number of pixels is greater than a first number threshold.
[0180] In one or more embodiments of this application, the third determining module 904 is further configured to:
[0181] If the first painted connected region is not included in the plurality of painted connected regions, determine the distance between the second painted connected region and the third painted connected region, wherein the second painted connected region and the third painted connected region are any two different painted connected regions among the plurality of painted connected regions;
[0182] Based on the distance between the second painted connected region and the third painted connected region, determine whether to merge the second painted connected region and the third painted connected region;
[0183] If so, the coating type of the oil pipe is determined based on the total number of pixels contained in the merged coating connected region.
[0184] In one or more embodiments of this application, the third determining module 904 is further configured to:
[0185] If not, determine that the coating type of the oil pipe is adhesive coating.
[0186] In one or more embodiments of this application, the third determining module 904 is further configured to:
[0187] Based on the center coordinates of the second painted connected domain and the center coordinates of the third painted connected domain, determine the distance between the center of the second painted connected domain and the center of the third painted connected domain in the horizontal direction.
[0188] Based on the distance between the second painted connected region and the third painted connected region, and the distance between the regional centers of the second painted connected region and the third painted connected region in the horizontal axis direction, it is determined whether to merge the second painted connected region and the third painted connected region.
[0189] In one or more embodiments of this application, the second determining module 903 is further configured to:
[0190] Based on the color of each painted area, the painted areas with the same color are identified as the target painted areas;
[0191] For a first painted pixel in the target painted area, if multiple neighborhoods of the first painted pixel include other painted pixels, it is determined that the first painted pixel and the other painted pixels belong to the same painted connected region, wherein the first painted pixel is any painted pixel in the target painted area.
[0192] In one or more embodiments of this application, the first determining module 902 is further configured to:
[0193] Threshold segmentation is performed on the image to be identified in the three channels of hue, saturation and brightness to obtain the painted area in each channel;
[0194] The intersection of the painted areas of the three channels is used to obtain multiple painted areas in the image to be identified.
[0195] In one or more embodiments of this application, the third determining module 904 is further configured to:
[0196] The image to be identified is subjected to contrast enhancement and sharpening processing to obtain the processed image to be identified;
[0197] The processed image to be identified is then subjected to threshold segmentation.
[0198] The paint type identification device provided in this application acquires an image of an oil pipe to be identified; performs threshold segmentation on the image to be identified to determine multiple painted areas in the image, and identifies the color of each painted area; determines multiple painted connected regions based on the color of each painted area and the distance between painted pixels in the multiple painted areas; and determines the paint type of the oil pipe according to the total number of painted pixels contained in each painted connected region. By using the above method for paint type identification, the identification efficiency can be improved, manpower waste can be reduced, and determining painted connected regions for paint type identification can avoid misjudgment caused by irregular paint on the oil pipe due to adhesion or other reasons, thus improving the accuracy of paint type identification.
[0199] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the paint type identification device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here in the embodiments of this application.
[0200] This application provides a computing device, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the instructions stored in the memory to implement the paint type identification method described in any of the embodiments of this application.
[0201] For example, please refer to Figure 10 , Figure 10 This is a schematic diagram of the structure of a computing device provided in an embodiment of this application, such as... Figure 10 As shown, the computing device 1000 includes a memory 1001 and a processor 1002. The memory 1001 stores programs, and the processor 1002 executes the programs stored in the memory 1001 to implement any of the paint type identification methods provided in the embodiments of this application.
[0202] Optionally, such as Figure 10 As shown, the computing device 1000 may further include at least one communication interface 1003 and at least one communication bus 1004. The memory 1001, processor 1002, and communication interface 1003 are communicatively connected via the communication bus 1004.
[0203] This application provides a computer storage medium storing instructions that, when executed on a processing component, cause the processing component to perform any of the paint type identification methods described in this application.
[0204] The above embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented in the form of a computer program product, which includes a number of computer instructions to cause a computer to execute any of the methods described in the embodiments of this application.
[0205] The computer may include a general-purpose computer or a computer network. The computer stores computer instructions through its storage medium or retrieves computer instructions from other storage media. The storage medium can be any available medium that the computer can access, or a data storage device such as a server or data center that integrates one or more available media. The available medium can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media, or semiconductor media (e.g., solid-state drives).
[0206] In this application, the terms "first," "second," and "third," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. "At least one" means one or more, "multiple" means two or more, and "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship, unless otherwise explicitly defined.
[0207] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the claims.
[0208] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A method for identifying paint type, characterized in that, The method includes: Obtain the image of the oil pipe to be identified; The image to be identified is subjected to threshold segmentation to determine multiple painted areas in the image to be identified, and color recognition is performed on each painted area. Based on the color of each painted area and the distance between painted pixels in multiple painted areas, multiple painted connected components are determined. The coating type of the oil pipe is determined based on the total number of coated pixels contained in each coated connected region. If the first coated connected region is included among the multiple coated connected regions, the coating type of the oil pipe is determined to be normal coating, wherein the first coated connected region is a coated connected region whose total number of pixels is greater than a first threshold. If the first coated connected region is not included among the multiple coated connected regions, the distance between the second and third coated connected regions is determined, wherein the second and third coated connected regions are any two different coated connected regions among the multiple coated connected regions. Based on the distance between the second and third coated connected regions, it is determined whether to merge the second and third coated connected regions. If so, the coating type of the oil pipe is determined based on the total number of pixels contained in the merged coated connected region.
2. The method according to claim 1, characterized in that, After determining whether to merge the second painted connected region with the third painted connected region, the process further includes: If not, determine that the coating type of the oil pipe is adhesive coating.
3. The method according to claim 1, characterized in that, After determining the distance between the second and third painted connected components, the following steps are also included: Based on the center coordinates of the second painted connected domain and the center coordinates of the third painted connected domain, determine the distance between the center of the second painted connected domain and the center of the third painted connected domain in the horizontal direction. Accordingly, determining whether to merge the second painted connected region and the third painted connected region based on the distance between them includes: Based on the distance between the second painted connected region and the third painted connected region, and the distance between the regional centers of the second painted connected region and the third painted connected region in the horizontal axis direction, it is determined whether to merge the second painted connected region and the third painted connected region.
4. The method as described in claim 1, characterized in that, The determination of multiple painted connected components based on the color of each painted area and the distance between painted pixels in multiple painted areas includes: Based on the color of each painted area, the painted areas with the same color are identified as the target painted areas; For a first painted pixel in the target painted area, if multiple neighborhoods of the first painted pixel include other painted pixels, it is determined that the first painted pixel and the other painted pixels belong to the same painted connected region, wherein the first painted pixel is any painted pixel in the target painted area.
5. The method according to claim 1, characterized in that, The threshold segmentation process performed on the image to be identified to determine multiple painted areas in the image to be identified includes: Threshold segmentation is performed on the image to be identified in the three channels of hue, saturation and brightness to obtain the painted area in each channel; The intersection of the painted areas of the three channels is used to obtain multiple painted areas in the image to be identified.
6. A device for identifying paint type, characterized in that, The device includes: The acquisition module is configured to acquire the image of the oil pipe to be identified; The first determining module is configured to perform threshold segmentation processing on the image to be identified, determine multiple painted areas in the image to be identified, and perform color recognition on each painted area. The second determining module is configured to determine multiple painted connected components based on the color of each painted area and the distance between painted pixels in multiple painted areas. The third determining module is configured to determine the coating type of the oil pipe based on the total number of coating pixels contained in each coating connected region. The third determining module determines the paint type of the oil pipe based on the total number of painted pixels contained in each painted connected region, including: if the plurality of painted connected regions include a first painted connected region, determining that the paint type of the oil pipe is normal painting, wherein the first painted connected region is a painted connected region whose total number of pixels is greater than a first number threshold; if the plurality of painted connected regions do not include the first painted connected region, determining the distance between the second painted connected region and the third painted connected region, and determining whether to merge the second painted connected region and the third painted connected region based on the distance between the second painted connected region and the third painted connected region; if so, determining the paint type of the oil pipe based on the total number of pixels contained in the merged painted connected region.
7. A computing device, characterized in that, include: processor; Memory for storing the executable instructions of the processor; The processor is configured to execute instructions stored in the memory to implement the method of any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The storage medium stores instructions that, when executed on a processing component, cause the processing component to perform the method as described in any one of claims 1-5.
Citation Information
Patent Citations
Color identification method and device, terminal equipment and storage medium
CN112070096A
Target area detection method and device, equipment and storage medium
CN113947613A