Real-time non-destructive detection method and system for gender of underwater crabs based on image enhancement and computer vision

By using an underwater crab sex detection model based on YOLOv8 and combining it with image enhancement technology, the accuracy and applicability issues of crab sex detection in underwater environments have been solved, achieving real-time and accurate crab sex identification and supporting aquaculture management and resource utilization.

CN121921634BActive Publication Date: 2026-06-19CHINA AGRI UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA AGRI UNIV
Filing Date
2026-01-26
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

When existing technologies are used to detect the sex of crabs in underwater environments, the image quality is affected by light absorption, scattering, and color distortion, resulting in insufficient clarity, color distortion, and degradation of structural information, which limits the accuracy and applicability of the detection.

Method used

An underwater crab sex detection model based on YOLOv8 is adopted, which combines a cross-stage feature fusion module with coordinate attention mechanism and a local kernel context attention module to perform image enhancement processing, including color dynamic enhancement, color temperature correction, contrast and sharpness improvement and local enhancement. Feature fusion is performed through a weighted bidirectional feature pyramid network.

Benefits of technology

It improves the accuracy and robustness of underwater crab sex detection, realizes real-time non-destructive detection, meets the needs of actual aquaculture production, provides timely and accurate crab sex information, and supports management and germplasm resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121921634B_ABST
    Figure CN121921634B_ABST
Patent Text Reader

Abstract

This invention provides a real-time non-destructive method and system for underwater crab sex detection based on image enhancement and computer vision, relating to the field of image processing. The method includes: constructing and training an underwater crab sex detection model based on YOLOv8. The underwater crab sex detection model includes an input layer, a backbone network, a feature fusion layer, and a detection head. Both the backbone network and the feature fusion layer of the underwater crab sex detection model include a cross-stage feature fusion module incorporating a coordinate attention mechanism. Both the backbone network and the feature fusion layer embed local kernel context attention modules. The method also involves acquiring an image of the aquaculture area to be detected; enhancing the image of the aquaculture area to be detected based on a multi-dimensional fusion enhancement strategy to generate an enhanced image of the aquaculture area to be detected; and identifying the sex of crabs in the enhanced image of the aquaculture area to be detected using the trained underwater crab sex detection model. This method has the advantage of improving the accuracy of underwater crab sex detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing, and in particular to a method and system for real-time non-destructive detection of the sex of underwater crabs based on image enhancement and computer vision. Background Technology

[0002] In Asian aquaculture, the Chinese mitten crab (Eriocheir sinensis) is an important aquaculture species due to its rich nutrition and high economic value. Currently, polyculture is commonly used, but there are significant differences between male and female Chinese mitten crabs in terms of growth rate, gonadal development patterns, and nutritional requirements. Accurate and continuous monitoring of sex dynamics is of great significance for staged and precise feeding management, determining the optimal market time, and evaluating growth progress and quality indicators.

[0003] Traditional sex determination relies on manual external morphological observation, which is inefficient, labor-intensive, and prone to stress-induced damage to crabs, making it difficult to meet the demands of large-scale farming and efficient sales. Machine vision technology, with its advantages of real-time, non-destructive, and automated detection, is gradually being applied to aquaculture. Currently, most experiments are based on sex morphological feature classification, such as combining image processing, fuzzy logic, and K-nearest neighbor classifiers to analyze abdominal images, achieving an accuracy of 85%; some deep learning networks are used for individual and sex identification, with an average accuracy of 98.45%. However, these methods mostly rely on abdominal images, which greatly limits their application in unconstrained farming scenarios. At the same time, underwater imaging is affected by factors such as light absorption, scattering, and color distortion, resulting in problems such as decreased contrast and brightness, blue-green bias, image blurring, and loss of detail. This leads to insufficient clarity, color distortion, and degradation of structural information, greatly limiting visual quality and application potential. The lack of effective data augmentation methods severely restricts the applicability of models in underwater scenarios.

[0004] Therefore, there is a need to provide a real-time non-destructive detection method and system for underwater crab sex based on image enhancement and computer vision, in order to improve the accuracy of underwater crab sex detection. Summary of the Invention

[0005] This invention provides a real-time non-destructive method for underwater crab sex detection based on image enhancement and computer vision, comprising: constructing and training an underwater crab sex detection model based on YOLOv8, wherein the underwater crab sex detection model includes an input layer, a backbone network, a feature fusion layer, and a detection head; both the backbone network and the feature fusion layer of the underwater crab sex detection model include a cross-stage feature fusion module incorporating a coordinate attention mechanism; both the backbone network and the feature fusion layer embed a local kernel context attention module; acquiring an image of the aquaculture area to be detected; enhancing the image of the aquaculture area to be detected based on a multi-dimensional fusion enhancement strategy to generate an enhanced image of the aquaculture area to be detected; and identifying the sex of crabs in the enhanced image of the aquaculture area to be detected using the trained underwater crab sex detection model.

[0006] Furthermore, the cross-stage feature fusion module that introduces a coordinate attention mechanism includes a first convolutional layer, a segmentation layer, a coordinate attention mechanism, multiple stacked bottleneck units, a connection layer, and a second convolutional layer connected in sequence, wherein the segmentation layer is also connected to the connection layer.

[0007] Furthermore, the local kernel context attention module includes an input layer, a first two-dimensional convolution, a GELU activation function, a large kernel attention mechanism, a second two-dimensional convolution, and an output layer connected in sequence. The large kernel attention mechanism includes a deep convolution layer, an expanded deep convolution layer, and a 1x1 convolution layer. The output of the GELU activation function is multiplied element-wise by the output of the 1x1 convolution layer.

[0008] Furthermore, the feature fusion layer introduces a weighted bidirectional feature pyramid network to replace the connection module.

[0009] Furthermore, based on a multi-dimensional fusion enhancement strategy, the image of the aquaculture area to be detected is enhanced to generate an enhanced image of the aquaculture area to be detected. This includes: performing dynamic color enhancement and color temperature correction on the image of the aquaculture area to be detected to generate an image of the aquaculture area to be detected after the first stage of processing; performing contrast and sharpness enhancement processing on the image of the aquaculture area to be detected after the first stage of processing to generate an image of the aquaculture area to be detected after the second stage of processing; and performing local enhancement processing on the image of the aquaculture area to be detected after the second stage of processing to generate an enhanced image of the aquaculture area to be detected.

[0010] Furthermore, the image of the aquaculture area to be detected is subjected to dynamic color enhancement and color temperature correction to generate the image of the aquaculture area to be detected after the first stage of processing. This includes: using an adaptive color compensation algorithm to dynamically enhance the color of the image of the aquaculture area to be detected, generating the image of the aquaculture area to be detected after dynamic color enhancement; converting the image of the aquaculture area to be detected after dynamic color enhancement from the RGB color space to the Lab color space, and using an adaptive white balance algorithm to correct the color temperature, generating the image of the aquaculture area to be detected after the first stage of processing.

[0011] Furthermore, the image of the aquaculture area to be detected after the first stage of processing is subjected to contrast and sharpness enhancement processing to generate the image of the aquaculture area to be detected after the second stage of processing. This includes: adaptively adjusting the contrast of the image of the aquaculture area to be detected after the first stage of processing using the Sigmoid function to generate a contrast-enhanced image of the aquaculture area to be detected; enhancing the details of the image of the aquaculture area to be detected using the GaussianBlur function to generate a detail-enhanced image of the aquaculture area to be detected; and fusing the contrast-enhanced image of the aquaculture area to be detected and the detail-enhanced image of the aquaculture area to be detected using non-subsampled contourlet transform to generate the image of the aquaculture area to be detected after the second stage of processing.

[0012] Furthermore, the image of the aquaculture area to be detected after the second stage of processing is subjected to local enhancement processing to generate an enhanced image of the aquaculture area to be detected. This includes: dividing the image of the aquaculture area to be detected after the second stage of processing into multiple sub-regions, performing histogram equalization independently within each sub-region based on contrast limiting, and generating an enhanced image of the aquaculture area to be detected.

[0013] This invention provides a real-time non-destructive underwater crab sex detection system based on image enhancement and computer vision, comprising: a model building module for constructing and training an underwater crab sex detection model based on YOLOv8, wherein the underwater crab sex detection model includes an input layer, a backbone network, a feature fusion layer, and a detection head; both the backbone network and the feature fusion layer of the underwater crab sex detection model include a cross-stage feature fusion module incorporating a coordinate attention mechanism; and both the backbone network and the feature fusion layer embed a local kernel context attention module; an image preprocessing module for acquiring an image of the aquaculture area to be detected, and enhancing the image of the aquaculture area to be detected based on a multi-dimensional fusion enhancement strategy to generate an enhanced image of the aquaculture area to be detected; and a sex detection module for identifying the sex of crabs in the enhanced image of the aquaculture area to be detected using the trained underwater crab sex detection model.

[0014] Compared with existing technologies, the underwater crab sex real-time non-destructive detection method and system based on image enhancement and computer vision provided by this invention has at least the following beneficial effects:

[0015] 1. A cross-stage feature fusion module with coordinate attention mechanism and a local kernel context attention module are introduced into the backbone network and feature fusion layer. The coordinate attention mechanism enhances the model's sensitivity to feature location information, the cross-stage feature fusion module facilitates full interaction of features from different stages, and the local kernel context attention module strengthens the capture of global context information and attention to key structures. Simultaneously, a weighted bidirectional feature pyramid network is introduced to replace the connection module in the feature fusion layer, realizing cross-scale bidirectional information flow and dynamic feature weighting, effectively improving the model's feature fusion and representation capabilities for crab targets in complex backgrounds, thereby improving the accuracy and robustness of gender detection.

[0016] 2. A multi-dimensional fusion enhancement strategy is employed to process images from the aquaculture area in multiple stages. Dynamic color enhancement and color temperature correction compensate for underwater light attenuation and color cast, improving color accuracy. Contrast and sharpness enhancement improve image details and overall clarity. Local enhancement further mitigates the effects of forward scattering. This strategy optimizes image quality from multiple dimensions, providing the model with clearer and more accurate input, which helps the model better identify crab sex characteristics and improve detection accuracy.

[0017] 3. Real-time, non-destructive detection of crab sex underwater has been achieved. While ensuring detection accuracy, it also meets real-time requirements, making it applicable to actual aquaculture production. It provides timely and accurate information on crab sex, offering strong support for aquaculture management and germplasm resource utilization, and possesses high practical value and economic benefits. Attached Figure Description

[0018] This specification will be further described by way of exemplary embodiments, which will be described in detail with reference to the accompanying drawings. These embodiments are not limiting; in these embodiments, the same reference numerals denote the same structures, wherein:

[0019] Figure 1 This is a flowchart illustrating a real-time non-destructive detection method for the sex of underwater crabs based on image enhancement and computer vision, according to some embodiments of this specification.

[0020] Figure 2 This is a structural schematic diagram of an underwater crab sex detection model according to some embodiments of this specification;

[0021] Figure 3 This is a schematic diagram of the structure of a cross-stage feature fusion module that incorporates a coordinate attention mechanism, as shown in some embodiments of this specification.

[0022] Figure 4 This is a schematic diagram of the structure of a local kernel context attention module according to some embodiments of this specification;

[0023] Figure 5This is a schematic diagram of the loss curves shown in some embodiments according to this specification;

[0024] Figure 6 This is a schematic diagram of the visualization results of gender detection for multiple models shown in some embodiments of this specification;

[0025] Figure 7 This is a schematic diagram of a module of an underwater crab sex real-time non-destructive detection system based on image enhancement and computer vision, as shown in some embodiments of this specification. Detailed Implementation

[0026] To more clearly illustrate the technical solutions of the embodiments in this specification, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are merely some examples or embodiments of this specification. For those skilled in the art, these drawings can be applied to other similar scenarios without creative effort. Unless obvious from the linguistic context or otherwise specified, the same reference numerals in the drawings represent the same structures or operations.

[0027] Figure 1 This is a flowchart illustrating a real-time non-destructive detection method for underwater crab sex based on image enhancement and computer vision, as shown in some embodiments of this specification. Figure 1 As shown, a real-time non-destructive detection method for the sex of underwater crabs based on image enhancement and computer vision can include the following process.

[0028] Step 110: Based on YOLOv8, construct an underwater crab sex detection model and train it.

[0029] like Figure 2 As shown, the underwater crab sex detection model (BLC-YOLOv8n) includes an input layer, a backbone network, a feature fusion layer, and a detection head.

[0030] Specifically, the input layer introduces Mosaic data augmentation (generating diverse training samples by stitching together four images) and adaptive image scaling (dynamically adjusting the input resolution according to the target size), which significantly improves the model's generalization ability and robustness to different underwater scenarios (such as changes in lighting and interference from suspended particles).

[0031] The backbone network continues the deep convolutional structure of DarkNet53, constructing a deep feature extraction network through 53 layers of residual connections, effectively alleviating the gradient vanishing problem and supporting the transmission of deep semantic information. Multi-scale convolutional kernels (such as 3×3 and 5×5) and strided convolutions are used to abstract crab shell features layer by layer, achieving efficient capture from low-level textures (such as carapace patterns) to high-level semantics (such as sex-related morphological differences). To address the blurring problem in underwater imaging, deformable convolutions are introduced to dynamically adjust the sampling position of the convolutional kernels, enhancing the feature extraction capability for irregular structures such as crab shell edges.

[0032] The feature fusion layer (Neck) combines FPN (Feature Pyramid Network) (which propagates strong semantic features from top to bottom) and PAN (Path Aggregation Network) (which propagates strong localization features from bottom to top) to construct a bidirectional feature pyramid structure. Through lateral connections and adaptive weighted fusion, the interaction between features at different levels (such as the overall morphology of the crab shell at higher levels and the local texture at lower levels) is enhanced, significantly improving the detection accuracy for small targets (such as juvenile crabs or localized crab shell regions). During feature fusion, a Convolutional Block Attention Module (CBAM) is introduced to dynamically focus on sex-related features (such as abdominal morphological changes caused by ovarian development in female crabs) through channel and spatial attention mechanisms, suppressing background noise interference.

[0033] The detection head separates the bounding box regression and class classification tasks, using independent convolutional layers for optimization. This avoids parameter conflicts between multiple tasks, improves model stability, and further enhances the model's robustness in underwater crab sex identification.

[0034] In underwater environments with insufficient lighting and complex backgrounds, existing detection models face challenges in extracting and utilizing effective feature information, manifested in problems such as insufficient target representation ability and decreased detection accuracy. To enhance the model's ability to perceive key crab shell regions in complex environments, the backbone network and feature fusion layer of the underwater crab sex detection model both include a cross-stage feature fusion module (C2f_CA) that incorporates a coordinate attention mechanism.

[0035] like Figure 3As shown, the cross-stage feature fusion module (C2f_CA) that introduces a coordinate attention mechanism includes a first convolutional layer, a segmentation layer, a coordinate attention mechanism, multiple stacked bottleneck units, a connection layer, and a second convolutional layer connected in sequence. The segmentation layer is also connected to the connection layer.

[0036] Specifically, the cross-stage feature fusion module (C2f_CA) that introduces coordinate attention mechanism is based on the cross-stage feature fusion structure (C2f). It embeds coordinate attention mechanism (CA) in front of multiple stacked bottleneck units to form an enhanced unit of "channel-space joint modeling". The core process is as follows: The input feature map is first processed by the first convolutional layer for preliminary feature extraction. Then, the feature is split into horizontal and vertical components along the spatial dimension by the segmentation layer, which encode position information respectively. The coordinate attention mechanism dynamically calculates the horizontal and vertical spatial attention weights based on the split features to generate an attention map with position awareness. This mechanism not only retains the inter-channel correlation of traditional channel attention, but also achieves fine modeling of spatial features by embedding spatial coordinate information (such as the relative position of the crab shell edge), effectively alleviating the problem of spatial information loss caused by insufficient lighting or background interference. After the attention map is multiplied element-wise with the original feature map, it is subjected to deep feature abstraction through multiple stacked bottleneck units. These units strengthen gradient flow through residual connections to avoid degradation of deep networks. Subsequently, the connection layer re-integrates the features of the horizontal and vertical branches to restore the complete spatial structure. Finally, the enhanced feature map is output through the second convolutional layer.

[0037] Traditional attention mechanisms (such as the SE module) only focus on the channel dimension, while CA explicitly encodes spatial location information (such as the horizontal texture and vertical contour of the crab shell) into the feature map through segmentation layers and attention weight calculations. This allows the model to more accurately focus on salient structures of the crab shell (such as the abdominal bulge of female crabs or the claw features of male crabs) and reduce interference from complex backgrounds (such as aquatic plants and rocks). The stacked bottleneck units adopt cross-stage partial connections, with some features directly passed to subsequent stages, avoiding redundant calculations while retaining multi-scale information and improving feature extraction efficiency. Through element-wise multiplication of the attention map and the feature map, the model can adaptively adjust the feature response intensity at different locations (such as the center and edges of the crab shell), strengthen the expression of sex-related semantic features (such as texture changes caused by ovarian development), and suppress irrelevant environmental signals.

[0038] Both the backbone network and the feature fusion layer embed local kernel context attention modules.

[0039] like Figure 4As shown, the Local Kernel Context Attention (LKCA) module includes an input layer, a first two-dimensional convolution, a GELU activation function, a large kernel attention mechanism, a second two-dimensional convolution, and an output layer connected in sequence. The large kernel attention mechanism includes a deep convolution layer, an expanded deep convolution layer, and a 1x1 convolution layer. The output of the GELU activation function is multiplied element-wise by the output of the 1x1 convolution layer.

[0040] Specifically, to address the confusion caused by the complex shell structure and high similarity between the edges and chelipeds / legs in underwater crab sex detection, the underwater crab sex detection model embeds a Large Kernel Conv2D Attention (LKCA) module in the backbone network and feature fusion layer. By enhancing global context awareness and multi-scale feature fusion capabilities, the model significantly improves its ability to distinguish key shell structures.

[0041] The local kernel context attention module is based on "local-global collaborative modeling." Its process is as follows: the input feature map is first subjected to a first two-dimensional convolution for preliminary feature extraction. Then, the features are non-linearly transformed and mean-scaled using the GELU activation function, preserving low-level texture details while suppressing noise interference, providing a more stable feature base for subsequent attention calculations. The large kernel attention mechanism, as the core of the module, consists of a deep convolutional layer (DW-Conv) and a dilated deep convolutional layer (Dilated Depthwise Convolution). The system consists of a convolutional layer (DW-D-Conv) and a 1×1 convolutional layer. The deep convolutional layer extracts local spatial features through channel-wise convolution. The expanded deep convolutional layer expands the receptive field to 7×7 or even larger using dilated sampling, covering the global structure of the crab shell (such as the overall outline and the distribution of chelicerae). The 1×1 convolutional layer performs inter-channel information interaction to generate initial attention weights. To further enhance the response in key regions, the local kernel context attention module performs element-wise multiplication of the output of the GELU activation function (including detailed information) with the output of the 1×1 convolutional layer (including global weights), dynamically adjusting the weight value at each position in the feature map. This makes the model more focused on sex-related regions such as the edges of the crab shell and texture mutations (such as the abdominal groove of the female crab or the spines of the male crab's pincers), while suppressing interference from similar structures such as chelicerae and walking legs. Finally, the feature map enhanced by the second two-dimensional convolution is output to the next stage.

[0042] like Figure 1As shown, to address the issues of crab shell targets being easily affected by background interference in complex underwater environments and the decline in gender detection accuracy due to insufficient multi-scale feature fusion, a weighted bidirectional feature pyramid network (BiFPN) is introduced in the feature fusion layer to replace the connection module (Concat).

[0043] Traditional Concat modules transmit features only through unidirectional paths (such as top-down or bottom-up), resulting in insufficient interaction between shallow and deep layers. BiFPN, however, introduces bidirectional connections, both horizontally and vertically, enabling high-level semantic features (such as the overall outline of a crab shell) and low-level detailed features (such as shell texture) to interact repeatedly across multiple scales. This creates a synergistic enhancement effect where "deep layers guide shallow layer localization, and shallow layers enrich deep layer semantics." For example, when detecting small-scale juvenile crabs, high-resolution shallow features can transmit edge details to deeper layers through bidirectional paths, helping to correct localization errors caused by downsampling of high-level features. Simultaneously, deep semantic features can suppress shallow background noise (such as aquatic plants and suspended particles), highlighting key areas of the crab shell.

[0044] To address the issue of high-level information being diluted by low-level details during feature fusion, BiFPN further proposes a fast normalization and adaptive weighting strategy: On each cross-scale connection path, the model dynamically calculates the weights of features at different resolutions through fast normalization. These weights are generated based on the statistical information of the feature channels (such as mean and variance), requiring no additional parameter training and balancing efficiency and adaptability. Subsequently, an adaptive weighting module performs a weighted summation of the input features, ensuring that more important features (such as crab shell edges and sex-related textures) dominate the fusion process, avoiding excessive interference from irrelevant low-level details (such as background textures). For example, in low-light scenes, the model can automatically increase the weights of high-level semantic features, strengthening the perception of the blurred crab shell contour; while in high-contrast regions, it enhances the contribution of low-level detail features, capturing subtle sex differences (such as the depth of the abdominal groove in female crabs).

[0045] In the design of the loss function, adaptive weighting coefficients are introduced for each part of the loss function (e.g., location loss, category loss, and confidence loss) to focus on key regions or tasks. Weighting coefficients for regions of interest, such as crab shell edges and gender features, are added to enhance the network's training on key regions (e.g., crab shell edges) and target features.

[0046] The weighting coefficients were determined through experimental tuning and feature importance analysis. The weighting coefficients for position loss, category loss, and confidence loss were adjusted based on the criticality of the target region, with higher weighting coefficients assigned to crab shell edges and sex-specific regions. These coefficients were validated through cross-experiments to ensure the model's efficiency and stability at different training stages. Finally, adaptive weighting coefficients were used to optimize the model's detection accuracy and robustness in complex underwater environments.

[0047] The positional loss measures the difference in position between the predicted and ground truth bounding boxes. For important regions (such as the edges of a crab shell), increasing the weighting factor of the positional loss allows the model to focus more on the precise localization of these regions, thus improving localization accuracy. The category loss measures the difference between the predicted and ground truth categories. In underwater crab sex identification tasks, sex-related feature regions (such as features distinguishing male and female crabs) are more important. The confidence loss measures the model's confidence in the existence of the target bounding box. To improve the model's confidence predictions in key regions, higher confidence loss weighting factors can be assigned to these regions, ensuring the model can better identify important sex features.

[0048] Step 120: Obtain an image of the aquaculture area to be detected.

[0049] Step 130: Based on the multi-dimensional fusion enhancement strategy, the image of the aquaculture area to be detected is enhanced to generate an enhanced image of the aquaculture area to be detected.

[0050] Specifically, it includes:

[0051] The image of the aquaculture area to be detected is subjected to dynamic color enhancement and color temperature correction to generate the image of the aquaculture area to be detected after the first stage of processing.

[0052] The contrast and sharpness of the aquaculture area image to be detected after the first stage of processing are improved to generate the aquaculture area image to be detected after the second stage of processing.

[0053] The image of the aquaculture area to be detected after the second stage of processing is locally enhanced to generate an enhanced image of the aquaculture area to be detected.

[0054] In some embodiments, color dynamic enhancement and color temperature correction are performed on the image of the aquaculture area to be detected to generate a processed image of the aquaculture area to be detected, including:

[0055] An adaptive color compensation algorithm is used to dynamically enhance the color of the aquaculture area image to be detected, generating a dynamically enhanced image of the aquaculture area to be detected.

[0056] The image of the aquaculture area to be detected, after dynamic color enhancement, is converted from the RGB color space to the Lab color space, and an adaptive white balance algorithm is used for color temperature correction to generate the image of the aquaculture area to be detected after the first stage of processing.

[0057] Specifically, to address the color distortion problem caused by the varying degrees of attenuation of different wavelengths of light propagating in water in underwater environments, an adaptive color compensation algorithm is employed to dynamically enhance the color of images. This algorithm analyzes the pixel distribution characteristics of each channel (e.g., red, green, and blue) in the image, combines this with an underwater light attenuation model, and dynamically adjusts the gain coefficient of each channel. It prioritizes compensating for wavelengths with severe attenuation (e.g., red light attenuates rapidly underwater), thereby balancing the attenuation effects of different wavelengths, enhancing the color gradation and contrast of the image, and generating a dynamically enhanced image. For example, in turbid water, the pixel value of the red channel may be significantly lower than other channels; the algorithm will specifically increase the brightness of the red channel to restore the natural color proportions.

[0058] To further correct color temperature deviations (such as overall tone shifts caused by underwater light sources leaning towards blue or green), the dynamically enhanced image is converted from the RGB color space to the Lab color space. The Lab space is designed based on human visual characteristics, where the L channel represents luminance, and the a and b channels represent the contrasting dimensions of red-green and yellow-blue, respectively. This allows for more independent processing of luminance and chromaticity information, avoiding the coupling problem between color adjustment and luminance changes in the RGB space. In the Lab space, an adaptive white balance algorithm is used for color temperature correction. This algorithm combines the advantages of the gray-world assumption (assuming no color shift in the overall average reflectance of the image, achieving white balance by balancing the average values ​​of each channel) and the maximum perfect reflectance model (assuming a point with maximum reflectance corresponding to white in the image, correcting the color temperature by locating this point). By constructing a quadratic mapping matrix and combining the characteristics of the underwater crab image (such as the reflectivity of the crab shell surface and the color distribution of the background water) to predict the proportion of white pixels, it adaptively selects the optimal white balance strategy. For example, in aquaculture areas with a large amount of green algae in the background, the algorithm will prioritize the color distribution of high-reflectance areas such as the crab shell, avoiding over-correction by misjudging green as a natural color. Ultimately, the color temperature-corrected image effectively compensates for the color shift caused by underwater lighting conditions (such as the color temperature of artificial light sources and the penetration depth of natural light) and the attenuation of the transmission medium (such as water turbidity and suspended particles), generating the first-stage processed image of the aquaculture area to be detected, providing more accurate color and texture information for subsequent target detection (such as crab sex identification).

[0059] In some embodiments, the image of the aquaculture area to be detected after the first stage processing is subjected to contrast and sharpness enhancement processing to generate an image of the aquaculture area to be detected after the second stage processing, including:

[0060] The contrast of the aquaculture area image to be detected is adaptively adjusted by using the Sigmoid function after the first stage of processing, resulting in a contrast-enhanced image of the aquaculture area to be detected.

[0061] The GaussianBlur function is used to perform unsharpened mask detail enhancement on the aquaculture area image to be detected after the first stage of processing, generating a detail-enhanced aquaculture area image to be detected.

[0062] Using non-subsampled contourlet transform, the contrast-enhanced and detail-enhanced images of the aquaculture area to be detected are fused to generate the second-stage processed image of the aquaculture area to be detected.

[0063] Specifically, based on the characteristic of high proportion of dark areas in underwater images, the center point of contrast change is set to 0.4, and a dynamic nonlinear transformation is performed on the image of the aquaculture area to be detected after the first stage of processing. This operation significantly improves the visibility of details in low-brightness areas such as crab shell texture and edges by stretching the distribution range of pixel values ​​in dark areas, while compressing the dynamic range of bright areas (such as water surface reflections and overexposed areas of artificial light sources) to avoid loss of details caused by local overexposure, ultimately generating an image with enhanced contrast.

[0064] The unsharp masking detail enhancement channel is started in parallel. First, the image is smoothed and filtered using a 5×5 Gaussian kernel to extract low-frequency components (i.e., the blurred background and overall structure). Then, the high-frequency residual signal (containing details such as edges and textures) is calculated by the difference between the original image and the low-frequency components, and the residual is enhanced by a gain of 1.5 (an empirical value that balances detail enhancement and noise suppression). Finally, the enhanced high-frequency signal is superimposed on the original image, which sharpens the crab shell spines, joints and other small structures while preserving the overall color tone of the image. At the same time, the Gaussian filtering preprocessing effectively suppresses interference from underwater suspended particles, sensor noise and other factors, generating an image with enhanced details.

[0065] Non-subsampled contourlet transform (NSCT), as a multi-directional, multi-resolution image decomposition tool, can decompose contrast-enhanced images and detail-enhanced images into low-frequency sub-bands (overall structure) and high-frequency sub-bands (directional details), respectively. By using weighted fusion rules (such as averaging the low-frequency sub-bands and weighting the high-frequency sub-bands according to detail sharpness), the advantageous features of the contrast-enhanced and detail-enhanced images of the aquaculture area to be detected are merged. This avoids the local tone distortion that may be caused by Sigmoid adjustment and makes up for the lack of global contrast enhancement by unsharpened masks.

[0066] In some embodiments, the image of the aquaculture area to be detected after the second stage processing is subjected to local enhancement processing to generate an enhanced image of the aquaculture area to be detected, including:

[0067] The image of the aquaculture area to be detected after the second stage of processing is divided into multiple sub-regions. Based on contrast limiting, histogram equalization is performed independently within each sub-region to generate an enhanced image of the aquaculture area to be detected.

[0068] Specifically, to further mitigate the impact of forward scattering (light is scattered by suspended particles when it propagates in water, resulting in blurred target edges and reduced contrast) on image quality in underwater imaging, this experiment introduced Limited Contrast Adaptive Histogram Equalization (CLAHE) based on OpenCV to perform local enhancement processing on the aquaculture area images after the second stage of processing, generating the final enhanced image. First, the image is divided into multiple non-overlapping sub-regions (such as 8×8 or 16×16 pixel blocks). Local analysis replaces global processing, avoiding the overexposure or underexposure problems caused by excessive stretching of the overall image in traditional histogram equalization (HE). Then, a grayscale histogram is calculated independently in each sub-region, and the histogram is cropped and redistributed based on a set contrast limiting parameter (such as 2.0, which limits the proportion of a single gray level in the histogram to suppress excessive local contrast enhancement). This ensures that the enhanced pixel value distribution conforms to the local lighting characteristics and avoids excessive amplification of noise (such as underwater suspended particles and sensor thermal noise). Finally, bilinear interpolation is used to smoothly blend the enhancement results of each sub-region, eliminating block effects and generating an image with balanced overall brightness and clear local details. To address the brightness difference between the crab shell region (high reflectivity) and the background water area (low reflectivity) in underwater images, sub-region segmentation ensures independent optimization of local areas under different lighting conditions. For example, histogram stretching is used to enhance contrast and highlight texture features in dark areas such as the crab shell edge; while over-enhancement is suppressed in bright areas (such as water surface reflections) by limiting amplitude to preserve structural information.

[0069] Step 140: Using the trained underwater crab sex detection model, identify the sex of crabs in the enhanced image of the aquaculture area to be detected.

[0070] The following section uses experimental data to illustrate the beneficial effects of a real-time, non-destructive method for detecting the sex of underwater crabs based on image enhancement and computer vision.

[0071] The data used in this experiment were collected from a Chinese mitten crab farming base, with farmed Chinese mitten crabs as the experimental subjects. Data collection took place in May and August, with images and videos collected for one week in each batch. During the experiment, a total of 256 crabs of different sizes were randomly caught from the farming ponds, including 136 males and 120 females. The sex of all individuals was identified by aquaculture experts to ensure the accuracy of sex labeling. To enhance data diversity and model generalization ability, image samples were collected under various background conditions, including a single black background and a complex background simulating a natural farming environment (with natural sand and aquatic plants). In addition, to support multi-target sex recognition experiments, multi-target images were simultaneously collected under a single background.

[0072] To quantitatively evaluate the effectiveness of underwater image enhancement, this experiment combined full-reference and no-reference image quality evaluation metrics, comprehensively assessing multiple dimensions including image structure restoration, color fidelity, and visual quality. Specifically, these included the Structural Similarity Index (SSIM), Underwater Color Image Quality Evaluation (UCIQE), and Underwater Image Quality Measure (UIQM). A higher SSIM value indicates greater structural similarity between the image and the original image; higher UCIQE and UIQM values ​​indicate better visual quality.

[0073] To evaluate the performance of the underwater crab sex detection model, this experiment selected precision (P), recall (R), F1 score, mean average precision (mAP), and frames per second (FPS) as performance metrics. FPS measures the inference speed of the sex detection model, i.e., the number of image frames processed per second, representing the real-time performance of the detection algorithm. Precision measures the proportion of correctly predicted positive class samples, while recall measures the proportion of successfully identified positive class samples. mAP is the average precision (AP) across multiple classes, comprehensively reflecting the sex detection model's ability to detect different classes.

[0074] To construct a dataset for crab sex detection, image samples were randomly extracted from videos. Specifically, 2,560 images of a single crab and 500 images of multiple crabs were extracted against a single black background. To enhance the model's robustness against complex backgrounds, 800 images were randomly extracted from a simulated experimental environment with natural sand and aquatic plants. To further verify the applicability of the proposed method in real-world aquaculture scenarios, 300 images were randomly extracted from actual pond cage culture videos. Finally, a diverse dataset containing 4,160 images of Chinese mitten crabs was constructed, covering crab images of varying numbers, poses, and background complexity.

[0075] Because crab claws and legs are often hidden under their shells, making them difficult to identify and analyze, this experiment primarily focused on labeling the crab shell area to minimize interference from irrelevant background information. Images were manually labeled, and all labeled data was saved in YOLO format, including target category, bounding box coordinates, and image size, providing a reliable data foundation for subsequent model training and evaluation. After labeling, the images were randomly divided into training, validation, and test sets in a 7:2:1 ratio. YOLOv8n was used as the baseline model in the experiment, and the basic experimental parameters are shown in Table 1.

[0076] Table 1 Basic Experimental Parameters

[0077]

[0078] This experiment employs an image-centric training scheme, selecting the lightweight and highly efficient YOLOv8n network architecture for object detection modeling. Training utilizes a stochastic gradient descent (SGD) optimizer with an initial learning rate of 0.01 to support dynamic convergence at different training stages. To further enhance stability and accelerate convergence in the early stages of training, a learning rate warm-up and smoothing strategy is introduced. The momentum coefficient is set to 0.9, and the weight decay coefficient to 0.0001 to suppress overfitting and improve model robustness. Training is conducted in mini-batch format with a batch size of 16 and a total of 150 training epochs. During training, the learning rate warm-up and decay strategies, combined with a curriculum learning strategy, are used to gradually increase the learning rate, helping the model smoothly transition in the early stages of training and decrease the learning rate later to ensure stable convergence. The curriculum learning strategy aims to guide the model from simple to complex samples, enabling it to learn basic features in the early stages of training and gradually adapt to more challenging tasks. Specifically, in the initial training phase, the model is only exposed to image samples with simple backgrounds, high contrast, and clearly visible crab targets to ensure stable learning of basic gender-related features. As training progresses, underwater images with uneven lighting and complex backgrounds, or scenes with target occlusion, are gradually introduced to improve the model's ability to extract gender features in complex environments. In the advanced task phase, the model begins to handle multi-target detection and gender recognition tasks in complex backgrounds, further improving the model's accuracy and robustness. Appropriate momentum coefficients (0.9) and weight decay coefficients (0.0001) are set in the optimizer to avoid overfitting and accelerate the training process.

[0079] Figure 5 shows the loss curves of the YOLOv8n model during training using the original image and the enhanced image processed by the multi-dimensional fusion enhancement strategy proposed in this method, including training loss and validation loss. It can be seen that in the first 20 epochs, both training loss and validation loss decrease rapidly, indicating that the model can quickly learn the key features in the crab sex recognition task. Thereafter, the loss values ​​gradually enter a stable phase, stabilizing after about 100 epochs with small fluctuations, showing good convergence performance. Around 140 epochs, all loss curves tend to be horizontal, indicating that the model has reached a relatively optimal training state. It is worth noting that throughout the training process, the loss curves corresponding to the original image and the enhanced image show basically the same trend, and the validation loss always closely follows the training loss with a small difference, showing no obvious overfitting or underfitting. The validation loss only fluctuates slightly within a limited range, further indicating that the model has good generalization ability to different data distributions. In contrast, the training and validation losses for augmented images are generally slightly lower than those for the original images, indicating that augmented images are beneficial for feature extraction and make the model more robust in recognition under complex backgrounds.

[0080] To improve the recognizability and sex identification performance of crab images in complex underwater environments, this experiment performed image enhancement processing on original images collected in different typical scenarios. The image samples before and after enhancement cover four representative environmental conditions: Group a represents environments with a single background; Group b represents multi-target scenes with a single background; Group c represents scenes with a complex background; and Group d represents scenes from real aquaculture environments, representing turbid water and low visibility conditions. To comprehensively evaluate the enhancement effect, this experiment systematically compared and analyzed the quality of images before and after enhancement, combining subjective visual perception with objective evaluation indicators.

[0081] The enhanced image processed by the multi-dimensional fusion enhancement strategy proposed in this method exhibits significant advantages in contrast improvement, color restoration, and detail preservation. Especially in Group c and Group d scenes, the crab target in the original image is almost indistinguishable from the complex background, while after enhancement, its contour edges are clearer, color distortion is effectively mitigated, and target saliency is significantly improved (as shown in the red circle in the figure). Furthermore, in the multi-target scene of Group b, the enhancement algorithm effectively enhances the boundary separation between targets and reduces recognition interference caused by overlap, thus providing a clearer and more reliable input foundation for subsequent refined detection and recognition tasks.

[0082] The image quality evaluation metrics are shown in Table 2. The results show that the enhancement process significantly improved image quality in all image groups. Specifically, the UIQM score generally improved by approximately 1.5 to 2.0 points, indicating an effective improvement in the overall visual perception quality of the images. The UCIQE value increased from a minimum of 0.2303 to a maximum of 0.4234, reflecting comprehensive optimization in dimensions such as color saturation, color contrast, and edge sharpness. The improvement was most significant in Group d, validating the adaptability and robustness of the proposed method under low visibility conditions.

[0083] Table 2 Image Quality Evaluation

[0084]

[0085] Furthermore, the SSIM metric is used to measure the consistency of structural features before and after image enhancement. As shown in Table 2, the SSIM of all enhanced images in the group is higher than 0.75, with Group c reaching the highest value of 0.7904. This indicates that the enhancement method effectively improves image quality while preserving the structural information of the original image well, without introducing obvious artifacts or information loss.

[0086] Combined subjective visual evaluation and objective index analysis show that the proposed image enhancement method exhibits stable and significant improvement effects in various complex underwater scenarios. This method not only enhances image visibility and information fidelity but also provides clearer and higher-quality input images for subsequent tasks such as crab target detection and gender recognition.

[0087] This experiment compared and evaluated the detection performance of the YOLOv8n model on two datasets: original images and enhanced images. The results are shown in Table 3. On the original images, the YOLOv8n model achieved a precision of 91.92% and a recall of 93.546%, with an F1-score of 92.72%, and mAP@0.50 and mAP@0.50:0.95 of 95.65 and 84.15, respectively. This indicates that the model already possesses strong detection capabilities without image enhancement. When the image enhancement strategy is applied, the model improves on all evaluation metrics. Image enhancement increases recall by 1.07%, while precision decreases slightly by 0.37%. This indicates that image enhancement reduces the false negative rate by enriching the details of the crab shell (such as texture and edges), but may introduce a small number of false positives due to slight noise. The improvement in F1-score verifies the effective balance between precision and recall achieved by the enhancement strategy. More significantly, mAP@0.50 and mAP@0.50:0.95 improved by 1.36% and 2.46%, respectively. This result demonstrates that image enhancement helps improve the model's generalization ability and detection accuracy, especially under the more stringent mAP@0.50:0.95 metric, where the model's performance is significantly improved across multiple IoU thresholds. This verifies the significant optimization of bounding box localization accuracy by image enhancement, particularly its robustness enhancement in complex scenes (such as target overlap and scale variation).

[0088] Table 3 Detection Performance

[0089]

[0090] To further verify the effectiveness of image augmentation in crab sex detection, tests were conducted in various typical underwater scenarios. The results show that, under the same test conditions, the model trained on augmented images exhibits superior performance. In scenarios with multiple crabs, the model not only detected a greater number of individuals on the augmented image data but also significantly reduced the false negative rate. In complex backgrounds (such as aquatic plants and sandy environments) and low-resolution actual aquaculture scenarios, the augmented model maintained high detection accuracy on the augmented image data, accurately identifying target individuals; while the model on the original image was prone to false negatives or significant bounding box deviations. Image augmentation not only significantly improved the model's detection rate and robustness in multi-target and complex environments but also reduced sensitivity to non-target interference factors, comprehensively improving the accuracy and practicality of sex detection.

[0091] To verify the impact of the proposed improvement modules on model performance, this experiment used the same dataset and hardware / software environment, with YOLOv8n as the baseline model, and conducted ablation experiments on the detection performance of different improvement modules in turn. The specific ablation experiment results are shown in Table 4, where "√" indicates that the improvement was used, and "-" indicates that the improvement was not used.

[0092] Table 4 Ablation Test Results

[0093]

[0094] As can be clearly seen from Table 4, after introducing the CA module alone (Model 2), the model's F1-score slightly decreased to 92.88%, but the mAP@0.5 significantly improved to 97.48%, and the mAP@0.5:0.95 also increased to 87.46%. This indicates that although the channel attention mechanism has a limited impact on the overall balanced accuracy (F1-score), it significantly enhances the model's localization ability and robustness under multiple thresholds. The model with the LKCA module introduced (Model 3) achieved a significant improvement in precision, reaching 92.91%, indicating that this module helps reduce the false positive rate. However, its mAP@0.5 was 96.59%, slightly lower than the baseline, and the F1-score decreased to 91.71%, showing that it is more advantageous in improving judgment accuracy, but may have sacrificed some recall ability. Model 4, which introduces the BiFPN structure alone, performs well in terms of recall (93.53%) and F1-score (91.69%), similar to the baseline. This indicates that while introducing BiFPN alone enhances feature fusion, its improvement on overall detection performance is relatively limited.

[0095] To further verify the synergistic effect between modules, Model 5 simultaneously introduced the CA and LKCA modules, achieving an F1-score of 91.71%, similar to Model 3, indicating that the combination of the two did not result in a significant performance gain. Model 6, combining the CA and BiFPN modules, showed a significant performance improvement, with the F1-score increasing to 93.28%, and mAP@0.5 and mAP@0.5:0.95 reaching 97.53% and 86.76% respectively, verifying their complementarity in feature selection and fusion. Model 7, comprehensively introducing the CA, LKCA, and BiFPN modules, achieved optimal performance: Precision increased to 95.92%, the F1-score reached 94.82%, and mAP@0.5 and mAP@0.5:0.95 reached 98.21% and 87.72% respectively. Compared to the base model, its F1-score improved by 1.76%, mAP@0.5 improved by 1.21%, and mAP@0.5:0.95 improved by 1.11%, fully validating the effectiveness and superiority of the proposed module combination.

[0096] To visually evaluate the superiority of the BCL-YOLOv8n model in crab sex detection and recognition, this experiment used an augmented dataset to perform visualization analysis on each module. Based on the baseline model, after adding the CA module, the C2f_CA module can retain information from each channel and establish long-short-term contextual dependencies, thereby enhancing the model's feature extraction capabilities in different scenarios. However, its performance is still insufficient when handling similar features. Subsequently, BiFPN was used to replace PAN and FPN as the Neck network, further improving the model's ability to perceive local and global information and significantly enhancing its performance in multi-feature extraction. Based on the introduction of the C2f_CA and BiFPN modules, the LKCA module was added. The results show that the model's ability to focus on the global structure of the crab shell and key edge information was further enhanced. The synergistic effect of the three modules effectively improved the model's performance in terms of false negatives and false positives, accurately identifying crab sex in various scenarios while improving the target confidence. The visualization analysis results further validate the significant advantages of the proposed multi-scenario crab sex detection method in feature representation and model localization accuracy, effectively identifying the target and providing higher confidence.

[0097] To further test the advantages of the proposed BLC-YOLOv8n model in crab sex detection across multiple scenarios, this experiment selected current mainstream lightweight detection models, including YOLOv8n, YOLOv9t, YOLOv10n, YOLOv11n, and YOLOv12n, as baselines for comparison, and evaluated their system performance against the BLC-YOLOv8n model. Evaluation metrics included Precision (P), Recall (R), F1-score, and mAP@0.5, as well as model size (MB), computational complexity (GFLOPs), and inference speed (Frames Per Second, FPS). The experimental results are shown in Table 5.

[0098] Table 5. Test Results

[0099]

[0100] As shown in Table 5, BLC-YOLOv8n achieves the best performance among all models, with a precision of 95.92%, recall of 93.76%, and F1-score of 94.82%, significantly higher than all other models. It performs particularly well in mAP@0.5, reaching 98.21%, a 1.21% improvement compared to the original YOLOv8n's 97.00%, indicating stronger generalization ability in terms of accuracy and robustness in gender detection. Compared to the latest version, YOLOv10n, although the latter is slightly more computationally efficient (5.9 GFLOPs, 63.29 FPS), BLC-YOLOv8n improves detection accuracy by 3.61% in F1-score and 1.54% in mAP@0.5. Furthermore, compared to YOLOv9t, BLC-YOLOv8n shows a more significant improvement in F1-score, reaching 7.65%, while mAP0.5 is improved by nearly 4%. This indicates that BLC-YOLOv8n not only performs strongly in lightweight detection tasks, but also significantly enhances detection accuracy while maintaining a controllable model size (7.1 MB) and reasonable inference speed (50.76 FPS).

[0101] In terms of model size and computational complexity, BLC-YOLOv8n has a similar number of parameters to YOLOv8n (7.1 MB and 6.5 MB, respectively), and its GFLOPs remain at 6.3, only slightly higher than YOLOv8n's 6.1, indicating that the computational burden of the model did not increase significantly after the introduction of the improved module. Meanwhile, compared to YOLOv9t's 27.2 GFLOPs, BLC-YOLOv8n's computational complexity is significantly reduced, to approximately 23%, meaning the model is more efficient and more suitable for deployment on resource-constrained devices. Although BLC-YOLOv8n's inference speed (50.76 FPS) is slightly lower than some models such as YOLOv10n (63.29 FPS) and YOLOv8n (62.11 FPS), it still remains within the performance requirements of real-time detection, achieving a good balance between accuracy and speed. Therefore, BLC-YOLOv8n significantly improves the accuracy and stability of object detection while maintaining a small model size and real-time inference speed. It outperforms several existing lightweight object detection models and has high practical value and deployment potential.

[0102] To more intuitively evaluate the superiority of the BCL-YOLOv8n model in crab sex detection, this experiment conducted a visual comparative analysis with the baseline model. The results of multiple models are shown below. Figure 6 As shown in the figure, the scene types include realistic aquaculture environments, complex background interference, multiple targets interacting with each other, and occlusion. For realistic aquaculture environments with insufficient lighting, the BLC-YOLOv8n model shows significant improvement, especially in underwater crab shell extraction and sex detection. For scenes with strong background interference, the BLC-YOLOv8n algorithm has higher detection accuracy for small crab shell targets. In multi-target detection scenarios, BLC-YOLOv8n can effectively reduce the probability of missed detection of crab shell targets and accurately extract complete crab shell information. The detection results show that the BLC-YOLOv8n model exhibits excellent performance in all scenarios, especially in realistic environments and multi-target scenarios.

[0103] This experiment proposes a multi-dimensional fusion enhancement strategy to address common problems in underwater images, such as color distortion, low contrast, and blurred details. Experimental results show that this strategy excels in improving overall image quality, restoring the true color and texture details of the crab shell, and significantly enhancing the visibility and separability of target features.

[0104] The BCL-YOLOv8 model demonstrates excellent adaptability in terms of gender detection accuracy and robustness in complex environments. Experimental results show that the method achieves high recognition accuracy and stability on the constructed real underwater dataset, validating its application potential in practical aquaculture scenarios.

[0105] For low-light conditions in real-world aquaculture environments, the BCL-YOLOv8n model demonstrates significant improvements over the baseline model, particularly in underwater crab shell extraction and sex detection. In multi-target detection scenarios, BCL-YOLOv8n exhibits strong robustness in crab shell target recognition, effectively reducing false negatives and accurately extracting sex information from multiple targets. Especially with the introduction of the LKCA module, the model can more accurately identify the global structure and key edge information of the crab shell, effectively avoiding the difficulties traditional models face in extracting similar features. This represents a significant breakthrough in improving detection accuracy, enhancing robustness, and addressing challenges in practical applications.

[0106] Figure 7 This is a schematic diagram of a module of an underwater crab sex real-time non-destructive detection system based on image enhancement and computer vision, as shown in some embodiments of this specification. Figure 7 As shown, the underwater crab sex real-time non-destructive detection system based on image enhancement and computer vision can include a model building module, an image preprocessing module, and a sex detection module.

[0107] The model building module is used to build and train an underwater crab sex detection model based on YOLOv8. The underwater crab sex detection model includes an input layer, a backbone network, a feature fusion layer, and a detection head. The backbone network and feature fusion layer of the underwater crab sex detection model both include a cross-stage feature fusion module that introduces a coordinate attention mechanism. The backbone network and feature fusion layer both embed a local kernel context attention module.

[0108] The image preprocessing module is used to acquire images of the aquaculture area to be detected, and to enhance the images of the aquaculture area to be detected based on a multi-dimensional fusion enhancement strategy, thereby generating enhanced images of the aquaculture area to be detected.

[0109] The sex detection module is used to identify the sex of crabs in the enhanced images of the aquaculture area to be detected by using a trained underwater crab sex detection model.

[0110] The real-time non-destructive testing system for underwater crab sex based on image enhancement and computer vision can be used to perform real-time non-destructive testing methods for underwater crab sex based on image enhancement and computer vision, which will not be elaborated here.

[0111] Finally, it should be understood that the embodiments described in this specification are merely illustrative of the principles of the embodiments described herein. Other variations may also fall within the scope of this specification. Therefore, alternative configurations of the embodiments described herein are intended to be illustrative rather than limiting, and are considered consistent with the teachings of this specification. Accordingly, the embodiments described herein are not limited to those explicitly introduced and described herein.

Claims

1. An underwater crab gender real-time non-destructive detection method based on image enhancement and computer vision, characterized in that, include: A sex detection model for underwater crabs was constructed and trained based on YOLOv8. The underwater crab sex detection model includes an input layer, a backbone network, a feature fusion layer, and a detection head. Both the backbone network and the feature fusion layer of the underwater crab sex detection model include a cross-stage feature fusion module that incorporates a coordinate attention mechanism. Both the backbone network and the feature fusion layer embed a local kernel context attention module. Acquire images of the aquaculture area to be inspected; Based on a multi-dimensional fusion enhancement strategy, the image of the aquaculture area to be detected is enhanced to generate an enhanced image of the aquaculture area to be detected. The trained underwater crab sex detection model identifies the sex of crabs in the enhanced images of the aquaculture area to be detected. Among them, based on a multi-dimensional fusion enhancement strategy, the image of the aquaculture area to be detected is enhanced to generate an enhanced image of the aquaculture area to be detected, including: The image of the aquaculture area to be detected is subjected to dynamic color enhancement and color temperature correction to generate the image of the aquaculture area to be detected after the first stage of processing. The contrast and sharpness of the aquaculture area image to be detected after the first stage of processing are improved to generate the aquaculture area image to be detected after the second stage of processing. The image of the aquaculture area to be detected after the second stage of processing is locally enhanced to generate an enhanced image of the aquaculture area to be detected. The image of the aquaculture area to be detected undergoes dynamic color enhancement and color temperature correction to generate the first-stage processed image of the aquaculture area to be detected, including: An adaptive color compensation algorithm is used to dynamically enhance the color of the aquaculture area image to be detected, generating a dynamically enhanced image of the aquaculture area to be detected. The image of the aquaculture area to be detected after dynamic color enhancement is converted from RGB color space to Lab color space, and color temperature correction is performed using an adaptive white balance algorithm to generate the image of the aquaculture area to be detected after the first stage of processing. The image of the aquaculture area to be detected after the first stage of processing is subjected to contrast and sharpness enhancement processing to generate the image of the aquaculture area to be detected after the second stage of processing, including: The contrast of the aquaculture area image to be detected is adaptively adjusted by using the Sigmoid function after the first stage of processing, resulting in a contrast-enhanced image of the aquaculture area to be detected. The GaussianBlur function is used to perform unsharpened mask detail enhancement on the aquaculture area image to be detected after the first stage of processing, generating a detail-enhanced aquaculture area image to be detected. Using non-subsampled contourlet transform, the contrast-enhanced and detail-enhanced images of the aquaculture area to be detected are fused to generate the second-stage processed image of the aquaculture area to be detected.

2. The image enhancement and computer vision based real-time non-destructive detection method of gender of crabs underwater according to claim 1, characterized in that, The cross-stage feature fusion module that introduces a coordinate attention mechanism includes a first convolutional layer, a segmentation layer, a coordinate attention mechanism, multiple stacked bottleneck units, a connection layer, and a second convolutional layer connected in sequence, wherein the segmentation layer is also connected to the connection layer.

3. The image enhancement and computer vision based real-time non-destructive detection method of gender of crabs underwater according to claim 2, characterized in that, The local kernel context attention module includes an input layer, a first two-dimensional convolution, a GELU activation function, a large kernel attention mechanism, a second two-dimensional convolution, and an output layer connected in sequence. The large kernel attention mechanism includes a deep convolution layer, an extended deep convolution layer, and a 1x1 convolution layer. The output of the GELU activation function is multiplied element-wise by the output of the 1x1 convolution layer.

4. The image enhancement and computer vision based real-time non-destructive detection method of gender of crabs underwater according to claim 2, characterized in that, The feature fusion layer introduces a weighted bidirectional feature pyramid network to replace the connection module.

5. The real-time non-destructive detection method for underwater crab sex based on image enhancement and computer vision according to any one of claims 1-4, characterized in that, The image of the aquaculture area to be detected after the second stage of processing is subjected to local enhancement processing to generate an enhanced image of the aquaculture area to be detected, including: The image of the aquaculture area to be detected after the second stage of processing is divided into multiple sub-regions. Based on contrast limiting, histogram equalization is performed independently within each sub-region to generate an enhanced image of the aquaculture area to be detected.

6. A real-time non-destructive underwater crab sex detection system based on image enhancement and computer vision, characterized in that, The method for real-time non-destructive detection of underwater crab sex based on image enhancement and computer vision as described in claim 1 includes: The model building module is used to build and train an underwater crab sex detection model based on YOLOv8. The underwater crab sex detection model includes an input layer, a backbone network, a feature fusion layer, and a detection head. The backbone network and feature fusion layer of the underwater crab sex detection model both include a cross-stage feature fusion module that introduces a coordinate attention mechanism. The backbone network and feature fusion layer both embed a local kernel context attention module. The image preprocessing module is used to acquire images of the aquaculture area to be detected, and to enhance the images of the aquaculture area to be detected based on a multi-dimensional fusion enhancement strategy, thereby generating enhanced images of the aquaculture area to be detected. The sex detection module is used to identify the sex of crabs in the enhanced images of the aquaculture area to be detected by using a trained underwater crab sex detection model.