An ice bag size image recognition method, device and computer

By using the Canny edge operator and Hough transform to extract the scale tilt angle in ice pack size image recognition, correcting the pixel path, and performing symmetry analysis, the problem of insufficient accuracy and robustness in size recognition in existing technologies is solved, and high-precision ice pack size recognition is achieved.

CN120375341BActive Publication Date: 2025-10-21XIAOXIAN STEWED BAZHOU FOOD CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510620742.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-14
Publication Date
2025-10-21
Estimated Expiration
2045-05-14

AI Technical Summary

Technical Problem

Existing technologies struggle to dynamically adjust pixel orientation in image size recognition, leading to projection errors when tilt angles are large or edge line segment continuity is insufficient. Furthermore, they lack the ability to recognize slight structural distortions or irregular boundaries in images, affecting the accuracy and robustness of size conversion.

Method used

By acquiring the grayscale edge map of the scale region in the ice pack size image, the longest line segment is extracted using the Canny edge operator and Hough transform. The tilt angle of the scale is calculated, the tilt projection vector direction is established, the pixel path is corrected, and the blurred boundary region is identified by combining the scale region conversion ratio and symmetry analysis.

Benefits of technology

It achieves high-precision recognition of ice pack size, enhances adaptability and robustness to complex contour changes, and improves the accuracy and stability of image recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120375341B_ABST
    Figure CN120375341B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of image recognition, in particular to an ice bag size image recognition method, device and computer, comprising the following steps: scale positioning and correction are realized through Canny edge extraction, Hough transformation and angle correction, and conversion ratio is used to complete ice bag image symmetry analysis and fuzzy boundary recognition.In the present application, the spatial positioning of the longest line segment is realized by first extracting the image gray edge and combining the continuous linear features of the edge contour, ensuring the accuracy of angle measurement, and the rotation vector path of the tilt direction is established with the help of the angle information to complete the accurate adjustment of the pixel direction in the image coordinates.In this process, the vector mapping of the direction parameter makes the pixel path dynamically corrected according to the actual direction, effectively solving the scale error caused by the scale tilt in the image. The continuous extraction of the pixel spacing and the normalized calculation of the path density further promote the accurate mapping of the pixel path and the known scale, thereby realizing the unified standard of proportion conversion.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image recognition technology, and in particular to an ice bag size image recognition method, device and computer. Background Art

[0002] The field of image recognition technology encompasses methods that use computer vision and image processing to detect, analyze, and identify specific objects in images or videos. The core of this technology involves analyzing image data at the pixel level to extract target features and convert them into meaningful structured data. This process typically involves steps such as image acquisition, feature extraction, target classification, and output.

[0003] The ice pack size image recognition method uses image recognition technology to identify and quantify the size parameters of an ice pack's appearance image. High-resolution image acquisition equipment is used to capture the ice pack image, and edge detection methods are used to extract the target outline. This information is then converted from pixel data into actual physical dimensions using a reference object calibration mechanism, ultimately yielding the ice pack's size parameters.

[0004] The existing technology mainly relies on edge extraction and reference object calibration mechanisms to achieve length conversion during the image size recognition process. Although the boundary contour can be obtained, it is difficult to dynamically adjust the pixel direction when faced with the problem of tilted scale or unstable shooting angle in the image, resulting in projection errors when the tilt angle is large or the edge line segment continuity is insufficient, which in turn affects the accuracy of size conversion. In addition, the existing technology does not fully model the corner points, direction angles and symmetrical structures in the pixel path, and lacks the ability to recognize abnormal areas when there are slight structural distortions or irregular boundaries in the image. For example, in the blurred area formed by light and shadow changes or material folding at the edge of the ice bag, traditional methods are often unable to determine it as an abnormality, resulting in the risk of misjudgment of the boundary recognition results in the application. The lack of analysis of image directional information and vector path correction mechanism makes the existing technology significantly insufficient in the robustness of structure recognition and the stability of scale conversion. Summary of the Invention

[0005] The purpose of the present invention is to solve the shortcomings of the prior art and to propose an ice bag size image recognition method, device and computer.

[0006] In order to achieve the above object, the present invention adopts the following technical solution: a method for ice bag size image recognition, comprising the following steps:

[0007] S1: Obtain the grayscale edge map of the scale area in the ice pack size image, call the Canny edge operator to perform a preliminary outline of the image contour, use the Hough transform to extract the longest line segment in the continuous straight line area in the line segment, perform angle measurement on the horizontal axis of the image based on the endpoint coordinates, and generate the scale tilt direction angle;

[0008] S2: Locate the tilt position of the ruler line segment in the image according to the ruler tilt direction angle, establish the tilt projection vector direction, and map it to the image coordinate system to construct a pixel direction adjustment basis, and generate pixel direction rotation vector data;

[0009] S3: Correcting the pixel path in the ruler direction of the image based on the pixel direction rotation vector data, calling the known length scale information in the ruler image for ratio correspondence, and generating a ruler area conversion ratio;

[0010] S4: Calling the scale area conversion ratio to perform pixel length correction on the overall edge map of the image, screening out the area boundary pairs with positional misalignment, and generating the ice bag structure symmetry analysis result;

[0011] S5: Based on the symmetry analysis result of the ice bag structure, mark the current boundary segment as an abnormal area, perform aggregation operation on all marked areas in the image and cover them into the edge image area map to generate a fuzzy boundary area recognition image.

[0012] As a further solution of the present invention, the ruler tilt direction angle specifically includes the coordinates of the starting end of the line segment, the coordinates of the ending end of the line segment, and the direction angle value of the line segment; the pixel direction rotation vector data includes the rotation direction parameter, the direction mapping path, and the image coordinate system vector; the ruler area conversion ratio specifically refers to the pixel spacing distribution value, the scale conversion reference value, and the conversion ratio reference value; the ice bag structure symmetry analysis result includes the left and right edge structure difference, the corner point distribution symmetry offset value, and the edge length comparison factor; the fuzzy boundary area recognition image specifically includes the boundary dislocation annotation layer, the structural abnormality aggregation partition, and the edge image data after recognition.

[0013] As a further solution of the present invention, the step of obtaining the tilt direction angle of the ruler is specifically as follows:

[0014] S111: Obtain a grayscale edge map of the scale area in the ice bag size image, call the Canny edge operator to extract all edge segments in the image, screen the linear continuity features of the edge segments, perform a preliminary screening of the length trend based on the edge pixel connection sequence, determine whether it meets the linear direction consistency condition, and obtain the linear edge structure;

[0015] S112: Constructing a set of direction vectors of all line segments on the image plane based on the linear edge structure, calling Hough transform to perform polar coordinate accumulation transformation on pixel pairs in each line segment set, calculating the position with the maximum amplitude in the transformation space, extracting the corresponding image straight line expression item, locating the coordinates of the starting and ending points of the line segments, and obtaining the coordinate set of the longest line segment endpoints;

[0016] S113: Extracting the coordinate differences in the horizontal and vertical directions based on the longest line segment endpoint coordinate set, calculating the projection angle of the line segment in the horizontal axis direction of the image, and obtaining the scale tilt direction angle by constructing the angle ratio between the direction vector slope and the horizontal axis of the image coordinate.

[0017] As a further solution of the present invention, the step of obtaining the pixel direction rotation vector data is specifically as follows:

[0018] S211: Based on the scale tilt direction angle, collect reference direction angle parameters of the image boundary segment on the horizontal axis of the coordinate system and compare the direction angle difference change, select the valid deviation angle based on the consistency requirement between the angle difference change and the image reference direction, calculate the direction offset range of the angle difference value of the valid deviation angle within the pixel space range, and obtain the tilt direction angle offset;

[0019] S212: Constructing an initial projection vector in the rotation direction based on the tilt direction angle offset, setting the offset angle as a rotation reference factor in the two-dimensional image coordinate system, mapping the angle change between the specified length direction and the coordinate axis, adjusting the angle path relationship of each direction in the original pixel path according to the angle change, and generating pixel direction rotation vector data for the scale direction in the current image.

[0020] As a further solution of the present invention, the step of obtaining the scale area conversion ratio is specifically as follows:

[0021] S311: Correcting the pixel path direction of the ruler line segment in the image based on the pixel direction rotation vector data, mapping the pixels arranged in the original direction to the rotated vector path, sequentially extracting the spatial coordinate difference between each pixel point on the vector path, and combining and measuring the lengths between consecutive pixel points to obtain a ruler path pixel spacing set;

[0022] S312: Call the ruler path pixel spacing set to obtain the specified length distribution of the pixel path, extract the change trend of all pixel densities on the path, perform mean normalization processing according to the change amplitude of the density distribution, establish a proportional mapping relationship with the length represented by the known ruler scale in the image, perform a conversion operation based on the overall path length, and obtain the ruler area conversion ratio.

[0023] As a further solution of the present invention, the steps for obtaining the symmetry analysis results of the ice bag structure are specifically as follows:

[0024] S411: Calling the scale area conversion ratio to proportionally adjust the length of pixel segments in the overall edge map of the image to obtain a corrected edge contour image, locating the left and right boundary paths of the ice pack area in the image, extracting the start and end coordinates and direction information of all continuous line segments on the boundary paths, establishing a set of line segments on the left and right boundaries, and obtaining the ice pack boundary structure line segments;

[0025] S412: Extract the corresponding line segments in the left and right boundary sets from the ice bag boundary structure line segments, obtain the line segment length distribution, contour direction angle distribution and corner point aggregation trend respectively, align the matching positions according to the vertical axis of the image, construct a line segment pair structure set, compare the parameter values ​​in the structure set and set the offset threshold range, filter the line segment combinations that exceed the offset threshold, count the distribution of the line segment combinations, and generate the ice bag structure symmetry analysis results.

[0026] As a further solution of the present invention, the step of acquiring the fuzzy boundary area recognition image is specifically as follows:

[0027] S511: Locate the dislocated boundary segment based on the symmetry analysis results of the ice bag structure, extract the corner point distribution of the dislocated boundary segment area, determine the continuous interruption position of the corner point, count the number of corresponding gradient direction changes, and determine whether it exceeds a set threshold based on the degree of inconsistency. Mark it as an anomaly and obtain a boundary segment anomaly identification index;

[0028] S512: extracting all abnormal regions according to the boundary segment abnormality identification index, performing a coordinate aggregation operation, uniformly mapping them into the image edge map, and generating a fuzzy boundary region identification image.

[0029] An ice bag size image recognition device, the ice bag size image recognition device is used to perform the above-mentioned ice bag size image recognition method, the device comprising:

[0030] The tilt angle extraction module obtains the grayscale edge map of the scale area in the ice pack size image, uses the Canny edge operator to perform a preliminary outline of the image contour, uses the Hough transform to extract the longest line segment in the continuous straight line area in the line segment, and performs angle measurement on the horizontal axis of the image based on the endpoint coordinates to generate the scale tilt direction angle;

[0031] The rotation vector analysis module locates the tilt position of the ruler line segment in the image according to the ruler tilt direction angle, establishes the tilt projection vector direction, and maps it to the image coordinate system to construct a pixel direction adjustment basis, thereby generating pixel direction rotation vector data;

[0032] The scale conversion module corrects the pixel path in the ruler direction of the image based on the pixel direction rotation vector data, calls the known length scale information in the ruler image for ratio correspondence, and generates a ruler area conversion ratio;

[0033] The correction analysis module uses the scale area conversion ratio to perform pixel length correction on the overall edge map of the image, screens out regional boundary pairs with positional misalignment, and generates a symmetry analysis result of the ice bag structure;

[0034] The abnormality marking module marks the current boundary segment as an abnormal area based on the symmetry analysis result of the ice bag structure, performs an aggregation operation on all marked areas in the image and covers them into the edge image area map to generate a fuzzy boundary area recognition image.

[0035] A computer device includes a memory and a processor. The memory stores a computer program. When the processor executes the computer program, an ice pack size image recognition device is implemented.

[0036] Compared with the prior art, the advantages and positive effects of the present invention are:

[0037] In the present invention, by first extracting the grayscale edge of the image and combining it with the continuous linear features of the edge contour, the spatial positioning of the longest line segment is achieved, the accuracy of the angle measurement is ensured, and the rotation vector path of the tilt direction is established with the help of the angle information to complete the precise adjustment of the pixel direction in the image coordinates. In this process, the vector mapping of the direction parameter allows the pixel path to be dynamically corrected according to the actual direction, effectively solving the scale error caused by the tilt of the ruler in the image. By using the continuous extraction of pixel spacing and the normalized calculation of path density, the accurate mapping of the pixel path and the known ruler scale is further promoted, thereby achieving a unified standard for proportional conversion. After correcting the edge path based on the conversion result within the global scope of the image, the symmetry analysis of the boundary direction, length and corner point structure is performed to construct a data set of structural differences on both sides, thereby enhancing the morphological recognition ability of the ice bag boundary. When phenomena such as abnormal boundary direction and discontinuous corner points are identified, an abnormal layer is generated by coordinate aggregation to achieve effective labeling of the fuzzy boundary area. This method promotes the high-precision dimension calibration and systematization of symmetry analysis in images through the combined operations of multi-dimensional directional angle correction, vector mapping path construction, and density ratio conversion, enhances the ability to accurately identify structural anomalies, and improves the adaptability and robustness of the recognized image to complex contour changes. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 It is a schematic diagram of the workflow of the present invention;

[0039] Figure 2 This is a flow chart of step S1 of the present invention;

[0040] Figure 3 This is a flow chart of step S2 of the present invention;

[0041] Figure 4 This is a flow chart of step S3 of the present invention;

[0042] Figure 5 This is a flow chart of step S4 of the present invention;

[0043] Figure 6 This is a flow chart of step S5 of the present invention. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0045] In the description of the present invention, it should be understood that the terms "length," "width," "up," "down," "front," "back," "left," "right," "vertical," "horizontal," "top," "bottom," "inside," "outside," and the like, indicating positions or relationships, are based on the positions or relationships shown in the accompanying drawings and are intended only to facilitate the description of the present invention and simplify the description. They do not indicate or imply that the devices or elements referred to must have a specific orientation, be constructed, or operate in a specific orientation. Therefore, they should not be construed as limiting the present invention. Furthermore, in the description of the present invention, "plurality" means two or more, unless otherwise expressly and specifically defined.

[0046] See also Figure 1 The present invention provides a technical solution: a method for identifying ice bag size images, comprising the following steps:

[0047] S1: Obtain the grayscale edge map of the scale area in the ice pack size image, use the Canny edge operator to preliminarily outline the image contour, select edge segments with linear structures, use the Hough transform to extract the longest segment in the continuous straight line area of ​​the segment, obtain the coordinates of the two endpoints of the longest segment, and perform angle measurement on the horizontal axis of the image based on the endpoint coordinates to generate the scale tilt direction angle;

[0048] S2: Locate the tilt direction of the ruler line segment in the image according to the ruler tilt angle, calculate the angle offset by calling the horizontal reference direction angle of the image boundary, extract the offset angle as the rotation reference of the ruler direction, establish the tilt projection vector direction, and map it to the image coordinate system to construct the pixel direction adjustment basis, generating pixel direction rotation vector data;

[0049] S3: Correct the pixel path in the ruler direction of the image based on the pixel direction rotation vector data, remap the pixels in the original straight line direction to the rotation vector direction, measure the spacing combination between consecutive pixels, extract the pixel density distribution on the path, call the known length scale information in the ruler image for ratio correspondence, and generate the ruler area conversion ratio;

[0050] S4: Calling the scale area conversion ratio to perform pixel length correction on the overall edge map of the image, obtaining the left and right boundary line segment data of the ice bag image under the corrected scale, extracting the length characteristics, contour direction and corner point distribution trend of the edges on both sides, performing corresponding structure ratio judgment according to the vertical axis of the image, screening the regional boundary pairs with positional misalignment, and generating the ice bag structure symmetry analysis results;

[0051] S5: Based on the symmetry analysis results of the ice pack structure, the corresponding dislocated boundary segments in the image are tracked, the continuity interruption locations of the corner points in the region and the frequency of gradient direction changes are extracted, and the current boundary segment is marked as an abnormal region based on the degree of boundary inconsistency. All marked regions in the image are aggregated and overlaid into the edge image region map to generate a fuzzy boundary region recognition image;

[0052] The ruler tilt direction angle specifically includes the coordinates of the starting end of the line segment, the coordinates of the ending end of the line segment, and the direction angle value of the line segment. The pixel direction rotation vector data includes the rotation direction parameter, the direction mapping path, and the image coordinate system vector. The ruler area conversion ratio specifically refers to the pixel spacing distribution value, the scale conversion reference value, and the conversion ratio benchmark value. The ice bag structure symmetry analysis results include the left and right edge structure difference, the corner point distribution symmetry offset value, and the edge length comparison factor. The fuzzy boundary area recognition image specifically includes the boundary dislocation annotation layer, the structural abnormality aggregation partition, and the edge image data after recognition.

[0053] See also Figure 2 , the steps for obtaining the tilt direction angle of the ruler are as follows:

[0054] S111: Obtain a grayscale edge map of the scale area in the ice bag size image, call the Canny edge operator to extract all edge segments in the image, screen the linear continuity features of the edge segments, perform a preliminary screening of their length trends based on the edge pixel connection sequence, determine whether they meet the linear direction consistency condition, and obtain the linear edge structure;

[0055] When obtaining the grayscale edge map of the scale area in the ice bag size image, you need to first collect an ice bag image containing the scale from the actual scene. The original image is usually a color image. It can be converted into a grayscale image by calculating the brightness value of each pixel. This operation uses channel brightness conversion, where the grayscale value of each pixel is set to the average of the weighted sum of the red, green, and blue channels to obtain a single-channel grayscale image as the edge detection input image. When the Canny edge operator detects edges, two gradient thresholds must be set: a low threshold and a high threshold. The setting method is to count the grayscale values ​​of the pixels in the image, construct a grayscale histogram, calculate the distribution range of the gradient amplitude of all pixels, and set the low threshold to the average of the first 10% of the most frequently occurring grayscale gradient segments, and the high threshold to the average of the last 10%. For example, if the most frequent interval in the grayscale gradient statistical distribution of an image is concentrated between 40 and 180, the low threshold can be set to 40 and the high threshold to 180. The threshold settings are as follows:

[0056] ,in, is the low threshold, is the high threshold, and The gradient sets of the first 10% and the last 10% of the gradient distribution are generated respectively. A binary edge map is generated through non-maximum suppression and double threshold connection. The edge pixel value in the output edge map is 255, and the rest of the area is 0. Then linear structure screening is performed, and all edge connected areas are traversed. For each edge segment, its head and tail coordinates are extracted, and its direction vector is calculated. If the angle change of all continuous edge vectors does not exceed the set angle threshold, it is considered that their directions are consistent. The angle threshold can be set to half of the standard deviation of the overall edge direction change of the image. If the standard deviation is 24 degrees, the threshold is 12 degrees. The expression is as follows:

[0057] ,in, is the direction consistency judgment threshold, is the standard deviation of the image edge direction distribution. Assume that 5 line segments are extracted, and their direction differences are 5 degrees, 8 degrees, 30 degrees, 3 degrees, and 10 degrees, and their lengths are 40, 60, 22, 35, and 55 pixels, respectively. The line segments with a direction difference greater than the threshold of 12 degrees are eliminated, that is, the line segments corresponding to 30 degrees are removed, and the line segments with a length greater than the set minimum length threshold of 30 pixels are retained in the remaining line segments, resulting in two line segments with lengths of 60 and 55, which constitute the linear edge structure set.

[0058] S112: Construct a set of direction vectors for all line segments on the image plane based on the linear edge structure, call the Hough transform to perform polar coordinate accumulation transformation on the pixel pairs in each line segment set, calculate the position with the maximum amplitude in the transformation space, extract the corresponding image straight line expression item, locate the coordinates of the starting and ending points of the line segments from it, and obtain the coordinate set of the endpoints of the longest line segment;

[0059] For a linear edge structure set, we perform the longest line segment extraction operation, record the starting and ending coordinates of each line segment, and use the Euclidean distance to calculate the line segment length. The calculation formula is as follows: ,in, For the The length of the line segment, is the starting point coordinate, is the end point coordinate; taking the two extracted line segments as an example, let the first line segment endpoint coordinates be (100, 120) and (400, 150), and the second line segment endpoint coordinates be (50, 60) and (350, 100), and substitute them into the calculation: , , compare the lengths of the two line segments, the second one is longer, select it as the longest structural line segment, obtain its endpoint coordinates as the longest line segment endpoint coordinate set. In order to confirm its linearity, all point pairs are processed by Hough transform, and the parameter pairs of each point pair in polar coordinate space are constructed. , the parameter pairs with the most votes are counted and compared with the actual segment direction. If the direction difference is less than the set direction tolerance threshold, such as 5 degrees, the segment structure is considered to meet the consistency and the segment can be retained.

[0060] S113: Extracting the coordinate differences in the horizontal and vertical directions based on the coordinate set of the longest line segment endpoints, calculating the projection angle of the line segment in the horizontal axis direction of the image, and obtaining the scale tilt direction angle by constructing the angle ratio between the direction vector slope and the horizontal axis of the image coordinates;

[0061] According to the coordinates of the longest line segment endpoint, set the starting point to , the end point is , calculate the horizontal and vertical differences respectively: , calculate the direction angle value of the line segment in the image coordinate system, the formula is: , the angle value represents the inclination angle between the line segment and the horizontal axis of the image, and the unit is degree system. The inverse tangent function is used in its calculation, and the direction change is reflected by the increment of the horizontal and vertical coordinates; is the angle value of the ruler line segment direction, are the differences between the horizontal and vertical axes of the line segment in the image coordinate system, which are used to construct the direction vector; the final output angle value is approximately 7.59 degrees, generating the angle value of the ruler tilt direction. The benefit of the above direction angle calculation formula is that the angle value is directly calculated using the coordinates of two points, avoiding complex fitting or contour fitting processes, and the angle value is used as the basic parameter for the ruler area projection correction, which can be continuously passed to the subsequent pixel rotation correction step to form a unified direction input interface. The angle value calculated in this step is approximately 7.59 degrees, indicating that there is a slight tilt in the direction of the ruler in the image. This result will be used as the angle input for the generation of the rotation vector in the subsequent steps, which directly affects the pixel projection direction. Therefore, the accuracy of the angle calculation directly determines the quality of the basic offset parameters for image direction correction.

[0062] See also Figure 3 , the specific steps for obtaining pixel direction rotation vector data are:

[0063] S211: Based on the scale tilt direction angle, collect reference direction angle parameters of the image boundary segment on the horizontal axis of the coordinate system and compare the direction angle difference change. Filter the valid deviation angle based on the consistency requirement between the angle difference change and the image reference direction. Count the direction offset range of the angle difference value of the valid deviation angle within the pixel space range to obtain the tilt direction angle offset.

[0064] To collect the direction parameters of the image boundary segments, it is necessary to first extract the boundary segments corresponding to the horizontal direction in the overall image bounding box in the image coordinate system. The image bounding box can be realized by obtaining the upper, lower, left, and right boundary coordinates of the image pixel matrix, and then define its direction angle as the base reference angle, which is generally set to 0 degrees or 90 degrees. If the current image is acquired using standard foresight, the default base angle is 0 degrees. After obtaining the base direction, the corresponding ruler tilt direction angle value obtained in the previous stage is called. For example, the angle obtained by extracting the boundary segment coordinates in the image is 12.3 degrees. The calculation of the direction offset is the difference between the two, that is, 12.3 degrees − 0 degrees = 12.3 degrees. This angle is the ruler segment relative to the image reference edge. The angular offset value of the boundary is obtained, and then the offset angle is judged. If the offset angle is within the specified tolerance range, the rotation can be ignored. If the offset angle exceeds the tolerance range, it is necessary to further establish a direction offset set, and perform angle comparison operations on local scale segments in multiple sampling areas to form a statistical data set of angle offsets. The mean and variance in the data set are calculated. For example, if the angles of the five sample segments are 11.9, 12.1, 12.5, 12.0, and 11.8 degrees, respectively, the average is 12.06 degrees and the variance is 0.07. If the offset mean exceeds the system-set offset threshold range, such as 5 degrees, rotation correction needs to be started, and the offset mean is set as the rotation reference angle to input the next stage processing flow to obtain the tilt direction angle offset.

[0065] S212: constructing an initial projection vector in the rotation direction based on the tilt direction angle offset, setting the offset angle as a rotation reference factor in the two-dimensional image coordinate system, mapping the angle change between the specified length direction and the coordinate axis, adjusting the angle path relationship of each direction in the original pixel path according to the angle change, and generating pixel direction rotation vector data for the scale direction in the current image;

[0066] First, a projection vector reference structure before rotation is established in the image's two-dimensional coordinate space based on a 1-pixel length direction vector. The reference direction is set as the horizontal pixel vector (1px, 0px), and the offset angle is used as the rotation reference factor. The rotation transformation is performed using the direction mapping rule in the image's two-dimensional space. The reference vector obtained in the image and the offset angle are used to calculate the new direction vector after rotation, and a set of rotated projection directions is constructed. Assuming the offset angle is 12.06 degrees, the direction of the vector obtained by performing the direction rotation transformation in the coordinate plane is (0.978px, 0.209px). Next, this rotated direction vector is superimposed on the direction structure of each scale pixel in the image. The original pixel path direction is replaced by the current direction-mapped structure through vector mapping. A new mapping relationship between the overall pixel direction and the image coordinate system is then constructed. Based on the direction-corrected pixel arrangement path, the mapping distance difference of the direction vector at each pixel position is extracted to form a rotation vector field, where each vector unit contains starting point, direction, and length information. Finally, the complete direction calibration dataset, i.e., pixel direction rotation vector data, is generated by combining the two vector units.

[0067] See also Figure 4 , the steps for obtaining the scale area conversion ratio are as follows:

[0068] S311: Correcting the pixel path direction of the ruler line segment in the image based on the pixel direction rotation vector data, mapping the pixels arranged in the original direction to the rotated vector path, sequentially extracting the spatial coordinate difference between each pixel point on the vector path, and combining and measuring the lengths between consecutive pixel points to obtain a set of ruler path pixel spacings;

[0069] First, the direction vector of the ruler area in the original image is called, and all pixel paths are remapped according to the rotation angle offset value. Specifically, the pixels originally arranged along the horizontal axis of the image are repositioned to the new direction path established based on the rotation vector. For example, if the starting and ending pixels of the ruler segment in the original image are points with dot After the rotation angle is offset to 15°, the two points can be transformed into 、 , the rotated path is obtained again. The spacing between consecutive pixels on the path needs to be analyzed in combination with the pixel coordinate difference, and then the Euclidean distance combination between consecutive pixels is established. Take 5 consecutive pixel pairs such as: 、 ...measure the distance and get the pixel distance array ,, the unit is uniformly pixel, and the data is the set of pixel spacing of the ruler path.

[0070] S312: Calling the ruler path pixel spacing set to obtain the specified length distribution of the pixel path, extracting the change trend of all pixel densities on the path, performing mean normalization processing based on the change amplitude of the density distribution, establishing a proportional mapping relationship with the length represented by the known ruler scale in the image, performing a conversion operation based on the overall path length, and obtaining the ruler area conversion ratio;

[0071] Call the ruler path pixel spacing set, calculate the unit length density corresponding to all spacing values, and express it as unit length density ratio ,in is the total number of path pixels, is the total pixel spacing of the path (unit is pixel). For example, if the total number of pixels in the path is 100 and the total distance of the path is 550 pixels, then the current pixel density is , and then compare it with the known ruler scale information in the image. If the actual ruler segment length in the image is 10 cm, which corresponds to 450 pixels in the image, then the unit conversion ratio is ,in, : No. Segment pixel spacing, in pixels (px), : No. Segment pixel density in , obtained by combining the length occupied by a unit pixel (in pixels) with the equivalent physical length (in centimeters), : The total length of the ruler, in centimeters (cm), : The average value of the pixel segment distance, the unit is pixel (px), : The number of participating segments, an integer, : The calculated conversion ratio in units of .

[0072] Set the pixel segment spacing set to: , the pixel density set is: , actual length of the ruler , number of segments .

[0073] The formula calculation process is as follows:

[0074] The first part is: ;

[0075] ;

[0076] The second part is: ;

[0077] ,

[0078] ;

[0079] Merge to: .

[0080] Result description: The result shows that the equivalent physical length corresponding to the unit pixel conversion in the current ruler image path is , which can be used for length restoration or size measurement in subsequent image recognition processes, directly linking to the scale area conversion ratio. The formula's beneficial effect lies in its inclusion of density-weighted pixel segment spacing and relative difference terms, effectively accounting for uneven pixel distribution and edge fluctuations. This makes the conversion value more robust and locally stable to changes in the ice pack image's structural boundaries.

[0081] See also Figure 5 , the specific steps for obtaining the symmetry analysis results of the ice bag structure are:

[0082] S411: Using the scale area conversion ratio to proportionally adjust the pixel segment lengths in the overall edge map of the image, obtaining a corrected edge contour image, locating the left and right boundary paths of the ice pack area in the image, extracting the start and end coordinates and direction information of all continuous line segments on the boundary paths, establishing a set of line segments on the left and right boundaries, and obtaining the ice pack boundary structure line segments;

[0083] The ruler area conversion ratio is called to proportionally adjust the length of the pixel segments in the overall edge map of the image. First, the pixel path coordinate extraction and region segmentation of the entire image must be completed. The vertical center axis of the image is used as the dividing line to determine the boundary path of the ice bag area in the area to the left and right of the central structure. The edge path is extracted using the Canny operator and the contour closure strategy, and the distance of all pixel segments is calculated in the order of the path. , and then use the conversion ratio obtained uniformly Perform an equivalent length adjustment using the path length correction formula: ,in: : No. The corrected physical length of the boundary pixel path, in centimeters (cm); : No. The original pixel length of the pixel path, in pixels (px); : Unit conversion ratio, in centimeters per pixel (cm / px). For example, the original pixel spacing of a boundary path segment , then its corrected equivalent length is After the correction is completed, mark the path segment and record its starting point and end point pixel coordinates, such as the starting point ,end , and further calculate its direction vector as , direction angle Use the following formula to calculate:

[0084] ,in: ': The angle between the pixel path direction and the horizontal axis of the image, in degrees; : The difference between the horizontal coordinates of the end point and the starting point of the pixel path, in pixels (px); : The difference between the vertical coordinates of the end point and the starting point of the pixel path, in pixels (px).

[0085] In the above example, , , then the direction angle is , indicating that the path is vertical. All boundary line segment information is stored in the line segment structure data table. The line segment set for the left boundary is uniformly named "Left Boundary Line Segment Set" and the line segment set for the right boundary is named "Right Boundary Line Segment Set". Each structure entry contains the following fields: equivalent length, direction angle, start and end pixel coordinates, line segment number, and boundary type. Finally, the ice bag boundary structure segments are generated.

[0086] S412: extracting corresponding line segments in the left and right boundary sets from the ice bag boundary structure line segments, obtaining the line segment length distribution, contour direction angle distribution, and corner point aggregation trend, aligning the matching positions according to the vertical axis of the image, constructing a line segment pair structure set, performing ratio comparison on the parameter values ​​in the structure set and setting an offset threshold range, filtering out line segment combinations that exceed the offset threshold, and statistically analyzing the distribution of the line segment combinations to generate the ice bag structure symmetry analysis results;

[0087] Extract all line segments in the "left boundary line segment set" and "right boundary line segment set" from the ice bag boundary structure segments. Take the image center axis as the symmetry reference line and construct the line segment structure pairs with corresponding heights through the projection matching rule of the longitudinal coordinate area. Name it the "left and right boundary line segment structure pair list". Extract three features from each structure pair: equivalent length, contour direction angle and corner point distribution density, and construct the length pair. , direction angle , Corner density , perform symmetric offset ratio calculation on the equivalent length value, using the original structure offset ratio formula defined in the following image: ,in: : No. The symmetrical offset ratio of the structural line segments (dimensionless), which represents the ratio of the length difference to the total length; : No. The equivalent physical length of the left line segment in the structure, in centimeters (cm); : No. The equivalent physical length of the right line segment in the structure, in centimeters (cm). For example, if the equivalent length of the left segment is , on the right , substitute into the calculation: , if the structural symmetry offset threshold is set , then because , the structure pair is judged to have length offset and its number is recorded. Continue to extract its direction angle. If the left direction angle , right direction angle , then the direction shifts , the offset condition is satisfied again; if the corner point distribution density is 、 , the density difference is , also meeting the corner offset conditions. Ultimately, this structure pair met the criteria for length, orientation, and density and was included in the offset set, the "Symmetrical Offset Structure Set." After traversing all structure pairs, the offset ratios were calculated and the symmetry analysis results for the ice pack structure were generated.

[0088] See also Figure 6 ,The specific steps for obtaining the fuzzy boundary area recognition image are:

[0089] S511: Locate the dislocated boundary segment based on the symmetry analysis results of the ice pack structure, extract the corner point distribution in the dislocated boundary segment area, determine the continuous interruption position of the corner point, count the number of corresponding gradient direction changes, and determine whether it exceeds the set threshold based on the degree of inconsistency. Mark it as an anomaly and obtain the boundary segment anomaly identification index;

[0090] First, the image pixel sequence corresponding to each boundary segment is extracted, and the distribution area of ​​continuous corner points is identified in the sequence. The index change is used to determine whether there is a break in the corner point numbering. If there is a discontinuous numbered segment, it can be regarded as the location of the corner point continuity interruption. The number and spacing of each interruption are counted as the interruption index. At the same time, the pixel grayscale gradient direction in these areas is extracted to construct a direction sequence. The number of sudden changes in the direction angle in the sequence is determined and the change frequency is used to represent the local boundary direction instability. Combined with the length offset ratio, direction angle difference and corner point density distribution difference of the boundary segment in the previous stage, these parameters are aggregated and judged. When all three eigenvalues ​​exceed the set threshold benchmark, the boundary segment is judged as an area with high inconsistency and marked as an abnormal boundary segment. Finally, the marking is summarized in the image to obtain the boundary segment abnormality recognition index.

[0091] S512: extract all abnormal areas according to the boundary segment abnormality identification index, perform coordinate aggregation operation, and uniformly map them into the image edge map to generate a fuzzy boundary area identification image;

[0092] According to the abnormal boundary segment index indicated in the boundary segment abnormality recognition index, the pixel coordinate sets of all corresponding areas are extracted, and the minimum closed boundary structure of each area is constructed in the image space. The spatial proximity relationship between these boundaries is further judged. If the boundaries of adjacent areas have a continuous or overlapping trend, they are merged into the same abnormal block. Several aggregated area blocks are formed through the merging operation and uniformly converted into a standard image mask format. The mask area is projected and mapped to the corresponding position in the original edge map. A new boundary image result is generated through pixel-level coverage operation. The image retains the original edge contour information while marking all identified abnormal boundary blocks, and the output is a fuzzy boundary area recognition image.

[0093] An ice bag size image recognition device, which is used to perform the above-mentioned ice bag size image recognition method, includes:

[0094] The tilt angle extraction module obtains the grayscale edge map of the scale area in the ice pack size image, uses the Canny edge operator to perform a preliminary outline of the image contour, uses the Hough transform to extract the longest line segment in the continuous straight line area in the line segment, and performs angle measurement on the horizontal axis of the image based on the endpoint coordinates to generate the scale tilt direction angle;

[0095] The rotation vector analysis module locates the tilt position of the ruler line segment in the image according to the ruler tilt direction angle, establishes the tilt projection vector direction, and maps it to the image coordinate system to construct the pixel direction adjustment basis, generating pixel direction rotation vector data;

[0096] The scale conversion module corrects the pixel path in the ruler direction of the image based on the pixel direction rotation vector data, calls the known length scale information in the ruler image for ratio correspondence, and generates the ruler area conversion ratio;

[0097] The correction analysis module uses the scale area conversion ratio to perform pixel length correction on the overall edge map of the image, screens out the regional boundary pairs with positional misalignment, and generates the symmetry analysis results of the ice bag structure;

[0098] The anomaly labeling module marks the current boundary segment as an abnormal area based on the symmetry analysis results of the ice bag structure, performs an aggregation operation on all the marked areas in the image and covers them into the edge image area map to generate a fuzzy boundary area recognition image.

[0099] A computer device includes a memory and a processor, wherein a computer program is stored in the memory and an ice pack size image recognition device is implemented when the processor executes the computer program.

[0100] The above are merely preferred embodiments of the present invention and do not limit the present invention in any other form. Any technician familiar with the profession may use the technical content disclosed above to change or modify it into an equivalent embodiment with equivalent changes and apply it to other fields. However, any simple modification, equivalent change and modification made to the above embodiment based on the technical essence of the present invention without departing from the content of the technical solution of the present invention shall still fall within the scope of protection of the technical solution of the present invention.

Claims

1. A method for identifying ice bag size images, characterized in that: The following steps are involved: S1: Obtain the grayscale edge map of the scale area in the ice pack size image, call the Canny edge operator to perform a preliminary outline of the image contour, use the Hough transform to extract the longest line segment in the continuous straight line area in the line segment, perform angle measurement on the horizontal axis of the image based on the endpoint coordinates, and generate the scale tilt direction angle; S2: Locate the tilt position of the ruler line segment in the image according to the ruler tilt direction angle, establish the tilt projection vector direction, and map it to the image coordinate system to construct a pixel direction adjustment basis, and generate pixel direction rotation vector data; S3: Correcting the pixel path in the ruler direction of the image based on the pixel direction rotation vector data, calling the known length scale information in the ruler image for ratio correspondence, and generating a ruler area conversion ratio; S4: Calling the scale area conversion ratio to perform pixel length correction on the overall edge map of the image, screening out the area boundary pairs with positional misalignment, and generating the ice bag structure symmetry analysis result; S5: Based on the symmetry analysis result of the ice bag structure, mark the current boundary segment as an abnormal area, perform an aggregation operation on all marked areas in the image and overlay them into the edge image area map to generate a fuzzy boundary area recognition image; The ruler tilt direction angle specifically includes the coordinates of the starting end of the line segment, the coordinates of the ending end of the line segment, and the direction angle value of the line segment. The pixel direction rotation vector data includes the rotation direction parameter, the direction mapping path, and the image coordinate system vector. The ruler area conversion ratio specifically refers to the pixel spacing distribution value, the scale conversion reference value, and the conversion ratio benchmark value. The ice bag structure symmetry analysis result includes the left and right edge structure difference, the corner point distribution symmetry offset value, and the edge length comparison factor. The fuzzy boundary area recognition image specifically includes the boundary dislocation annotation layer, the structural abnormality aggregation partition, and the edge image data after recognition.

2. The ice pack size image recognition method according to claim 1, characterized in that: The steps for obtaining the tilt direction angle of the ruler are specifically as follows: S111: Obtain a grayscale edge map of the scale area in the ice bag size image, call the Canny edge operator to extract all edge segments in the image, screen the linear continuity features of the edge segments, perform a preliminary screening of the length trend based on the edge pixel connection sequence, determine whether it meets the linear direction consistency condition, and obtain the linear edge structure; S112: Constructing a set of direction vectors of all line segments on the image plane based on the linear edge structure, calling Hough transform to perform polar coordinate accumulation transformation on pixel pairs in each line segment set, calculating the position with the maximum amplitude in the transformation space, extracting the corresponding image straight line expression item, locating the coordinates of the starting and ending points of the line segments, and obtaining the coordinate set of the longest line segment endpoints; S113: Extracting the coordinate differences in the horizontal and vertical directions based on the longest line segment endpoint coordinate set, calculating the projection angle of the line segment in the horizontal axis direction of the image, and obtaining the scale tilt direction angle by constructing the angle ratio between the direction vector slope and the horizontal axis of the image coordinate.

3. The ice pack size image recognition method according to claim 2, characterized in that: The steps for obtaining the pixel direction rotation vector data are specifically as follows: S211: Based on the scale tilt direction angle, collect reference direction angle parameters of the image boundary segment on the horizontal axis of the coordinate system and compare the direction angle difference change, select the valid deviation angle based on the consistency requirement between the angle difference change and the image reference direction, calculate the direction offset range of the angle difference value of the valid deviation angle within the pixel space range, and obtain the tilt direction angle offset; S212: Constructing an initial projection vector in the rotation direction based on the tilt direction angle offset, setting the offset angle as a rotation reference factor in the two-dimensional image coordinate system, mapping the angle change between the specified length direction and the coordinate axis, adjusting the angle path relationship of each direction in the original pixel path according to the angle change, and generating pixel direction rotation vector data for the scale direction in the current image.

4. The ice pack size image recognition method according to claim 3, characterized in that: The steps for obtaining the scale area conversion ratio are specifically as follows: S311: Correcting the pixel path direction of the ruler line segment in the image based on the pixel direction rotation vector data, mapping the pixels arranged in the original direction to the rotated vector path, sequentially extracting the spatial coordinate difference between each pixel point on the vector path, and combining and measuring the lengths between consecutive pixel points to obtain a ruler path pixel spacing set; S312: Call the ruler path pixel spacing set to obtain the specified length distribution of the pixel path, extract the change trend of all pixel densities on the path, perform mean normalization processing according to the change amplitude of the density distribution, establish a proportional mapping relationship with the length represented by the known ruler scale in the image, perform a conversion operation based on the overall path length, and obtain the ruler area conversion ratio.

5. The ice pack size image recognition method according to claim 4, characterized in that: The steps for obtaining the symmetry analysis results of the ice bag structure are specifically as follows: S411: Calling the scale area conversion ratio to proportionally adjust the length of pixel segments in the overall edge map of the image to obtain a corrected edge contour image, locating the left and right boundary paths of the ice pack area in the image, extracting the start and end coordinates and direction information of all continuous line segments on the boundary paths, establishing a set of line segments on the left and right boundaries, and obtaining the ice pack boundary structure line segments; S412: Extract the corresponding line segments in the left and right boundary sets from the ice bag boundary structure line segments, obtain the line segment length distribution, contour direction angle distribution and corner point aggregation trend respectively, align the matching positions according to the vertical axis of the image, construct a line segment pair structure set, compare the parameter values ​​in the structure set and set the offset threshold range, filter the line segment combinations that exceed the offset threshold, count the distribution of the line segment combinations, and generate the ice bag structure symmetry analysis results.

6. The ice pack size image recognition method according to claim 5, characterized in that: The steps for obtaining the fuzzy boundary area recognition image are specifically as follows: S511: Locate the dislocated boundary segment based on the symmetry analysis results of the ice bag structure, extract the corner point distribution of the dislocated boundary segment area, determine the continuous interruption position of the corner point, count the number of corresponding gradient direction changes, and determine whether it exceeds a set threshold based on the degree of inconsistency. Mark it as an anomaly and obtain a boundary segment anomaly identification index; S512: extracting all abnormal regions according to the boundary segment abnormality identification index, performing a coordinate aggregation operation, uniformly mapping them into the image edge map, and generating a fuzzy boundary region identification image.

7. An ice pack size image recognition device, characterized in that: The ice bag size image recognition method according to any one of claims 1 to 6, wherein the device comprises: The tilt angle extraction module obtains the grayscale edge map of the scale area in the ice pack size image, uses the Canny edge operator to perform a preliminary outline of the image contour, uses the Hough transform to extract the longest line segment in the continuous straight line area in the line segment, and performs angle measurement on the horizontal axis of the image based on the endpoint coordinates to generate the scale tilt direction angle; The rotation vector analysis module locates the tilt position of the ruler line segment in the image according to the ruler tilt direction angle, establishes the tilt projection vector direction, and maps it to the image coordinate system to construct a pixel direction adjustment basis, thereby generating pixel direction rotation vector data; The scale conversion module corrects the pixel path in the ruler direction of the image based on the pixel direction rotation vector data, calls the known length scale information in the ruler image for ratio correspondence, and generates a ruler area conversion ratio; The correction analysis module uses the scale area conversion ratio to perform pixel length correction on the overall edge map of the image, screens out regional boundary pairs with positional misalignment, and generates a symmetry analysis result of the ice bag structure; The abnormality marking module marks the current boundary segment as an abnormal area based on the symmetry analysis result of the ice bag structure, performs an aggregation operation on all marked areas in the image and covers them into the edge image area map to generate a fuzzy boundary area recognition image.

8. A computer device comprising a memory and a processor, characterized in that: The memory stores a computer program, and when the processor executes the computer program, the ice pack size image recognition device according to claim 7 is implemented.

Citation Information

Patent Citations

  • Multi-size shelf commodity detection method

    CN110321769A

  • Intelligent positioning method and system for can making stamping

    CN119295548A