Wild jujube pulp and kernel image segmentation and extraction system based on image processing
Through image processing technology, the cranial cranium is screened using grayscale value distribution and clustering algorithms to obtain accurate seed points for regional growth, which solves the problem of inaccurate segmentation in the separation of jujube pulp and achieves higher accuracy of core segmentation and stirring degree judgment.
Patent Information
- Application Number
- CN202510700975.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-28
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2045-05-28
AI Technical Summary
In the prior art, when the jujube pulp and the core are separated, the regional growth algorithm is inaccurate in segmentation due to the similar grayscale values of the pulp and core and the holes inside the core, and the degree of stirring cannot be accurately judged.
Through image processing technology, the suspected fruit kernel area is divided using grayscale value distribution characteristics and clustering algorithm, and the crux reliability is screened based on grayscale change characteristics, accurate seed points are obtained for regional growth, and the area of the core area is judged to evaluate the stirring degree.
It improves the accuracy of the core area segmentation, can more accurately judge the stirring degree of jujube, eliminates interference from the flesh and shadow areas, and ensures the integrity of the core separation.
Smart Images

Figure CN120525902A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer vision, and in particular to a sour jujube pulp and core image segmentation and extraction system based on image processing. Background Art
[0002] As a fruit that can be used as both medicine and food, the pulp and core of sour jujube have important medicinal and economic value. Therefore, separating the pulp and core of sour jujube helps to better utilize the value of the pulp and core of sour jujube. The existing technology usually uses a stirring device to separate the pulp and core of sour jujube. The degree of separation of the pulp and core is judged by the degree of stirring of the sour jujube. Sufficient stirring means that the core is completely separated from the pulp. Under traditional methods, the degree of stirring of sour jujube mainly relies on manual judgment, which is inefficient and costly. With the development of computer vision technology, image processing technology can be used to realize the automatic segmentation of the pulp and core of sour jujube, so as to better judge the degree of stirring of sour jujube.
[0003] Existing technologies typically use region growing algorithms to automatically segment the pulp and core of hawthorn jujubes. This algorithm places seed points and then grows each seed point into a region, creating the core region. However, due to the overlapping nature of the pulp and core of hawthorn jujubes, the shadowed areas in hawthorn jujube images have similar local features to the core covered by the pulp, resulting in similar grayscale values in different regions. This interferes with the placement of seed points in the region growing algorithm, reducing their accuracy and resulting in the growth results not all being core regions. Furthermore, due to the presence of pitting holes in the core of hawthorn jujubes, grayscale differences within the core can result in incomplete region growth. These issues reduce the accuracy of core and pulp segmentation and extraction, making it impossible to accurately determine the degree of agitation in hawthorn jujubes.
[0004] Therefore, how to accurately obtain the seed points in the sour jujube image so that the accuracy of the core area segmented by the region growing algorithm is higher becomes an urgent problem to be solved. Summary of the Invention
[0005] In view of this, an embodiment of the present invention provides a jujube pulp and core image segmentation and extraction system based on image processing to solve the problem of how to accurately obtain seed points in jujube images so that the accuracy of the core area segmented by the region growing algorithm is higher.
[0006] An embodiment of the present invention provides a sour jujube pulp and core image segmentation and extraction system based on image processing, comprising a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the following method is implemented: Capturing an image of the stirred sour jujube to obtain a sour jujube image, and gray-scaling the sour jujube image to obtain a target image; Segmenting the target image according to the grayscale value distribution characteristics of the pixels in the target image to obtain at least two suspected fruit core regions; For any suspected fruit core region, obtaining the fruit core credibility of the suspected fruit core region based on the grayscale change characteristics of the pixels in the suspected fruit core region, obtaining the fruit core credibility of each suspected fruit core region, and screening at least one target region from all suspected fruit core regions based on the fruit core credibility of each suspected fruit core region; Record any target area as the area to be delivered, obtain seed points in the area to be delivered according to the grayscale value distribution characteristics of the pixels in the area to be delivered, and obtain the growth area of each seed point according to the region growing algorithm to form the fruit core area in the area to be delivered; The area of the core region in each area to be placed is obtained, and the degree of stirring of the sour jujube is judged according to the area of all the core regions, which is used to evaluate the core segmentation status of the sour jujube.
[0007] Preferably, the target image is segmented according to the grayscale value distribution characteristics of the pixels in the target image to obtain at least two suspected fruit core areas, including: Constructing a two-dimensional rectangular coordinate system in the target image, obtaining the coordinates of each pixel in the target image according to the two-dimensional rectangular coordinate system, combining the coordinates of each pixel and its grayscale value into a three-dimensional feature vector, clustering the pixels in the target image according to the three-dimensional feature vector of each pixel to obtain at least two clusters, and obtaining at least two cluster regions according to the pixels corresponding to each cluster; Constructing a grayscale histogram of the target image, where the horizontal axis of the grayscale histogram is the grayscale level and the vertical axis is the number of pixels corresponding to the grayscale level, obtaining a cumulative distribution function of each grayscale level in the grayscale histogram except for the maximum grayscale level and the minimum grayscale level, and using the grayscale level corresponding to the minimum cumulative distribution function as the grayscale threshold; For any cluster region, obtain the grayscale value of the mean grayscale value of the pixels in the cluster region in the grayscale histogram, and record it as the grayscale level of the cluster region. If the grayscale level of the cluster region is less than or equal to the grayscale threshold, record the cluster region as a suspected fruit core region. The grayscale of each cluster region is obtained, and at least two suspected fruit core regions are obtained according to the grayscale of each cluster region.
[0008] Preferably, obtaining the fruit core credibility of any suspected fruit core region according to the grayscale change characteristics of the pixels in any suspected fruit core region includes: Obtaining the first fruit core credibility based on the grayscale value difference between each pixel point in the suspected fruit core area and its horizontal and vertical pixels; Constructing a grayscale curve graph of any suspected fruit core region, wherein the horizontal axis of the grayscale curve graph represents the grayscale value and the vertical axis represents the number of pixels corresponding to the grayscale value, and obtaining the credibility of the second fruit core based on the fluctuation characteristics of the data in the grayscale curve graph; The maximum value between the first fruit core credibility and the second fruit core credibility is obtained, and the maximum value is used as the fruit core credibility of any suspected fruit core area.
[0009] Preferably, obtaining the first fruit core credibility according to the grayscale value difference between each pixel point in any suspected fruit core area and its horizontal and vertical pixels includes: For any pixel point in any suspected fruit core area, in the suspected fruit core area, the grayscale values of the pixel point and all the pixels in its horizontal direction form a horizontal grayscale value sequence, and the grayscale values of the pixel point and all the pixels in its vertical direction form a vertical grayscale value sequence; Obtaining a standard deviation of the horizontal grayscale value sequence, obtaining a change rate of each grayscale value in the horizontal grayscale value sequence, screening target change rates whose change rates are not zero, recording the mean of all target change rates as a change rate mean, obtaining the product of the standard deviation and the change rate mean, and obtaining a grayscale change degree of the horizontal grayscale value sequence; Obtaining the grayscale change degree of the vertical grayscale value sequence, calculating the average of the grayscale change degree of the horizontal grayscale value sequence and the grayscale change degree of the vertical grayscale value sequence, and obtaining the change degree of any pixel point; Normalize the average value of the degree of change of all pixels in any suspected fruit core area to obtain the first fruit core credibility.
[0010] Preferably, obtaining the credibility of the second fruit core according to the fluctuation characteristics of the data in the grayscale curve graph includes: Obtain a valley point in the grayscale curve graph. If there is only one valley point in the grayscale curve graph, obtain the pixel points corresponding to each data point to the right of the valley point in the grayscale curve graph, record them as covered pixel points, obtain the average grayscale value of all covered pixel points, and obtain the average covered grayscale value; The cluster area with a gray level greater than the gray level threshold is recorded as the flesh area, the gray value mean of all the flesh areas is obtained to obtain the regional gray value mean, and the absolute value of the difference between the coverage gray value mean and the regional gray value mean is calculated to obtain the degree of difference; Constructing a gray level co-occurrence matrix of any suspected fruit core region, obtaining a gray level eigenvalue based on the gray level uniformity of the gray level co-occurrence matrix, obtaining the product of the difference degree and the gray level eigenvalue, performing inverse proportional normalization on the product, and obtaining a second fruit core credibility; If there is no valley point in the grayscale curve graph, it is confirmed that the reliability of the second core is a constant 0.
[0011] Preferably, screening at least one target area from all suspected fruit core areas according to the fruit core credibility of each suspected fruit core area includes: A fruit core credibility threshold is set, and suspected fruit core regions whose fruit core credibility is greater than or equal to the fruit core credibility threshold are screened from all suspected fruit core regions and recorded as target regions.
[0012] Preferably, obtaining the seed points in the area to be delivered according to the grayscale value distribution characteristics of the pixels in the area to be delivered includes: Constructing a grayscale change curve for the area to be delivered, wherein the horizontal axis of the grayscale change curve is the grayscale value and the vertical axis is the number of pixels corresponding to the grayscale value, and obtaining the peak point and valley point of the grayscale change curve; The peak point, valley point, first data point and last data point of the grayscale change curve are recorded as key points, and the pixel point corresponding to the grayscale value of each key point is the initial seed point in the area to be delivered; Obtain a global region growing threshold for performing region segmentation on the target image using a region growing algorithm, and for any key point, obtain S target key points corresponding to the key point based on the grayscale value difference between the key point and its right adjacent key point and the global region growing threshold; For any target key point among the S target key points, obtain the grayscale value of any target key point based on the difference between the global region growing threshold and the grayscale value corresponding to the any key point, obtain the grayscale value of each target key point, and the pixel point corresponding to the grayscale value of each target key point is the seed point to be added corresponding to the any key point; The seed points to be added corresponding to each key point are obtained, and all initial seed points and all seed points to be added are used as seed points in the area to be delivered.
[0013] Preferably, obtaining S target key points corresponding to any key point according to the grayscale value difference between the any key point and its right adjacent key point and the global region growing threshold includes: Obtain the difference in grayscale value between the right adjacent key point of any key point and the key point, record it as the grayscale difference, calculate the ratio of the grayscale difference to the preset multiple of the global growth area threshold, round down the ratio, and obtain S target key points corresponding to any key point.
[0014] Preferably, obtaining the grayscale value of any target key point according to the difference between the global region growing threshold and the grayscale value corresponding to any key point includes: The S target key points corresponding to any key point are numbered, the product of the number of any target key point at a preset multiple and the global region growth threshold is obtained to obtain the value to be added, the grayscale value of any key point and the addition result of the value to be added are obtained to obtain the grayscale value of any target key point.
[0015] Preferably, judging the stirring degree of the sour jujube according to the area of all fruit core regions includes: For any of the fruit core regions, obtaining the area of the circumscribed ellipse of the fruit core region, and recording it as the actual fruit core region; Obtaining the area cumulative value of all core regions to obtain the total core area, obtaining the area cumulative value of all actual core regions to obtain the total actual core area, and calculating the ratio of the total core area to the total actual core area to obtain the sour jujube separation ratio; If the sour jujube separation ratio is greater than the preset separation ratio threshold, it is confirmed that the sour jujube is sufficiently stirred. If the sour jujube separation ratio is less than or equal to the preset separation ratio threshold, it is confirmed that the sour jujube is not sufficiently stirred.
[0016] Compared with the prior art, the embodiments of the present invention have the following beneficial effects: The present invention collects images of the stirred sour jujube to obtain a sour jujube image, performs grayscale processing on the sour jujube image to obtain a target image; segments the target image according to the grayscale value distribution characteristics of pixel points in the target image to obtain at least two suspected fruit core areas; for any suspected fruit core area, obtains the fruit core credibility of any suspected fruit core area according to the grayscale change characteristics of the pixel points in the any suspected fruit core area, obtains the fruit core credibility of each suspected fruit core area, and screens at least one target area in all suspected fruit core areas according to the fruit core credibility of each suspected fruit core area; records any target area as a to-be-delivered area, obtains seed points in the to-be-delivered area according to the grayscale value distribution characteristics of the pixel points in the to-be-delivered area, obtains the growth area of each seed point according to a region growing algorithm, and forms a fruit core area in the to-be-delivered area; obtains the area of the fruit core area in each to-be-delivered area, and judges the stirring degree of the sour jujube according to the area of all the fruit core areas, so as to evaluate the fruit core segmentation state of the sour jujube. Among them, according to the grayscale value distribution characteristics of the pixel points in the target image, the pulp area in the target image can be identified, eliminating the interference of the pulp area in the target image; then, according to the credibility of the suspected core area, it can be identified whether the suspected core area is the shadow area between the pulp and the core in the target image, eliminating the interference of the shadow area in the target image; finally, according to the grayscale value distribution characteristics of the pixel points in the area to be delivered, the seed points in the area to be delivered are more accurately obtained to obtain the core area, so that the accuracy of the core area segmented by the region growing algorithm is higher. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 This is a flow chart of a method for segmenting and extracting the pulp and core of a sour jujube fruit based on image processing provided in the first embodiment of the present invention; Figure 2 This is an example image of a sour jujube provided in Example 1 of the present invention; Figure 3 This is an example diagram of a sour jujube fruit core provided in Example 1 of the present invention. DETAILED DESCRIPTION
[0019] The embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and intended to be used to explain the present disclosure, but should not be understood as limiting the present disclosure.
[0020] It should be noted that the terms "first," "second," and the like in the specification of the present disclosure and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure.
[0021] In order to illustrate the technical solution of the present invention, specific embodiments are provided below.
[0022] The embodiment of the present invention provides a sour jujube pulp and core image segmentation and extraction system based on image processing, comprising a processor and a memory, wherein the processor executes a computer program in the memory to implement a sour jujube pulp and core image segmentation and extraction method based on image processing, such as Figure 1 As shown, the method includes the following steps: Step S101 , collecting an image of the stirred sour jujube to obtain a sour jujube image, and gray-scaling the sour jujube image to obtain a target image.
[0023] As a fruit that is both medicinal and edible, the pulp and core of sour jujube have important medicinal and economic value. Therefore, separating the pulp and core of sour jujube helps to better utilize the value of the pulp and core of sour jujube. Existing technology generally uses a stirring device to separate the pulp and core of sour jujube. The degree of separation of the pulp and core is determined by the degree of stirring of the sour jujube. Sufficient stirring indicates that the core is completely separated from the pulp.
[0024] In this embodiment, after the sour jujube is collected and cleaned, it is first put into a steamer and steamed over high heat for 30-40 minutes. There is no restriction here and it can be set according to the specific implementation scenario. Then it is cooled and peeled. The peeled sour jujube is placed in a container for stirring. The stirring device is located above the conveying device, and the sour jujube container is placed on the conveying device. The high-definition camera is installed directly above the conveying device. In order to prevent excessive stirring from causing the sour jujube core to break, the sour jujube needs to be stirred for different lengths of time. After the first stirring is set for 5 minutes, the stirring is stopped every 1 minute. There is no restriction here and it can be set according to the specific implementation scenario. After each stirring time is reached, the stirring is stopped and the sour jujube in the stirring container is photographed to obtain a sour jujube image, such as Figure 2 shown.
[0025] After obtaining the sour jujube image, the sour jujube image is grayscaled to obtain a target image, and the grayscale value of each pixel in the target image is obtained. The grayscale processing and the acquisition of the grayscale value belong to the existing technology and will not be repeated here.
[0026] Existing technologies typically use region growing algorithms to automatically segment the pulp and core of hawthorn jujubes. This algorithm places seed points and then grows each seed point into a region, creating the core region. However, due to the overlapping nature of the pulp and core of hawthorn jujubes, the shadowed areas in hawthorn jujube images have similar local features to the core covered by the pulp, resulting in similar grayscale values in different regions. This interferes with the placement of seed points in the region growing algorithm, reducing their accuracy and resulting in the growth results not all being core regions. Furthermore, due to the presence of pitting holes in the core of hawthorn jujubes, grayscale differences within the core can result in incomplete region growth. These issues reduce the accuracy of core and pulp segmentation and extraction, making it impossible to accurately determine the degree of agitation in hawthorn jujubes.
[0027] Therefore, this embodiment obtains the seed points in the target image based on the grayscale distribution characteristics of the pixel points in the target image, and then obtains the fruit core area in the target image. Then, based on the area of the fruit core area, the degree of stirring of the sour jujube is judged, so that the accuracy of the fruit core area segmented by the region growing algorithm is higher.
[0028] Step S102 : segmenting the target image according to the grayscale value distribution characteristics of the pixels in the target image to obtain at least two suspected fruit core regions.
[0029] After stirring, the sour jujube will produce pulp, core and core covered by pulp (that is, core that is not completely separated). Since the core of the sour jujube and the core covered by pulp both show low grayscale values in the target image, the target image can be segmented into multiple regions through a clustering algorithm, and then the suspected core area can be obtained based on the grayscale value distribution characteristics of pixel points in different areas of the target image.
[0030] In this embodiment, a two-dimensional rectangular coordinate system is constructed with the lower left corner vertex of the target image as the origin, the horizontal direction as the abscissa, and the vertical direction as the ordinate. The coordinates of each pixel point in the target image are obtained according to the two-dimensional rectangular coordinate system, and the coordinates of each pixel point and its grayscale value are combined into a three-dimensional feature vector. According to the three-dimensional feature vector of each pixel point, the pixel points in the target image are mean shift clustered to obtain at least two clusters, and then each pixel point in the cluster is marked in the target image. All pixel points corresponding to a cluster form an initial area. For any initial area, a circumscribed ellipse of any initial area is obtained. In any initial area, the pixel point with the shortest distance to the circumscribed ellipse in each direction is obtained as an edge point. All edge points are connected to obtain the cluster area corresponding to any initial area. According to the method for obtaining the cluster area corresponding to any initial area, at least two cluster areas are obtained.
[0031] Since the area where the flesh is located in the target image is much larger than the area where the core is located, and the area where the flesh is located has a higher grayscale value, there should be an obvious dividing line between the area where the core is located and the area where the flesh is located in the grayscale histogram of the target image. Therefore, the grayscale histogram of the target image can be constructed, the horizontal axis of the grayscale histogram is the grayscale level, and the vertical axis is the number of pixels corresponding to the grayscale level. The cumulative distribution function of each grayscale level except the maximum grayscale level and the minimum grayscale level in the grayscale histogram is obtained, and the grayscale level corresponding to the minimum cumulative distribution function is used as the grayscale level threshold, that is, the dividing line in the target image. According to the grayscale value distribution characteristics of the pixel points in different areas and the grayscale threshold, the suspected core area is obtained.
[0032] Specifically, for any cluster area, due to the presence of pitting holes in the sour jujube kernel, such as Figure 3 As shown, isolated pixels may appear in the cluster area. In order to reduce the influence of interference factors such as pitting holes, the various cluster areas are preprocessed using morphological opening operations. By corroding and then expanding the various cluster areas, the shape boundaries are smoothed and isolated pixels in the area are removed. The morphological opening operation belongs to the existing technology and will not be described here. The grayscale level of the grayscale value mean of the pixel points in any of the preprocessed cluster areas in the grayscale histogram is obtained and recorded as the grayscale level of any of the cluster areas. If the grayscale level of any of the cluster areas is less than or equal to the grayscale threshold, the any of the cluster areas is recorded as a suspected fruit core area. The grayscale of each cluster region is obtained. According to the above-mentioned method for obtaining the suspected fruit core region, at least two suspected fruit core regions are obtained in the target image according to the grayscale of each cluster region.
[0033] At this point, the suspected fruit core area in the target image is obtained.
[0034] Step S103, for any suspected fruit core area, obtain the fruit core credibility of any suspected fruit core area based on the grayscale change characteristics of the pixel points in the any suspected fruit core area, obtain the fruit core credibility of each suspected fruit core area, and screen at least one target area among all suspected fruit core areas based on the fruit core credibility of each suspected fruit core area.
[0035] The target image may also include a shadow area formed by the gap between the fruit pulp and the core. Since the grayscale value of the area where the fruit core is covered by the fruit pulp is similar to that of the shadow area, there may be a shadow area in the suspected fruit core area obtained in step S102. In order to more accurately obtain the area where the fruit core is located in the target image, it is necessary to eliminate the interference of the shadow area on the area where the fruit core is located.
[0036] The area where the fruit core is located includes the area where the ordinary fruit core is located and the area where the fruit core is covered by the pulp. Due to the pitting holes on the surface of the fruit core, the area where the ordinary fruit core is located shows a large number of local grayscale changes and a fast grayscale change speed; while the area where the fruit core is covered by the pulp shows high local grayscale complexity and poor grayscale consistency. The grayscale value of the grayscale difference part in the area covered by the pulp is similar to that of the flesh area; and the shadow area is formed by the gap between the flesh or the fruit core. The grayscale complexity in the area is low and the grayscale consistency is high, and there is no flesh part in the area, that is, there is no grayscale value interference from the flesh area. Therefore, for any suspected fruit core area, the fruit core credibility of any suspected fruit core area can be obtained according to the grayscale change characteristics of the pixel points in any suspected fruit core area, and then the interference of the shadow area on the fruit core area is eliminated according to the fruit core credibility, and the target area is screened.
[0037] The method for obtaining the fruit core credibility of any suspected fruit core region based on the grayscale change characteristics of the pixel points in any suspected fruit core region is as follows: (1) Obtain the first fruit core credibility based on the grayscale value difference between each pixel point in any suspected fruit core area and its horizontal and vertical pixels.
[0038] Specifically, for any pixel point in any suspected fruit core area, in the suspected fruit core area, the grayscale values of the pixel point and all the pixels in its horizontal direction are combined into a horizontal grayscale value sequence, and the grayscale values of the pixel point and all the pixels in its vertical direction are combined into a vertical grayscale value sequence; Obtain the standard deviation of the horizontal grayscale value sequence, number the grayscale values in the horizontal grayscale value sequence from left to right according to the positions of the corresponding pixel points, and construct a grayscale value curve graph of the horizontal grayscale value sequence with the grayscale value number as the horizontal axis and the grayscale value as the vertical axis. In the grayscale value curve graph, obtain the average change rate between each grayscale value and the next grayscale value as the change rate of each grayscale value. The change rate of the last grayscale value in the horizontal grayscale value sequence is 0. The average change rate belongs to the prior art and will not be repeated here. Target change rates with a change rate that is not 0 are screened, and the average of all target change rates is recorded as the change rate mean. Obtain the product of the standard deviation and the change rate mean to obtain the grayscale change degree of the horizontal grayscale value sequence; Obtain the grayscale change degree of the vertical grayscale value sequence according to the above-mentioned method for obtaining the grayscale change degree of the horizontal grayscale value sequence with a change rate, calculate the average of the grayscale change degree of the horizontal grayscale value sequence and the grayscale change degree of the vertical grayscale value sequence, and obtain the change degree of any pixel point; Normalize the average value of the degree of change of all pixels in any suspected fruit core area to obtain the first fruit core credibility.
[0039] In one embodiment, taking the i-th suspected fruit core region as an example, the calculation formula for the credibility of the first fruit core in the i-th suspected fruit core region is: ; in, is the credibility of the first fruit core in the i-th suspected fruit core area; is the standard deviation of the horizontal grayscale value sequence or vertical grayscale value sequence of the j-th pixel in the i-th suspected fruit core area; is the mean rate of change of the horizontal grayscale value sequence or vertical grayscale value sequence of the jth pixel in the i-th suspected fruit core area; f is the horizontal grayscale value sequence or vertical grayscale value sequence of the jth pixel in the i-th suspected fruit core area; N is the number of pixels in the i-th suspected fruit core area; exp() is an exponential function with a natural constant as the base, which is used for normalization.
[0040] It should be noted that is the grayscale change degree of the horizontal grayscale value sequence or the vertical grayscale value sequence, The larger it is, the more times the grayscale value changes in the horizontal grayscale value sequence or the vertical grayscale value sequence, the greater the grayscale change amplitude, and the greater the degree of grayscale change; The larger the value is, the greater the intensity of the grayscale change in the horizontal grayscale value sequence or the vertical grayscale value sequence, and the greater the degree of grayscale change. The greater the degree of grayscale change, the more the j-th pixel point in the i-th suspected fruit core area conforms to the characteristics of the pitting holes in the area where the ordinary fruit core is located, and the greater the credibility of the first fruit core.
[0041] (2) Construct a grayscale curve graph of any suspected fruit core area, wherein the horizontal axis of the grayscale curve graph is the grayscale value and the vertical axis is the number of pixels corresponding to the grayscale value. The credibility of the second fruit core is obtained based on the fluctuation characteristics of the data in the grayscale curve graph.
[0042] Specifically, the valley point in the grayscale curve is obtained by AMPD algorithm. AMPD algorithm belongs to the prior art and will not be described here. Since the grayscale value of the area where the fruit core covered by the pulp is located is significantly different from that of the area where the ordinary fruit core is located, the grayscale curve Figure 1 Generally, it presents a bimodal feature, that is, there is only one valley point. In special cases, the grayscale curve graph does not have a valley point. For example, the suspected fruit core area is the area where the ordinary fruit core is located (the fruit core is completely separated) or the shadow area. Therefore, if there is no valley point in the grayscale curve, it means that the suspected fruit core area is the area where the ordinary fruit core is located (the fruit core is completely separated) or the shadow area, and the reliability of the second fruit core is confirmed to be a constant 0; If there is only one valley point in the grayscale curve graph, obtain the pixel point corresponding to each data point on the right side of the valley point in the grayscale curve graph, record them as covered pixel points, obtain the average grayscale value of all covered pixel points, and obtain the average covered grayscale value; The cluster area with a gray level greater than the gray level threshold is recorded as the flesh area, the gray value mean of all the flesh areas is obtained to obtain the regional gray value mean, and the absolute value of the difference between the coverage gray value mean and the regional gray value mean is calculated to obtain the degree of difference; Construct a grayscale co-occurrence matrix of any suspected fruit core area, and obtain a grayscale eigenvalue based on the grayscale uniformity of the grayscale co-occurrence matrix. The grayscale uniformity of the grayscale co-occurrence matrix is a prior art and will not be described here. Obtain the product of the degree of difference and the grayscale eigenvalue, perform inverse proportional normalization on the product, and obtain the credibility of the second fruit core.
[0043] In one embodiment, taking the i-th suspected fruit core region as an example, the calculation formula for the second fruit core credibility of the i-th suspected fruit core region is: ; in, is the credibility of the second fruit core in the i-th suspected fruit core area; J is the grayscale eigenvalue; is the gray value of the mth covered pixel; M is the number of covered pixels; is the mean gray value of the region; is the absolute value symbol; exp(-) is an exponential function with a natural constant as the base, which is used for inverse proportional normalization.
[0044] It should be noted that For the degree of difference, The smaller J is, the more similar the grayscale value of the covered pixel is to the grayscale value of the pulp area, that is, the more the i-th suspected core area conforms to the characteristics of the area where the core covered by the pulp is located, and the greater the credibility of the second core in the i-th suspected core area; the smaller J is, the greater the difference in the grayscale values of the pixels in the i-th suspected core area is, that is, the grayscale consistency is poor, the more the i-th suspected core area conforms to the characteristics of the area where the core covered by the pulp is located, and the greater the credibility of the second core in the i-th suspected core area.
[0045] (3) Since the area where the fruit core is located includes the area where the ordinary fruit core is located and the area where the fruit core covered by the fruit pulp is located, and each area where the fruit core is located can only belong to one of the areas between the area where the ordinary fruit core is located and the area where the fruit core covered by the fruit pulp is located, the maximum value between the first fruit core credibility and the second fruit core credibility is obtained, and the maximum value is used as the fruit core credibility of any suspected fruit core area.
[0046] Furthermore, based on the credibility of the fruit core, the method of eliminating the interference of the shadow area on the area where the fruit core is located and screening the target area is as follows: Based on historical experience, the fruit core credibility threshold is set to 0.8. There is no restriction here and it can be set according to the specific implementation scenario. If the fruit core credibility of the i-th suspected fruit core area is greater than or equal to 0.8, it means that the i-th suspected fruit core area is more consistent with the characteristics of the area where ordinary fruit cores are located or the fruit core area covered by pulp. Therefore, among all suspected fruit core areas, the suspected fruit core areas with fruit core credibility greater than or equal to the said fruit core credibility threshold are screened and recorded as target areas.
[0047] At this point, the target area in the target image is obtained, that is, the area where the fruit core is located.
[0048] Step S104, record any target area as the area to be delivered, obtain the seed points in the area to be delivered according to the grayscale value distribution characteristics of the pixels in the area to be delivered, obtain the growth area of each seed point according to the region growing algorithm, and form the fruit core area in the area to be delivered.
[0049] After obtaining the target area in the target image, it is necessary to place seed points in the target area, and then obtain the fruit core area in the target image through the region growing algorithm. Any target area is recorded as the area to be placed. Since region growing is based on the grayscale value as the threshold to grow and segment each area, and there are some pitting holes in the fruit core itself, there is a certain grayscale difference between the pitting holes and the fruit core itself. Therefore, when a large grayscale difference appears in the area, performing region growth on the seed points may result in incomplete region growth, resulting in inaccurate fruit core area segmentation results. Therefore, when performing region growth on the seed points, in order to ensure the integrity of the fruit core area growth, it is necessary to obtain the seed points in the area to be placed based on the grayscale value distribution characteristics of the area to be placed, and then obtain the fruit core area in the area to be placed based on the seed points.
[0050] In order to better analyze the grayscale value distribution characteristics of the area to be deployed, a grayscale change curve of the area to be deployed is constructed. The horizontal axis of the grayscale change curve is the grayscale value, and the vertical axis is the number of pixels corresponding to the grayscale value. The peak point and valley point of the grayscale change curve are obtained by the AMPD algorithm. The AMPD algorithm belongs to the existing technology and will not be repeated here.
[0051] Since there are some pitting holes in the fruit core itself, there is a certain grayscale difference between the pitting holes and the fruit core itself. In order to obtain the complete fruit core area, the peak point, valley point, first data point and last data point of the grayscale change curve are recorded as key points, and the pixel point corresponding to the grayscale value of each key point is the initial seed point in the area to be delivered.
[0052] A global region growing threshold is obtained for performing region segmentation on the target image using a region growing algorithm. The global region growing threshold in the region growing algorithm is set by the user. The present invention only improves the number and position of seed points, and the other steps of the region growing algorithm remain unchanged. They can be directly obtained here. If the key point is simply used as the seed point, when twice the global region growing threshold is less than the difference in the corresponding grayscale values between the key points, the growth result is not ideal. For example, the grayscale values of two key points are 5 and 35 respectively, and the global region growing threshold is 5. If a key point corresponds to only one seed point, two growth regions will be obtained by performing region growing on the two seed points. However, the two seed points should be in the same growth region. Therefore, for any key point, based on the grayscale value difference between the any key point and its right adjacent key point, and the global region growing threshold, S target key points corresponding to the any key point are obtained as the target key points that need to be added between any key point and its right adjacent key point to prevent incomplete growth of the fruit core region.
[0053] Specifically, the difference in grayscale value between the right adjacent key point of any key point and the key point is obtained, recorded as the grayscale difference, the ratio of the grayscale difference to the preset multiple of the global growth area threshold is calculated, the ratio is rounded down, and S target key points corresponding to any key point are obtained.
[0054] In one embodiment, taking the kth key point as an example, the calculation formula for the number of S target key points corresponding to the kth key point is: ; Among them, S is the number of S target key points corresponding to the k-th key point; is the gray value of the k+1th key point in the gray change curve; is the gray value of the kth key point in the gray change curve; C is the global region growth threshold; 2 is the preset multiple; is the floor symbol.
[0055] It should be noted that is the grayscale difference, The larger it is, the greater the difference in grayscale values between the kth key point and the k+1th key point in the grayscale change curve is, and more seed points are needed for regional growth, and the larger S is.
[0056] Furthermore, for any target key point among the S target key points, the grayscale value of any target key point is obtained according to the difference between the global region growing threshold and the grayscale value corresponding to the any key point.
[0057] Specifically, the S target key points corresponding to any key point are numbered, the product of the number of any target key point at a preset multiple and the global region growth threshold is obtained to obtain the value to be added, the addition result of the grayscale value of any key point and the value to be added is obtained to obtain the grayscale value of any target key point.
[0058] In one embodiment, taking the xth target key point corresponding to the kth key point as an example, the calculation formula for the grayscale value of the xth target key point corresponding to the kth key point is: ; in, is the grayscale value of the xth target key point corresponding to the kth key point; is the grayscale value of the kth key point; x is the number of the target key point corresponding to the kth key point; C is the global region growing threshold; 2 is the preset multiple.
[0059] The grayscale value of each target key point corresponding to the k-th key point is obtained, and the pixel point corresponding to the grayscale value of each target key point is the seed point to be added corresponding to the k-th key point.
[0060] According to the method for obtaining the seed points to be added corresponding to the kth key point, the seed points to be added corresponding to each key point in the grayscale change curve are obtained, and all initial seed points and all seed points to be added are used as seed points in the area to be placed.
[0061] After obtaining all the seed points in the area to be placed, the growth area of each seed point is obtained according to the global region growth threshold and the region growing algorithm to form the fruit core area in the area to be placed. The region growing algorithm belongs to the existing technology and will not be described here.
[0062] At this point, the fruit core area in the area to be placed is obtained.
[0063] Step S105, obtaining the area of the core region in each area to be placed, and judging the stirring degree of the sour jujube according to the area of all the core regions, so as to evaluate the core segmentation state of the sour jujube.
[0064] According to the above-mentioned method for obtaining the fruit core area in the area to be delivered, the fruit core area in each area to be delivered is obtained. Since there are areas where ordinary fruit cores are located and areas where fruit cores covered by pulp are located in the target area, and the sour jujube fruit cores are generally uniform in size and close to an ellipse in shape, for any of the fruit core areas, the area of the circumscribed ellipse of any of the fruit core areas is obtained and recorded as the actual fruit core area. The degree of stirring of the sour jujube can be judged based on the difference in area between the fruit core area and the actual fruit core area.
[0065] Among them, the method for judging the degree of stirring of sour jujube according to the difference in area between the core area and the actual core area is as follows: Obtaining the area cumulative value of all core regions to obtain the total core area, obtaining the area cumulative value of all actual core regions to obtain the total actual core area, and calculating the ratio of the total core area to the total actual core area to obtain the sour jujube separation ratio; If the sour jujube separation ratio is greater than 0.9, it means that the closer the core area is to the actual core area to be obtained, the more the sour jujube is sufficiently stirred; if the sour jujube separation ratio is less than or equal to 0.9, it means that the greater the difference between the core area and the actual core area to be obtained, the more the sour jujube is insufficiently stirred, wherein 0.9 is the separation ratio threshold set in this embodiment, and the separation ratio threshold needs to be set according to the separation completeness required by the user. The larger the threshold, the higher the required separation completeness. There is no restriction here, and it can be set according to the specific implementation scenario.
[0066] In order to prevent some fruit cores from being located at the bottom of the stirring device and causing insufficient stirring, when the jujube separation ratio in the target image is greater than 0.9, the stirring time of the stirring device is changed to 30s and stopped once for taking pictures. When 5 consecutive target images are judged to be sufficient stirring of the jujube, it is confirmed that the flesh and core of the jujube in the stirring device are completely separated, and the staff is reminded that they can proceed to the next step; when there is at least one target image in 5 consecutive target images that the jujube is not sufficiently stirred, stirring needs to be continued until it is confirmed that the flesh and core of the jujube in the stirring device are completely separated.
[0067] The embodiment of the present invention collects images of the stirred sour jujube to obtain a sour jujube image, performs grayscale processing on the sour jujube image to obtain a target image; segments the target image according to the grayscale value distribution characteristics of the pixels in the target image to obtain at least two suspected fruit core areas; for any suspected fruit core area, obtains the fruit core credibility of any suspected fruit core area according to the grayscale change characteristics of the pixels in the suspected fruit core area, obtains the fruit core credibility of each suspected fruit core area, and screens at least one target area in all suspected fruit core areas according to the fruit core credibility of each suspected fruit core area; records any target area as a to-be-delivered area, obtains seed points in the to-be-delivered area according to the grayscale value distribution characteristics of the pixels in the to-be-delivered area, obtains the growth area of each seed point according to the region growing algorithm, and forms the fruit core area in the to-be-delivered area; obtains the area of the fruit core area in each to-be-delivered area, and judges the degree of stirring of the sour jujube according to the area of all the fruit core areas, so as to evaluate the fruit core segmentation status of the sour jujube. Among them, according to the grayscale value distribution characteristics of the pixel points in the target image, the pulp area in the target image can be identified, eliminating the interference of the pulp area in the target image; then, according to the credibility of the suspected core area, it can be identified whether the suspected core area is the shadow area between the pulp and the core in the target image, eliminating the interference of the shadow area in the target image; finally, according to the grayscale value distribution characteristics of the pixel points in the area to be delivered, the seed points in the area to be delivered are more accurately obtained to obtain the core area, so that the accuracy of the core area segmented by the region growing algorithm is higher.
[0068] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.
Claims
1. A system for segmenting and extracting the pulp and core of a sour jujube fruit based on image processing, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the following method is implemented: Capturing an image of the stirred sour jujube to obtain a sour jujube image, and gray-scaling the sour jujube image to obtain a target image; Segmenting the target image according to the grayscale value distribution characteristics of the pixels in the target image to obtain at least two suspected fruit core regions; For any suspected fruit core region, obtaining the fruit core credibility of the suspected fruit core region based on the grayscale change characteristics of the pixels in the suspected fruit core region, obtaining the fruit core credibility of each suspected fruit core region, and screening at least one target region from all suspected fruit core regions based on the fruit core credibility of each suspected fruit core region; Record any target area as the area to be delivered, obtain seed points in the area to be delivered according to the grayscale value distribution characteristics of the pixels in the area to be delivered, and obtain the growth area of each seed point according to the region growing algorithm to form the fruit core area in the area to be delivered; The area of the core region in each area to be placed is obtained, and the degree of stirring of the sour jujube is judged according to the area of all the core regions, which is used to evaluate the core segmentation status of the sour jujube.
2. The sour jujube pulp and core image segmentation and extraction system based on image processing according to claim 1 is characterized in that: The target image is segmented according to the grayscale value distribution characteristics of the pixels in the target image to obtain at least two suspected fruit core regions, including: Constructing a two-dimensional rectangular coordinate system in the target image, obtaining the coordinates of each pixel in the target image according to the two-dimensional rectangular coordinate system, combining the coordinates of each pixel and its grayscale value into a three-dimensional feature vector, clustering the pixels in the target image according to the three-dimensional feature vector of each pixel to obtain at least two clusters, and obtaining at least two cluster regions according to the pixels corresponding to each cluster; Constructing a grayscale histogram of the target image, where the horizontal axis of the grayscale histogram is the grayscale level and the vertical axis is the number of pixels corresponding to the grayscale level, obtaining a cumulative distribution function of each grayscale level in the grayscale histogram except for the maximum grayscale level and the minimum grayscale level, and using the grayscale level corresponding to the minimum cumulative distribution function as the grayscale threshold; For any cluster region, obtain the grayscale value of the mean grayscale value of the pixels in the cluster region in the grayscale histogram, and record it as the grayscale level of the cluster region. If the grayscale level of the cluster region is less than or equal to the grayscale threshold, record the cluster region as a suspected fruit core region. The grayscale of each cluster region is obtained, and at least two suspected fruit core regions are obtained according to the grayscale of each cluster region.
3. The sour jujube pulp and core image segmentation and extraction system based on image processing according to claim 2 is characterized in that: The obtaining of the fruit core credibility of any suspected fruit core region according to the grayscale change characteristics of the pixel points in any suspected fruit core region includes: Obtaining the first fruit core credibility based on the grayscale value difference between each pixel point in the suspected fruit core area and its horizontal and vertical pixels; Constructing a grayscale curve graph of any suspected fruit core region, wherein the horizontal axis of the grayscale curve graph represents the grayscale value and the vertical axis represents the number of pixels corresponding to the grayscale value, and obtaining the credibility of the second fruit core based on the fluctuation characteristics of the data in the grayscale curve graph; The maximum value between the first fruit core credibility and the second fruit core credibility is obtained, and the maximum value is used as the fruit core credibility of any suspected fruit core area.
4. The sour jujube pulp and core image segmentation and extraction system based on image processing according to claim 3 is characterized in that: The obtaining of the first fruit core credibility according to the grayscale value difference between each pixel point in the any suspected fruit core area and its horizontal and vertical pixels includes: For any pixel point in any suspected fruit core area, in the suspected fruit core area, the grayscale values of the pixel point and all the pixels in its horizontal direction form a horizontal grayscale value sequence, and the grayscale values of the pixel point and all the pixels in its vertical direction form a vertical grayscale value sequence; Obtaining a standard deviation of the horizontal grayscale value sequence, obtaining a change rate of each grayscale value in the horizontal grayscale value sequence, screening target change rates whose change rates are not zero, recording the mean of all target change rates as a change rate mean, obtaining the product of the standard deviation and the change rate mean, and obtaining a grayscale change degree of the horizontal grayscale value sequence; Obtaining the grayscale change degree of the vertical grayscale value sequence, calculating the average of the grayscale change degree of the horizontal grayscale value sequence and the grayscale change degree of the vertical grayscale value sequence, and obtaining the change degree of any pixel point; Normalize the average value of the degree of change of all pixels in any suspected fruit core area to obtain the first fruit core credibility.
5. The sour jujube pulp and core image segmentation and extraction system based on image processing according to claim 3 is characterized in that: The obtaining of the second fruit core credibility according to the fluctuation characteristics of the data in the grayscale curve graph includes: Obtain a valley point in the grayscale curve graph. If there is only one valley point in the grayscale curve graph, obtain the pixel points corresponding to each data point to the right of the valley point in the grayscale curve graph, record them as covered pixel points, obtain the average grayscale value of all covered pixel points, and obtain the average covered grayscale value; The cluster area with a gray level greater than the gray level threshold is recorded as the flesh area, the gray value mean of all the flesh areas is obtained to obtain the regional gray value mean, and the absolute value of the difference between the coverage gray value mean and the regional gray value mean is calculated to obtain the degree of difference; Constructing a gray level co-occurrence matrix of any suspected fruit core region, obtaining a gray level eigenvalue based on the gray level uniformity of the gray level co-occurrence matrix, obtaining the product of the difference degree and the gray level eigenvalue, performing inverse proportional normalization on the product, and obtaining a second fruit core credibility; If there is no valley point in the grayscale curve graph, it is confirmed that the reliability of the second core is a constant 0.
6. The sour jujube pulp and core image segmentation and extraction system based on image processing according to claim 1 is characterized in that: The step of screening at least one target area from all suspected fruit core areas according to the fruit core credibility of each suspected fruit core area comprises: A fruit core credibility threshold is set, and suspected fruit core regions whose fruit core credibility is greater than or equal to the fruit core credibility threshold are screened from all suspected fruit core regions and recorded as target regions.
7. The sour jujube pulp and core image segmentation and extraction system based on image processing according to claim 1 is characterized in that: The step of obtaining the seed points in the area to be delivered according to the grayscale value distribution characteristics of the pixels in the area to be delivered comprises: Constructing a grayscale change curve for the area to be delivered, wherein the horizontal axis of the grayscale change curve is the grayscale value and the vertical axis is the number of pixels corresponding to the grayscale value, and obtaining the peak point and valley point of the grayscale change curve; The peak point, valley point, first data point and last data point of the grayscale change curve are recorded as key points, and the pixel point corresponding to the grayscale value of each key point is the initial seed point in the area to be delivered; Obtain a global region growing threshold for performing region segmentation on the target image using a region growing algorithm, and for any key point, obtain S target key points corresponding to the key point based on the grayscale value difference between the key point and its right adjacent key point and the global region growing threshold; For any target key point among the S target key points, obtain the grayscale value of any target key point based on the difference between the global region growing threshold and the grayscale value corresponding to the any key point, obtain the grayscale value of each target key point, and the pixel point corresponding to the grayscale value of each target key point is the seed point to be added corresponding to the any key point; The seed points to be added corresponding to each key point are obtained, and all initial seed points and all seed points to be added are used as seed points in the area to be delivered.
8. The sour jujube pulp and core image segmentation and extraction system based on image processing according to claim 7 is characterized in that: The step of obtaining S target key points corresponding to any key point according to the grayscale value difference between the any key point and its right adjacent key point and the global region growing threshold comprises: Obtain the difference in grayscale value between the right adjacent key point of any key point and the key point, record it as the grayscale difference, calculate the ratio of the grayscale difference to the preset multiple of the global growth area threshold, round down the ratio, and obtain S target key points corresponding to any key point.
9. The sour jujube pulp and core image segmentation and extraction system based on image processing according to claim 7, characterized in that: The obtaining of the grayscale value of any target key point according to the difference between the global region growing threshold and the grayscale value corresponding to any key point includes: The S target key points corresponding to any key point are numbered, the product of the number of any target key point at a preset multiple and the global region growth threshold is obtained to obtain the value to be added, the grayscale value of any key point and the addition result of the value to be added are obtained to obtain the grayscale value of any target key point.
10. The sour jujube pulp and core image segmentation and extraction system based on image processing according to claim 1, characterized in that: The method of judging the degree of stirring of the sour jujube according to the area of all the fruit core regions includes: For any of the fruit core regions, obtaining the area of the circumscribed ellipse of the fruit core region, and recording it as the actual fruit core region; Obtaining the area cumulative value of all core regions to obtain the total core area, obtaining the area cumulative value of all actual core regions to obtain the total actual core area, and calculating the ratio of the total core area to the total actual core area to obtain the sour jujube separation ratio; If the sour jujube separation ratio is greater than the preset separation ratio threshold, it is confirmed that the sour jujube is sufficiently stirred. If the sour jujube separation ratio is less than or equal to the preset separation ratio threshold, it is confirmed that the sour jujube is not sufficiently stirred.
Citation Information
Patent Citations
SAR remote-sensing image oil spilling detection and identification method
CN104951799A
Gold ore mineral analysis method based on video analysis for a draw shaft
CN112163631A
Fiberboard quality evaluation method based on image processing
CN114419025A
Image segmentation method and device and readable storage medium
CN114638840A
Coating production abnormity identification system
CN116091499A
Cited By
Cherry juice processing raw material crushing state identification and detection method
CN121214429A