Ice bag size image recognition method and device and computer
Through Canny edge detection and Hough transform extraction of the scale tilt angle, combined with pixel direction rotation and proportional conversion, the problem of tilt and blurred areas in image size recognition is solved, and high-precision ice bag size recognition is achieved.
Patent Information
- Application Number
- CN202510620742.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-14
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2045-05-14
AI Technical Summary
The prior art is difficult to dynamically adjust the pixel direction in image size recognition, resulting in insufficient tilt angle or edge segment continuity, resulting in inaccurate size conversion and lack of ability to identify blurred areas in the image.
Through Canny edge detection and Hough transformation, the angle of the inclination direction is extracted, the pixel direction rotation vector path is established, proportional conversion is performed based on the scale scale information, and the boundary is corrected through symmetric analysis and abnormal area recognition to generate a fuzzy boundary recognition image.
High-precision size recognition is achieved, which enhances the adaptability and robustness to complex contour changes, and improves the stability and accuracy of image recognition.
Smart Images

Figure CN120375341A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and in particular to a method, device and computer for ice bag size image recognition. Background Art
[0002] The technical field of image recognition includes related methods for detecting, analyzing and recognizing specific targets in images or videos by means of computer vision and image processing. The core content of this technical field is to extract target feature information through pixel-level analysis of image data and convert it into structured data with practical significance. This process usually involves steps such as image acquisition, feature extraction, target classification and result output.
[0003] Among them, the ice bag size image recognition method refers to a method for recognizing and quantifying the size parameters in the appearance image of an ice bag by using image recognition technology. An ice bag image is obtained through a high-resolution image acquisition device, and the edge detection method is used to extract the target contour. Then, combined with the reference object calibration mechanism, the pixel information is converted into actual physical dimensions, and finally the size parameter information of the ice bag is obtained.
[0004] The existing technology mainly relies on edge extraction and reference object calibration mechanisms to achieve length conversion during image size recognition. Although the boundary contour can be obtained, when facing problems such as scale inclination or unstable shooting angle in the image, it is difficult to dynamically adjust the pixel direction, resulting in projection errors when the inclination angle is large or the continuity of the edge line segment is insufficient, thereby affecting the accuracy of size conversion. In addition, the existing technology does not fully model the corner points, direction angles and symmetric structures in the pixel path, and lacks the ability to identify abnormal areas when there are slight structural distortions or boundary irregularities 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 often cannot determine it as abnormal, resulting in a risk of misjudgment in the application of the boundary recognition result. The lack of analysis of image directional information and vector path correction mechanism makes the existing technology significantly insufficient in terms of 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 deficiencies existing in the prior art, and to propose a method, device and computer for ice bag size image recognition.
[0006] In order to achieve the above purpose, the present invention adopts the following technical solutions: An ice bag size image recognition method includes the following steps: S1: Obtain the grayscale edge map of the scale area in the ice bag size image, call the Canny edge operator to preliminarily outline the image contour line, use the Hough transform to extract the longest line segment in the continuous straight line area of the line segment, and perform an angle measurement on the horizontal axis of the image based on the endpoint coordinates to generate the scale inclination direction angle; S2: Locate the inclined position of the scale line segment in the image according to the inclined direction angle of the scale, establish the direction of the inclined projection vector, and map it to the image coordinate system to construct the basis for pixel direction adjustment, and generate pixel direction rotation vector data; S3: Based on the pixel direction rotation vector data, correct the pixel path in the scale direction in the image, call the known length scale information in the scale image for ratio correspondence, and generate the scale area conversion ratio; S4: Call the scale area conversion ratio to correct the pixel length of the overall edge map of the image, screen the area boundaries with position misalignment pairs, and generate the ice bag structure symmetry analysis result; S5: According to the ice bag structure symmetry analysis result, mark the current boundary segment as an abnormal area, perform an aggregation operation on all marked areas in the image and cover them to the edge image area map to generate a fuzzy boundary area recognition image.
[0007] As a further solution of the present invention, the inclined direction angle of the scale specifically includes the starting end coordinates of the line segment, the ending end coordinates of the line segment, and the line segment direction angle value. The pixel direction rotation vector data includes the rotation direction parameter, the direction mapping path, and the image coordinate system vector. The scale 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 amount, the corner point distribution symmetry offset value, and the edge length comparison factor. The fuzzy boundary area recognition image is specifically a boundary misalignment annotation layer, a structure abnormal aggregation partition, and the edge image data after recognition.
[0008] As a further solution of the present invention, the obtaining steps of the inclined direction angle of the scale are specifically as follows: S111: Obtain the gray edge map of the scale area in the ice bag size image, call the Canny edge operator to extract all edge line segments in the image, screen the linear continuity features of the edge line segments, and perform a preliminary screening on the length trend according to the connection order of the edge pixels to determine whether it meets the linear direction consistency condition, and obtain the linear edge structure; S112: Based on the linear edge structure, construct a set of direction vectors of all line segments on the image plane, call the Hough transform to perform polar coordinate cumulative conversion on the pixel pairs in each line segment set, calculate the position with the largest amplitude in the conversion space, extract the corresponding image straight line expression term, and locate the starting and ending coordinates of the line segment from it to obtain the longest line segment endpoint coordinate set; S113: According to the longest line segment endpoint coordinate set, respectively extract the coordinate differences in the horizontal and vertical axis directions, calculate the projection angle of the line segment in the horizontal axis direction of the image, and obtain the inclined direction angle of the scale by constructing the ratio of the included angle between the direction vector slope and the horizontal axis of the image coordinate.
[0009] As a further solution of the present invention, the step of obtaining the pixel direction rotation vector data is specifically as follows: S211: According to the scale tilt direction angle, collect the reference direction angle parameters of the image boundary line segment on the coordinate horizontal axis and compare the change of the direction angle difference. Select the effective deviation angle according to the requirement of the consistency between the angle difference change and the image reference direction. Statistically analyze the direction offset range of the angle difference value of the effective deviation angle within the pixel space range, and obtain the tilt direction angle offset amount; S212: Based on the tilt direction angle offset amount, construct an initial projection vector in the rotation direction. Set the offset angle as the rotation reference factor in the two-dimensional image coordinate system, map the angle change between the specified length direction and the coordinate axis, adjust the angle path relationship of each direction in the original pixel path according to the angle change, and generate the pixel direction rotation vector data for the scale direction in the current image.
[0010] As a further solution of the present invention, the step of obtaining the scale area conversion ratio is specifically as follows: S311: Based on the pixel direction rotation vector data, correct the pixel path direction of the scale line segment in the image, map the pixel points arranged in the original direction to the rotated vector path, sequentially extract the spatial coordinate differences between each pixel point on the vector path, and perform a combined measurement on the lengths between consecutive pixel points to obtain the scale path pixel spacing set; S312: Call the scale 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 range of the density distribution, establish a proportional mapping relationship with the length represented by the known scale graduations in the image, and perform a conversion operation in combination with the overall path length to obtain the scale area conversion ratio.
[0011] As a further solution of the present invention, the step of obtaining the ice bag structure symmetry analysis result is specifically as follows: S411: Call the scale area conversion ratio to adjust the length ratio of the pixel segments in the overall edge map of the image, obtain the corrected edge contour image, locate the left and right boundary paths of the ice bag area in the image, extract the start and end coordinates and the direction information of all continuous line segments on the boundary paths, establish a line segment set for the left and right boundaries, and obtain the ice bag boundary structure line segments; S412: Extract the corresponding line segments from the left and right boundary sets in the ice bag boundary structure line segments, respectively obtain the line segment length distribution, the contour direction angle distribution, and the corner point aggregation trend. Align and match the positions according to the vertical axis of the image to construct a line segment pair structure set. Compare the parameter values in the structure set and set an offset threshold range. Screen out the line segment combinations that exceed the offset threshold, statistically analyze the distribution of the line segment combinations, and generate the ice bag structure symmetry analysis result.
[0012] As a further solution of the present invention, the steps for obtaining the blurred boundary region recognition image are specifically as follows: S511: Locate the misaligned boundary segment according to the ice bag structure symmetry analysis result, extract the corner point distribution of the misaligned boundary segment region, judge the position where the corner points are continuously interrupted, count the number of times of change in the corresponding gradient direction, and determine whether it exceeds the set threshold in combination with the degree of inconsistency, mark it as abnormal, and obtain the boundary segment abnormality recognition index; S512: Extract all abnormal regions according to the boundary segment abnormality recognition index, perform coordinate aggregation operation, uniformly map them to the image edge map, and generate the blurred boundary region recognition image.
[0013] An ice bag size image recognition device is used to execute the above ice bag size image recognition method. The device includes: The inclination extraction module obtains the grayscale edge map of the scale region in the ice bag size image, calls the Canny edge operator to preliminarily outline the image contour line, uses the Hough transform to extract the longest line segment for the continuous straight line region in the line segment, measures the included angle in the horizontal axis direction of the image based on the endpoint coordinates, and generates the scale tilt direction angle; The rotation vector analysis module locates the tilt position of the scale line segment in the image according to the scale tilt direction angle, establishes the tilt projection vector direction, and maps it to the image coordinate system to construct the pixel direction adjustment basis, and generates the pixel direction rotation vector data; The ratio conversion module corrects the pixel path in the scale direction in the image based on the pixel direction rotation vector data, calls the known length scale information in the scale image for ratio correspondence, and generates the scale region conversion ratio; The calibration analysis module calls the scale region conversion ratio to perform pixel length calibration on the overall edge map of the image, screens the region boundaries with position misalignment pairs, and generates the ice bag structure symmetry analysis result; The abnormality marking module marks the current boundary segment as an abnormal region according to the ice bag structure symmetry analysis result, performs an aggregation operation on all marked regions in the image and covers them to the edge image region map, and generates the blurred boundary region recognition image.
[0014] A computer device includes a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the ice bag size image recognition device is implemented.
[0015] Compared with the prior art, the advantages and positive effects of the present invention are as follows: In the present invention, by first extracting the grayscale edges of the image and combining the continuous linear features of the edge contours, the spatial positioning of the longest line segment is achieved, ensuring the accuracy of angle measurement. With the aid of this angle information, a rotational vector path in the tilt direction is established to complete the precise adjustment of the pixel direction in the image coordinates. During this process, the vector mapping of the direction parameters enables the pixel path to be dynamically corrected according to the actual direction, effectively solving the scale error caused by the tilt of the scale in the image. By continuously extracting the pixel pitch and performing normalized calculation of the path density, the precise mapping of the pixel path and the known scale graduations is further promoted, thus realizing the unified standard of proportional conversion. After correcting the edge path according to the conversion result within the global scope of the image, by analyzing the symmetry of the boundary trend, length, and corner structure, a data set of the structural differences on both sides is constructed, strengthening the morphological recognition ability of the ice bag boundary. When phenomena such as abnormal boundary trend and discontinuous corners are identified, an abnormal layer is generated through coordinate aggregation to effectively label the blurred boundary area. This method promotes the high precision of dimension calibration and the systematization of symmetry analysis in the image through the combined operations of multi-dimensional direction angle correction, construction of the vector mapping path, and density ratio conversion, enhances the precise recognition ability of structural abnormalities, and improves the adaptability and robustness of the recognition image to complex contour changes. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 is a schematic diagram of the working process of the present invention; Figure 2 is a flowchart of step S1 of the present invention; Figure 3 is a flowchart of step S2 of the present invention; Figure 4 is a flowchart of step S3 of the present invention; Figure 5 is a flowchart of step S4 of the present invention; Figure 6 is a flowchart of step S5 of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0017] In order to make the objectives, technical solutions, and advantages of the present invention clearer and more understandable, 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 used to limit the present invention.
[0018] In the description of the present invention, it should be understood that the orientation or positional relationship indicated by the terms "length", "width", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings, and is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be construed as a limitation to the present invention. In addition, in the description of the present invention, the meaning of "a plurality of" is two or more, unless otherwise specifically defined.
[0019] Please refer to Figure 1 , the present invention provides a technical solution: an ice bag size image recognition method, including the following steps: S1: Obtain the grayscale edge map of the scale area in the ice bag size image, call the Canny edge operator to preliminarily outline the image contour line, screen the edge line segments with linear structures, use the Hough transform to extract the longest line segment in the continuous straight line area of the line segment, obtain the coordinates of the two endpoints of the longest line segment, perform an 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 direction of the scale line segment in the image according to the scale tilt direction angle, call the horizontal reference direction angle of the image boundary to calculate the angle offset, extract the offset angle as the rotation amount reference of the scale direction, establish the tilt projection vector direction, and map it to the image coordinate system to construct the pixel direction adjustment basis, and generate the pixel direction rotation vector data; S3: Correct the pixel path in the scale direction in the image based on the pixel direction rotation vector data, remap the pixel points on the original straight line direction to the rotation vector direction, measure the distance combination between consecutive pixel points, extract the pixel density distribution on the path, call the known length scale information in the scale image for ratio correspondence, and generate the scale area conversion ratio; S4: Call the scale area conversion ratio to correct the pixel length of the overall edge map of the image, obtain the left and right boundary line segment data of the ice bag image under the corrected scale, extract the length characteristics, contour direction and corner point distribution trend of the two sides of the edge, perform the corresponding structure ratio judgment along the vertical axis of the image, screen the area boundaries with position misalignment pairs, and generate the ice bag structure symmetry analysis result; S5: Trace the corresponding misaligned boundary segments in the image according to the ice bag structure symmetry analysis result, extract the position where the corner point continuity is interrupted and the gradient direction change frequency in the area, combine the degree of boundary inconsistency, mark the current boundary segment as an abnormal area, perform an aggregation operation on all the marked areas in the image and cover them to the edge image area map, and generate a fuzzy boundary area recognition image; The angle of the ruler tilt direction specifically includes the starting - end coordinates of the line segment, the ending - end coordinates of the line segment, and the line - direction angle value. 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 amount, the corner - point distribution symmetry offset value, and the edge - length comparison factor. The blurred - boundary region recognition image is specifically the boundary - dislocation annotation layer, the structure - anomaly aggregation partition, and the edge - image data after recognition.
[0020] Please refer to Figure 2 , and the steps for obtaining the angle of the ruler tilt direction are specifically as follows: S111: Obtain the grayscale edge map of the ruler area in the ice - bag size image, call the Canny edge operator to extract all edge line segments in the image, screen the linear - continuity features of the edge line segments, preliminarily screen their length trends according to the connection order of edge pixels, judge whether they meet the linear - direction - consistency condition, and obtain the linear edge structure; When obtaining the grayscale edge map of the ruler area in the ice - bag size image, first collect an ice - bag image containing the ruler from the actual scene. The original image is usually a color image, which 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 as the average of the weighted sums of the red, green, and blue channels, obtaining a single - channel grayscale image as the input image for edge detection. 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 statistically analyze the pixel grayscale values in the image, construct a grayscale histogram, calculate the distribution range of the gradient amplitudes of all pixels, and set the low threshold as the mean of the first 10% of the most frequently occurring grayscale - gradient segments, and the high threshold as the mean of the last 10%. For example, in the grayscale - gradient statistical distribution of an image, the most frequent interval 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: , where, is the low threshold, is the high threshold, and are the gradient sets of the first 10% and the last 10% of the gradient distribution respectively. Through non - maximum suppression and double - threshold connection methods, a binary edge map is generated. The value of the edge - pixel points in the output edge map is 255, and the rest of the area is 0. Then, linear - structure screening is carried out. Traverse all edge - connected regions. For each edge line segment, extract its start and end coordinates, calculate its direction vector. If the angle change of all consecutive edge vectors does not exceed the set angle threshold, it is considered that their directions are consistent. This angle threshold can be set as half of the standard deviation of the overall edge - direction change of the image. For example, if the standard deviation is 24 degrees, the threshold is 12 degrees. The expression is as follows: , where 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 respectively, and their lengths are 40, 60, 22, 35, and 55 pixels respectively. Remove the line segments with direction differences greater than the threshold of 12 degrees, that is, the line segment corresponding to 30 degrees is removed. Among the remaining line segments, retain the line segments with lengths greater than the set minimum length threshold of 30 pixels, and obtain two line segments with lengths of 60 and 55, forming a linear edge structure set.
[0021] S112: Based on the linear edge structure, construct a set of direction vectors of all line segments on the image plane, call the Hough transform to perform polar coordinate accumulation conversion on the pixel pairs in each line segment set, calculate the position with the largest amplitude in the conversion space, extract the corresponding image straight line expression term, locate the starting and ending coordinates of the line segment from it, and obtain the set of endpoint coordinates of the longest line segment; For the linear edge structure set, perform the longest line segment extraction operation, record the starting and ending coordinates of each line segment, and calculate the line segment length using the Euclidean distance. The calculation formula is as follows: , where is the length of the th line segment, is the starting coordinate, is the ending coordinate; Taking the two extracted line segments as an example, assume that the endpoint coordinates of the first line segment are (100, 120) and (400, 150), and the second one is (50, 60) and (350, 100). Substitute and calculate: , , Compare the lengths of the two line segments. The second one is longer. Select it as the longest structural line segment, and obtain its endpoint coordinates as the set of endpoint coordinates of the longest line segment. To confirm its linearity, process all point pairs through the Hough transform, construct the parameter pair of each point pair in the polar coordinate space, count the parameter pair with the most votes and compare it with the actual line segment direction. If the direction difference is less than the set direction tolerance threshold such as 5 degrees, it is considered that the line segment structure meets the consistency, and the line segment can be retained.
[0022] S113: According to the set of endpoint coordinates of the longest line segment, extract the coordinate differences in the horizontal and vertical axis directions respectively, calculate the projection angle of the line segment in the horizontal axis direction of the image, and obtain the scale tilt direction angle by constructing the ratio of the angle between the slope of the direction vector and the horizontal axis of the image coordinates; According to the coordinates in the set of endpoint coordinates of the longest line segment, assume the starting point is , and the ending point is , and 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 direction angle of the line segment with respect to the horizontal axis of the image, in degrees, and the arctangent function is used in its calculation. The direction change is reflected by the increments of the horizontal and vertical coordinates. Among them, is the direction angle value of the scale line segment, are the differences between the horizontal and vertical axes of the line segment in the image coordinate system respectively, which are used to construct the direction vector. The finally output angle value is approximately 7.59 degrees, generating the scale inclination direction angle value. The advantage of the above direction angle calculation formula is that the angle value is directly calculated from the two-point coordinates, avoiding complex fitting or contour fitting processes. And this angle value, as the basic parameter for scale area projection correction, can be continuously input into 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 the scale direction in the image has a slight inclination. This result will be used as the angle input for generating the rotation vector in the subsequent steps, directly affecting the pixel projection direction. Therefore, the accuracy of the angle calculation directly determines the quality of the basic offset parameter for image direction correction.
[0023] Please refer to Figure 3 , the steps for obtaining the pixel direction rotation vector data are specifically as follows: S211: According to the scale inclination direction angle, collect the reference direction angle parameters of the image boundary line segment on the coordinate horizontal axis and compare the change of the direction angle difference. Filter the effective deviation angles according to the requirement of the consistency between the angle difference change and the image reference direction, and count the direction offset range of the angle difference of the effective deviation angles within the pixel space range to obtain the inclination direction angle offset amount; To collect the direction parameters of the boundary segments of the acquired image, it is necessary to first extract the boundary segments corresponding to the horizontal direction in the overall boundary box of the image in the image coordinate system. The image boundary box can be achieved by obtaining the upper, lower, left, and right boundary coordinates of the image pixel matrix, and then define its direction angle as the reference angle, which is generally set to 0 degrees or 90 degrees. If the current image is acquired with a standard forward view, the default reference angle is 0 degrees. After obtaining this reference direction, the angle value of the scale tilt direction obtained in the previous stage is called correspondingly. For example, the angle obtained by extracting through 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 angle offset value of the scale segment relative to the image reference boundary. Then, judge this offset angle. 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 an angle comparison operation on the local scale segments in multiple sampling areas to form a statistical data set of angle offsets, and calculate the mean and variance in this data set. For example, assume that the angles of 5 sample segments are 11.9, 12.1, 12.5, 12.0, and 11.8 degrees respectively, the average value 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, it is necessary to start the rotation correction, set this offset mean as the rotation reference angle and input it into the next stage of the processing flow to obtain the angle offset of the tilt direction.
[0024] S212: Construct an initial projection vector in the rotation direction based on the angle offset of the tilt direction, set the offset angle as the rotation reference factor in the two-dimensional image coordinate system, map the angle change between the specified length direction and the coordinate axis, adjust the angle path relationship of each direction in the original pixel path according to the angle change, and generate pixel direction rotation vector data for the scale direction in the current image; First, based on the 1-pixel length direction vector, a reference structure of the projection vector before rotation is established in the two-dimensional image coordinate space. Let the reference direction be the horizontal pixel vector (1px, 0px), and the offset angle be used as the rotation reference factor. The rotation transformation is performed using the direction mapping rule in the two-dimensional image space. The obtained reference vector in the image and the offset angle are used to calculate the new direction vector after rotation, and a set of rotation 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 rotation direction vector is superimposed on each scale pixel direction structure in the image. The original pixel path direction is replaced with the structure after the current direction mapping through vector mapping, and then a new mapping relationship between the overall pixel direction and the image coordinate system is constructed. According to the pixel arrangement path after direction correction, 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 start point, direction, and length information. Finally, a complete direction calibration data set, that is, pixel direction rotation vector data, is generated by combination.
[0025] Please refer to Figure 4 , and the specific steps for obtaining the conversion ratio of the scale area are as follows: S311: Based on the pixel direction rotation vector data, correct the pixel path direction of the scale line segment in the image, map the pixel points arranged in the original direction to the rotated vector path, and sequentially extract the spatial coordinate differences between each pixel point on the vector path to combine and measure the lengths between consecutive pixel points to obtain a set of pixel spacings of the scale path; First, call the direction vector of the scale area in the original image, and remap all pixel paths according to the rotation angle offset value. Specifically, reposition the pixel points originally arranged along the horizontal axis of the image to the new direction path established based on the rotation vector. For example, if the starting and ending pixels of the scale line segment in the original image are points and point , after the rotation angle offset is 15°, the two points can be transformed into and respectively through the coordinate rotation matrix to obtain the rotated path again. The spacing between consecutive pixel points on this path needs to be analyzed in combination with the pixel coordinate differences, and then the Euclidean distance combination between consecutive pixels is established. Take 5 consecutive pixel point pairs such as: and … for spacing measurement to obtain the pixel distance array , with the unit unified as pixels. This data is the set of pixel spacings of the scale path.
[0026] 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 according to 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 in combination with the overall path length, and obtaining the ruler area conversion ratio; 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 (in pixels). 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 , which is 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, in pixels (px), : The number of participating segments, an integer, : The calculated conversion ratio in units of .
[0027] Set the pixel segment spacing set to: , the pixel density set is: , actual length of ruler , number of segments .
[0028] The formula operation process is as follows: The first part is: ; ; The second part is: ; , ; Combined to get: .
[0029] Result description: This result indicates 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 dimension measurement in subsequent image recognition, and is directly associated with the conversion ratio of the ruler area. The benefit of the formula is that by introducing the density-weighted pixel segment spacing and the relative difference term, it effectively takes into account the unevenness of pixel distribution and edge floating conditions, making the conversion value more robust and locally stable when facing the boundary changes of the ice pack image structure.
[0030] Please refer to Figure 5 for the specific steps to obtain the symmetry analysis results of the ice pack structure: S411: Call the conversion ratio of the ruler area to adjust the length of the pixel segments in the overall edge map of the image, obtain the corrected edge contour image, locate the left and right boundary paths of the ice pack area in the image, extract the start and end coordinates and the direction information of all continuous line segments on the boundary paths, establish the line segment sets of the left and right boundaries, and obtain the ice pack boundary structure line segments; To call the conversion ratio of the ruler area to adjust the length of the pixel segments in the overall edge map of the image, it is necessary to first extract the pixel path coordinates and perform area segmentation on the entire image. Using the vertical central axis of the image as the dividing line, determine the boundary paths of the ice pack area in the left and right regions of the central structure. Extract the edge paths through the Canny operator and the contour closing strategy, and calculate the distances of all pixel segments in the path order , and then uniformly use the obtained conversion ratio to perform equivalent length adjustment, using the path length correction formula: , where: : The corrected physical length corresponding to the th boundary pixel path, in centimeters (cm); : The original pixel length of the th pixel path, in pixels (px); : The unit conversion ratio, in centimeters per pixel (cm / px). For example, if the original pixel spacing of a certain boundary path segment is , then its corrected equivalent length is . After the correction is completed, mark and record the start and end pixel coordinates of this path segment, such as the start point and the end point . Then further calculate its direction vector as , and the direction angle is calculated using the following formula: , where: ': The angle between the pixel path direction and the horizontal axis of the image, in degrees (°); : The difference between the abscissa of the end point and the abscissa of the start point of the pixel path, in pixels (px); : The difference between the vertical coordinates of the end point and the start point of the pixel path, with the unit of pixel (px).
[0031] In the above example, , , then the direction angle is , indicating that the path is vertical. Store all boundary line segment information into the line segment structure data table. The line segment set of the left boundary is uniformly named "left boundary line segment set", and the right set is named "right boundary line segment set". Each structure entry contains fields: equivalent length, direction angle, start and end pixel coordinates, line segment number, boundary attribution type, and finally summarize to generate the ice bag boundary structure line segment.
[0032] S412: Extract the corresponding line segments in the left and right boundary sets from the ice bag boundary structure line segment, respectively obtain the line segment length distribution, contour direction angle distribution, and corner point aggregation trend, align and match the positions according to the vertical axis of the image, construct the line segment pair structure set, compare the parameter values in the structure set and set the offset threshold range, screen the line segment combinations that exceed the offset threshold, and count the distribution of the line segment combinations to generate the ice bag structure symmetry analysis result; Extract all line segments in the "left boundary line segment set" and "right boundary line segment set" from the ice bag boundary structure line segment. Taking the central axis of the image as the symmetry reference line, construct the line segment structure pairs with corresponding heights through the projection matching rule of the longitudinal coordinate region, named "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 pair , and corner point density pair . Perform the symmetric offset ratio calculation on the equivalent length values, using the following original structure offset ratio formula defined in the image: , where: : The symmetric offset ratio (dimensionless) of the th pair of structure line segments, representing the proportion of the length difference relative to the total length; : The equivalent physical length of the left line segment in the th pair of structures, with the unit of centimeter (cm); : The equivalent physical length of the right line segment in the th pair of structures, with the unit of centimeter (cm). Taking the structure pair number as an example, if the equivalent length of the left line segment is , and the right side is , substitute into the calculation: . If the structure symmetry offset threshold is set, then because , the structure determines that a length offset has occurred and records its number. Continue to extract its direction angle. If the left direction angle , the right direction angle , then the direction offset , and the offset condition is met again. If the corner point distribution density is 、 , and the density difference is , the corner point offset condition is also met. Finally, the structure pair meets the judgment criteria in the three dimensions of length, direction, and density and is included in the offset set "symmetric offset structure set". After traversing all structure pairs, the offset ratio is statistically analyzed and the symmetric analysis result of the ice pack structure is generated.
[0033] Please refer to Figure 6 , and the specific steps for obtaining the image of the fuzzy boundary region are as follows: S511: Locate the misaligned boundary segment according to the symmetric analysis result of the ice pack structure, extract the corner point distribution in the misaligned boundary segment region, judge the corner point continuous interruption position, count the corresponding gradient direction change times, and combine the degree of inconsistency to judge whether it exceeds the set threshold, and mark it as abnormal to obtain the boundary segment abnormality recognition index; First, extract the image pixel sequence corresponding to each boundary segment, identify the distribution area of continuous corner points in this sequence, and judge whether there is a break in the corner point number through the index change. If there is a discontinuous number section, it can be regarded as the corner point continuity interruption position, count the interruption quantity and spacing of each section as the interruption index, and at the same time extract the pixel gray gradient direction in these areas to construct a direction sequence, judge the mutation times of the direction angle in this sequence and represent the local boundary direction instability with the change frequency, and then combine the length offset ratio, direction angle difference, and corner point density distribution difference of this boundary segment in the previous stage to make an aggregated judgment on these parameters. When all three eigenvalue exceed the set threshold benchmark, this boundary segment is determined as a region with a high degree of inconsistency and marked as an abnormal boundary segment. Finally, the mark summary is completed in the image to obtain the boundary segment abnormality recognition index.
[0034] S512: Extract all abnormal regions according to the boundary segment abnormality recognition index, perform coordinate aggregation operations, and uniformly map them to the image edge map to generate a fuzzy boundary region recognition image; According to the abnormal boundary segment indexes marked in the boundary segment abnormality recognition indexes, extract the pixel coordinate sets of all corresponding regions, construct the minimum closed boundary structures of each region in the image space, further judge the spatial proximity relationships between these boundaries. If there is a tendency of position continuity or coincidence between the boundaries of adjacent regions, merge them into the same abnormal block. Through the merging operation, several aggregated region blocks are formed, and they are uniformly converted into the standard image mask format. Project the mask region onto the corresponding position in the original edge map, and generate a new boundary image result through the pixel-level covering operation. This image retains the original edge contour information and marks all the recognized abnormal boundary blocks, and is output as the fuzzy boundary region recognition image.
[0035] An ice bag size image recognition device, which is used to execute the above ice bag size image recognition method. The device includes: The inclination extraction module obtains the gray edge map of the scale region in the ice bag size image, calls the Canny edge operator to preliminarily outline the image contour line, uses the Hough transform to extract the longest line segment for the continuous straight line region in the line segment, and performs the included 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 scale line segment in the image according to the scale 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 the pixel direction rotation vector data. The ratio conversion module corrects the pixel path in the scale direction in the image based on the pixel direction rotation vector data, calls the known length scale information in the scale image for ratio correspondence, and generates the scale region conversion ratio. The calibration analysis module calls the scale region conversion ratio to perform pixel length calibration on the overall edge map of the image, screens the region boundary pairs with position misalignment, and generates the ice bag structure symmetry analysis result. The abnormal annotation module marks the current boundary segment as an abnormal region according to the ice bag structure symmetry analysis result, performs an aggregation operation on all the marked regions in the image and covers them to the edge image region map, generating the fuzzy boundary region recognition image.
[0036] A computer device includes a memory and a processor. It is characterized in that a computer program is stored in the memory, and when the processor executes the computer program, the ice bag size image recognition device is realized.
[0037] The above are only the preferred embodiments of the present invention, and do not limit the present invention in other forms. Any person skilled in the relevant art may use the technical content disclosed above to make changes or modifications into equivalent embodiments with equivalent changes and apply them to other fields. However, as long as it does not depart from the technical solution content of the present invention, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention still fall within the protection scope of the technical solution of the present invention.
Claims
1. An ice pack size image recognition method, characterized in that, Including the following steps: S1: Obtain the grayscale edge map of the scale area in the ice bag size image, call the Canny edge operator to preliminarily outline the image contour line, use the Hough transform to extract the longest line segment in the continuous straight line area of the line segment, perform angle measurement in the horizontal axis direction of the image based on the endpoint coordinates, and generate the scale inclination direction angle; S2: Locate the inclined position of the scale line segment in the image according to the scale inclination direction angle, establish the inclined projection vector direction, and map it to the image coordinate system to construct the pixel direction adjustment basis, and generate the pixel direction rotation vector data; S3: Based on the pixel direction rotation vector data, correct the pixel path in the scale direction of the image, call the known length scale information in the scale image for ratio correspondence, and generate the scale area conversion ratio; S4: Call the scale area conversion ratio to correct the pixel length of the overall edge map of the image, screen the area boundaries with position misalignment pairs, and generate the ice bag structure symmetry analysis result; S5: According to the ice bag structure symmetry analysis result, mark the current boundary segment as an abnormal area, perform an aggregation operation on all marked areas in the image and cover them to the edge image area map to generate a blurred boundary area recognition image.
2. The ice pack size image recognition method according to claim 1, wherein The scale inclination direction angle specifically includes the line segment start-end coordinates, the line segment end-end coordinates, and the line segment direction angle value. The pixel direction rotation vector data includes the rotation direction parameter, the direction mapping path, and the image coordinate system vector. The scale 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 amount, the corner point distribution symmetry offset value, and the edge length comparison factor. The blurred boundary area recognition image is specifically the boundary misalignment annotation layer, the structure abnormal aggregation partition, and the recognized edge image data.
3. The ice pack size image recognition method according to claim 1, wherein, The specific steps for obtaining the scale inclination direction angle are as follows: S111: Obtain the grayscale edge map of the scale area in the ice bag size image, call the Canny edge operator to extract all edge line segments in the image, screen the linear continuity features of the edge line segments, perform a preliminary screening of the length trend according to the edge pixel connection order, and judge whether it meets the linear direction consistency condition to obtain the linear edge structure; S112: Based on the linear edge structure, construct a direction vector set of all line segments on the image plane, call the Hough transform to perform polar coordinate cumulative conversion on the pixel pairs in each line segment set, calculate the position with the largest amplitude in the conversion space, extract the corresponding image straight line expression item, and locate the start and end coordinates of the line segment from it to obtain the longest line segment endpoint coordinate set; S113: According to the longest line segment endpoint coordinate set, respectively extract the coordinate differences in the horizontal and vertical axis directions, calculate the projection angle of the line segment in the horizontal axis direction of the image, and obtain the scale inclination direction angle by constructing the angle ratio between the direction vector slope and the horizontal axis of the image coordinate.
4. The ice pack size image recognition method according to claim 3, characterized in that The specific steps for obtaining the pixel direction rotation vector data are as follows: S211: According to the inclination direction angle of the scale, collect the reference direction angle parameters of the image boundary line segment on the coordinate horizontal axis, compare the change of the direction angle difference, screen the effective deviation angles according to the consistency requirement between the angle difference change and the image reference direction, count the direction offset range of the angle difference of the effective deviation angles within the pixel space range, and obtain the inclination direction angle offset amount. S212: Based on the inclination direction angle offset amount, construct an initial projection vector in the rotation direction, set the offset angle as the rotation reference factor in the two-dimensional image coordinate system, map the angle change between the specified length direction and the coordinate axis, adjust the angle path relationship of each direction in the original pixel path according to the angle change, and generate the pixel direction rotation vector data for the scale direction in the current image.
5. The ice pack size image recognition method according to claim 4, wherein The specific steps for obtaining the conversion ratio of the scale area are as follows: S311: Based on the pixel direction rotation vector data, correct the pixel path direction of the scale line segment in the image, map the pixel points arranged in the original direction to the rotated vector path, sequentially extract the spatial coordinate differences between each pixel point on the vector path, and perform a combined measurement on the lengths between consecutive pixel points to obtain the scale path pixel spacing set. S312: Call the scale 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 variation range of the density distribution, establish a proportional mapping relationship with the length represented by the known scale graduations in the image, and perform a conversion operation in combination with the overall path length to obtain the scale area conversion ratio.
6. The ice pack size image recognition method according to claim 5, characterized in that, The specific steps for obtaining the ice bag structure symmetry analysis result are as follows: S411: Call the scale area conversion ratio to adjust the length of the pixel segment in the overall edge map of the image proportionally, obtain the corrected edge contour image, locate the left and right boundary paths of the ice bag area in the image, extract the start and end coordinates and the direction information of all continuous line segments on the boundary paths, establish a line segment set for the left and right boundaries, and obtain the ice bag boundary structure line segments. S412: Extract the corresponding line segments from the left and right boundary sets in the ice bag boundary structure line segments, respectively obtain the line segment length distribution, the contour direction angle distribution, and the corner point aggregation trend, align and match the 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, screen 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 result.
7. The ice bag size image recognition method according to claim 6, wherein, The specific steps for obtaining the image of the fuzzy boundary area recognition are as follows: S511: Locate the misaligned boundary segments according to the ice bag structure symmetry analysis result, extract the corner point distribution in the misaligned boundary segment area, judge the continuous interruption position of the corner points, count the number of changes in the corresponding gradient direction, and combine the degree of inconsistency to judge whether it exceeds the set threshold, mark it as abnormal, and obtain the boundary segment abnormality recognition index. S512: Extract all abnormal areas according to the boundary segment abnormality recognition index, perform a coordinate aggregation operation, and uniformly map them to the image edge map to generate the image of the fuzzy boundary area recognition.
8. An ice pack size image recognition device, characterized in that, The ice bag size image recognition method according to any one of claims 1-7, the device comprising: The inclination angle extraction module obtains the grayscale edge map of the scale region in the ice bag size image, calls the Canny edge operator to preliminarily outline the image contour line, uses the Hough transform to extract the longest line segment in the continuous straight line region of the line segment, and performs an 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 scale line segment in the image according to the scale 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; The ratio conversion module corrects the pixel path in the scale direction of the image based on the pixel direction rotation vector data, calls the known length scale information in the scale image for ratio correspondence, and generates the scale region conversion ratio; The calibration analysis module calls the scale region conversion ratio to perform pixel length calibration on the overall edge map of the image, screens the region boundaries with position misalignment pairs, and generates the ice bag structure symmetry analysis result; The abnormal annotation module marks the current boundary segment as an abnormal region according to the ice bag structure symmetry analysis result, performs an aggregation operation on all the annotated regions in the image and covers them to the edge image region map, generating a blurred boundary region recognition image.
9. A computer device, comprising a memory and a processor, characterized in that, A computer program is stored in the memory, and when the processor executes the computer program, the ice bag size image recognition device according to claim 8 is implemented.
Citation Information
Patent Citations
Method for correcting certificate image inclination
CN101625760A
Inclination correction method and system of text image
CN105761219A
Multi-size shelf commodity detection method
CN110321769A
Method for accurately measuring profile steel overall dimension based on data analysis
CN118314191A
Intelligent positioning method and system for can making stamping
CN119295548A
Cited By
Power transmission and distribution line channel anomaly detection method, system and device and computer program product
CN121904483A
Power transmission and distribution line passage anomaly detection method, system, device and computer program product
CN121904483B