A method, device and medium for enhancing image data of zebrafish courtship behavior

By acquiring and labeling the initial infrared video, using the SAM segmentation large model and the affine transformation function to generate the transformed zebrafish foreground mask, and combining it with the new background image for data enhancement, it solves the problem of multi-scale zebrafish behavior and posture recognition in the existing technology. The problem of missing information improves data diversity and identification accuracy.

CN118314034BInactive Publication Date: 2024-08-30CHINA UNIV OF GEOSCIENCES (WUHAN)
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410732876.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-08-30
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing image data enhancement methods lack multi-scale information, feature interaction information and light intensity information when processing zebrafish behavioral posture recognition, resulting in a single diversity of generated data and unable to effectively solve the occlusion and intersection problems in multi-animal behavior recognition. .

Method used

By obtaining the initial infrared video, labeling joint points and manual trajectories, using the SAM segmentation large model to extract the foreground mask, performing centralized processing, and constructing an affine transformation function to generate the transformed male and female foreground masks, combined with the new Background image for data augmentation.

Benefits of technology

It improves the accuracy of target detection and pose points at multiple scales, reduces the number of labeled samples, and improves data collection efficiency and time cycle.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118314034B
    Figure CN118314034B
Patent Text Reader

Abstract

The invention provides a method, device and medium for enhancing data of zebrafish courtship behavior images, and relates to the field of image processing. The method comprises: marking joint points and manual tracks of an initial infrared image collected; determining a first picture for training and data enhancement from the initial infrared image; extracting a foreground mask of the first picture by using a SAM segmentation large model; performing inverse masking and processing on the foreground mask to obtain a new background picture; performing centralization processing on the foreground mask of the first picture; generating data by inputting a track or generating data by overlapping and crossing; performing affine transformation on the centralized foreground mask and joint points according to the affine transformation function and the function value to obtain a transformed male fish foreground mask and a female fish foreground mask; combining the transformed male fish foreground mask and the female fish foreground mask, and superimposing them with the new background picture to generate a preset number of data-enhanced new zebrafish courtship behavior images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing, and in particular to a method, device and medium for enhancing image data of zebrafish courtship behavior. Background Art

[0002] Zebrafish and humans share 70% of their genomes, and their high-quality genomes have given people a clearer understanding of the key genomic features of zebrafish. Zebrafish research plays an important role in genetic diseases, toxicology experiments, and drug discovery. At the same time, zebrafish courtship behavior is of great significance in gene screening and editing. Medical researchers attempt to change the reproduction rate of zebrafish by cutting or replacing genes to understand the impact of these genes on human reproduction and genetic mechanisms. The purpose is to solve the problem of human infertility. The water quality environment in which they live is closely related to the number of times zebrafish courtship behavior occurs.

[0003] Posture recognition is the most important step in animal behavior analysis in the field of computer vision. At present, when dealing with animal behavior posture recognition tasks, professional animal keepers and video data acquisition engineers are required to cooperate on site to debug and collect video data in a specific experimental environment, and rely on a large number of manual operations to annotate the collected data. The mating behavior between zebrafish will frequently cause mutual occlusion problems, and the number of frames is relatively small compared to the entire video, which is one of the difficulties in joint point model recognition. The image processing method involved in Chinese Patent 202410251755.2 relies on image flipping, mirroring, translation, cropping, brightness transformation or GAN super-resolution to enhance the data of zebrafish images and generate new annotated key points and frame data, which lacks multi-scale information, interaction information between two features, and light intensity information, resulting in a single diversity of generated data. These three factors are particularly important in the process of behavior recognition between multiple animals. Secondly, the copy-paste method has achieved certain improvements in the field of target detection and instance segmentation, but it has not yet been applied to joint point recognition. In the multi-animal behavior recognition task, due to the mutual occlusion, intersection and overlap between animals, the copy-paste algorithm can improve the detection effect of multi-scale frames, but the generated images still cannot effectively improve the false detection and missed detection caused by intersection and overlap. For the spatial position of animals in different spatiotemporal states, the morphological change prediction effect is not good. In summary, conventional image data enhancement methods are not suitable for zebrafish behavior posture recognition. Summary of the invention

[0004] The purpose of the present invention is to provide a zebrafish courtship behavior image data enhancement method, device and medium in order to solve the problem that conventional image data enhancement methods are not suitable for zebrafish behavior posture recognition.

[0005] The above object of the present invention is achieved through the following technical solutions:

[0006] S1: Obtain the initial infrared video and extract the frames at intervals to obtain the initial infrared image; mark the joint points of the initial infrared image and the manual trajectory of the zebrafish in the initial infrared image;

[0007] S2: Select a specific frame from the initial infrared image to obtain a first image for training and data enhancement;

[0008] S3: extracting a foreground mask of the first image using the SAM segmentation model; performing inverse masking on the foreground mask of the first image to obtain an inverse mask background image;

[0009] S4: performing centralization processing on the foreground mask of the first image;

[0010] S5: construct an affine transformation function; generate a function value of the affine transformation function by inputting a trajectory to generate data or by overlapping and crossing to generate data; perform an affine transformation on the centralized foreground mask and the joint points according to the affine transformation function and the function value to obtain a transformed male fish foreground mask and a female fish foreground mask;

[0011] S6: Process the anti-masked background image to obtain a new background image;

[0012] S7: Combining the transformed male fish foreground mask with the female fish foreground mask and superimposing them with the new background image to generate a preset number of data-enhanced new zebrafish courtship behavior images.

[0013] Optionally, step S1 includes:

[0014] Using an infrared camera to shoot N groups of different male and female zebrafish in a top-down plane, to obtain initial infrared videos of the N groups of male and female zebrafish;

[0015] The initial infrared image of the zebrafish is obtained by extracting fixed frames from N groups of initial infrared videos;

[0016] Use an image annotation tool to annotate the joint points of each zebrafish in the initial infrared images of N groups of zebrafish;

[0017] Annotate the manual tracks of N groups of zebrafish using an image annotation tool.

[0018] Optionally, step S3 includes:

[0019] Suppose the first frame image in the first picture The two sets of marked joint points are as follows:

[0020]

[0021]

[0022] in, for 5 joint points; for 5 joint points;

[0023] Through the two sets of marked joint points, SAM is used to segment the large model and obtain the Frame Image The foreground mask and foreground mask ;

[0024] Foreground mask and foreground mask Superimpose and assign 0 to the pixel value of the superimposed foreground mask area to generate the first Frame Image The anti-mask background image .

[0025] Optionally, step S4 includes:

[0026] Retrieve the foreground mask The non-0 index values ​​are as follows:

[0027]

[0028] in and Represent the row index list and column index list respectively; Represents the foreground mask The pixel coordinates in the image;

[0029] For the foreground mask The minimum row , Maximum row , minimum column and the maximum column ,as follows:

[0030]

[0031] Calculate the lth frame image Height and width ,as follows:

[0032]

[0033] Calculate the foreground mask Move to the lth frame image The required translation of the center is as follows:

[0034]

[0035] in, Indicates the column translation amount; Indicates the row translation amount;

[0036] The first frame image The foreground mask Foreground mask after centering It is expressed as:

[0037]

[0038] in, Represents the pixel coordinates of the centered foreground mask in the image;

[0039] In the foreground mask In the above example, the centralized joint points are expressed as:

[0040]

[0041] in, Represents the coordinates of the annotated joint points.

[0042] Optionally, step S5 includes:

[0043] S51: The affine transformation of the affine transformation function includes: displacement, rotation and scaling, as follows:

[0044] Define the displacement matrix of the centered foreground mask ,as follows:

[0045]

[0046] in and Represents the displacement of the foreground mask Directional translation and Directional translation;

[0047] Define the rotation and scaling transformation matrix ,as follows:

[0048]

[0049] in, is the rotation angle; represents the scaling factor, and are the coordinates of the center of the image, and Respectively represent the sine and cosine of the rotation angle;

[0050] The combination change matrix is ​​defined as: ;

[0051] By combining the change matrix Foreground mask after centering Every pixel Perform affine transformation, foreground mask after affine transformation ,as follows:

[0052]

[0053] in, are the pixel coordinates of the foreground mask in the output image after the affine transformation;

[0054] The central joint point coordinates Perform dimensionality upgrading as follows:

[0055]

[0056] in and Represents the coordinate value of the joint point after dimensionality upgrade;

[0057] By combining the change matrix The coordinates of the joint points after dimensionality increase Processing is performed to obtain the coordinates of the joint points after affine transformation ,as follows:

[0058]

[0059] S52: Constructing affine transformation functions , the expression is as follows:

[0060]

[0061] S53: Generate a preset number of function values ​​by inputting a trajectory to generate data or by overlapping and crossing to generate data; the function values ​​include: rotation angle , displacement , scale ;

[0062] S54: Input the function value into the affine transformation function (); through the affine transformation function () Perform affine transformation on the centralized foreground mask and the centralized joint points to obtain the male fish foreground mask and the female fish foreground mask after affine transformation.

[0063] Optionally, the specific steps of generating a preset number of function values ​​by inputting a trajectory to generate data include:

[0064] L1: Normalize the coordinates of the centered zebrafish joints and the coordinates of each track point of the manual track, and align the orientation of the centered foreground mask with the orientation of the movement along the manual track, as follows:

[0065] Set the joint point of zebrafish 1 Articulation point 2 with zebrafish Vector , the manual track starts from the starting point To the first coordinate reached after departure Vector , calculate the angle between vector a and vector b , the calculation formula is expressed as:

[0066]

[0067]

[0068]

[0069]

[0070] in, represents the cross product of vectors, represents the magnitude of a vector;

[0071] The angle Convert to degrees ;

[0072] Using the dot product and cross product The sign of the angle The positive and negative angle Cross product with vector The symbolic relationship is expressed as:

[0073] when hour, Direction and in the opposite direction;

[0074] when hour, Direction and The direction is the same;

[0075] when hour, Direction and The symbols are consistent;

[0076] Angle When is positive, the centered foreground mask is rotated clockwise through the affine transformation function. When is negative, the centered foreground mask is rotated counterclockwise by the affine transformation function, and the rotation angle is ;

[0077] Displacement of the foreground mask after centering ;

[0078] Scaling remain unchanged;

[0079] L2: Repeat step L1 to obtain the function value of the preset number of groups.

[0080] Optionally, the specific steps of generating a preset number of function values ​​by overlapping and crossing data generation include:

[0081] A1: Pass () function to obtain the displacement of the male fish foreground mask , rotation angle ; Displacement of the male fish foreground mask With rotation angle As the benchmark value, set the normal distribution variance , get the position of the female fish foreground mask With rotation angle , the expression is as follows:

[0082]

[0083] in, The function is a normal distribution simulation function; represents the scale of the male fish foreground mask, represents the scale of the foreground mask of the female fish, and the scale remains unchanged; represents the mean of the normal distribution; represents the dispersion coefficient between two zebrafish, which is used to simulate the degree of interaction between male and female fish;

[0084] A2: Repeat step A1 to obtain the function value of the preset number of groups.

[0085] Optionally, step S6 includes:

[0086] The processing methods of the anti-mask background image include: bilateral filtering, light intensity transformation, adding Gaussian noise and no processing;

[0087] Any one of the processing methods for the anti-mask background image is selected to process the anti-mask background image to obtain a new background image.

[0088] An electronic device comprises a processor, a memory, a user interface and a network interface, wherein the memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device executes a method for enhancing image data of zebrafish courtship behavior.

[0089] A computer-readable storage medium stores instructions. When the instructions are executed, a method for enhancing image data of zebrafish courtship behavior is performed.

[0090] The beneficial effects brought by the technical solution provided by the present invention are:

[0091] Through the SAM segmentation model, the problem of zebrafish mask segmentation was solved. The mask was centered and aligned with the corresponding annotated joint points. The random overlapping and occluded images between multiple masks obtained by translation, rotation, and scaling, as well as the enhanced images according to the trajectory, solved the problems of target and posture point detection at multiple scales, inaccurate recognition due to frequent occlusion and alternating recognition, and environmental interference, reduced the number of labeled samples, improved data collection efficiency, and shortened the time period for data collection. BRIEF DESCRIPTION OF THE DRAWINGS

[0092] The present invention will be further described below with reference to the accompanying drawings and embodiments, in which:

[0093] Figure 1 is a flow chart of a method for enhancing zebrafish courtship behavior image data in an embodiment of the present invention;

[0094] Figure 2 is a schematic diagram of mask generation based on trajectories of a zebrafish courtship behavior image data enhancement method in an embodiment of the present invention;

[0095] Figure 3 This is an effect diagram of mask generation based on overlapping and crossing of the zebrafish courtship behavior image data enhancement method in an embodiment of the present invention;

[0096] Figure 4 is a trajectory-based mask generation effect diagram of the zebrafish courtship behavior image data enhancement method in an embodiment of the present invention;

[0097] Figure 5 It is a schematic diagram of the electronic device structure of the zebrafish courtship behavior image data enhancement method in an embodiment of the present invention. DETAILED DESCRIPTION

[0098] In order to have a clearer understanding of the technical features, purposes and effects of the present invention, specific embodiments of the present invention are now described in detail with reference to the accompanying drawings.

[0099] An embodiment of the present invention provides a method for enhancing zebrafish courtship behavior image data.

[0100] Please refer to Figure 1 , Figure 1 : is a flow chart of a zebrafish courtship behavior image data enhancement method according to an embodiment of the present invention, comprising:

[0101] S1: Obtain the initial infrared video and extract the frames at intervals to obtain the initial infrared image; mark the joint points of the initial infrared image and the manual trajectory of the zebrafish in the initial infrared image;

[0102] Step S1 includes:

[0103] Using an infrared camera to shoot N groups of different male and female zebrafish in a top-down plane, to obtain initial infrared videos of the N groups of male and female zebrafish;

[0104] The initial infrared image of the zebrafish is obtained by extracting fixed frames from N groups of initial infrared videos;

[0105] Use an image annotation tool to annotate the joint points of each zebrafish in the initial infrared images of N groups of zebrafish;

[0106] Annotate the manual tracks of N groups of zebrafish using an image annotation tool.

[0107] Specifically, the initial infrared image used to extract the manual trajectory needs to meet the following requirements: the video is cut into n segments showing different behaviors, each segment is extracted at regular intervals, the extracted male and female fish are distinguished and annotated with joint points, the annotated joint points are located near the gills of the zebrafish, and the json file generated after annotation is processed to obtain the trajectory joint point segments.

[0108] Specifically, the number of zebrafish in the reverse masked image is 2, the morphology of zebrafish in each group of different images is significantly different, there is no mutual occlusion, and there is no overlap between the positions of any four zebrafish in image A and image B used to generate the background. The initial infrared image used for training and data enhancement needs to meet the requirement that the morphology of zebrafish is significantly different and there is no mutual occlusion.

[0109] S2: Select a specific frame from the initial infrared image to obtain a first image for training and data enhancement;

[0110] S3: extracting a foreground mask of the first image using the SAM segmentation model; performing inverse masking on the foreground mask of the first image to obtain an inverse mask background image;

[0111] Specifically, SAM (Segmeng Anything Models) segmentation large models.

[0112] Step S3 includes:

[0113] Suppose the first frame image in the first picture The two sets of marked joint points are as follows:

[0114]

[0115]

[0116] in, for 5 joint points; for 5 joint points;

[0117] Through the two sets of marked joint points, SAM is used to segment the large model and obtain the Frame Image The foreground mask and foreground mask ;

[0118] Foreground mask and foreground mask Superimpose and assign 0 to the pixel value of the superimposed foreground mask area to generate the first Frame Image The anti-mask background image .

[0119] S4: performing centralization processing on the foreground mask of the first image;

[0120] Step S4 includes:

[0121] Retrieve the foreground mask The non-0 index values ​​are as follows:

[0122]

[0123] in and Represent the row index list and column index list respectively; Represents the foreground mask The pixel coordinates in the image;

[0124] For the foreground mask The minimum row , Maximum row , minimum column and the maximum column ,as follows:

[0125]

[0126] Calculate the lth frame image Height and width ,as follows:

[0127]

[0128] Calculate the foreground mask Move to the lth frame image The required translation of the center is as follows:

[0129]

[0130] in, Indicates the column translation amount; Indicates the row translation amount;

[0131] The first frame image The foreground mask Foreground mask after centering It is expressed as:

[0132]

[0133] in, Represents the pixel coordinates of the centered foreground mask in the image;

[0134] In the foreground mask In the above example, the centralized joint points are expressed as:

[0135]

[0136] in, Represents the coordinates of the annotated joint points.

[0137] S5: construct an affine transformation function; generate a function value of the affine transformation function by inputting a trajectory to generate data or by overlapping and crossing to generate data; perform an affine transformation on the centralized foreground mask and the joint points according to the affine transformation function and the function value to obtain a transformed male fish foreground mask and a female fish foreground mask;

[0138] Step S5 includes:

[0139] S51: The affine transformation of the affine transformation function includes: displacement, rotation and scaling, as follows:

[0140] Define the displacement matrix of the centered foreground mask ,as follows:

[0141]

[0142] in and Represents the displacement of the foreground mask Directional translation and Directional translation;

[0143] Define the rotation and scaling transformation matrix ,as follows:

[0144]

[0145] in, is the rotation angle; represents the scaling factor, and are the coordinates of the center of the image, and Respectively represent the sine and cosine of the rotation angle;

[0146] The combination change matrix is ​​defined as: ;

[0147] By combining the change matrix Foreground mask after centering Every pixel Perform affine transformation, foreground mask after affine transformation ,as follows:

[0148]

[0149] in, are the pixel coordinates of the foreground mask in the output image after the affine transformation;

[0150] The central joint point coordinates Perform dimensionality upgrading as follows:

[0151]

[0152] in and Represents the coordinate value of the joint point after dimensionality upgrade;

[0153] By combining the change matrix The coordinates of the joint points after dimensionality increase Processing is performed to obtain the coordinates of the joint points after affine transformation ,as follows:

[0154]

[0155] S52: Constructing affine transformation functions , the expression is as follows:

[0156]

[0157] S53: Generate a preset number of function values ​​by inputting a trajectory to generate data or by overlapping and crossing to generate data; the function values ​​include: rotation angle , displacement , scale ;

[0158] S54: Input the function value into the affine transformation function (); through the affine transformation function () Perform affine transformation on the centralized foreground mask and the centralized joint points to obtain the male fish foreground mask and the female fish foreground mask after affine transformation.

[0159] Specifically, Figure 4 This is a trajectory-based mask generation effect diagram.

[0160] like Figure 2 As shown, the specific steps of generating a preset number of function values ​​by inputting a trajectory to generate data include:

[0161] L1: Normalize the coordinates of the centered zebrafish joints and the coordinates of each track point of the manual track, and align the orientation of the centered foreground mask with the orientation of the movement along the manual track, as follows:

[0162] Set the joint point of zebrafish 1 Articulation point 2 with zebrafish Vector , the manual track starts from the starting point To the first coordinate reached after departure Vector , calculate the angle between vector a and vector b , the calculation formula is expressed as:

[0163]

[0164]

[0165]

[0166]

[0167] in, represents the cross product of vectors, represents the magnitude of a vector;

[0168] The angle Convert to degrees ;

[0169] Using the dot product and cross product The sign of the angle The positive and negative angle Cross product with vector The symbolic relationship is expressed as:

[0170] when hour, Direction and in the opposite direction;

[0171] when hour, Direction and The direction is the same;

[0172] when hour, Direction and The symbols are consistent;

[0173] Angle When is positive, the centered foreground mask is rotated clockwise through the affine transformation function. When is negative, the centered foreground mask is rotated counterclockwise by the affine transformation function, and the rotation angle is ;

[0174] Displacement of the foreground mask after centering ;

[0175] Scaling remain unchanged;

[0176] L2: Repeat step L1 to obtain the function value of the preset number of groups.

[0177] The specific steps of generating a preset number of function values ​​by overlapping and crossing data generation include:

[0178] A1: Pass () function to obtain the displacement of the male fish foreground mask , rotation angle ; Displacement of the male fish foreground mask With rotation angle As the benchmark value, set the normal distribution variance , get the position of the female fish foreground mask With rotation angle , the expression is as follows:

[0179]

[0180] in, The function is a normal distribution simulation function; represents the scale of the male fish foreground mask, represents the scale of the foreground mask of the female fish, and the scale remains unchanged; represents the mean of the normal distribution; represents the dispersion coefficient between two zebrafish, which is used to simulate the degree of interaction between male and female fish;

[0181] A2: Repeat step A1 to obtain the function value of the preset number of groups.

[0182] Specifically, The function comes from np.random.randn() in PYTHON's numpy library and is used to simulate the normal distribution of data.

[0183] Specifically, the parameters are substituted into the affine transformation function, and the foreground masks of the female fish and the male fish are superimposed to obtain the overlapping and intersecting (non-linear combination) foreground masks. The non-linear combination (interaction) method is similar to the generated enhanced image result. Figure 3 shown.

[0184] S6: Process the anti-masked background image to obtain a new background image;

[0185] S7: Combining the transformed male fish foreground mask with the female fish foreground mask and superimposing them with the new background image to generate a preset number of data-enhanced new zebrafish courtship behavior images.

[0186] Step S6 includes:

[0187] The processing methods of the anti-mask background image include: bilateral filtering, light intensity transformation, adding Gaussian noise and no processing;

[0188] Any one of the processing methods for the anti-mask background image is selected to process the anti-mask background image to obtain a new background image.

[0189] Specifically, since different groups of male and female zebrafish may have different sizes, we use all existing background images as candidates and randomly select a picture as the background image to be used. By padding or cropping the foreground mask around, the size of the mask and the background image to be used are kept aligned. After ensuring that the size of the mask and the background image to be used are aligned, the image processing including bilateral filtering, light intensity transformation, adding Gaussian noise, and no processing is performed through the numpy library array operation method.

[0190] From N groups of zebrafish courtship videos, M background extraction images are selected for each group, and data of 10 joint points are annotated for each image (5 for female and 5 for male fish), with the annotated amount of 10*M*N joint points. New annotated data is generated by inputting trajectory data generation method or overlapping cross-generation data generation method. Set displacement, rotation, scale scaling, background image, as the constant changing quantity in data enhancement, and the total number of enhanced images (including data augmented images and original annotated images) are:

[0191]

[0192]

[0193]

[0194] Among them, num_sample is the number of randomly generated masks for each group, num_trajectory is the average number of trajectory markers, and n is the number of trajectories used for each group of masks. At least 100 labeled image joints are required to obtain a data enhancement structure with rich features, so as to meet the time requirements as much as possible. When (M=5, N=20, =20, n=5), 15100 data-enhanced images and joints are obtained. It has been verified that there is a good recognition effect on the training of the joint neural network.

[0195] The present invention also discloses an electronic device. Figure 5 , Figure 5 The electronic device 500 may include: at least one processor 501 , at least one network interface 504 , a user interface 503 , a memory 505 , and at least one communication bus 502 .

[0196] The communication bus 502 is used to realize the connection and communication between these components.

[0197] The user interface 503 may include a display screen and a camera, and the optional user interface 503 may also include a standard wired interface and a wireless interface.

[0198] The network interface 504 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).

[0199] The above are only exemplary embodiments of the present disclosure and cannot be used to limit the scope of the present disclosure. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the disclosure of the specification and the truth of practice, those skilled in the art will easily think of other embodiments of the present disclosure.

[0200] The present invention is intended to cover any variation, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the art not described in the present disclosure. The description and examples are to be regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.

Claims

1. A zebrafish courtship behavior image data enhancement method, characterized in that: The method comprises the following steps: S1: Obtain the initial infrared video and extract the frames at intervals to obtain the initial infrared image; mark the joint points of the initial infrared image and the manual trajectory of the zebrafish in the initial infrared image; S2: Select a specific frame from the initial infrared image to obtain a first image for training and data enhancement; S3: extracting the foreground mask of the first image using the SAM segmentation model; Demasking the foreground mask of the first image to obtain a demasked background image; Step S3 includes: Suppose the first frame image in the first picture The two sets of marked joint points are as follows: in, for 5 joint points; for 5 joint points; Through the two sets of marked joint points, SAM is used to segment the large model and obtain the Frame Image The foreground mask and foreground mask ; Foreground mask and foreground mask Superimpose and assign 0 to the pixel value of the superimposed foreground mask area to generate the first Frame Image The anti-mask background image ; S4: performing centralization processing on the foreground mask of the first image; Step S4 includes: Retrieve foreground mask The non-0 index values ​​are as follows: in and Represent the row index list and column index list respectively; Represents the foreground mask The pixel coordinates in the image; For the foreground mask The minimum row , Maximum row , minimum column and the maximum column ,as follows: Calculate the lth frame image Height and width ,as follows: Calculate the foreground mask Move to the lth frame image The required translation of the center is as follows: in, Indicates the column translation amount; Indicates the row translation amount; The first frame image The foreground mask Foreground mask after centering It is expressed as: in, Represents the pixel coordinates of the centered foreground mask in the image; In the foreground mask In the above example, the centralized joint points are expressed as: in, Represents the coordinates of the annotated joint points; S5: construct an affine transformation function; generate a function value of the affine transformation function by inputting a trajectory to generate data or by overlapping and crossing to generate data; perform an affine transformation on the centralized foreground mask and the joint points according to the affine transformation function and the function value to obtain a transformed male fish foreground mask and a female fish foreground mask; Step S5 includes: S51: The affine transformation of the affine transformation function includes: displacement, rotation and scaling, as follows: Define the displacement matrix of the centered foreground mask ,as follows: in and Represents the displacement of the foreground mask Directional translation and Directional translation; Define the rotation and scaling transformation matrix ,as follows: in, is the rotation angle; represents the scaling factor, and are the coordinates of the center of the image, and Respectively represent the sine and cosine of the rotation angle; The combination change matrix is ​​defined as: ; By combining the change matrix Foreground mask after centering Every pixel Perform affine transformation, foreground mask after affine transformation ,as follows: in, are the pixel coordinates of the foreground mask in the output image after the affine transformation; The central joint point coordinates Perform dimensionality upgrading as follows: in and Represents the coordinate value of the joint point after dimensionality upgrade; By combining the change matrix The coordinates of the joint points after dimensionality increase Processing is performed to obtain the coordinates of the joint points after affine transformation ,as follows: S52: Constructing affine transformation functions , the expression is as follows: S53: Generate a preset number of function values ​​by inputting a trajectory to generate data or by overlapping and crossing to generate data; the function values ​​include: rotation angle , displacement , scale ; S54: Input the function value into the affine transformation function (); through the affine transformation function () performing affine transformation on the centralized foreground mask and the centralized joint points to obtain the male fish foreground mask and the female fish foreground mask after affine transformation; The specific steps of generating a preset number of function values ​​by inputting a trajectory to generate data include: L1: Normalize the coordinates of the centered zebrafish joints and the coordinates of each track point of the manual track, and align the orientation of the centered foreground mask with the orientation of the movement along the manual track, as follows: Set the joint point of zebrafish 1 Articulation point 2 with zebrafish The vector composed of , the manual track starts from the starting point To the first coordinate reached after departure The vector composed of , calculate the angle between vector a and vector b , the calculation formula is expressed as: in, represents the cross product of vectors, represents the magnitude of a vector; The angle Convert to degrees ; Using the dot product and cross product The sign of the angle The positive and negative angle Cross product with vector The symbolic relationship is expressed as: when hour, Direction and in the opposite direction; when hour, Direction and The direction is the same; when hour, Direction and The symbols are consistent; Angle When is positive, the centered foreground mask is rotated clockwise through the affine transformation function. When is negative, the centered foreground mask is rotated counterclockwise by the affine transformation function, and the rotation angle is ; Displacement of the foreground mask after centering ; Scaling remain unchanged; L2: Repeat step L1 to obtain the function value of the preset number of groups; The specific steps of generating a preset number of function values ​​by overlapping and crossing data generation include: A1: Pass () function to obtain the displacement of the male fish foreground mask , rotation angle ; Displacement of the male fish foreground mask With rotation angle As the benchmark value, set the normal distribution variance , get the position of the female fish foreground mask With rotation angle , the expression is as follows: in, The function is a normal distribution simulation function; represents the scale of the male fish foreground mask, represents the scale of the foreground mask of the female fish, and the scale remains unchanged; represents the mean of the normal distribution; represents the coefficient of dispersion between two zebrafish; A2: Repeat step A1 to obtain the function value of the preset number of groups; S6: Process the anti-masked background image to obtain a new background image; S7: Combining the transformed male fish foreground mask with the female fish foreground mask and superimposing them with the new background image to generate a preset number of data-enhanced new zebrafish courtship behavior images.

2. A zebrafish courtship behavior image data enhancement method as claimed in claim 1, characterized in that: Step S1 includes: Using an infrared camera to shoot N groups of different male and female zebrafish in a top-down plane, to obtain initial infrared videos of the N groups of male and female zebrafish; The initial infrared image of the zebrafish is obtained by extracting fixed frames from N groups of initial infrared videos; Use an image annotation tool to annotate the joint points of each zebrafish in the initial infrared images of N groups of zebrafish; Annotate the manual tracks of N groups of zebrafish using an image annotation tool.

3. A zebrafish courtship behavior image data enhancement method as claimed in claim 1, characterized in that: Step S6 includes: The processing methods of the anti-mask background image include: bilateral filtering, light intensity transformation, adding Gaussian noise and no processing; Any one of the processing methods for the anti-mask background image is selected to process the anti-mask background image to obtain a new background image.

4. An electronic device, characterized in that: The electronic device comprises a processor (501), a memory (505), a user interface (503) and a network interface (504), wherein the memory (505) is used to store instructions, the user interface (503) and the network interface (504) are used to communicate with other devices, and the processor (501) is used to execute the instructions stored in the memory (505) so that the electronic device executes the method according to any one of claims 1 to 3.

5. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed by a computer, the method steps according to any one of claims 1 to 3 are executed.

Citation Information

Patent Citations

  • Intelligent recognition method and device for zebra fish courtship behavior and medium

    CN117854114A

  • Data enhancement method and device, computing equipment and computer storage medium

    CN110503146A

  • Image enhancement method and device, equipment and storage medium

    CN115578294A