Multi-view grain image processing method, storage medium and electronic device
Through multi-view shooting and image merging, combined with neural network model training, the problems of incomplete grain image processing and slow training speed in the existing technology are solved, and the accuracy and efficiency of grain particle detection are improved.
Patent Information
- Application Number
- CN202411138724.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-08-19
AI Technical Summary
In the existing technology, it is difficult to collect complete grain information through grain image processing, resulting in poor visual detection accuracy and slow speed when training models with multiple images.
Multi-view shooting is used to obtain images of different sides of the target grain, the images are stretched through the maximum circumscribed rectangle and the minimum circumscribed rectangle, merged into a third grain image, and trained based on the neural network model.
It reduces the amount of image data processed, retains the image features of different sides, and improves the accuracy of the model's feature recognition of the sides of grain particles and the speed of model training.
Smart Images

Figure CN118658046B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a multi-viewing angle grain image processing method, a storage medium and an electronic device. Background Art
[0002] In the related art, in order to improve the visual detection of grains, a visual detection model is trained to recognize grain images. In order to train the visual detection model, grain images are required as samples.
[0003] During training, since grain particles have multiple sides, if only one grain image is taken, complete grain information cannot be collected, and the captured grain image does not fully represent the characteristics of the grain, which can easily lead to poor accuracy of visual detection; however, if multiple grain images are taken and the visual detection model is trained with the captured images, it is necessary to obtain features for each image, which is slower. Summary of the invention
[0004] The present invention aims to solve one of the technical problems in the related art at least to a certain extent. To this end, one object of the present invention is to provide a multi-view grain image processing method, storage medium and electronic device to improve the speed of model training.
[0005] According to a first aspect of an embodiment of the present invention, a multi-view grain image processing method is provided, the method comprising:
[0006] Acquire a first grain image of a target grain from multiple perspectives;
[0007] For each of the at least two first grain images, the first grain image is stretched based on a maximum circumscribed rectangle of a grain outline in the first grain image and a minimum circumscribed rectangle of the grain outline to obtain a second grain image corresponding to the first grain image;
[0008] acquiring at least one image pair including different sides of the target grain from each of the second grain images, and merging each image pair into a third grain image;
[0009] The preset neural network model is trained based on each third grain image.
[0010] According to a second aspect of an embodiment of the present invention, there is provided a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the multi-view grain image processing method described above is implemented.
[0011] According to a third aspect of an embodiment of the present invention, there is provided an electronic device comprising: a memory and a processor; a computer program is stored in the memory, and when the computer program is executed by the processor, the multi-view grain image processing method described above is implemented.
[0012] In the solution provided by the embodiment of the present invention, through multi-angle shooting, it is possible to obtain an image pair containing different sides of the target grain, and merge the images in the image pair into a third grain image. In this way, through image merging, the amount of image data that needs to be processed can be reduced. At the same time, the image features of grains on different sides are retained during merging, so that the model can recognize the features of the sides of the grain particles, thereby learning the defect features of the grain particles presented on each side, improving the recognition accuracy of imperfect grains, and increasing the speed of model training while ensuring the richness of image information. In addition, by stretching the grain contour, the focus area of each first grain image, that is, the image area where the grain is located, is expanded, and the focus area features are stretched accordingly, so that the model can better learn the features of the grain during the model training process.
[0013] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 is a schematic flow chart of a multi-view grain image processing method provided by an embodiment of the present invention;
[0015] Figure 2 is a structural schematic diagram of a first shooting device provided by an embodiment of the present invention;
[0016] Figure 3 is a structural schematic diagram of a second shooting device provided by an embodiment of the present invention;
[0017] Figure 4 is a scene schematic diagram of a first image stretching method provided by an embodiment of the present invention;
[0018] Figure 5 is a schematic diagram of a scene of a second image stretching method provided by an embodiment of the present invention;
[0019] Figure 6 is a flowchart of an image merging method provided by an embodiment of the present invention;
[0020] Figure 7 is a structural schematic diagram of a neural network model provided by an embodiment of the present invention;
[0021] Figure 8 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0022] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.
[0023] The following describes a multi-view grain image processing method, a storage medium, and an electronic device according to an embodiment of the present invention with reference to the accompanying drawings.
[0024] In one embodiment of the present invention, see Figure 1 , provides a multi-view grain image processing method, which includes steps S101-S104.
[0025] S101: Acquire a first grain image of a target grain from multiple perspectives;
[0026] Specifically, different shooting devices may be used to shoot the target grain from different viewing angles to obtain a plurality of first grain images containing the target grain.
[0027] In one embodiment of the present invention, five cameras, camera A to camera E, may be used to obtain five first grain images. Figure 2 It shows four cameras A, B, C, and D, F is a conveying mechanism for carrying grains, and camera E can be set directly opposite to camera C.
[0028] Among them, camera A can be set to obtain the bottom image of the target grain, and cameras BCDE can be set to obtain the upper images of different sides of the target grain.
[0029] In order to make cameras BCDE include different sides, cameras BCDE can be set opposite to each other, such as Figure 3 As shown, BCDE represents four cameras, and F represents a conveying mechanism for carrying grains. In this way, the repeated parts in the images collected by the four cameras inclined at the top can be reduced.
[0030] S102: for each of the at least two first grain images, stretching the first grain image based on the maximum circumscribed rectangle and the minimum circumscribed rectangle of the grain outline in the first grain image to obtain a second grain image corresponding to the first grain image;
[0031] Ideally, the grains move in a horizontal direction from left to right. However, the grain state during loading is uncontrollable, resulting in different orientations of the grains. Therefore, it is necessary to correct the grain posture by stretching to unify the direction of the grains.
[0032] The specific stretching method may be as follows.
[0033] The coordinates of the third corner point after stretching are determined based on the first corner point coordinates of the maximum circumscribed rectangle of the grain outline in the first grain image and the second corner point coordinates of the minimum circumscribed rectangle of the grain outline, and the first grain image is stretched based on the transformation relationship between the second corner point coordinates and the third corner point coordinates.
[0034] like Figure 4 As shown, the coordinates of the first corner point , , , Indicates the maximum enclosing rectangle, the coordinates of the second corner point , , , Represents the minimum enclosing rectangle, the coordinates of the third corner point are , , , .
[0035] After obtaining the coordinates of the first corner point and the second corner point, they can be adjusted by rotation and stretching.
[0036] by Figure 3 Taking the illustrated embodiment as an example, for camera B, the coordinates of the third corner point can be determined as follows.
[0037]
[0038] For camera C, the coordinates of the third corner point can be determined as follows.
[0039]
[0040] For camera D, the coordinates of the third corner point can be determined as follows.
[0041]
[0042] For camera E, the coordinates of the third corner point can be determined as follows.
[0043]
[0044] Among them, w and h are the width and height of the image, and the calculation method is as follows:
[0045]
[0046]
[0047] a is a preset coefficient, for example, it can be set to 0.25, 0.3, etc.
[0048] In this way, the second corner point coordinates can be transformed into the third corner point coordinates by using perspective transformation, thereby determining the transformation relationship between the corner point coordinates and using the determined transformation relationship to act on all pixel points in the first grain image to complete the stretching.
[0049] Compared with directly rotating the image, the first grain image can be stretched by using the maximum circumscribed rectangle and the minimum circumscribed rectangle, which can unify the angle of the image and magnify the features of the grain in the image.
[0050] like Figure 5 As shown, the pixel size of the graphic area representing the worm-eaten tunnel in the original image is 42*91. After stretching according to the coordinates of the third triangle point of the camera B, the pixel size is stretched to 107*125, and the defect feature is magnified.
[0051] S103: acquiring at least one image pair including different sides of the target grain from each second grain image, and merging each image pair into a third grain image;
[0052] S104: Training a preset neural network model based on each third grain image.
[0053] For example, a neural network can be trained to identify the category of grains, and each third grain image can be labeled with a type. Each third grain image can be input into a preset neural network model, and model parameters of the neural network model can be adjusted according to the difference between the grain type output by the neural network model and the labeled type to implement model training.
[0054] For another example, the annotation type of the imperfect grain in the first grain image can be set. The annotation type can be as follows: Figure 4 The insect damage type, or mildew type, spot type, etc. in the embodiment, then stretch the first grain image, magnify the defect features of the imperfect grains, obtain a second grain image, and merge it with another second grain image of the same grain to obtain a third grain image, input the third grain image into a preset neural network model, and adjust the model parameters of the neural network model according to the difference between the defect type output by the neural network model and the labeled type to realize model training.
[0055] Alternatively, the neural network model may be trained based on the feature fusion method in subsequent embodiments, which will not be described in detail here.
[0056] In the solution provided by the embodiment of the present invention, through multi-angle shooting, it is possible to obtain an image pair containing different sides of the target grain, and merge the images in the image pair into a third grain image. In this way, through image merging, the amount of image data that needs to be processed can be reduced. At the same time, the image features of grains on different sides are retained during merging, so that the model can recognize the features of the sides of the grain particles, thereby learning the defect features of the grain particles presented on each side, improving the recognition accuracy of imperfect grains, and increasing the speed of model training while ensuring the richness of image information. In addition, by stretching the grain contour, the focus area of each first grain image, that is, the image area where the grain is located, is expanded, and the focus area features are stretched accordingly, so that the model can better learn the features of the grain during the model training process.
[0057] In one embodiment, the preset neural network may be trained based on each third grain image in the following manner.
[0058] The brightness value of a color channel is determined according to the pixel value of each third grain image, and a composite grain image is obtained based on the brightness value of each color channel, and a preset neural network model is trained based on the composite grain image and each third grain image.
[0059] The synthesis method is as follows:
[0060] Acquire synthetic image features of the synthetic grain image and third image features of each third grain image; perform feature fusion on the synthetic image features and each third image feature to obtain fusion features; and train a preset neural network model based on the fusion features.
[0061] The following filters can be used to extract image features, such as Figure 7 shown.
[0062] The neural network filter consists of a convolution layer, a batch normalization layer, a ReLU layer, and a pooling layer. The specific structure is as follows:
[0063] 1. Convolution layer: The convolution kernel size is 7×7, the stride is 2, the padding is 3 pixels, and the number of output channels is 16, that is, 16 feature maps are generated. The convolution layer receives input.
[0064] 2. Batch Normalization Layer: Batch normalize the output of the convolutional layer.
[0065] 3. ReLU layer: Perform ReLU activation on the batch normalized output.
[0066] 4. Pooling layer: MaxPooling is used, the pooling window size is 3×3, the step size is 2, and the padding is 1 pixel. The pooling layer outputs image features.
[0067] The synthetic image feature is the image feature of the synthetic grain image, which is extracted in the same way as the third image feature, both of which are extracted through the above-mentioned neural network filter, and the only difference is the replacement of the name concept.
[0068] After being processed by this filter, the image features of each input image can be represented by a feature vector of size 16×56×56. Then, the four input images are processed by the filter respectively to obtain feature maps representing the image features, and the feature maps are concatenated in the channel dimension to obtain an output feature map of size 64×56×56, which is a fused feature. This feature map can be connected to other networks for training and supports backpropagation to update parameters. For example, this feature layer can directly replace the first layer of the ResNet network series, so that the model can learn richer features while retaining more original image information. This design not only improves the training effect, but also reduces the processing time while maintaining the details and panoramic information of the image. In this way, the accuracy and efficiency of the neural network model in the task of grain particle detection can be improved.
[0069] The color channels in the above embodiment may be RGB three channels. In other embodiments, eight or more first grain images may be obtained through step S101, so that at least four third grain images may be obtained when the third grain images are combined. In this case, the obtained third grain images may be synthesized as the values of the CMYK four channels.
[0070] In other embodiments, only the image features of the third grain image may be used for feature fusion to obtain fused features.
[0071] In one embodiment of the present invention, each image pair may be merged into a third grain image in the following manner.
[0072] For each image pair, the two second grain images in the image pair are cropped respectively to obtain a fourth grain image and a fifth grain image; based on the grain contour in the fourth grain image and the grain contour in the fifth grain image, the fourth grain image and the fifth grain image are spliced to obtain a third grain image.
[0073] Stitching the second grain image after cropping reduces the amount of image processing data compared to directly processing the image, and avoids the problem that panoramic stitching is highly dependent on features, has a slow speed, and cannot meet the real-time detection requirements of the device.
[0074] When cropping, portions of the two second grain images may be retained according to a preset ratio. For example, 60% of the area on the side of the grain represented by each image may be cropped, and 10% of the redundant image may be retained.
[0075] Alternatively, 50% or 70% of each image may be cropped.
[0076] Specifically, during the stitching process, the fourth grain image and the fifth grain image may be binarized respectively to obtain a first grain outline image corresponding to the fourth grain image and a second grain outline image corresponding to the fifth grain image;
[0077] The size of the first grain outline image is adjusted so that the outline edge in the first grain outline image is aligned with the outline edge in the second grain outline image; the adjusted first grain outline image and the second grain outline image are merged, and the fourth grain image and the fifth grain image are spliced based on the merged grain outline image to obtain a third grain image.
[0078] For each image pair, the fourth grain image may be any one of the grain images, and the fifth grain image may be the other grain image.
[0079] In one embodiment, the image with a larger outline area can be used as the first grain outline image, and the corresponding grain image can be used as the fourth grain image. In this way, when adjusting the size of the first grain outline image, the image is scaled rather than magnified to reduce the blurring of the adjusted image.
[0080] like Figure 6 After the original image is cropped, the cropped fourth grain image and the fifth grain image can be binarized respectively. When aligning the contours, the start and end points of the edges cropped from the two images are used for alignment. In this embodiment, the fourth grain image D obtained by processing the first grain image taken by camera D and the fifth grain image B obtained by processing the first grain image taken by camera B are taken as examples.
[0081] like Figure 6 Cropped parts of the original image, the upper part is the cropped image D, and the lower part is the cropped image B.
[0082]
[0083]
[0084] represents the starting point 1 in image B, Indicates end point 2 in image B. The pixel value x of the edge represents the xth pixel point on the edge from left to right.
[0085] In the figure, that is, on the cropped edge, from left to right, the first white pixel is the starting point, and the last white pixel is the ending point, such as Figure 6 As shown in . The start and end points of the two images are located at the same position after the images are resized, forming contour edge alignment.
[0086] The adjusted first grain outline image and the second grain outline image are merged, and edge expansion compensation can be performed to make the overall shape of the image square. Taking the BD merging of images as an example, the edge expansion is performed in the following manner.
[0087]
[0088]
[0089]
[0090]
[0091] in, represents the image after edge expansion, () function means adjusting the size of image D. The adjustment method is , is the width of image d, is the height of image d, is the proportionality coefficient; represents the starting point of image D, represents the starting point of image B, Indicates the end point of image B. They are the lengths of the expansion edges on the left side of the starting point and on the right side of the ending point in image D respectively.
[0092] After edge expansion compensation, a combined grain outline image is obtained, and the image areas representing grains in the fourth grain image and the fifth grain image are mapped to the combined grain outline to obtain a third grain image.
[0093] In one embodiment, the fourth grain image may be binarized in the following manner to obtain the first grain contour image corresponding to the fourth grain image.
[0094] A first brightness value of a red channel and a second brightness value of a brightness channel of the fourth grain image are obtained, a target grayscale value is calculated based on the first brightness value and the second brightness value, and a grayscale image corresponding to the fourth grain image is generated based on the target grayscale value; and image segmentation is performed on the grayscale image to obtain a first grain contour image corresponding to the fourth grain image.
[0095] The method for calculating the target grayscale value can be seen in Formula 1.
[0096]
[0097] in, represents the target grayscale value of the i-th row and j-th column in the fourth grain image, represents the first brightness value of the i-th row and j-th column in the fourth grain image, is the maximum brightness value of the brightness channel, which can be calculated as follows:
[0098] =
[0099] in Indicates the maximum brightness value, , , They are respectively the brightness value of the red channel, the brightness value of the green channel, and the brightness value of the blue channel in the i-th row and j-th column of the fourth grain image.
[0100] The brightness channel is a channel formed by the maximum brightness value among the brightness values of the red channel, the green channel, and the blue channel.
[0101] In some other embodiments, in addition to using the brightness value of the red channel, the brightness value of the green channel or the bright color channel may be used to replace the brightness value of the red channel for the above processing.
[0102] Specifically, according to the conditions of different types of grains, a color channel with a higher average brightness value can be selected for processing in the above manner. For example, if the average brightness value of the red channel in the images of corn, wheat and rice is higher, the brightness value of the red channel is selected.
[0103] The manner of performing binarization processing on the fifth grain image is similar to the manner of performing binarization processing on the fourth grain image described above, and will not be described in detail here.
[0104] In one embodiment, after generating the grayscale image corresponding to the fourth grain image based on the target grayscale value, the method further includes:
[0105] The grayscale image is processed by any one or more of the following methods:
[0106] Performing a white point reduction operation on the grayscale image;
[0107] Performing a dark portion stretching operation on the grayscale image;
[0108] A bright portion stretching operation is performed on the grayscale image.
[0109] The above white point reduction operation can be implemented according to Formula 2 below.
[0110]
[0111] Wherein, ' represents the gray value of the i-th row and j-th column after processing, represents the gray value of the i-th row and j-th column before processing; is a preset white point value. The clip() function is used to represent the limitation of the function value. Specifically, clip(x, a, b) means to limit x within the closed interval [a, b]. If x > b, the clip function assigns x to b; if x < a, the clip function assigns x to a.
[0112] The dark part refers to the image area in the grayscale image where the gray value is lower than the preset gray threshold value, and vice versa for the bright part. The stretching operation means to increase the range of the gray values of the dark part and the bright part.
[0113] Among them, the dark part stretching operation can be carried out according to Formula 3 below.
[0114] Formula 3:
[0115]
[0116] Wherein, is the gray value of the i-th row and j-th column after the dark part stretching operation, is the gray value of the i-th row and j-th column before the dark part stretching operation. The clip() function is used to represent the limitation of the function value, the same as above; S is a preset shadow value.
[0117] The bright part stretching operation can be carried out according to Formula 4 below.
[0118] Formula 4
[0119]
[0120] Wherein, is the gray value of the i-th row and j-th column after the bright part stretching operation, is the gray value of the i-th row and j-th column before the bright part stretching operation. The clip() function is used to represent the limitation of the function value, the same as above; H is a preset highlight value.
[0121] If there are lesions on the surface of the cereal grains, it may lead to poor segmentation effect of the dark areas in the grayscale image. Especially when the lesion area is at the edge of the grain, it is not easy to distinguish from the background. To solve this problem, the embodiments of the present invention enhance the image by stretching the dark part and the bright part, adjusting the difference between the bright and dark areas in the image, and highlighting the main body of the grain.
[0122] In one embodiment of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, any of the multi-view grain image processing methods described above is implemented.
[0123] In one embodiment of the present invention, an electronic device is provided, comprising: a memory and a processor; a computer program is stored in the memory, and when the computer program is executed by the processor, any of the multi-view grain image processing methods described above is implemented.
[0124] Figure 8 It is a structural block diagram of an electronic device according to an embodiment of the present invention.
[0125] like Figure 8 As shown, the electronic device 800 includes: a processor 801 and a memory 803. The processor 801 and the memory 803 are connected, such as through a bus 802. Optionally, the electronic device 800 may also include a transceiver 804. It should be noted that in actual applications, the transceiver 804 is not limited to one, and the structure of the electronic device 800 does not constitute a limitation on the embodiments of the present invention.
[0126] The processor 801 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of the present invention. The processor 801 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0127] The bus 802 may include a path to transmit information between the above components. The bus 802 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 802 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0128] The memory 803 is used to store a computer program corresponding to the multi-view grain image processing method of the above embodiment of the present invention, and the computer program is controlled and executed by the processor 801. The processor 801 is used to execute the computer program stored in the memory 803 to implement the content shown in the above method embodiment.
[0129] Among them, the electronic device 800 includes but is not limited to: mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The electronic device 800 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0130] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection portion with one or more wirings (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0131] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0132] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0133] In the description of the present invention, it is to be understood that the terms “center”, “longitudinal”, “lateral”, “length”, “width”, “thickness”, “up”, “down”, “front”, “back”, “left”, “right”, “vertical”, “horizontal”, “top”, “bottom”, “inside”, “outside”, “clockwise”, “counterclockwise”, “axial”, “radial”, “circumferential”, etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.
[0134] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0135] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0136] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, a first feature being "above", "above" or "above" a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being "below", "below" or "below" a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.
[0137] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A multi-view grain image processing method, It is characterized in that The method comprises: Acquire a first grain image of a target grain from multiple perspectives; For each of the at least two first grain images, the first grain image is stretched based on a maximum circumscribed rectangle of a grain outline in the first grain image and a minimum circumscribed rectangle of the grain outline to obtain a second grain image corresponding to the first grain image; acquiring at least one image pair including different sides of the target grain from each of the second grain images, and merging each image pair into a third grain image; The preset neural network model is trained based on each third grain image.
2. The multi-view grain image processing method according to claim 1, It is characterized in that The training of a preset neural network based on each third grain image includes: The brightness value of a color channel is determined according to the pixel value of each third grain image, and a composite grain image is obtained based on the brightness value of each color channel, and a preset neural network model is trained based on the composite grain image and each third grain image.
3. The multi-view grain image processing method according to claim 1, It is characterized in that The stretching of the first grain image based on the maximum circumscribed rectangle of the grain outline in the first grain image and the minimum circumscribed rectangle of the grain outline comprises: The coordinates of the third corner point after stretching are determined based on the first corner point coordinates of the maximum circumscribed rectangle of the grain outline in the first grain image and the second corner point coordinates of the minimum circumscribed rectangle of the grain outline, and the first grain image is stretched based on the transformation relationship between the second corner point coordinates and the third corner point coordinates.
4. The multi-view grain image processing method according to claim 1, It is characterized in that The step of merging each pair of images into a third grain image comprises: For each image pair, two second grain images in the image pair are cropped respectively to obtain a fourth grain image and a fifth grain image; The fourth grain image and the fifth grain image are spliced based on the grain contour in the fourth grain image and the grain contour in the fifth grain image to obtain a third grain image.
5. The multi-view grain image processing method according to claim 4, It is characterized in that The step of splicing the fourth grain image and the fifth grain image based on the grain contour in the fourth grain image and the grain contour in the fifth grain image to obtain the third grain image includes: performing binarization processing on the fourth grain image and the fifth grain image respectively to obtain a first grain outline image corresponding to the fourth grain image and a second grain outline image corresponding to the fifth grain image; The size of the first grain outline image is adjusted so that the outline edge in the first grain outline image is aligned with the outline edge in the second grain outline image; the adjusted first grain outline image and the second grain outline image are merged, and the fourth grain image and the fifth grain image are spliced based on the merged grain outline image to obtain a third grain image.
6. The multi-view grain image processing method according to claim 5, It is characterized in that The fourth grain image is binarized in the following manner to obtain a first grain contour image corresponding to the fourth grain image: A first brightness value of a red channel and a second brightness value of a brightness channel of the fourth grain image are obtained, a target grayscale value is calculated based on the first brightness value and the second brightness value, and a grayscale image corresponding to the fourth grain image is generated based on the target grayscale value; and image segmentation is performed on the grayscale image to obtain a first grain contour image corresponding to the fourth grain image.
7. The multi-view grain image processing method according to claim 6, It is characterized in that After generating the grayscale image corresponding to the fourth grain image based on the target grayscale value, the method further includes: The grayscale image is processed by any one or more of the following methods: Performing a white point reduction operation on the grayscale image; Performing a dark portion stretching operation on the grayscale image; A bright portion stretching operation is performed on the grayscale image.
8. The multi-view grain image processing method according to claim 2, It is characterized in that The step of training a preset neural network model based on the synthesized grain image and each third grain image comprises: acquiring a composite image feature of the composite grain image and a third image feature of each third grain image; Performing feature fusion on the synthetic image feature and each third image feature to obtain a fused feature; The preset neural network model is trained based on the fusion features.
9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the multi-view grain image processing method according to any one of claims 1 to 8 is implemented.
10. An electronic device, It is characterized in that include: Memory, processor; The memory stores a computer program, and when the computer program is executed by the processor, the multi-view grain image processing method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Unsound wheat grain recognition method based on machine vision
CN108875747A
Integrated method for extracting grain shape characters of rice panicle grains
CN116612178A
