Search

CN-121999205-A - Automatic detection method and system for morphological parameters of irregular object

CN121999205ACN 121999205 ACN121999205 ACN 121999205ACN-121999205-A

Abstract

The invention discloses an automatic detection method and system for morphological parameters of an irregular object, and relates to the technical field of image processing. The method comprises the steps of extracting an effective contour from a preprocessed image, generating a mask, cutting an ROI (region of interest) area to focus a target, adopting a self-defined convolution kernel to accurately detect a skeleton endpoint, extracting a longest skeleton path through a bidirectional BFS algorithm, repairing a breakpoint through linear interpolation, and finally mapping a path coordinate back to an original image, and accordingly comprehensively calculating core morphological parameters such as the length of a skeleton axis, the maximum linear distance between two ends of the contour, the average width based on dynamic partition and distance transformation, and the like. The method and the device have the advantages that the efficiency is remarkably improved through the local treatment of the ROI, robustness and high precision are ensured by means of an innovative endpoint detection and path repair mechanism, comprehensive and automatic accurate detection of morphological characteristics of the irregular small object is realized, and the problems of low efficiency, treatment failure, poor engineering suitability and the like in the prior art are effectively solved.

Inventors

  • Su Xuemiao
  • Lai Enqi
  • YANG CHUNNING
  • DONG JUNMIN
  • LIU YOUJUN
  • Ge Nizhi
  • CHEN YUN
  • GAO YONGXIN
  • YANG LIXIAN
  • SHEN LI
  • QI YAN

Assignees

  • 云南烟叶复烤有限责任公司楚雄复烤厂

Dates

Publication Date
20260508
Application Date
20260205

Claims (10)

  1. 1. An automatic detection method for morphological parameters of an irregular object is characterized by comprising the following steps: Acquiring an original image of a target object and converting the original image into a binary image; Extracting a plurality of object contours from the binary image, compressing contour points, reserving key points of each object contour, and verifying contour effectiveness; Generating a target area mask image for each effective contour, cutting out an interested area image only containing a target area from the target area mask image according to circumscribed rectangular parameters of the effective contour, converting the interested area image into a binary image, performing skeletonizing treatment to obtain a skeleton image with single pixel width, and performing convolution operation on the skeleton image to detect skeleton endpoints; Taking the end point of the skeleton as a starting point or taking the geometric center point of the skeleton as the starting point when the end point is not present, determining the two farthest points of the skeleton by breadth-first search and constructing a longest skeleton path between the two farthest points, initializing a new path list based on the longest skeleton path, checking the Euclidean distance between the subsequent points and the end point of the new path point by point according to the path sequence, judging as a breakpoint when the distance is larger than a preset path interpolation maximum gap value, obtaining a continuous longest skeleton path by interpolation restoration, and mapping the continuous longest skeleton path to an original image coordinate system; And calculating the skeleton axis length of the target object based on the continuous longest skeleton path in the original image coordinate system, wherein the skeleton axis length is the actual physical length of the continuous longest skeleton path of the object, and calculating the average width and the linear distance between two ends of the object based on the target area mask image.
  2. 2. The method of claim 1, wherein the step of verifying the validity of the profile comprises: And judging the contours of the object contour key points with the number larger than or equal to the preset number and the area of the contour surrounding area larger than or equal to the preset pixels as effective contours.
  3. 3. The method for automatically detecting morphological parameters of an irregular object according to claim 1, wherein the step of performing convolution operation on the skeleton image to detect skeleton end points specifically comprises: Constructing a3 multiplied by 3 custom convolution kernel, wherein the weight of the center position of the convolution kernel is set to n, n is an integer greater than 1, and the weights of the rest 8 neighborhood positions are set to 1; And carrying out convolution operation on the skeleton image through the 3X 3 custom convolution check, and screening pixel points with the convolution result of n+1 as skeleton endpoints.
  4. 4. The method for automatically detecting morphological parameters of irregular objects according to claim 1, wherein the skeleton geometric center point is obtained by extracting coordinates of all skeleton pixel points in a skeleton image, and respectively averaging the horizontal coordinates and the vertical coordinates of all the skeleton pixel points to obtain the coordinates of the skeleton geometric center point.
  5. 5. The method according to claim 1, wherein determining two farthest points of the skeleton and constructing a longest skeleton path between the two farthest points through breadth-first search includes determining a first farthest point from a starting point through a first breadth-first search, determining a second farthest point from the first farthest point through a second breadth-first search, tracing back to the first farthest point according to the second breadth-first search record from the second farthest point, and reconstructing a complete path between the first farthest point and the second farthest point as the longest skeleton path.
  6. 6. The method according to claim 1, wherein the step of calculating the skeleton axis length of the target object based on the continuous longest skeleton path in the original image coordinate system comprises: And calculating Euclidean distance between continuous adjacent skeleton points in a continuous longest skeleton path under an original image coordinate system, summing to obtain skeleton axis pixel length, and dividing the skeleton axis pixel length by pixel equivalent to obtain the skeleton axis length of the target object.
  7. 7. The method according to claim 1, wherein the step of calculating an average width of the object based on the target area mask image comprises: Partitioning the object in the mask image of the target area based on the circumscribed rectangle length of the object contour, the preset partition number and the minimum partition length, extracting the target area in each partition, calculating the linear distance from each pixel point in the target area to the pixel point at the edge of the nearest contour through L2 distance transformation, taking the maximum value of the linear distance as the maximum radius of the object in the partition, multiplying by 2 to obtain the partition width of the object, and taking the average value of the partition widths of all the objects as the average width of the object.
  8. 8. An automatic detection system for morphological parameters of an irregular object, comprising: the image preprocessing module is used for acquiring an original image of a target object and converting the original image into a binary image; the contour processing module is used for extracting a plurality of object contours from the binary image, compressing contour points, reserving key points of each object contour and verifying contour effectiveness; The framework processing module is used for generating a target area mask image for each effective contour, cutting out an interested area image only containing a target area from the target area mask image according to the circumscribed rectangle parameters of the effective contour, converting the interested area image into a binary image, performing skeletonization processing to obtain a framework image with single pixel width, and performing convolution operation on the framework image to detect a framework endpoint; the path extraction module is used for taking the framework end points as starting points or taking the framework geometric center points as starting points when no end points exist, determining two farthest framework points by breadth-first search and constructing a longest framework path between the two farthest framework points, initializing a new path list based on the longest framework paths, checking the Euclidean distance between the subsequent points and the end points of the new path point by point according to the path sequence, judging as break points when the distance is larger than a preset path interpolation maximum gap value, obtaining a continuous longest framework path by interpolation restoration, and mapping the continuous longest framework path to an original image coordinate system; the morphological parameter detection module is used for calculating the skeleton axis length of the target object based on the continuous longest skeleton path under the original image coordinate system, wherein the skeleton axis length is the actual physical length of the continuous longest skeleton path of the object, and calculating the average width and the straight line distance at two ends of the object based on the target area mask image.
  9. 9. The system for automatically detecting morphological parameters of an irregular object according to claim 8, further comprising a configuration management module, the configuration management module comprising: The parameter encapsulation layer is used for dividing callable parameters of the overall form parameter detection process into a preprocessing parameter layer, a measurement parameter layer and an output parameter layer, and encapsulating the parameters into a dictionary structure in a key value pair form for algorithm analysis and calling; The core algorithm layer comprises a configuration loading and analyzing algorithm, a recursion incomplete algorithm, a parameter accurate positioning algorithm and a parameter persistence algorithm, and is used for parameter configuration management; the interface adaptation layer comprises a parameter acquisition interface and a parameter updating interface and is used for realizing the adaptation and calling of the core algorithm layer and other modules.
  10. 10. An irregular object form parameter automatic detection system according to claim 8, further comprising: the log management module is used for recording the operation log, the error log and the warning log in a grading manner so as to conduct problem investigation; The acquisition module is used for acquiring a camera preview picture in real time, drawing an operation prompt and an acquisition frame, responding to a case instruction to complete the acquisition of the irregular small object, and transmitting an acquired original image to the image preprocessing module to start real-time detection; the anomaly processing module is used for verifying the validity of the image path and the validity of the outline, capturing and recording anomalies in the detection process through the decorator; And the batch detection module is used for acquiring original images of all the irregular small objects in the designated folder, sequentially transmitting the original images to the image preprocessing module to start batch detection, and summarizing and storing all the detection data.

Description

Automatic detection method and system for morphological parameters of irregular object Technical Field The invention relates to the technical field of image processing, in particular to an automatic detection method and system for morphological parameters of irregular objects. Background In the fields of industrial detection, biomedicine and the like, the precise detection of morphological parameters of irregular small objects is a key for guaranteeing product quality and researching sample characteristics, and the traditional detection relies on manual or contact equipment, so that the defects of low efficiency, high labor intensity, easiness in being influenced by human and the like exist, complex forms are difficult to adapt, and even precise or soft objects can be damaged. With the development of machine vision technology, a non-contact detection method based on image processing, in particular a technical path taking skeleton extraction as a core, has become an industrial research hot spot, and skeleton extraction aims to simplify the object form into a single-pixel center line and provides a basis for parameter detection such as length, orientation and the like. However, the prior art faces a series of serious challenges in engineering landing, and it is difficult to directly meet the strict requirements of industrial sites on instantaneity, accuracy and robustness, such as: The general skeleton algorithm mostly adopts a full-image processing mode, so that the waste of computing resources is serious, the real-time requirement of high-resolution images or batch detection is difficult to meet, the skeleton generated by the algorithm contains a large number of redundant branches, the extraction of the core skeleton of an object is seriously interfered, and the engineering practicability of parameter detection is reduced; Aiming at the problem of failure caused by the fact that an effective endpoint cannot be positioned in the traditional method, and aiming at the problem of breakage easily generated in the skeletonizing process, an effective repairing mechanism is lacking, so that measurement errors are increased. Therefore, an innovative detection solution capable of systematically solving the above problems of efficiency, precision, robustness and engineering practicality is needed in the industry. Disclosure of Invention In view of the defects or shortcomings in the prior art, the invention provides an automatic detection method and system for irregular object morphological parameters, which greatly improve detection efficiency through ROI local focusing skeletonization, adopt a self-defined convolution kernel accurate detection endpoint and combine a bidirectional BFS and breakpoint repairing mechanism to remarkably enhance the robustness and precision of longest path extraction, comprehensively characterize the object morphology through fusion of multi-parameter detection such as skeleton axis length, straight line distance at two ends and average width of dynamic subareas, and ensure the flexibility and maintainability of engineering application by a systematic configuration management framework. In one aspect, the present invention provides a method for automatically detecting morphological parameters of an irregular object, including: Acquiring an original image of a target object and converting the original image into a binary image; Extracting a plurality of object contours from the binary image, compressing contour points, reserving key points of each object contour, and verifying contour effectiveness; Generating a target area mask image for each effective contour, cutting out an interested area image only containing a target area from the target area mask image according to circumscribed rectangular parameters of the effective contour, converting the interested area image into a binary image, performing skeletonizing treatment to obtain a skeleton image with single pixel width, and performing convolution operation on the skeleton image to detect skeleton endpoints; Taking the end point of the skeleton as a starting point or taking the geometric center point of the skeleton as the starting point when the end point is not present, determining the two farthest points of the skeleton by breadth-first search and constructing a longest skeleton path between the two farthest points, initializing a new path list based on the longest skeleton path, checking the Euclidean distance between the subsequent points and the end point of the new path point by point according to the path sequence, judging as a breakpoint when the distance is larger than a preset path interpolation maximum gap value, obtaining a continuous longest skeleton path by interpolation restoration, and mapping the continuous longest skeleton path to an original image coordinate system; And calculating the skeleton axis length of the target object based on the continuous longest skeleton path in the original image coordinate system, whe