Pear stem length measuring method based on machine vision

文档序号:1718647 发布日期:2019-12-17 浏览:37次 中文

阅读说明:本技术 一种基于机器视觉的梨果柄长度的测量方法 (Pear stem length measuring method based on machine vision ) 是由 齐开杰 张绍铃 陶书田 谢智华 殷豪 于 2019-10-24 设计创作,主要内容包括:本发明提出了一种基于机器视觉的梨果柄长度的测量方法,通过照相设备直接采集整体梨表面图像,经过预处理、人工选取等操作得到果柄图像,基于机器视觉处理图像,遍历果柄图像中的像素点,提取图像中的多个特征点,利用特征点自动计算梨果柄长度。本发明计算量小、计算速度快,不需要过多人工参与,测量成本更低,测量效率更高,测量精度更好,适用于大规模果柄测量,对我国梨种质研究有着深远的意义。(The invention provides a method for measuring the length of a pear stalk based on machine vision. The method has the advantages of small calculated amount, high calculating speed, no need of excessive manual participation, lower measuring cost, higher measuring efficiency and better measuring precision, is suitable for large-scale stalk measurement, and has profound significance for Chinese pear germplasm research.)

1. A method for measuring the length of a pear stalk based on machine vision is characterized by comprising the following steps:

S1, collecting an integral pear surface image, and preprocessing the pear surface image, wherein the preprocessing comprises gray value processing, binarization processing and denoising processing in sequence;

S2, selecting a pear stalk image from the preprocessed images, and calculating the highest point P of the stalk in the pear stalk imagemaxand the lowest point PminThe pixel coordinates of (a);

s3, according to the highest point PmaxAnd the lowest point PminAnd extracting a characteristic point set, calculating the length of the actual fruit handle according to the characteristic point set, and calibrating by a size standard plate.

2. The machine vision-based pome stalk length measuring method according to claim 1, wherein the step S1 specifically comprises:

S11, collecting a pear surface image, performing gray value processing on the pear surface image, and extracting the gray value of a pixel point by taking blue as a value channel to obtain a gray value image;

S12, performing binarization processing on the gray value image by adopting an iterative clustering method, and dividing pixels of the gray value image into a target class and a background class, wherein the target class comprises a pear carpopodium image, and the background class comprises other images except the pear carpopodium to obtain a binarized image;

And S13, removing noise points in the binary image by adopting a median filtering method to obtain a denoised image.

3. the machine vision-based pome stalk length measuring method according to claim 2, wherein the step S12 specifically comprises:

(1) Taking the average gray value of the gray value image as a threshold value T ═ T0,T0the calculation formula of (a) is as follows:

wherein h issExpressing the gray value of the s-th pixel point in a gray value image, wherein s is 1,2, … and t, and the gray value image has t pixel points;

(2) Classifying pixels with gray values smaller than threshold T in gray value image into class G1classifying pixels with gray values greater than a threshold value T into a class G2Separately computing class G1and class G2average gray value f of1And f2

(3) updating the threshold value, ordering the threshold value

(4) Repeating the steps (2) and (3) until the difference value delta T between the threshold value T in the current iteration and the threshold value T in the last iteration is less than or equal to a preset threshold value A, and stopping the iteration;

(5) Classifying pixel points in the gray value image into a class G by utilizing a threshold value T when iteration is stopped1And G2Class G of1Gray value of all the pixels in the image is 0, class G2and obtaining a binary image when the gray values of all the pixel points are 255.

4. The machine vision-based pome stalk length measuring method according to claim 2, wherein the step S13 specifically comprises:

Randomly selecting a pixel point q from the binary imagesPixel point qshas a gray value of hsby pixel point qsAs the central point, taking the neighborhood pixel point qrGray value h ofrAccording to the gray value, the pixel point q issAnd its neighborhood pixel point qrSequencing to obtain an ordered sequence Q, and taking the gray value of the pixel point of the middle position of the ordered sequence Q as a central point QsThe gray value of (a);

And repeating the operation until all pixel points in the binary image are processed to obtain the denoised image.

5. the method for measuring the length of the pome stalk based on the machine vision is characterized in that the neighborhood is a square area, and the value range of the square area is [15 x 15] to [23 x 23 ].

6. The machine vision-based pome stalk length measuring method according to claim 1, wherein the step S2 specifically comprises:

S21, removing the image of the useless area from the preprocessed image, and selecting a pear stalk image only containing a pear stalk area, wherein the pear stalk image comprises m rows and n columns of pixels;

s22, establishing a rectangular coordinate system by taking the lower left corner of the pear stalk image as the origin of coordinates, taking the coordinates of the pixel points P as (j, i), traversing all the pixel points in the stalk image, and calculating the highest point P of the stalkmaxAnd the lowest point PminPixel coordinate of (2), highest point PmaxHas the coordinates of (j)max,imax) Lowest point PminHas the coordinates of (j)min,imin) Highest point PmaxThe highest point and the lowest point P of the vertical coordinate on the pear stalkminthe point with the lowest ordinate on the pear stalk is calculated as follows:

Wherein HiRepresenting the sum of the grey values of the pixels of the ith row in the stalk image, hi,jExpressing the gray values of the ith row and jth column pixel points in the carpopodium image, Hi+1representing the sum of the gray values of the pixels of the (i + 1) th row in the carpopodium image, hi+1,jRepresenting the gray value H of the pixel points of the i +1 th row and the j th column in the fruit stem imagei-1Representing the sum of the grey values of the pixels of the i-1 th row in the stalk image, hi-1,jRepresenting the gray values of the pixel points of the ith-1 st row and the jth column in the carpopodium image, Denotes the ithmaxGray values of pixel points in the row and the j-1 th column,Denotes the ithmaxThe gray values of the pixel points in the row and the jth column,Denotes the ithmaxThe gray values of the pixel points in the row and the j +1 th column, Denotes the ithminGray values of pixel points in the row and the j-1 th column,denotes the ithminThe gray values of the pixel points in the row and the jth column,denotes the ithminthe gray values of the pixels in the row and the j +1 th column, i is 0,1, …, m, j is 0,1, …, n.

7. The machine vision-based pome stalk length measuring method according to claim 1, wherein the step S3 specifically comprises:

s31, according to PmaxAnd Pminextracting L characteristic points on the fruit handle, wherein L is a positive integer, and the difference between the vertical coordinates of two adjacent characteristic points satisfies the following conditions:

Wherein round (·) is a rounding function;

S32, setting the characteristic point set as P ═ Pki k 0,1, …, L-1, where P is0=Pmin,PL-1=PmaxCharacteristic point PkHas the coordinates of (i)k,jk):

ik=imin+kD

Wherein the content of the first and second substances,Denotes the ithkgray values of pixel points in the row and the j-1 th column,Denotes the ithkRow and j column pixelThe gray-scale value of the point or points,Denotes the ithkgray values of pixel points in the row and the j +1 th column;

S33, sequentially connecting the characteristic points in the characteristic point set P to form L-1 line segments, and calculating the sum of the lengths of the L-1 line segments as the length Z of the pear stalk:

And S34, calibrating the size of the image by using a size standard plate, and converting the pear stalk length Z from equivalent pixels into millimeter size to obtain the actual pear stalk length.

Technical Field

the invention belongs to the technical field of pear germplasm resource measurement, and particularly relates to a method for measuring the length of a pear stalk based on machine vision.

background

The pear is the third fruit in China, the planting area and the yield of the pear are the largest in the world, the pear is used as the largest pear producing and consuming country in the world and is also the country with the most abundant pear germplasm resources, and the scientific research personnel in China have conducted a great deal of research on the pear resources. The phenotypic diversity is an important research content of the biodiversity, the phenotypic variation of the population in various environments in a distribution area of the population is mainly researched, the research and analysis of the phenotypic diversity of the pear germplasm resources is beneficial to understanding of the genetic development mechanism of the pear germplasm resources, the evaluation and excavation of the pear germplasm resources and the cultivation of characteristic diversified varieties are facilitated, and meanwhile, the research of the phenotypic diversity of the pear germplasm resources can also provide a data basis and a theoretical basis for the standardization and standardization of the description of the pear germplasm resources, and the efficient utilization of the pear germplasm resources is promoted.

Among the phenotypic characteristics, the variation of fruit is one of the most important characteristics of genetic variation, and mainly includes the extrinsic qualities of fruit longitudinal and transverse meridians, fruit weight, fruit shape, ground color, cover color, fruit rust, fruit points, fruit stalks, sepals, fruit stalks and the like, and the intrinsic qualities of fruit core size, hardness, texture, soluble solid content, stone cells, juice, flavor, aroma and the like.

the measurement of the size of the fruit stem is one of the important properties of the appearance quality of fruits and is limited by measurement equipment, the length, the angle and other information of the fruit stem are mainly measured manually at present, and because the manual measurement cost is high, the workload is high and large errors exist, the description of the pear stem in the pear standard is only limited to characters of large or small deflection angle of the fruit stem, no specific value, measurement of the diameter size value of the fruit stem only can be measured by three points, the measurement precision is low, the average value cannot be calculated, and the length value of the fruit stem cannot be accurately calculated, and the current measurement method and the description specification of the pear stem are not enough to carry out the research of the genetic diversity and the variation coefficient of the properties.

Disclosure of Invention

Aiming at the problems that the length of the pear stem needs to be manually measured at present, the cost is high, and the measurement precision is low, the invention provides the method for measuring the length of the pear stem based on machine vision.

In order to solve the technical problems, the invention adopts the following technical means:

a method for measuring the length of a pear stalk based on machine vision comprises the following steps:

s1, collecting an integral pear surface image, and preprocessing the pear surface image, wherein the preprocessing comprises gray value processing, binarization processing and denoising processing in sequence;

S2, selecting a pear stalk image from the preprocessed images, and calculating the highest point P of the stalk in the pear stalk imagemaxand the lowest point PminThe pixel coordinates of (a);

S3, according to the highest point PmaxAnd the lowest point PminAnd extracting a characteristic point set, calculating the length of the actual fruit handle according to the characteristic point set, and calibrating by a size standard plate.

Further, in the method for measuring the length of the pome stalk based on machine vision, the step S1 specifically includes:

S11, collecting a pear surface image, performing gray value processing on the pear surface image, and extracting the gray value of a pixel point by taking blue as a value channel to obtain a gray value image;

S12, performing binarization processing on the gray value image by adopting an iterative clustering method, and dividing pixels of the gray value image into a target class and a background class, wherein the target class comprises a pear carpopodium image, and the background class comprises other images except the pear carpopodium to obtain a binarized image;

And S13, removing noise points in the binary image by adopting a median filtering method to obtain a denoised image.

Further, in the method for measuring the length of the pome stalk based on machine vision, the step S12 specifically includes:

(1) Taking the average gray value of the gray value image as a threshold value T ═ T0,T0The calculation formula of (a) is as follows:

wherein h issExpressing the gray value of the s-th pixel point in a gray value image, wherein s is 1,2, … and t, and the gray value image has t pixel points;

(2) Classifying pixels with gray values smaller than threshold T in gray value image into class G1Classifying pixels with gray values greater than a threshold value T into a class G2Separately computing class G1And class G2average gray value f of1And f2

(3) Updating the threshold value, ordering the threshold value

(4) Repeating the steps (2) and (3) until the difference value delta T between the threshold value T in the current iteration and the threshold value T in the last iteration is less than or equal to a preset threshold value A, and stopping the iteration;

(5) Classifying pixel points in the gray value image into a class G by utilizing a threshold value T when iteration is stopped1And G2Class G of1Gray value of all the pixels in the image is 0, class G2and obtaining a binary image when the gray values of all the pixel points are 255.

further, in the method for measuring the length of the pome stalk based on machine vision, the step S13 specifically includes:

Randomly selecting a pixel point q from the binary imagesPixel point qsHas a gray value of hsBy pixel point qsAs the central point, taking the neighborhood pixel point qrGray value h ofrAccording to the gray value, the pixel point q issand its neighborhood pixel point qrSequencing to obtain an ordered sequence Q, and taking the gray value of the pixel point of the middle position of the ordered sequence Q as a central point QsThe gray value of (a);

And repeating the operation until all pixel points in the binary image are processed to obtain the denoised image.

Furthermore, according to the method for measuring the length of the pear stalk based on the machine vision, the neighborhood is a square area, and the value range of the square area is [15 × 15] to [23 × 23 ].

further, in the method for measuring the length of the pome stalk based on machine vision, the step S2 specifically includes:

s21, removing the image of the useless area from the preprocessed image, and selecting a pear stalk image only containing a pear stalk area, wherein the pear stalk image comprises m rows and n columns of pixels;

S22, establishing a rectangular coordinate system by taking the lower left corner of the pear stalk image as the origin of coordinates, taking the coordinates of the pixel points P as (j, i), traversing all the pixel points in the stalk image, and calculating the highest point P of the stalkmaxAnd the lowest point PminPixel coordinate of (2), highest point Pmaxhas the coordinates of (j)max,imax) Lowest point Pminhas the coordinates of (j)min,imin) Highest point PmaxThe highest point and the lowest point P of the vertical coordinate on the pear stalkminthe point with the lowest ordinate on the pear stalk is calculated as follows:

Wherein HiRepresenting the sum of the gray values of the pixels of the ith row in the stalk image,hi,jExpressing the gray values of the ith row and jth column pixel points in the carpopodium image, Hi+1Representing the sum of the gray values of the pixels of the (i + 1) th row in the carpopodium image, hi+1,jrepresenting the gray value H of the pixel points of the i +1 th row and the j th column in the fruit stem imagei-1Representing the sum of the grey values of the pixels of the i-1 th row in the stalk image, hi-1,jrepresenting the gray values of the pixel points of the ith-1 st row and the jth column in the carpopodium image, denotes the ithmaxGray values of pixel points in the row and the j-1 th column,Denotes the ithmaxThe gray values of the pixel points in the row and the jth column,Denotes the ithmaxThe gray values of the pixel points in the row and the j +1 th column, Denotes the ithmingray values of pixel points in the row and the j-1 th column,Denotes the ithminThe gray values of the pixel points in the row and the jth column,Denotes the ithminThe gray values of the pixels in the row and the j +1 th column, i is 0,1, …, m, j is 0,1, …, n.

Further, in the method for measuring the length of the pome stalk based on machine vision, the step S3 specifically includes:

s31, according to PmaxAnd PminExtracting L characteristic points on the fruit handle, wherein L is a positive integer, and the difference between the vertical coordinates of two adjacent characteristic points satisfies the following conditions:

Wherein round (·) is a rounding function;

S32, setting the characteristic point set as P ═ PkI k 0,1, …, L-1, where P is0=Pmin,PL-1=PmaxCharacteristic point Pkhas the coordinates of (i)k,jk):

ik=imin+kD (7)

Wherein the content of the first and second substances,denotes the ithkgray values of pixel points in the row and the j-1 th column,denotes the ithkThe gray values of the pixel points in the row and the jth column,denotes the ithkGray values of pixel points in the row and the j +1 th column;

s33, sequentially connecting the characteristic points in the characteristic point set P to form L-1 line segments, and calculating the sum of the lengths of the L-1 line segments as the length Z of the pear stalk:

And S34, calibrating the size of the image by using a size standard plate, and converting the pear stalk length Z from equivalent pixels into millimeter size to obtain the actual pear stalk length.

Compared with the prior art, the invention adopting the technical scheme has the following technical effects:

According to the method, a large amount of useless data is removed during early-stage pretreatment, and the subsequent calculation process is simple, so that the method is small in calculation amount, low in requirements on hardware equipment, high in calculation speed, extremely high in measurement efficiency compared with the existing manual measurement method, and capable of measuring the lengths of the fruit stalks of a large number of pear samples in a short time. Meanwhile, the characteristic of natural bending of the fruit stem is considered, a large number of characteristic points are extracted to calculate the length of the fruit stem, the measuring precision is far higher than that of manual measurement, and meanwhile, the automation degree of the whole measuring process is high, excessive manual operation is not needed, the method is particularly suitable for the situation that more samples need to be measured, and the measuring cost can be greatly reduced.

Drawings

FIG. 1 is a flow chart of the method for measuring the length of a pear stalk based on machine vision.

FIG. 2 is a gray scale image according to an embodiment of the present invention.

FIG. 3 is a preprocessed carpopodium image of an embodiment of the invention.

FIG. 4 is a diagram of a dimension standard plate according to an embodiment of the present invention.

Detailed Description

reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the accompanying drawings are illustrative only for the purpose of explaining the present invention, and are not to be construed as limiting the present invention.

a method for measuring the length of a pear stalk based on machine vision is disclosed, as shown in figure 1, and comprises the following steps:

S1, collecting an integral pear surface image, and preprocessing the pear surface image, wherein the preprocessing comprises gray value processing, binarization processing and denoising processing in sequence;

S2, selecting a pear stalk image from the preprocessed images, and calculating the highest point P of the stalk in the pear stalk imagemaxand the lowest point PminThe pixel coordinates of (a);

S3, according to the highest point PmaxAnd the lowest point Pminand extracting a characteristic point set, calculating the length of the actual fruit handle according to the characteristic point set, and calibrating by a size standard plate.

14页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种火花塞中心电极检测装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!