Fish body length measuring method and system
By combining geometric measurement with statistical models to estimate fish body length, the problems of accuracy and stability in fish body length measurement under complex environments have been solved, achieving low-cost and highly reliable fish body length measurement that is suitable for aquaculture environments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG UNIV
- Filing Date
- 2026-04-09
- Publication Date
- 2026-05-08
AI Technical Summary
Existing fish length measurement technologies suffer from low accuracy and poor stability in complex aquaculture environments, and are also computationally expensive, making it difficult to meet the actual needs of aquaculture.
An adaptive fusion mechanism was constructed by combining geometric measurement and statistical modeling, along with fish contour extraction and skeleton analysis. The measurement weights were evaluated and adjusted by shape quality indicators to achieve stable measurement of fish length.
It improves the stability and accuracy of measurements in complex environments, reduces the demand for computing resources, adapts to different fish species and shooting conditions, and has low cost and high interpretability.
Smart Images

Figure CN121999355A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent detection technology in aquaculture, and relates to a method and system for measuring fish body length. Background Technology
[0002] In the process of large-scale and intelligent development of the aquaculture industry, the counting of fish fry and the detection of their body length are core foundational data supports for assessing fry quality, optimizing stocking density, guiding precise feeding, and conducting growth status analysis. In traditional aquaculture models, fry counting relies heavily on manual estimation or simple screening tools, while body length detection is completed through manual sampling and measurement. This is not only inefficient and labor-intensive, but also prone to data inaccuracies due to human error and fish stress responses, making it difficult to meet the demands of modern aquaculture for data accuracy and real-time performance. The industry has gradually developed automated fry counters based on machine vision, sensors, and other technologies, as well as various methods for fish body length detection.
[0003] Existing fish fry length detection technologies generally suffer from adaptability defects: most solutions are designed only for specific length ranges and specific species of fish fry, and have high requirements for the cleanliness of the detection environment and the stability of light. However, aquaculture sites often have complex conditions such as turbid water, dense movement of fish fry, and large fluctuations in light, which leads to a significant decrease in the detection accuracy of existing technologies. In pursuit of measurement accuracy, some solutions overcomplicate the technical process, which not only increases the difficulty of equipment deployment and maintenance costs, but also reduces the stability of system operation, failing to meet the practical application needs of low cost, easy operation, and high reliability in aquaculture sites.
[0004] From the perspective of detection algorithms, existing fish length measurement methods mainly include geometric feature-based methods and estimation methods based on statistical or machine learning models. Geometric feature-based methods typically calculate length using the fish's skeleton, endpoints, or contour geometry. While they offer high accuracy when the fish's posture is relatively straight and the segmentation results are complete, they are prone to significant measurement errors when the fish is curved, the tail is missing, the contour is broken, or segmentation noise is present. On the other hand, length estimation methods based on statistical models or machine learning, while exhibiting good stability to some extent, often require large amounts of labeled data for training and rely on significant computational resources. In practical aquaculture environments, they face challenges such as difficulty in data acquisition, high training costs, and insufficient model interpretability.
[0005] Therefore, developing a fish length measurement method that is simple to implement, consumes low computational resources, produces stable and highly interpretable results, can adapt to the complex environment of aquaculture sites, and can achieve both high measurement accuracy and good stability under conditions of fish posture changes, segmentation errors, and limited data samples is a technical problem that urgently needs to be solved in this field. Summary of the Invention
[0006] The purpose of this invention is to address the shortcomings of existing technologies by providing a method and system for measuring fish length, which is a fish length estimation method based on the fusion of geometric measurement and statistical models. This method first obtains the geometric length Lgeo through fish contour extraction and skeleton analysis. Simultaneously, it constructs a statistical length estimation model based on the fish's area and shape features to obtain the area-estimated length Larea. The statistical model utilizes shape parameters such as fish area, aspect ratio, and convex hull ratio to construct a nonlinear length estimation relationship to compensate for the influence of changes in fish posture on the area estimation.
[0007] To improve the stability of the system in complex scenarios, this invention further constructs an adaptive fusion mechanism based on shape quality indicators. By evaluating indicators such as fish body contour integrity, contour smoothness, and region filling rate, the measurement confidence weight is calculated, and the geometric measurement results and area estimation results are adaptively fused according to the weight to obtain the final fish body length estimate.
[0008] The technical solution adopted in this invention is as follows:
[0009] A method for measuring fish body length includes the following:
[0010] Step S1: Obtain an image region containing only a single fish body to obtain a single fish image;
[0011] Step S2: Perform geometric correction on the acquired image, establish the mapping relationship between pixel scale and actual physical scale, and normalize the scale of the corrected image;
[0012] Step S3: Preprocess the image obtained in step S2 to enhance the contrast between the fish body and the background and obtain the foreground region of the fish body; obtain the fish body area;
[0013] Step S4: Extract the fish body outline;
[0014] Step S5: Based on the extracted fish body contour points, perform statistical modeling on the fish body centerline to obtain the fitted fish body centerline;
[0015] Step S6: Based on the obtained fish body centerline, combined with the mapping relationship in step S2, the fish body length Lgeo is obtained by centerline fitting method. Based on the fish body area obtained in step S3, the fish body length Larea is obtained by area model method. Combined with the quality factor, the fish body length Lgeo and Larea are fused to obtain the actual fish body length.
[0016] In the above technical solution, further, in step S1, the image is a top-view image of the fish body acquired by the acquisition device, and the image area of a single fish body is obtained based on target detection.
[0017] Furthermore, in step S2, distortion correction is performed on the single fish image based on the camera intrinsic parameters of the image acquisition device; the corrected single fish image is scaled to give it a uniform actual size reference; and a mapping relationship between pixel scale and actual physical scale is established based on preset calibration parameters.
[0018] Furthermore, the preprocessing described in step S3 includes: grayscale conversion, noise reduction filtering, adaptive threshold segmentation, and morphological adaptive cleaning; specifically: after converting the image obtained in step S2 to grayscale, Gaussian low-pass filtering is performed, and an adaptive threshold segmentation algorithm is used to automatically determine the global threshold for the filtered grayscale image, and the image is binarized based on the threshold to obtain the initial fish foreground region.
[0019] Then, morphological adaptive cleaning is performed, including: adaptively determining the size of the morphological structural elements based on the scale information of the fish body in the single fish image, and performing opening, closing and region filling operations on the binary image in sequence based on the morphological structural elements to obtain a connected and noise-free fish body foreground region.
[0020] The dimensions of the morphological structural elements are adaptively determined as follows:
[0021]
[0022] w and h are the width and height of the circumscribed rectangle of the fish, respectively. and These are the minimum and maximum values, which are typically defined as follows: and μ is the proportionality constant, usually μ=0.05;
[0023] Simultaneously, the area A of the fish body is obtained by counting the number of pixels on the fish body, as follows:
[0024]
[0025] (x, y) are the pixel coordinates. In a binary image, for the foreground mask M, the fish body is 1 and the background is 0.
[0026] Furthermore, the method for extracting the fish body contour in step S4 is as follows:
[0027] In the preprocessed binary image, whether a pixel is a boundary pixel is determined based on the pixel neighborhood relationship, wherein the pixel neighborhood relationship is N8 neighborhood or N4 neighborhood; if the current pixel is a foreground pixel and there is at least one background pixel in its neighborhood, then the pixel is determined to be a fish body outline point, i.e. a boundary pixel.
[0028] Collect all fish body outline points to form a set of fish body boundary pixels B={(x1,y1),(x2,y2),...,(xn,yn)}.
[0029] Furthermore, the modeling method for the fish's centerline in step S5 is as follows:
[0030] Based on the extracted fish body contour points, the fish body centerline is modeled as a cubic polynomial function:
[0031] y(x) = a0 + a1x + a2x 2 +a3x 3 ,
[0032] Where a0, a1, a2, and a3 are the parameters to be fitted, the polynomial parameters are solved using the least squares method to obtain the fitted fish body centerline. Further, the calculation method for the fish body length Lgeo in step S6 is as follows:
[0033] Along the fitted fish centerline, point by point is determined to see if the centerline point is located within the foreground region of the fish. The starting point is determined by the position where the centerline first enters the foreground region from the background region. The actual starting point (x) is obtained by combining the mapping relationship. s ,y s The endpoint is determined by the position where the center line enters the background area from the foreground region of the fish. The actual endpoint (x) is then obtained by combining this with the mapping relationship. e ,y e );
[0034] Determine the effective interval of the centerline between the starting and ending points [x] s ,x e ];
[0035] Taking the derivative with respect to the centerline, we obtain the first derivative function of the centerline;
[0036] The curve length of the centerline within the effective interval is calculated using the arc length formula:
[0037] .
[0038] Furthermore, the calculation method for the fish body length Larea in step S6 is as follows:
[0039] The fish length Larea is obtained based on the area model:
[0040]
[0041] in, This is the scaling factor;
[0042] R is the aspect ratio of the circumscribed rectangle of the fish:
[0043]
[0044] It is a very small positive number, usually ;
[0045] For slenderness compensation index;
[0046] Q represents the convex hull ratio, which is the proportion of the fish's body area to the convex hull area.
[0047]
[0048] Where A hull It is the area of the convex hull; The bending compensation index; Area index; For bias terms;
[0049] , , , , All data were obtained by fitting real fish sample data.
[0050] Furthermore, in step S6, the fish body length Lgeo is fused with Larea using the quality factor to obtain the actual fish body length L, specifically as follows:
[0051]
[0052] Among them, quality factor ,for:
[0053]
[0054] Among them, S Q The quality score based on Q is:
[0055]
[0056] C represents roundness, which is:
[0057]
[0058] P is the perimeter of the fish's outline, which is calculated using the set of boundary pixel coordinates B.
[0059] S C The quality score based on C is:
[0060]
[0061] F represents the area ratio of the fish body within the bounding rectangle, i.e., the fill ratio, which is:
[0062]
[0063] S F For quality scores based on fill rate F
[0064]
[0065] F mid It is the center value of the fill rate; It is the fill rate decay control parameter, and also the tolerable range of the fill rate;
[0066] Q max Q min C max C min F max F min These are the maximum and minimum values of Q, C, and F in the fish fry samples;
[0067] Linear layer parameters b0, b Q b C b F It was obtained by fitting fish fry samples.
[0068] The present invention also provides an electronic device, comprising:
[0069] One or more processors;
[0070] Memory, used to store one or more programs;
[0071] When the one or more programs are executed by the one or more processors, the one or more processors perform the method as described in any of the preceding methods.
[0072] A computer-readable storage medium storing computer-executable instructions, which, when executed, are used to implement the method described in any of the preceding claims.
[0073] The beneficial effects of this invention are:
[0074] This invention utilizes traditional computer vision and statistical modeling techniques to construct a dual-channel length estimation method based on geometric measurement and area statistics models. Combined with an adaptive fusion mechanism based on shape quality indices, it achieves stable and reliable fish length measurement under complex fish poses and segmentation errors. Its advantages are as follows:
[0075] (1) By combining geometric measurement and statistical model, two length estimation methods are used to achieve multi-source information complementarity, which improves the stability of fish length measurement under posture changes and segmentation errors;
[0076] (2) By introducing a quality evaluation mechanism based on shape features, the reliability of geometric measurement results is evaluated, and the fusion weight is adaptively adjusted according to the credibility, so as to automatically select more reliable measurement results in different scenarios and improve the overall measurement accuracy.
[0077] (3) The method of the present invention does not rely on large-scale training data and high-performance computing equipment. It can achieve stable and reliable fish length measurement through traditional image processing and statistical modeling. Therefore, it can be run in real time on ordinary industrial cameras and general computing platforms, and has a low system deployment cost.
[0078] (4) The method of the present invention has good interpretability and scalability, and can quickly calibrate the model parameters according to different fish species or shooting conditions, thereby achieving stable deployment in different application scenarios. Attached Figure Description
[0079] Figure 1 This is a flowchart illustrating the method of the present invention. Detailed Implementation
[0080] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0081] According to a specific embodiment of the present invention, the present invention provides a method and system for measuring the length of a fish. The method can be used as one of the data processing modules of a fish fry counter. Based on the completion of image acquisition and target detection by the fish fry counter, the length of a single fish body image is estimated.
[0082] When applying the method of this invention, the camera can be installed above the aquaculture pond to capture a top-down image of the fish, ensuring sufficient and stable lighting conditions, that the fish are in a basically horizontal position without significant side-flipping or overturning, and that the length of the fish is less than the frame area, with no fish adhering to each other; Figure 1 As shown, the method includes the following:
[0083] Step S1: Obtain an image region containing only a single fish body to obtain a single fish image;
[0084] For the original image output by the camera, a single bounding box (Bbox) of the fish body is obtained using an object detection algorithm. The Bbox contains only one fish body. The boundaries of the Bbox are appropriately expanded to avoid the edges of the fish body being truncated.
[0085] The original image is cropped based on the expanded BBox to obtain a single fish image.
[0086] Step S2: Perform geometric correction on the acquired image and establish a mapping relationship between pixel scale and actual physical scale. Then, normalize the scale of the corrected image. Specifically:
[0087] The single fish image is subjected to position-based distortion correction based on the camera's intrinsic parameters; the corrected single fish image is scaled to give it a uniform actual size reference; and a mapping relationship between pixel scale and actual physical scale is established based on preset calibration parameters.
[0088] Step S3: Preprocess the image obtained in step S2 to enhance the contrast between the fish and the background and obtain the foreground region of the fish; specifically including the following:
[0089] 1) Grayscale processing: Convert the RGB image of a single fish into a grayscale image to eliminate the interference of color information on the extraction of the fish body area.
[0090] 2) Denoising filtering: Apply a Gaussian low-pass filter to the grayscale image to suppress image noise and smooth the brightness distribution.
[0091] 3) Adaptive threshold segmentation:
[0092] The filtered grayscale image is automatically thresholded using the Otsu or Isodata method, and then binarized based on the threshold to obtain the initial foreground region of the fish. This method can adapt to different lighting environments.
[0093] 4) Morphological adaptive cleaning:
[0094] The size of the morphological structural elements is adaptively determined based on the scale information of the fish body in the single fish image, and opening, closing and region filling operations are sequentially performed on the binary image.
[0095] This yields a connected and noise-free foreground region of the fish. When multiple connected regions exist in the image, only the largest connected region is retained as the fish region, which can effectively solve problems such as fish adhesion or invasion by other fish.
[0096] The dimensions of the morphological structural elements are adaptively determined as follows:
[0097]
[0098] w and h are the width and height of the circumscribed rectangle of the fish, respectively. and These are the minimum and maximum values, with a proportionality coefficient μ = 0.05;
[0099] Simultaneously, the area A of the fish body is obtained by counting the number of pixels on the fish body, as follows:
[0100]
[0101] (x, y) are the pixel coordinates. In a binary image, for the foreground mask M, the fish body is 1 and the background is 0.
[0102] Step S4: Extract the fish body outline;
[0103] In the preprocessed binary image, whether a pixel is a boundary pixel is determined based on the pixel neighborhood relationship, wherein the pixel neighborhood relationship is N8 neighborhood or N4 neighborhood, and more preferably N8 neighborhood is used to determine the foreground and background; if the current pixel is a foreground pixel and there is at least one background pixel in its neighborhood, then the pixel is determined to be a fish body outline point, i.e., a boundary pixel.
[0104] Collect all fish body outline points to form a set of fish body boundary pixels B={(x1,y1),(x2,y2),...,(xn,yn)}.
[0105] Step S5: Based on the extracted fish body contour points, perform statistical modeling on the fish body centerline to obtain the fitted fish body centerline; specifically:
[0106] The fish's centerline is modeled as a cubic polynomial function:
[0107] y(x) = a0 + a1x + a2x 2 +a3x 3 ,
[0108] The polynomial parameters are solved using the least squares method to obtain the fitted fish body centerline.
[0109] Step S6: Based on the obtained fish centerline, and combined with the mapping relationship from Step S2, the fish length Lgeo is obtained using the centerline fitting method. Based on the fish area obtained in Step S3, the fish length Larea is obtained using the area model method. The fish length Lgeo and Larea are then fused using a quality factor to obtain the actual fish length, as follows:
[0110] Along the fitted fish centerline, point by point is determined to see if the centerline point is located within the foreground region of the fish. The starting point is determined by the position where the centerline first enters the foreground region from the background region. Combined with the mapping relationship, the starting point (x) at the actual physical scale is obtained. s ,y s The endpoint is determined by the position where the center line enters the background region from the foreground region of the fish. This endpoint (x) is then used to obtain the actual physical scale endpoint based on the mapping relationship. e ,y e );
[0111] Determine the effective interval of the centerline between the starting and ending points [x] s ,xe ];
[0112] Taking the derivative with respect to the centerline, we obtain the first derivative function of the centerline;
[0113] The curve length of the centerline within the effective interval is calculated using the arc length formula:
[0114] .
[0115] The arc length integral is solved using a numerical integration method to obtain the curve length of the fish body; wherein the step size or error threshold of the numerical integration is a preset value to ensure that the curve length calculation error does not exceed a preset error range;
[0116] The fish length Larea is obtained based on the area model:
[0117]
[0118] Among them, the scaling factor Used to control the overall length scale, it is related to the fish species, camera distance, and imaging resolution;
[0119] R is the aspect ratio of the circumscribed rectangle of the fish:
[0120]
[0121] It is a very small positive number, usually This is used to avoid division by zero and to ensure that the value of R is always not less than 1;
[0122] R is the slenderness compensation index. The more slender the fish, the larger R is. The actual length is usually greater. δ is used to control the intensity of this compensation.
[0123] Q represents the convex hull ratio, which is the proportion of the fish's body area to the convex hull area.
[0124]
[0125] Where A hull It is the area of the convex hull;
[0126] The bending compensation index, Q, is generally used to indicate greater bending / concavity / imperfection. In such cases, relying solely on area often underestimates the true length. Increase the length;
[0127] As an area index, theoretically if ,but ≈0.5, the actual allowable deviation is to accommodate differences in body size and posture;
[0128] Bias term: used to correct systematic bias;
[0129] in , , , , All data were obtained by fitting real fish sample data.
[0130] The actual fish length L is obtained by fusing the fish body length Lgeo with Larea using the quality factor, specifically:
[0131]
[0132] The core idea of this fusion is: when the segmentation quality is good and the skeleton is reliable, more emphasis is placed on the Lgeo results; when segmentation breakage / bending leads to skeleton instability, more reliance is placed on Larea.
[0133] Among them, quality factor ,for:
[0134]
[0135] The quality factors are constructed by selecting indices that reflect "segmentation / shape quality," and each index is converted into a "quality score," where:
[0136] Q is the convex hull ratio, which indicates the degree of concavity / bending / defect;
[0137] C represents the smoothness / noise level of the contour. Abnormal burrs will cause the perimeter to increase dramatically, and C will become abnormally small.
[0138] F represents the fill rate of the mask within the bounding box. A small value often indicates defects, while a large value may indicate adhesion.
[0139] Among them, S Q The quality score based on Q is:
[0140]
[0141] P is the perimeter of the fish's outline, which is calculated using the set of boundary pixel coordinates B.
[0142] C represents roundness. If the segmentation produces a large number of burrs and noisy boundaries, the perimeter P will increase, which will cause C to become abnormally small.
[0143]
[0144] S C The quality score based on C is:
[0145]
[0146] F represents the area ratio of the fish body within the bounding rectangle, i.e., the fill ratio, which is:
[0147]
[0148] If F is too small, the fish may be incomplete or broken; if F is too large, multiple fish may stick together or the fish may swell.
[0149] S F For quality scores based on fill rate F:
[0150]
[0151] Where F mid It is the center value of the fill rate; This is the filling rate decay control parameter, and also the tolerance range for the filling rate. The default value is 0.1, but it can also be a statistical value based on fish fry samples. Specifically, the standard deviation of the filling rate of the fish fry samples is calculated first. , ;
[0152] Q max Q min C max C min F max F min These are the maximum and minimum values of Q, C, and F in the fish fry samples;
[0153] Linear layer parameters b0, b Q b C b F It was obtained by fitting fish fry samples.
[0154] Furthermore, in some embodiments of the present invention, when using the above method to detect the length of fish, a unique identifier ID can be assigned to each fish to support continuous processing of multiple frames; for the length results of the same ID fish in multiple frames, the maximum value, median value or average value is used as the final output result.
[0155] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0156] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0157] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0158] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0159] The embodiments described above are merely some preferred embodiments of the present invention, and are not intended to limit the invention. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the invention. Therefore, all technical solutions obtained by equivalent substitution or equivalent transformation fall within the protection scope of the present invention.
Claims
1. A method for measuring the length of a fish, characterized in that, Including the following: Step S1: Obtain an image region containing only a single fish body to obtain a single fish image; Step S2: Perform geometric correction on the acquired image, establish the mapping relationship between pixel scale and actual physical scale, and normalize the scale of the corrected image; Step S3: Preprocess the image obtained in step S2 to enhance the contrast between the fish body and the background and obtain the foreground region of the fish body; obtain the fish body area; Step S4: Extract the fish body outline; Step S5: Based on the extracted fish body contour points, perform statistical modeling on the fish body centerline to obtain the fitted fish body centerline; Step S6: Based on the obtained fish body centerline, combined with the mapping relationship in step S2, the fish body length Lgeo is obtained by centerline fitting method. Based on the fish body area obtained in step S3, the fish body length Larea is obtained by area model method. Combined with the quality factor, the fish body length Lgeo and Larea are fused to obtain the actual fish body length.
2. The method for measuring fish body length according to claim 1, characterized in that, In step S1, the image is a top-view image of the fish body acquired by the acquisition device, and the image region of a single fish body is obtained based on target detection.
3. The method for measuring fish body length according to claim 1, characterized in that, In step S2, distortion correction is performed on the single fish image based on the camera intrinsic parameters of the image acquisition device; the corrected single fish image is scaled to give it a uniform actual size reference; and a mapping relationship between pixel scale and actual physical scale is established based on preset calibration parameters.
4. The method for measuring fish body length according to claim 1, characterized in that, The preprocessing described in step S3 includes: grayscale conversion, noise reduction filtering, adaptive threshold segmentation, and morphological adaptive cleaning; specifically, the image obtained in step S2 is grayscaled and then subjected to Gaussian low-pass filtering. The filtered grayscale image is then subjected to an adaptive threshold segmentation algorithm to automatically determine the global threshold, and the image is binarized based on the threshold to obtain the initial fish foreground region. Then, morphological adaptive cleaning is performed, including: adaptively determining the size of the morphological structural elements based on the scale information of the fish body in the single fish image, and performing opening, closing and region filling operations on the binary image in sequence based on the morphological structural elements to obtain a connected and noise-free fish body foreground region. The dimensions of the morphological structural elements are adaptively determined as follows: , w and h are the width and height of the circumscribed rectangle of the fish, respectively. and These are the minimum and maximum values, where μ is the proportionality constant; Simultaneously, the area A of the fish body is obtained by counting the number of pixels on the fish body, as follows: , (x, y) are the pixel coordinates. In a binary image, for the foreground mask M, the fish body is 1 and the background is 0.
5. The method for measuring fish body length according to claim 1, characterized in that, The method for extracting the fish body contour in step S4 is as follows: In the preprocessed binary image, whether a pixel is a boundary pixel is determined based on the pixel neighborhood relationship, wherein the pixel neighborhood relationship is N8 neighborhood or N4 neighborhood; if the current pixel is a foreground pixel and there is at least one background pixel in its neighborhood, then the pixel is determined to be a fish body outline point, i.e. a boundary pixel. Collect all fish body outline points to form a set of fish body boundary pixels B={(x1,y1),(x2,y2),...,(xn,yn)}.
6. The method for measuring fish body length according to claim 1, characterized in that, The modeling method for the fish's centerline in step S5 is as follows: Based on the extracted fish body contour points, the fish body centerline is modeled as a cubic polynomial function: y(x)=a0+a1x+a2x 2 +a3x 3 , Where a0, a1, a2, and a3 are the parameters to be fitted, the least squares method is used to solve the polynomial parameters to obtain the fitted fish body centerline.
7. The method for measuring fish body length according to claim 1, characterized in that, The method for calculating the fish body length Lgeo in step S6 is as follows: Along the fitted fish centerline, point by point is determined to see if the centerline point is located within the foreground region of the fish. The starting point is determined by the position where the centerline first enters the foreground region from the background region. The actual starting point (x) is obtained by combining the mapping relationship. s ,y s The endpoint is determined by the position where the center line enters the background area from the foreground region of the fish. The actual endpoint (x) is then obtained by combining this with the mapping relationship. e ,y e ); Determine the effective interval of the centerline between the starting and ending points [x] s ,x e ]; Taking the derivative with respect to the centerline, we obtain the first derivative function of the centerline; The curve length of the centerline within the effective interval is calculated using the arc length formula: 。 8. The method for measuring fish body length according to claim 1, characterized in that, The calculation method for the fish body length Larea in step S6 is as follows: The fish length Larea is obtained based on the area model: , in, This is the scaling factor; R is the aspect ratio of the circumscribed rectangle of the fish: , It is a very small positive number; For slenderness compensation index; Q represents the convex hull ratio, which is the proportion of the fish's body area to the convex hull area. , Where A hull It is the area of the convex hull; The bending compensation index; Area index; For bias terms; , , , , All data were obtained by fitting real fish sample data.
9. The method for measuring fish body length according to claim 1, characterized in that, In step S6, the fish body length Lgeo is fused with Larea using the quality factor to obtain the actual fish body length L, specifically: , Among them, quality factor ,for: , Among them, S Q The quality score based on Q is: , C represents roundness, which is: , P is the perimeter of the fish's outline, which is calculated using the set of boundary pixel coordinates B. S C The quality score based on C is: , F represents the area ratio of the fish body within the bounding rectangle, i.e., the fill ratio, which is: , S F For quality scores based on fill rate F , Where F mid It is the center value of the fill rate; It is the fill rate decay control parameter, and also the tolerable range of the fill rate; Q max Q min C max C min F max F min These are the maximum and minimum values of Q, C, and F in the fish fry samples; Linear layer parameters b0, b Q b C b F It was obtained by fitting fish fry samples.
10. A fish body length measurement system, characterized in that, It contains computer-executable instructions, which, when executed, are used to implement the method of any one of claims 1 to 9.
Citation Information
Patent Citations
High-throughput detection method for grain form parameters
CN103808263A
Non-contact estimation method for length of fish body
CN110298856A
Overlook fish body length monitoring method and device used in farm
CN114916473A
Fish body length estimation method and system based on feature fusion and point cloud transformation
CN118967574A
Method, system and equipment for detecting tilapia mossambica behavior through image
CN121214197A