CN115345880B - Corn ear character estimation method and device based on corn ear unilateral scanning map - Google Patents

Corn ear character estimation method and device based on corn ear unilateral scanning map Download PDF

Info

Publication number
CN115345880B
CN115345880B CN202211269715.8A CN202211269715A CN115345880B CN 115345880 B CN115345880 B CN 115345880B CN 202211269715 A CN202211269715 A CN 202211269715A CN 115345880 B CN115345880 B CN 115345880B
Authority
CN
China
Prior art keywords
ear
rectangular
corn
row
rectangle
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211269715.8A
Other languages
Chinese (zh)
Other versions
CN115345880A (en
Inventor
朱旭华
陈渝阳
赵飞
刘荣利
张盛军
傅林锋
王闯
袁娜朵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Top Cloud Agri Technology Co ltd
Original Assignee
Zhejiang Top Cloud Agri Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Top Cloud Agri Technology Co ltd filed Critical Zhejiang Top Cloud Agri Technology Co ltd
Priority to CN202211269715.8A priority Critical patent/CN115345880B/en
Publication of CN115345880A publication Critical patent/CN115345880A/en
Application granted granted Critical
Publication of CN115345880B publication Critical patent/CN115345880B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/12Edge-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/10Image acquisition
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/26Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/28Quantising the image, e.g. histogram thresholding for discrimination between background and foreground patterns
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/44Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • G06V20/10Terrestrial scenes
    • G06V20/188Vegetation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30181Earth observation
    • G06T2207/30188Vegetation; Agriculture

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Quality & Reliability (AREA)
  • Image Analysis (AREA)

Abstract

The method comprises the steps of analyzing a scanned graph, cutting a single-ear graph from the graph according to a self-defined external rectangle of an ear, taking the length of the graph as the length of the ear, taking the distance between a center line of a middle section of the ear and two intersection points of a convex hull of the center line as the width of the ear, and taking intersection angles of fitting straight lines of two edges of the ear and a central axis of the ear as ear edge angles of the ear; obtaining a binary image, and determining the convex tip of the cluster according to the distribution condition of grains; carrying out local binarization on the single ear image to obtain a binary image of only corn grains, and determining the number of the grains in a row according to the condition that the number of the grains is large and the grain number is close to the middle of the ear in the axial direction of the ear; and determining the row number of the ears according to the condition that the ears are close to the center of the ears and the ears are more in the width direction of the ears. The parameters of the single side of the corn ear are used for predicting the parameters of the whole corn ear, the partial properties of the corn ear are conveniently estimated, and the method has the advantages of low cost, stability, advanced algorithm and the like.

Description

Corn ear character estimation method and device based on corn ear unilateral scanning map
Technical Field
The application relates to the field of image processing, in particular to a corn ear character estimation method and device based on a corn ear unilateral scanning map.
Background
The characteristics of the corn ears comprise the length, the width, the row grain number, the ear row angle, the convex tip, the ear edge angle and the like of the corn ears, the analysis and the research on the shape parameters of the corn ears are an important part of scientific research work, and the method has very important significance for breeding high-quality corn varieties and improving the corn yield. In other words, in order to examine the degree of influence of corn ear traits on corn yield and to clarify the influence of individual trait indicators on corn yield, it is necessary to measure individual traits of corn ears.
At present, the agricultural industry still adopts the mode of manual measurement statistics as the main thing, has the problem that work load is big, influence labor input, measurement efficiency and measurement accuracy are not good. In recent years, digital image technology is applied to measurement of corn ear test species, a common means is to fix corn ears by using a device, take pictures around the corn ears by using a camera and perform picture splicing to obtain a complete corn ear picture, and then estimate various property parameters of the complete corn ear picture. Of course, there is also a scheme of measuring the properties of the corn ears by collecting two-dimensional maps of multiple corn ears, but such a scheme requires strict control of corn placement and light supplement devices, and the change of light rays can affect the difference of corn parameters.
In summary, there are many disadvantages in the scheme of the method for estimating the maize ear trait in the market.
Disclosure of Invention
The embodiment of the application provides a corn ear character estimation method and device based on a corn ear unilateral scanning diagram, a scanner is used for acquiring a plurality of corn ear unilateral two-dimensional diagrams so as to estimate the character of the corn ear, and the estimation effect with lower cost, more ears, stable environmental performance, and more excellent algorithm advancement and accuracy is realized.
In a first aspect, an embodiment of the present application provides a method for estimating traits of a corn ear based on a single-side scan of the corn ear, where the method includes:
s100, acquiring a single side of a corn ear by using a scanner to obtain a corresponding first image, and performing binarization processing on the first image to obtain a first binary image;
s200, segmenting the first image according to the rectangular frame where the corn ears are located to obtain a corresponding second image, and segmenting the first binary image according to the rectangular frame where the corn ears are located to obtain a corresponding second binary image;
s300, acquiring the length of the second binary image as the ear length of the corn ear, and acquiring the distance between a middle section line of the middle section of the corn ear and two intersection points of an inner convex hull of the middle section of the corn ear as the ear width of the corn ear;
s400, acquiring an intersection angle of a straight line fitted with the contour of the two edges of the corn ear in the second binary image and a central axis of the corn ear as an ear edge angle of the corn ear;
s500, binarizing the blue channel image of the second image, determining a convex tip of the corn ear and a segmentation line of the kernel, and taking the convex tip on one side of the segmentation line as the convex tip of the corn ear.
In a second aspect, an embodiment of the present application provides an apparatus for estimating corn ear traits based on a single-side scan of a corn ear, including:
the scanning instrument is used for acquiring one side of the corn ear by using the scanner to obtain a corresponding first image;
the processing unit is used for carrying out binarization processing on the first image to obtain a first binary image, segmenting the first image according to a rectangular frame where the corn ears are located to obtain a corresponding second image, and segmenting the first binary image according to the rectangular frame where the corn ears are located to obtain a corresponding second binary image;
the ear length and width acquisition unit is used for acquiring the length of the second binary image as the ear length of the corn ear, and acquiring the distance between a middle section line of the middle section of the corn ear and two intersection points of a convex hull in the middle section of the corn ear as the ear width of the corn ear;
the ear edge angle acquisition unit is used for acquiring an intersection angle of a straight line fitted by the profiles of the two edges of the corn ear and the central axis of the corn ear in the second binary image as an ear edge angle of the corn ear;
the convex tip obtaining unit is used for determining a convex tip of the corn ear and a division line of the kernel after binarization is carried out on the blue channel image of the second image, and taking the convex tip on one side of the division line as the convex tip of the corn ear;
the first line grain number and ear row angle acquisition unit is used for carrying out local binarization processing on the second image to obtain a third binary image only containing corn grains, and selecting a rectangular frame where effective grains are located in the third binary image as a first positive external rectangular set of the grains; acquiring all rectangular rows in the first right external rectangular set along the horizontal direction of the corn ear stems as a first rectangular row set, selecting the rectangular rows which are close to the middle section of the corn ears and have more rectangular data in the first rectangular row set as preferred rectangular rows, acquiring the number of rectangular frames in the preferred rectangular rows as the first row grain number of the corn ears, and acquiring the intersection angle of the preferred rectangular rows and the central axis of the corn ears as the ear row angle of the corn ears;
and the first ear row number obtaining unit is used for selecting an area close to the middle section of the corn ear along the vertical direction of the corn ear shaft as a screening area, and obtaining the maximum value of the number of the rectangular rows of the first rectangular row set in the screening area as the first ear row number of the corn ear.
In a third aspect, an embodiment of the present application provides an electronic device, which includes a memory and a processor, where the memory stores a computer program, and the processor is configured to execute the computer program to perform any one of the methods for estimating corn ear traits based on a single-side scan of a corn ear.
In a fourth aspect, embodiments of the present application provide a readable storage medium having stored therein a computer program comprising program code for controlling a process to execute a process comprising any of the methods for ear trait estimation based on single-sided scans of ears of corn described herein.
The main contributions and innovation points of the invention are as follows:
according to the embodiment of the application, the corn ear image collected by the scanner is analyzed, so that the stability of the image collecting environment can be ensured, and the influence of ambient light and camera distortion is avoided; in addition, the scheme adopts an original algorithm to characterize the ear row number, ear row angle, row grain number, convex tip, ear edge angle, length of the corn ear, width of the corn ear and average grain height of the corn ear, so that an accurate measurement result can be obtained.
The details of one or more embodiments of the application are set forth in the accompanying drawings and the description below to provide a more thorough understanding of the application.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
FIG. 1 is a flow chart of a method for corn ear trait estimation based on a single-sided scan of a corn ear according to an embodiment of the present application;
FIG. 2 is a schematic illustration of a first acquired image;
FIG. 3 is a schematic diagram of a first binary map;
FIG. 4 is a schematic view of a circumscribed rectangle of an ear of corn;
FIG. 5 is a second image after cut correction, a second binary image and a third binary image;
FIG. 6 is a schematic representation of the length and width of an ear of corn;
FIG. 7 is a schematic representation of the fringe angle of an ear of corn;
FIG. 8 is a schematic view of the convex tip of an ear of corn;
FIG. 9 is a schematic diagram of the lookup of the row size number and ear row number for an ear of corn;
FIG. 10 is a schematic representation of parameters for various traits of an ear of corn;
fig. 11 is a hardware configuration diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of the specification. Rather, they are merely examples of apparatus and methods consistent with certain aspects of one or more embodiments of the specification, as detailed in the claims which follow.
It should be noted that: in other embodiments, the steps of the corresponding methods are not necessarily performed in the order shown and described herein. In some other embodiments, the method may include more or fewer steps than those described herein. Moreover, a single step described in this specification may be broken down into multiple steps for description in other embodiments; multiple steps described in this specification may be combined into a single step in other embodiments.
Example one
The scheme provides a corn ear character estimation method and device based on a corn ear unilateral scanning map, which are different from a traditional mode of splicing a whole image of a corn ear in a surrounding mode and a mode of acquiring an image of the corn ear by photographing through a plurality of cameras.
As shown in fig. 1, the method for estimating maize ear traits based on a maize ear unilateral scan map provided by the present scheme includes the following steps:
s100, acquiring a single side of a corn ear by using a scanner to obtain a corresponding first image, and performing binarization processing on the first image to obtain a first binary image;
s200, dividing the first image according to the rectangular frame where the corn ears are located to obtain a corresponding second image, and dividing the first binary image according to the rectangular frame where the corn ears are located to obtain a corresponding second binary image;
s300, acquiring the length of the second binary image as the ear length of the corn ear, and acquiring the distance between a middle section line of the middle section of the corn ear and two intersection points of an inner convex hull of the middle section of the corn ear as the ear width of the corn ear;
s400, acquiring an intersection angle of a straight line fitted with the contours of the two edges of the corn ear and a central axis of the corn ear in the second binary image as an ear edge angle of the corn ear;
s500, binarizing the blue channel image of the second image, determining a convex tip of the corn ear and a partition line of grains, and taking the convex tip on one side of the partition line as the convex tip of the corn ear;
s600, carrying out local binarization processing on the second image to obtain a third binary image only containing corn grains, and selecting a rectangular frame where effective grains are located in the third binary image as a first positive external rectangular set of the grains;
s700, taking all rectangular rows in the first right external rectangular set along the horizontal direction of the corn ear stems as a first rectangular row set, selecting the rectangular rows which are close to the middle section of the corn ears and have more rectangular data in the first rectangular row set as preferred rectangular rows, obtaining the number of rectangular frames in the preferred rectangular rows as the first row grain number of the corn ears, and obtaining the intersection angle of the preferred rectangular rows and the central axis of the corn ears as the ear row angle of the corn ears;
s800, selecting an area close to the middle section of the corn ear along the vertical direction of the corn ear shaft as a screening area, and obtaining the maximum value of the number of rectangular rows of the first rectangular row set in the screening area as the first ear row number of the corn ear.
In some embodiments, the present solution further comprises the steps of: estimating an average grain height of the corn ear based on the preferred rectangular row and the first row grain number, estimating a row grain number of the corn ear based on the ear length and the lobe, and estimating a ear row number of the corn ear based on the first ear row number. The method can estimate and obtain the ear row number, ear row angle, row grain number, convex tip, ear edge angle, ear length of the corn ear, ear width and average grain height of the corn ear as the character parameters of the corn ear, and the method can convert the pixel size into the actual size corresponding to the character parameters according to the parameters of the scanner.
In some embodiments, the obtained local parameters related to the traits of each type of corn ear are subjected to statistical analysis to predict the overall traits of the corn ear. Because the scanner acquires the single-side image of the corn ear, the acquired data is the single-view angle parameter of the corn ear, and the overall character parameter of the corn ear can be estimated through the single-view angle parameter.
It is worth noting that the present protocol is preferably applicable to both yellow and white corn ears.
In step S100, the single-side image of the corn ear is obtained by scanning the single side of the corn ear with a scanner, as shown in fig. 2, the single-side image of the corn ear is used as a first image, and the first image is binarized with a manual threshold to obtain a first binary image. It is worth mentioning that the first image is an image displayed in a color style.
This scheme adopts the mode of scanner collection first image, can guarantee to gather the stability of image environment, does not receive the influence of ambient light and camera distortion. The scanner sets dpi parameters, and then the dpi parameters can be used to convert the pixel sizes of various characters into actual sizes. In the embodiment of the scheme, a 300dpi parameter is adopted, in order to simplify the algorithm difficulty, the first image is binarized by using a manual threshold input mode, the same corn generally only needs to be set with one threshold, and the thresholds of different varieties of corn are different; the image directly acquired by the scanner is the first image.
Specifically, as shown in fig. 3, in the step of "performing binarization processing on the first image to obtain a first binary image", the method further includes the steps of:
1) Extracting an R channel map from the first image;
2) Carrying out binarization processing on the R channel map based on a set threshold value to obtain a binary map binary1;
3) Carrying out corrosion expansion operation on the binary image binary1 and removing noise to obtain a binary image binary2;
4) Traversing the connected domains of the binary image binary2, screening out effective connected domains, and filling the inner cavities of the effective connected domains to obtain a first binary image.
In some embodiments of the present disclosure, the valid connected domain is selected according to the following selection conditions:
and screening the connected domain with the pixel area larger than one fiftieth of the pixel area of the image and the ratio of the short side to the long side of the minimum circumscribed rectangle of the connected domain larger than 0.15 as an effective connected domain, wherein the obtained first binary image is shown in fig. 3.
The above screening conditions are formulated as follows:
(contoursaArea > ImageArea / 50)and(contoursaH1W > 0.15) ;
wherein contoursaArea is the pixel area of the connected domain, the pixel area of the ImageArea image; contoursaH1W is the ratio of the short side to the long side of the minimum bounding rectangle of the connected domain.
The screening conditions set by the scheme can well remove impurities except the corn ears.
In step S200, a second image is obtained by segmenting from the first image based on the rectangular frame of the ear of corn, and a second binary image is obtained by segmenting from the first binary image, and the obtained second binary image is shown in fig. 5. It is worth mentioning that the second image is a color-style image as the first image.
Step S200 further comprises the steps of:
in the first binary image, fitting edge lines on two sides of the corn ear to obtain a fitted straight line, constructing a circumscribed rectangle of the corn ear by taking the fitted straight line as an axis to serve as a rectangular frame of the corn ear, cutting and correcting the corn ear of the first image based on the circumscribed rectangle to obtain a second image, and forming a second image set by a plurality of second images; and cutting and correcting the corn ears of the first binary image based on the circumscribed rectangle to obtain a second binary image, wherein a plurality of second binary images form a second binary image set.
Specifically, as shown in fig. 4, in the scheme, fitting lines at two side edges of the corn ear are fitted to form a fitting straight line, an external rectangle is established as a rectangular frame of the corn ear by taking the fitting straight line as an axis, and the step of obtaining the rectangular frame of the corn ear is refined as follows:
1) Acquiring the outer ear contours of all corn ears in the first binary image to form an ear contour set, wherein the outer ear contour of the ith corn ear is recorded as contouri;
2) Carrying out smooth boundary processing on the outer contour of each cluster through corrosion expansion processing to obtain a smooth contour contouriSmooth;
3) Obtaining a minimum circumscribed rectangle A1A2A3A4 in the smooth contour contouriSmooth, keeping A1A2 as a long side and A1A4 as a short side through a first preset condition, keeping A1 and A4 at one end with a thin cluster and keeping A2 and A3 at one end with a thick cluster through a second preset condition;
the first preset condition is that the side length of the minimum external rectangle is compared, and the first preset condition is as follows:
distanceA12 > distanceA14
if the above formula is true, A1, A2, A3 and A4 are unchanged; if the formula is not satisfied, A1 and A3 are unchanged, and A2 and A4 are interchanged; wherein, A1, A2, A3, A4 are 4 corners corresponding to the minimum circumscribed rectangle A1A2A3A4, distanceA12 is the distance between A1 and A2, distanceA14 is the distance between A1 and A4.
Wherein the second preset condition is to compare the thickness of the two ends of the corn ear in the minimum circumscribed rectangle as follows:
countNonZeroA14 > countNonZeroA23
if the above formula is true, A1, A2, A3 and A4 are unchanged; if the formula is not satisfied, interchanging A1 and A2, interchanging A3 and A4; wherein, A1, A2, A3 and A4 are 4 corresponding corners of the minimum circumscribed matrix A1A2A3A4, the head and the tail of the corn ear are divided into two sections in the minimum circumscribed matrix A1A2A3A4, wherein, countNonZeroa14 is the number of foreground pixels of the ear at the A1A4 end, and countNonZeroa23 is the number of foreground pixels of the ear at the A2A3 end;
4) A part of the smooth contour contouriasmooth in the rectangular frame B1B2C 1 is cut out as a new contour, which is referred to as a B12 contour contouriasmooth B12, and a part of the smooth contour contouriasmooth in the rectangular frame B3B4C1C2 is cut out as a new contour, which is referred to as a B34 contour contouriasmooth B34;
the scheme corrects the smooth contour to eliminate the influence of larger deformation of two ends of the cluster on straight line fitting.
In the embodiment of the scheme, B1 is a division point on A1A2, and A1B 1: B1A2 = 1: 4 is satisfied; b2 is a break on A1A2, satisfying A1B 2: B2A2 =7: 1; b4 is a break on A4A3, satisfying A4B 4: B4A3 = 1: 4; b3 is a split point on A4A3, satisfying A4B 3: B3A3 =7: 1.
5) Performing linear fitting on the B12 contour contouriSmoothB12 to obtain a 12-fitting linear line12, and performing linear fitting on the B34 contour contouriSmoothB34 to obtain a 34-fitting linear line34; calculating the slope of a bisector between the line12 of the 12 fitting straight line and the line34 of the 34 fitting straight line, wherein the slope is combined with a midpoint D1 of A1 and A4 to form a straight line D1D2;
6) Traversing each coordinate point in each cluster outer contour contouri, acquiring at least one parallel straight line which passes through each coordinate point and is parallel to the straight line D1D2 to form a parallel straight line set, taking a parallel straight line E1E2 which is positioned at the leftmost side in the parallel straight line set, and taking a parallel straight line E3E4 which is positioned at the rightmost side in the parallel straight line set; and acquiring at least one vertical straight line which passes through each coordinate point and is perpendicular to the straight line D1D2 to form a vertical straight line set, taking the vertical straight line E2E3 positioned at the uppermost side in the vertical straight line set, taking the vertical straight line E1E4 positioned at the lowermost side in the vertical straight line set, and taking the matrix E1E2E3E4 as a rectangular frame of the corn ear.
In step S300, the length of the second binary image is used as the ear length of the ear, a 20% region located at the middle position of the ear is selected as the middle section of the ear, the convex hull of the ear in the middle section of the ear is identified, the distance between the middle section line of the middle section of the ear and the intersection of the two convex hulls of the convex hull is used as the ear width of the ear, and the middle section line of the middle section of the ear is perpendicular to the central axis of the ear.
As shown in fig. 6, the line A1A2 in fig. 6 is the length of the second binary image, and the length of the line A1A2 is the ear length of the corn ear.
The method for calculating the width of the corn ear can be further refined as follows:
1) Acquiring a rectangular area which is 20% of the middle position of the corn ear from the second binary image as a middle section C1C2C3C4 of the corn ear;
2) Finding out a convex hull covexhull in the foreground region in a middle section C1C2C3C4 of the corn ear, wherein the convex hull refers to the position of outward bulge on the outer contour of the corn ear, taking the midpoint of the C1C4 as C14, taking the midpoint of the C2C3 as C23, obtaining a middle section line of the middle section of the corn ear, which is taken as C14C23, and obtaining the distance between the central axis of the middle section of the corn ear and two intersection points B1 and B2 of the convex hull covexhull as the width of the corn ear.
In step S400, in the second binary image, straight line fitting is performed on the two edge contours of the corn ear to obtain two ear edge straight lines, and the intersection angles of the two ear edge straight lines and the central axis of the corn ear are used as the ear edge angles of the corn ear.
As shown in detail in fig. 7. The refining comprises the following steps:
1) Taking 4 corners of the second binary image and respectively marking the 4 corners as A1A2A3A4, wherein A1A2 is a long side, and A1A4 is a short side; a1 and A4 are arranged at the thin end of the corn ear, A2 and A3 are arranged at the thick end of the corn ear, and the outer contour contourer of the corn ear is obtained;
2) Performing smooth boundary treatment on the cluster outer contour contours through corrosion expansion treatment, and smoothing to obtain a smooth contour contourSmooth;
3) Taking the part of the smooth contour contourSmooth in the rectangular frame B1B2C 1 as a new contour, and recording the part of the smooth contour contouriasmooth in the rectangular frame B3B4C1C2 as a new contour, and taking the part of the flat pulley contour recording contourSmooth in the rectangular frame B12B 4C1C2 as a new contour, and recording the new contour as a B34 contour contourSmooth B34;
in this example, B1 is a division point on A1A2, satisfying A1B 1: B1A2 = 1: 4; b2 is a break on A1A2, satisfying A1B 2: B2A2 =7: 1; b4 is a break on A4A3, satisfying A4B 4: B4A3 = 1: 4; b3 is a break on A4A3, satisfying A4B 3: B3A3 =7: 1; c1 is the midpoint between B1 and B4, and C2 is the midpoint between B2 and B3.
3) Performing linear fitting on the contour contoursmoothB12 of the B12 to obtain a cluster edge straight line E1E2; performing linear fitting on the B34 profile contourSmoothB34 to obtain a fruit ear edge straight line F1F2;
4) And calculating an included angle angleE between the ear edge straight line E1E2 and the central axis C1C2 of the corn ear as an ear edge angle, and calculating an included angle angleF between the ear edge straight line F1F2 and the central axis C1C2 as an ear edge angle.
In step S500, the specific steps of determining the convex tip of the corn ear and the division line of the kernel after binarizing the blue channel map of the second image are as follows:
1) In the second binary image, the thin end is determined to be a convex tip according to the opening direction of the ear edge angle of the fruit ear.
As shown in fig. 7, the specific method is as follows: the line segments E1E2, F1F2 are on the fringe angle edges, the fringe angle opening can be determined by comparing the lengths of the line segments E1F1, F2E2, if the length of the line segment E1F1< F2E2, then the E1F1 end is the convex tip, and vice versa.
2) And taking the blue channel image from the second image to carry out binarization to obtain a blue channel binary image blueBinary.
The binarization method comprises the following steps: in the second image, taking the blue channel image as blue image, using the second binary image as a mask to calculate the average gray level of the blue channel image, and recording the average gray level as meanValue; carrying out smooth filtering on the blue channel image, then carrying out global binarization to obtain a blue channel binary image,
the binarization threshold is meanValue 0.68.
3) Carrying out contour searching on the blue channel binary image, and taking out all contours with contour areas larger than 50 to form a contour set contourArr4;
4) Traversing the contour set contourArr4, grouping the pixels with the distance between contours being less than 10 into a set, and taking the set with the maximum contour area as a contour set contourArr5;
5) In the contour set contourArr5, finding out a point closest to the convex tip from all contours, such as the point p marked in fig. 8; and (3) taking a vertical line passing through the mark point P as an x-axis as a dividing line, crossing the fruit cluster boundary at two points, taking the convex tip at one side of the dividing line as the convex tip of the corn fruit cluster, and concretely, crossing the fruit cluster boundary at two points H1 and H2 by the dividing line, wherein H1H2A4A1 is a convex tip area.
In step S600, the specific step of selecting the rectangular frame in which the effective grain is located in the third binary image as the first positive external rectangular set of grains is as follows:
1) Referring to the method for obtaining the binary image by using the local binarization method in the second image, performing corrosion expansion operation on the binary image obtained after the local binarization processing of the second image to remove impurities to obtain a third binary image, wherein the obtained third binary image is shown in fig. 5; the size of the sliding window for local binarization is optimally 1 to 2 times of the seed ruler, and the size of the sliding window in the example is 35;
2) Finding out the outlines of all the corn kernels in the third binary image, and making a positive external rectangle of all the outlines to form a positive external rectangle set recarr 2;
3) Traversing each positive external rectangle one by one in the positive external rectangle set rectAlr 2, if the center point of the current positive external rectangle is in other positive external rectangles in the rectAlr 2, deleting the current positive external rectangle until all the positive external rectangles are traversed and the processed positive external rectangle set rectAlr 3 is processed, and the rectangle in the rectangle can be well removed in the step;
4) In the positive external rectangle set recarr 3, traversing the positive external rectangles one by one, comparing the sizes and the position characteristics of the positive external rectangles respectively arranged at the left side and the right side by the current positive external rectangle, combining the smaller positive external rectangles, comparing the sizes and the position characteristics of the positive external rectangles respectively arranged at the upper side and the lower side by the current positive external rectangle, removing the smaller rectangles, and finally forming a grain rectangular frame of a rectangular set recarr 4 by the screened rectangles, which is shown in a) in fig. 9;
5) In the rectangle set rectAlr 4, the rectAlr 4 is sorted according to the increasing mode of the x coordinate of the center of the rectangle, and the sorted rectangle array is recorded as a first positive circumscribed rectangle set.
In step S700, in the first positive circumscribed rectangle set, finding out that all rectangle rows along the horizontal direction of the cob form a first rectangle row set, see b) in fig. 9, where a row of same-color rectangles form a rectangle row, and all rectangle rows form the first rectangle row set, and the process of obtaining the first rectangle row set includes the following steps:
1) Sequentially traversing rectangles in the first positive external rectangle set, finding out a first rectangle of a rectangle line according to a third preset condition, wherein the traversed rectangles are marked with a flag, the first rectangle is taken as a starting rectangle of the rectangle line, and then, the rectangle with the flag is directly skipped when finding the next rectangle line; the third preset condition is that the ratio of the perimeter of the convex hull of the grain image corresponding to the current rectangle in the third binary image to the perimeter of the outline is greater than a set threshold value.
The specific third preset condition is that the rectangles in the first positive external rectangle set are traversed in sequence, the ith rectangle is taken as the rect, the grain graph corresponding to the ith rectangle is found in the third binary graph according to the position of the rect, the edge outline of the grain and the convex hull of the outline of the grain are found, the perimeter len1 of the convex hull is calculated, and the perimeter len2 of the outline is calculated; when len1/len2 > 0.82 is satisfied, the current rectangle satisfies the requirement of the first rectangle firstRef;
2) Taking the first rectangle firstRef as a starting rectangle of the rectangle row, finding a rectangle meeting a fourth preset condition from the first rectangle in the first positive external rectangle set, replacing the original rectangle firstRef with the newly found rectangle to be used as a new first rectangle firstRef, marking the new rectangle firstRef as an upper flag, and repeating the step 2) until the fourth preset condition is not met; all iterated rectangles firstselect are formed into a row of rectangles and are marked as a first rectangle row, refer to b) in fig. 9, and a row of same-color rectangles are formed into a rectangle row which is also the first rectangle row;
the fourth preset condition is that the position distance and the area difference between the next rectangle and the current rectangle meet a set threshold and the arrangement direction is the same as that of the current rectangle, and the fourth preset condition is detailed as follows:
in the first positive circumscribed rectangle set, taking firstRef as a current rectangle, starting to traverse the rectangle backwards, and recording the jth rectangle as retj;
the next rectangle needs to satisfy the constraint to the right of the current rectangle:
(firstRectX + firstRectCols * 0.7)< rectjX;
the next rectangle needs to satisfy the up-down offset constraint with the current rectangle:
fabs(firstRectCenterY - rectjCenterY)/(firstRectRows*0.5 +rectjRows*0.5) < 0.8;
the next rectangle needs to satisfy the left-right distance constraint condition with the current rectangle:
fabs(firstRectCenterX - rectjCenterX)/(firstRectCols*0.5 +rectjCols*0.5) < 1.9;
the next rectangle needs to fill the area difference constraint of the current rectangle for the heel:
0.4 < firstRectArea / rectjArea < 2.5;
wherein firstRefX is the x coordinate to the left of the first rectangle firstRef, firstRecoCols is the width of the first rectangle firstRef, firstRecows is the height of the first rectangle firstRef, firstRecoX is the x coordinate of the center of the first rectangle firstRef, firstRecoY is the y coordinate of the center of the first rectangle firstRef, firstRecoArea is the area of the first rectangle firstRef; rectjX is the x coordinate to the left of the jth rectangle rectj, recjCols is the width of the jth rectangle rectj, rectjRows is the height of the jth rectangle rectj, rectjCenterX is the x coordinate of the center of the jth rectangle rectj, rectjCenterY is the y coordinate of the center of the jth rectangle rectj, rectjArea is the area of the jth rectangle rectj;
screening all rectangles meeting all the conditions, and forming a rectangle set which is recorded as retjSecondArr; traversing each rectangle in the rectjSecondArr, calculating miniDistLength values according to the following formula, and selecting a rectangle with the minimum miniDistLength value as a rectangle meeting a fourth preset condition;
miniDistAngle=distFirstRectCenter2rectkCenter*1.5slopeFirstRectCenter2rectkCenter;
wherein rectk is the kth rectangle in the rectangle set rectSecondAlrr, distFirstRefCenter 2rectkCenter is the distance from the center of the first rectangle firstRef to the center of the kth rectangle rectk, sloFirstRefCenter 2rectkCenter is the absolute value of the slope of a straight line from the center of the first rectangle firstRef to the center of the kth rectangle rectk; miniDistLength value can be minimized so that the next rectangle for the first rectangle firstRef is the rectangle closest to firstRef and continuing the row direction of the rectangle;
all the conditions constitute a fourth preset condition, and the condition is used for controlling the continuation and termination of the circulation of the step 2);
3) Repeating the step 1) and the step 2); when the step 1) is repeated, the rectangle with the flag mark is directly skipped, namely the first rectangle firstselect cannot carry the flag mark, and the process is finished until the first rectangle firstselect cannot be found; all the first rectangular rows found so far form a first rectangular row set, and b) a row of same-color rectangles is a rectangular row, and a row of rectangular rows forms a first rectangular row set;
4) And calculating the ear row angle of the fruit cluster.
In the first rectangular row set, a preferred rectangular row which is near the middle of the cluster and has a larger number of rectangles is found, and the number of rectangles in the preferred rectangular row is used as the first row grain number, which is referred to as the white rectangular row in b) in fig. 9. Referring to the white rectangular row in b) in fig. 9, preferably, a rectangular row is selected, all the rectangular centers of the selected rectangular row are fitted with straight lines, and the intersection angle of the fitted straight lines and the central axis of the ear is the ear row angle of the ear.
The process of obtaining the preferred rectangular row specifically comprises the following steps:
1) Sorting the rectangle rows in the first rectangle row set according to the number of rectangles in each row from more to less, and recording the sorted two-dimensional rectangle array as rectSortArr1;
2) Taking out the ith rectangular row from the two-dimensional rectangular array rectSortArr1, marking as rectSortArr1i, and marking as rectCenterY the y coordinate of the center coordinate of the rectangle positioned in the middle of the rectSortArr1 i; marking the y coordinate of the corn ear center coordinate of the corn ear image as earImageY; calculating the deviation degree of the ith row rectangular row from the y coordinate of the Center position of the cluster and recording the deviation degree as dist2Center, wherein the calculation formula is as follows:
dist2Center = abs(rectCenteriY - earImageY) / earImageY;
wherein the number of rectangles in the rectSortArr1i is recorded as rectSizei, and when i =0, the number of rectangles in the 0 th row of rectangular array is recorded as rectSize0;
calculating the deviation degree of the rectangle number of the ith rectangle line and the rectangle number of the 0 th rectangle line, and recording the deviation degree as distSizei, wherein the calculation formula is as follows:
distSizei = (rectSize0 - rectSizei) / 7.0 ;
3) Traversing all the rectangular rows in the recSortArr 1, and taking the rectangular row with the smallest combinaDist as a preferred rectangular row:
the selection of the preferred rectangular row needs to comprehensively consider the rectangular row, not only needs to be close to the center, but also needs to contain more rectangles, and the scheme sets a screening judgment formula as follows:
combineDist = dist2Center + distSize0;
the judgment standard of the judgment formula is equivalent to about 2 moment quantity differences deviating from one row; this example only traverses the first 3 most rectangle rows in the rectSortArr1, leaving the rectangle row traversing the last rectangle in the rectSortArr1 with the smaller number.
In step S800, the specific step of obtaining the first ear row number of the corn ear includes the following steps:
see c) in fig. 9, there are 7 lines in total for the line segments passing through the middle section of the cluster up and down, the number of rectangular rows is 7, and the first cluster row number is 7;
1) Taking out the ith rectangular line in the first rectangular line set, recording the ith rectangular line as rectSortArr1i, screening the rectSortArr1i according to a fifth preset condition, removing the rectangular lines which do not meet the condition, traversing the rectangular line set screened by each rectangular line in the first rectangular line set, recording the rectangular line set as selectRectSortArr1, and referring the screened rectangular lines to c) in fig. 9, wherein each line in c) in fig. 9 corresponds to one rectangular line in b) in fig. 9;
2) Taking out the jth rectangular line in the selectrectSortArr1, and recording the jth rectangular line as selectrectSortArr1j; the center points of each rectangle in the selectRectSortArr1j are connected in order as a straight line and drawn in an empty figure, and the result is illustrated as imageLine, see c in fig. 9);
3) Scanning from top to bottom in a result graph imageLine, and performing scanning at equal intervals along the x-axis direction, wherein the interval in the example is 1/40 of the length of the cluster, the number of connecting lines passed by the ith scanning is recorded as scanlinenium, and all the results of the scanning form a number array which is recorded as scanlinenium Arr; the x coordinate corresponding to the ith scanning position is marked as scanLineXi, and the x coordinates of all the scanning positions form an x coordinate array which is recorded as scanLineXArr;
4) Screening the scanLineNumArr according to the value of the scanLineNumi, only reserving array parts with the maximum member value and the second maximum member value, recording the array parts as the scanLineNumMaxAlrr, keeping the member values in the array of the scanLineNumMaxAlrr from large to small, correspondingly taking out the corresponding x coordinate from the scanLineXArr, and recording the x coordinate as the coordinate array scanLineXMaxAlrr; the j-th x coordinate value of the scanlineXMaxrr is recorded as scanlineXMaxj, and the distance distXCnterj of the scanlineXMaxj from the x coordinate of the cluster center is calculated according to the following formula;
distXCenterj = scanLineXMaxj - imageXcenter;
wherein the imageXcenter is the x coordinate of the center of the single fruit cluster, and the x coordinate value of the center of the example is the x coordinate of the center of the single fruit cluster after the embryo tip is removed, and the effect is better than that of the x coordinate of the center of the single fruit cluster graph directly; traversing the array scanLineXMaxerr, and finding out the minimum value of the distXCentj; if distXCnterj < imageXcenter 0.15 appears in the traversal process, the process is ended in advance; the coordinate value of x at the end is recorded as lineXcenter; see x coordinate of line segment position crossing the ear up and down in c) of fig. 9;
5) See fig. 9 c) for the transverse lines of the ears and the white rectangles found from the transverse lines, in each rectangular row through which the transverse lines pass, finding the rectangles nearest to the transverse lines, forming a group of rectangles from top to bottom, see fig. 9 c) for the white rectangles; the number of rectangles is the first ear row number.
In one embodiment, the method for predicting the whole ear parameter by using the local parameter and converting the pixel size into the actual size by converting the result parameter comprises the following steps:
1) Estimating the number of the grains in the rows of the fruit ears;
referring to fig. 10, a preferred rectangular row M1M2 is found, the number of rectangles in the preferred rectangular row is the first row size number of the ear, but the preferred rectangular row cannot cover the two ends of the ear, and the number of uncovered part of the seeds is filled up by estimation, as follows:
(1) In the step of estimating the average grain height of the corn ears based on the preferred rectangular line and the first row grain number, calculating the average grain height, which is recorded as seed Hight, in the following way;
seedHight = rectLineM12X / rectLineM12Num;
wherein, the rectLineM12X is the projection length of the preferred rectangular line M1M2 on the X axis, and the rectLineM12Num is the rectangular number of the preferred rectangular line M1M2, that is, the first line grain number;
(2) In the step of estimating the number of the row grains of the corn ear based on the length of the cluster and the length of the convex tip, the length of the cluster and the length of the convex tip are subtracted to obtain a difference value, and the quotient of the difference value and the average grain height is the number of the row grains.
Specifically, the number of the grains in the row of the cluster is calculated and is recorded as seed LineNum;
seedLineNum = lengthA2H2 / seedHight ;
referring to FIG. 9, length hA2H2 is the length of A2H2, i.e., the ear length minus the lobe length, and within the rectangle A1H2H2A4 is the lobe region; finally, the seed LineNum is used as the row grain number of the fruit cluster;
(3) Estimating the ear row number of the cluster in the step of estimating the ear row number of the cluster based on the first ear row number;
referring to FIG. 10, N1N2 is the first ear row number, which is only half the ear row number of the ear, and 2 times the first ear row number is taken as the ear row number of the ear; the ear edge angle, the length and the width of the ear calculated by the single-side ear image are directly used as the ear edge angle, the length and the width of the ear;
(4) Converting the pixel scale to an actual scale;
the scan dpi is dots per inch, 300dpi for this example, i.e., 300 dots per inch, thereby yielding a pixel equal to 1/300 inch, i.e., 25.4/300 mm; the pixel scale can be converted to millimeters of the actual scale by simply multiplying the above calculated parameters in pixels by 25.4/300 millimeters.
Example two
Based on the same conception, this application has still provided a corn ear property estimation device based on corn ear unilateral scanogram, includes:
the scanning instrument is used for acquiring one side of the corn ear by using the scanner to obtain a corresponding first image;
the processing unit is used for carrying out binarization processing on the first image to obtain a first binary image, segmenting the first image according to a rectangular frame where the corn ears are located to obtain a corresponding second image, and segmenting the first binary image according to the rectangular frame where the corn ears are located to obtain a corresponding second binary image;
the ear length and width acquisition unit is used for acquiring the length of the second binary image as the ear length of the corn ear, and acquiring the distance between a middle section line of the middle section of the corn ear and two intersection points of a convex hull in the middle section of the corn ear as the ear width of the corn ear;
the ear edge angle acquisition unit is used for acquiring an intersection angle of a straight line fitted by the profiles of the two edges of the corn ear and the central axis of the corn ear in the second binary image as an ear edge angle of the corn ear;
the convex tip obtaining unit is used for determining a convex tip of the corn ear and a division line of the kernel after binarization is carried out on the blue channel image of the second image, and taking the convex tip on one side of the division line as the convex tip of the corn ear;
the first grain number and ear row angle acquisition unit is used for carrying out local binarization processing on the second image to obtain a third binary image only containing corn grains, and selecting a rectangular frame where effective grains are located in the third binary image as a first positive external rectangular set of the grains; acquiring all rectangular rows in the first right external rectangular set along the horizontal direction of the corn ear shaft as a first rectangular row set, selecting the rectangular rows which are close to the middle section of the corn ear and have more rectangular data in the first rectangular row set as preferred rectangular rows, acquiring the number of rectangular frames in the preferred rectangular rows as the number of grains in the first row of the corn ear, and acquiring the intersection angle of the preferred rectangular rows and the central axis of the corn ear as the ear row angle of the corn ear;
and the first ear row number acquisition unit is used for selecting an area close to the middle section of the corn ear along the vertical direction of the corn ear shaft as a screening area, and acquiring the maximum value of the number of the rectangular rows of the first rectangular row set in the screening area as the first ear row number of the corn ear.
EXAMPLE III
The present embodiment further provides an electronic device, referring to fig. 11, comprising a memory 404 and a processor 402, wherein the memory 404 stores a computer program, and the processor 402 is configured to execute the computer program to perform the steps of any of the above embodiments of the method for estimating corn ear traits based on a single-side scan of a corn ear.
Specifically, the processor 402 may include a Central Processing Unit (CPU), or A Specific Integrated Circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
Memory 404 may include, among other things, mass storage 404 for data or instructions. By way of example, and not limitation, memory 404 may include a hard disk drive (hard disk drive, HDD for short), a floppy disk drive, a solid state drive (SSD for short), flash memory, an optical disk, a magneto-optical disk, tape, or a Universal Serial Bus (USB) drive or a combination of two or more of these. Memory 404 may include removable or non-removable (or fixed) media, where appropriate. The memory 404 may be internal or external to the data processing apparatus, where appropriate. In a particular embodiment, the memory 404 is a Non-Volatile (Non-Volatile) memory. In certain embodiments, memory 404 includes Read-only memory (ROM) and Random Access Memory (RAM). The ROM may be mask-programmed ROM, programmable ROM (PROM), erasable PROM (EPROM), electrically Erasable PROM (EEPROM), electrically erasable ROM (EEPROM), electrically Alterable ROM (EAROM), or FLASH memory (FLASH), or a combination of two or more of these, where appropriate. The RAM may be a static random-access memory (SRAM) or a dynamic random-access memory (DRAM), where the DRAM may be a fast page mode dynamic random-access memory 404 (FPMDRAM), an extended data output dynamic random-access memory (EDODRAM), a synchronous dynamic random-access memory (SDRAM), or the like.
Memory 404 may be used to store or cache various data files for processing and/or communication use, as well as possibly computer program instructions for execution by processor 402.
Memory 404 may be used to store or cache various data files that need to be processed and/or communicated for use, as well as computer program instructions for a possible corn ear trait estimation method based on a single-sided scan of a corn ear performed by processor 402.
The processor 402 reads and executes the computer program instructions stored in the memory 404 to implement any one of the above embodiments of the method for estimating the traits of an ear of corn based on a single-sided scan of the ear of corn.
Optionally, the electronic apparatus may further include a transmission device 406 and an input/output device 408, where the transmission device 406 is connected to the processor 402, and the input/output device 408 is connected to the processor 402.
The transmitting device 406 may be used to receive or transmit data via a network. Specific examples of the network described above may include wired or wireless networks provided by communication providers of the electronic devices. In one example, the transmission device includes a Network adapter (NIC) that can be connected to other Network devices through a base station to communicate with the internet. In one example, the transmitting device 406 may be a Radio Frequency (RF) module, which is used to communicate with the internet in a wireless manner.
The input and output devices 408 are used to input or output information. In this embodiment, the input information may be an image of the ear obtained by the scanner, and the output information may be various parameters representing the ear characteristics.
Optionally, in this embodiment, the processor 402 may be configured to execute the following steps by a computer program:
s100, acquiring a single side of a corn ear by using a scanner to obtain a corresponding first image, and performing binarization processing on the first image to obtain a first binary image;
s200, dividing the first image according to the rectangular frame where the corn ears are located to obtain a corresponding second image, and dividing the first binary image according to the rectangular frame where the corn ears are located to obtain a corresponding second binary image;
s300, acquiring the length of the second binary image as the ear length of the corn ear, and acquiring the distance between a middle section line of the middle section of the corn ear and two intersection points of an inner convex hull of the middle section of the corn ear as the ear width of the corn ear;
s400, acquiring an intersection angle of a straight line fitted with the contour of the two edges of the corn ear in the second binary image and a central axis of the corn ear as an ear edge angle of the corn ear;
s500, binarizing the blue channel image of the second image, determining a convex tip of the corn ear and a division line of grains, and taking the convex tip on one side of the division line as the convex tip of the corn ear;
s600, carrying out local binarization processing on the second image to obtain a third binary image only containing corn grains, and selecting a rectangular frame where effective grains are located in the third binary image as a first positive external rectangular set of the grains;
s700, taking all rectangular rows in the first right external rectangular set along the horizontal direction of the corn ear stems as a first rectangular row set, selecting the rectangular rows which are close to the middle section of the corn ears and have more rectangular data in the first rectangular row set as preferred rectangular rows, obtaining the number of rectangular frames in the preferred rectangular rows as the first row grain number of the corn ears, and obtaining the intersection angle of the preferred rectangular rows and the central axis of the corn ears as the ear row angle of the corn ears;
s800, selecting an area close to the middle section of the corn ear along the vertical direction of the corn ear shaft as a screening area, and acquiring the maximum value of the number of rectangular rows of the first rectangular row set in the screening area as the first ear row number of the corn ear.
It should be noted that, for specific examples in this embodiment, reference may be made to examples described in the foregoing embodiments and optional implementations, and details of this embodiment are not described herein again.
In general, the various embodiments may be implemented in hardware or special purpose circuits, software, logic or any combination thereof. Some aspects of the invention may be implemented in hardware, while other aspects may be implemented in firmware or software which may be executed by a controller, microprocessor or other computing device, although the invention is not limited thereto. While various aspects of the invention may be illustrated and described as block diagrams, flow charts, or using some other pictorial representation, it is well understood that these blocks, apparatus, systems, techniques or methods described herein may be implemented in, as non-limiting examples, hardware, software, firmware, special purpose circuits or logic, general purpose hardware or controller or other computing devices, or some combination thereof.
Embodiments of the invention may be implemented by computer software executable by a data processor of the mobile device, such as in a processor entity, or by hardware, or by a combination of software and hardware. Computer software or programs (also referred to as program products) including software routines, applets and/or macros can be stored in any device-readable data storage medium and they include program instructions for performing particular tasks. The computer program product may comprise one or more computer-executable components configured to perform embodiments when the program is run. The one or more computer-executable components may be at least one software code or a portion thereof. Further in this regard it should be noted that any block of the logic flow as in the figures may represent a program step, or an interconnected logic circuit, block and function, or a combination of a program step and a logic circuit, block and function. The software may be stored on physical media such as memory chips or memory blocks implemented within the processor, magnetic media such as hard or floppy disks, and optical media such as, for example, DVDs and data variants thereof, CDs. The physical medium is a non-transitory medium.
It should be understood by those skilled in the art that various features of the above embodiments can be combined arbitrarily, and for the sake of brevity, all possible combinations of the features in the above embodiments are not described, but should be considered as within the scope of the present disclosure as long as there is no contradiction between the combinations of the features.
The above examples are merely illustrative of several embodiments of the present application, and the description is more specific and detailed, but not to be construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.

Claims (10)

1. A corn ear character estimation method based on a corn ear unilateral scanning map is characterized by comprising the following steps:
s100, acquiring a single side of a corn ear by using a scanner to obtain a corresponding first image, and performing binarization processing on the first image to obtain a first binary image;
s200, segmenting the first image according to the rectangular frame where the corn ears are located to obtain a corresponding second image, and segmenting the first binary image according to the rectangular frame where the corn ears are located to obtain a corresponding second binary image;
s300, acquiring the length of the second binary image as the ear length of the corn ear, and acquiring the distance between a middle section line of the middle section of the corn ear and two intersection points of an inner convex hull of the middle section of the corn ear as the ear width of the corn ear;
s400, acquiring an intersection angle of a straight line fitted with the contours of the two edges of the corn ear and a central axis of the corn ear in the second binary image as an ear edge angle of the corn ear;
s500, binarizing the blue channel image of the second image, determining a convex tip of the corn ear and a partition line of grains, and taking the convex tip on one side of the partition line as the convex tip of the corn ear;
s600, carrying out local binarization processing on the second image to obtain a third binary image only containing corn grains, and selecting a rectangular frame where effective grains are located in the third binary image as a first positive external rectangular set of the grains;
s700, taking all rectangular rows in the first right external rectangular set along the horizontal direction of the corn ear stems as a first rectangular row set, selecting the rectangular rows which are close to the middle section of the corn ears and have more rectangular data in the first rectangular row set as preferred rectangular rows, obtaining the number of rectangular frames in the preferred rectangular rows as the first row grain number of the corn ears, and obtaining the intersection angle of the preferred rectangular rows and the central axis of the corn ears as the ear row angle of the corn ears;
s800, 1) taking out the ith rectangular line in the first rectangular line set, recording the ith rectangular line as a retSortArr 1i, screening the retSortArr 1i according to a fifth preset condition, removing the rectangular lines which do not meet the condition, traversing the rectangular line set screened out by each rectangular line in the first rectangular line set, and recording the rectangular line set as a selectrectSortArr1;
2) Taking out the jth rectangular line in the selectrectSortArr1, and recording the jth rectangular line as selectrectSortArr1j; the center points of each rectangle in the selectRectSortArr1j are sequentially connected into straight lines and drawn in an empty graph, and the result graph is recorded as imageLine;
3) Scanning from top to bottom in a result graph imageLine, and performing scanning at equal intervals along the x-axis direction, wherein the number of connecting lines passing through the ith scanning is recorded as scanlinenum, and all results of the scanning form a number array which is recorded as scanlinenum Arr; the x coordinate corresponding to the ith scanning position is marked as scanLineXi, and the x coordinates of all the scanning positions form an x coordinate array which is recorded as scanLineXArr;
4) Screening the scanLineNumArr according to the value of the scanLineNumi, only reserving an array part with the maximum member value and the second maximum member value, recording the array part as the member values in scanLineNumMaxAlrr, and the scanLineNumMaxAlrr array, still keeping the sequence from large to small, and recording the corresponding x coordinate as a coordinate array scanLineXAlrr, wherein the corresponding x coordinate is correspondingly taken out of the scanLineXArr; the j-th x coordinate value of scanlinexmaxrr is recorded as scanLineXMaxj, and the distance distxcentj of scanLineXMaxj from the x coordinate of the cluster center is calculated according to the following formula;
distXCenterj = scanLineXMaxj - imageXcenter;
wherein the imageXcenter is an x coordinate of the center of the single fruit cluster, and the x coordinate value of the center is the x coordinate of the center of the single fruit cluster after the embryo tip is removed;
traversing the array scanLineXMaxerr, finding out the minimum value of distXCnterj, and recording the coordinate value of x as lineXcenter when the operation is finished;
in each rectangular row through which the transverse line passes, a rectangle closest to the transverse line is found, so that a group of rectangles from top to bottom is formed, and the number of rectangles is the first ear row number.
2. The method of claim 1, wherein the average height of the ear is estimated based on the preferred rectangular row and the first row size, the row size of the ear is estimated based on the ear length and the lobe, and the ear row count of the ear is estimated based on the first ear row count.
3. The method for estimating maize ear traits based on single-side scan of maize ear as claimed in claim 1, wherein in step S200, in the first binary image, fitting the edge lines at both sides of the maize ear to obtain a fitting straight line, and constructing the circumscribed rectangle of the maize ear with the fitting straight line as the axis as the rectangular frame of the maize ear.
4. The corn ear trait estimation method based on corn ear unilateral scan maps according to claim 3, wherein the step of obtaining the rectangular frame of the corn ear comprises:
1) Acquiring the outer ear contours of all corn ears in the first binary image to form an ear contour set;
2) Performing smooth boundary processing on the outer contour of each cluster through corrosion expansion processing to obtain a smooth contour;
3, acquiring a minimum circumscribed rectangle A1A2A3A4 in the smooth contour, keeping A1A2 as a long side, keeping A1A4 as a short side, keeping A1 and A4 at the thin end of the cluster, and keeping A2 and A3 at the thick end of the cluster;
4) Cutting out the part of the smooth contour in the rectangular frame B1B2C2C1 as a new contour, and recording the part as a B12 contour contouriSmoothB12, and cutting out the part of the smooth contour in the rectangular frame B3B4C1C2 as a new contour, and recording the part as a B34 contour contouriSmoothB34; the fruit cluster middle section rectangular frame B1B2B3B4 is a rectangular frame obtained by cutting off the middle end of the fruit cluster, C1 is the midpoint of B1 and B4, C2 is the midpoint of B2 and B3, B1 is a division point on A1A2, B2 is a division point on A1A2, B4 is a division point on A4A3, and B3 is a division point on A4A 3;
1) Performing linear fitting on the B12 contour contouriSmoothB12 to obtain a 12-fitting linear line12, and performing linear fitting on the B34 contour contouriSmoothB34 to obtain a 34-fitting linear line34; calculating the slope of a bisector between the line12 of the 12-fitting straight line and the line34 of the 34-fitting straight line, wherein the slope is combined with the midpoint D1 of A1 and A4 to form a straight line D1D2;
2) Traversing each coordinate point in the outer contour of each cluster, acquiring at least one parallel straight line which passes through each coordinate point and is parallel to the straight line D1D2 to form a parallel straight line set, taking a parallel straight line E1E2 which is positioned at the leftmost side in the parallel straight line set, and taking a parallel straight line E3E4 which is positioned at the rightmost side in the parallel straight line set; and acquiring at least one vertical straight line which passes through each coordinate point and is perpendicular to the straight line D1D2 to form a vertical straight line set, taking the vertical straight line E2E3 positioned at the uppermost side in the vertical straight line set, taking the vertical straight line E1E4 positioned at the lowermost side in the vertical straight line set, and taking the matrix E1E2E3E4 as a rectangular frame of the corn ear.
5. The method for estimating maize ear traits based on maize ear unilateral scan pattern according to claim 1, characterized in that step S500 comprises the steps of:
1) In the second-value image, according to the opening direction of the ear edge angle of the fruit cluster, determining the thin end as a convex tip end;
1) Taking the blue channel image from the second image, and carrying out binarization to obtain a blue channel binary image;
2) Carrying out contour searching on the blue channel binary image, and taking out all contours with contour areas larger than 50 to form a contour set;
3) Traversing the contour set, grouping the pixels with the inter-contour distance smaller than 10 into a set, and taking the set with the maximum contour area as a contour set contourArr5;
4) In the contour set contourArr5, a point closest to the convex tip is found out from all contours to be used as a mark point, a perpendicular line passing through the mark point P and serving as an x-axis is used as a dividing line, the dividing line is crossed with the boundary of the corn ear at two points, and the convex tip at one side of the dividing line is taken as the convex tip of the corn ear.
6. The method for estimating maize ear traits based on maize ear unilateral scan pattern according to claim 1, characterized in that step S600 comprises the steps of:
1) Performing corrosion expansion operation on the binary image obtained after the local binarization processing of the second image to remove impurities to obtain a third binary image;
2) Finding out the outlines of all the corn kernels in the third binary image, and making positive external rectangles of all the outlines to form a positive external rectangle set;
3) Traversing each positive circumscribed rectangle one by one in the positive circumscribed rectangle set, if the center point of the current positive circumscribed rectangle is in other positive circumscribed rectangles in the positive circumscribed rectangle set, deleting the current positive circumscribed rectangle until all the positive circumscribed rectangles are traversed, and processing the processed positive circumscribed rectangle set rectAlr 3;
4) In the positive external rectangle set recarr 3, the positive external rectangles are traversed one by one, the current positive external rectangle is used for comparing the size and the position characteristics of the positive external rectangles which are respectively arranged at the left side and the right side, the smaller positive external rectangles are combined, the smaller rectangles are removed by comparing the size and the position characteristics of the positive external rectangles which are respectively arranged at the upper side and the lower side, and finally the screened rectangles form a rectangle set recarr 4;
5) In the rectangle set rectAlr 4, the rectAlr 4 is sorted according to the increasing mode of the x coordinate of the center of the rectangle, and the sorted rectangle array is recorded as a first positive circumscribed rectangle set.
7. The method for estimating corn ear traits based on single-side scan of corn ear as claimed in claim 1, wherein the step of obtaining the preferred rectangular row in step S700 comprises:
1) Sorting the rectangle rows in the first rectangle row set according to the number of rectangles in each row from more to less, and recording the sorted two-dimensional rectangle array as rectSortArr1;
2) Taking out the ith rectangular row from the two-dimensional rectangular array rectSortArr1, marking as rectSortArr1i, and marking as rectCenterY the y coordinate of the center coordinate of the rectangle positioned in the middle of the rectSortArr1 i; marking the y coordinate of the corn ear center coordinate of the corn ear image as earImageY; calculating the deviation degree of the y coordinate of the ith rectangular row from the Center position of the cluster as dist2Center, and calculating the deviation degree of the rectangle number of the ith rectangular row and the rectangle number of the 0 th rectangular row as distSizei;
3) Traversing all the rectangular rows in the recSortArr 1, and taking the rectangular row with the smallest combinaDist as a preferred rectangular row:
combineDist = dist2Center + distSizei。
8. a corn ear character estimation device based on a corn ear unilateral scanning diagram is characterized by comprising:
the scanning instrument is used for acquiring one side of the corn ear by using the scanner to obtain a corresponding first image;
the processing unit is used for carrying out binarization processing on the first image to obtain a first binary image, segmenting the first image according to a rectangular frame where the corn ears are located to obtain a corresponding second image, and segmenting the first binary image according to the rectangular frame where the corn ears are located to obtain a corresponding second binary image;
the ear length and width acquisition unit is used for acquiring the length of the second binary image as the ear length of the corn ear, and acquiring the distance between a middle section line of the middle section of the corn ear and two intersection points of a convex hull in the middle section of the corn ear as the ear width of the corn ear;
a fringe angle acquiring unit, configured to acquire an intersection angle between a straight line fitted to the contours of two edges of the corn ear in the second binary image and a central axis of the corn ear as a fringe angle of the corn ear;
the convex tip obtaining unit is used for determining a convex tip of the corn ear and a division line of the kernel after binarization is carried out on the blue channel image of the second image, and taking the convex tip on one side of the division line as the convex tip of the corn ear;
the first line grain number and ear row angle acquisition unit is used for carrying out local binarization processing on the second image to obtain a third binary image only containing corn grains, and selecting a rectangular frame where effective grains are located in the third binary image as a first positive external rectangular set of the grains; acquiring all rectangular rows in the first right external rectangular set along the horizontal direction of the corn ear stems as a first rectangular row set, selecting the rectangular rows which are close to the middle section of the corn ears and have more rectangular data in the first rectangular row set as preferred rectangular rows, acquiring the number of rectangular frames in the preferred rectangular rows as the first row grain number of the corn ears, and acquiring the intersection angle of the preferred rectangular rows and the central axis of the corn ears as the ear row angle of the corn ears;
a first ear row number obtaining unit, configured to perform the following steps:
1) Taking out the ith rectangular line in the first rectangular line set, recording the ith rectangular line as a rectSortArr1i, screening the rectSortArr1i according to a fifth preset condition, removing the rectangular lines which do not meet the condition, traversing the rectangular line set screened out by each rectangular line in the first rectangular line set, and recording the rectangular line set as a selectrectSortArr1;
2) Taking out the jth rectangular line in the selectrectSortArr1, and recording the jth rectangular line as selectrectSortArr1j; connecting the central points of each rectangle in the selectrectSortArr1j into a straight line in sequence and drawing the straight line in an empty picture, and marking the result as imageLine;
3) Scanning from top to bottom in a result graph imageLine, and performing scanning at equal intervals along the x-axis direction, wherein the number of connecting lines passing through the ith scanning is recorded as scanlinenum, and all results of the scanning form a number array which is recorded as scanlinenum Arr; the x coordinate corresponding to the ith scanning position is marked as scanLineXi, and the x coordinates of all the scanning positions form an x coordinate array which is recorded as scanLineXArr;
4) Screening the scanLineNumArr according to the value of the scanLineNumi, only reserving array parts with the maximum member value and the second maximum member value, recording the array parts as the scanLineNumMaxAlrr, keeping the member values in the array of the scanLineNumMaxAlrr from large to small, correspondingly taking out the corresponding x coordinate from the scanLineXArr, and recording the x coordinate as the coordinate array scanLineXMaxAlrr; the j-th x coordinate value of the scanlineXMaxrr is recorded as scanlineXMaxj, and the distance distXCnterj of the scanlineXMaxj from the x coordinate of the cluster center is calculated according to the following formula;
distXCenterj = scanLineXMaxj - imageXcenter;
wherein the imageXcenter is an x coordinate of the center of the single fruit cluster, and the x coordinate value of the center is the x coordinate of the center of the single fruit cluster after the embryo tip is removed;
traversing the array scanLineXMaxarr, finding out the minimum value of distXCentj, and recording the coordinate value of x as lineXcenter when the operation is finished;
in each rectangular row through which the transverse line passes, a rectangle closest to the transverse line is found, so that a group of rectangles from top to bottom is formed, and the number of rectangles is the first ear row number.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to perform the method for estimating the traits of an ear of corn based on a single-sided scan of the ear of corn according to any one of claims 1 to 7.
10. A readable storage medium having stored thereon a computer program comprising program code for controlling a process to perform a process, the process comprising the corn ear trait estimation method based on corn ear unilateral scan maps according to any one of claims 1 to 7.
CN202211269715.8A 2022-10-18 2022-10-18 Corn ear character estimation method and device based on corn ear unilateral scanning map Active CN115345880B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211269715.8A CN115345880B (en) 2022-10-18 2022-10-18 Corn ear character estimation method and device based on corn ear unilateral scanning map

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211269715.8A CN115345880B (en) 2022-10-18 2022-10-18 Corn ear character estimation method and device based on corn ear unilateral scanning map

Publications (2)

Publication Number Publication Date
CN115345880A CN115345880A (en) 2022-11-15
CN115345880B true CN115345880B (en) 2023-03-24

Family

ID=83957354

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211269715.8A Active CN115345880B (en) 2022-10-18 2022-10-18 Corn ear character estimation method and device based on corn ear unilateral scanning map

Country Status (1)

Country Link
CN (1) CN115345880B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117876466B (en) * 2024-03-13 2024-06-25 浙江托普云农科技股份有限公司 Corn ear phenotype parameter calculation method, system and device based on vision

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102425992A (en) * 2011-12-15 2012-04-25 青岛农业大学 Corn ear character measuring device and method for measuring line number of corncobs, ear-to-row inclination angel and ear edge angle
CN103500458A (en) * 2013-09-06 2014-01-08 李静 Method for automatically detecting line number of corncobs
CN108764294A (en) * 2018-04-28 2018-11-06 青岛农业大学 Line number automatic testing method based on corn ear symmetry

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103093456B (en) * 2012-12-25 2015-06-03 北京农业信息技术研究中心 Corn ear character index computing method based on images
CN103190224B (en) * 2013-03-26 2015-02-18 中国农业大学 Computer vision technique-based corn ear species test method, system and device
US10019791B2 (en) * 2015-07-24 2018-07-10 Raytheon Company Apparatus and methods for estimating corn yields
CN111724354B (en) * 2020-06-02 2023-05-30 浙江托普云农科技股份有限公司 Image processing-based method for measuring wheat ear length and wheat ear number of multiple wheat plants
CN111950436A (en) * 2020-08-07 2020-11-17 中国农业大学 Corn ear phenotype measuring method and system
CN112577956A (en) * 2020-12-04 2021-03-30 中国农业大学 Corn seed test system and method based on intelligent device photographing function

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102425992A (en) * 2011-12-15 2012-04-25 青岛农业大学 Corn ear character measuring device and method for measuring line number of corncobs, ear-to-row inclination angel and ear edge angle
CN103500458A (en) * 2013-09-06 2014-01-08 李静 Method for automatically detecting line number of corncobs
CN108764294A (en) * 2018-04-28 2018-11-06 青岛农业大学 Line number automatic testing method based on corn ear symmetry

Also Published As

Publication number Publication date
CN115345880A (en) 2022-11-15

Similar Documents

Publication Publication Date Title
US8837836B2 (en) Image processing device identifying attribute of region included in image
CN106780522B (en) A kind of bone marrow fluid cell segmentation method based on deep learning
CN115345880B (en) Corn ear character estimation method and device based on corn ear unilateral scanning map
JP2004005694A (en) Image processing method, digital image processor, digital camera, digital photograph finishing system, and program
CN115512232B (en) Crop seed germination condition identification model, construction method and application thereof
CN109035289B (en) Purple soil image segmentation and extraction method based on Chebyshev inequality H threshold
CN113962976B (en) Quality evaluation method for pathological slide digital image
CN114170148A (en) Corn plant type parameter measuring method, system, device and storage medium
CN111724354B (en) Image processing-based method for measuring wheat ear length and wheat ear number of multiple wheat plants
CN114745532A (en) White balance processing method and device for mixed color temperature scene, storage medium and terminal
CN116523898A (en) Tobacco phenotype character extraction method based on three-dimensional point cloud
CN110852207A (en) Blue roof building extraction method based on object-oriented image classification technology
CN117952960B (en) Electric power iron tower part defect detection method based on artificial intelligence
CN113436206B (en) Pathological tissue section scanning area positioning method based on cluster segmentation
CN113470104A (en) Wheat ear grain counting and measuring method and system based on gray value comparison
CN111161212A (en) Method, device, equipment and medium for counting mitotic image of digital pathological section
CN117635615A (en) Defect detection method and system for realizing punching die based on deep learning
CN117576121A (en) Automatic segmentation method, system, equipment and medium for microscope scanning area
CN115690107B (en) High-throughput counting method, system and device for pod fruit grains based on image processing
CN113011220A (en) Spike number identification method and device, storage medium and processor
CN113935991B (en) Corn cross section parameter measuring method and system, electronic equipment and storage medium
CN115375694A (en) Portable rice whole ear measuring method based on image recognition and application thereof
JP5456154B2 (en) Image area interpolation
CN110689586A (en) Tongue image identification method in traditional Chinese medicine intelligent tongue diagnosis and portable correction color card used for same
CN113888574A (en) Method for cleaning robot to acquire area of cleanable area

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant