A saliency-based object extraction method for flower and fruit images
The segmentation method of generating significant graphs and optimal data sources combined with FCM algorithms is solved by the SLIC-like algorithm, and the accuracy of target extraction under complex backgrounds and strong light conditions in the prior art is solved, and the accurate extraction of flower and fruit targets is achieved.
Patent Information
- Application Number
- CN202111579123.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-22
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2041-12-22
AI Technical Summary
Existing target extraction methods are mainly aimed at specific flowers or fruits, and it is difficult to accurately extract targets under complex natural backgrounds and bright light conditions.
A significant image of the image is generated by a SLIC-like algorithm, and a FCM algorithm is combined with the optimal data source to segment the target area and background area to extract the target area to achieve accurate extraction of the target.
The target areas of flowers and fruits can be accurately and completely extracted under complex backgrounds and strong light conditions, improving the universal applicability and practicality of the algorithm.
Smart Images

Figure CN114663441B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of digital image processing, and in particular relates to a method for extracting objects from flower and fruit images based on saliency. Background Art
[0002] With the continuous development of agricultural technology, the application of automated machines in agricultural production is becoming more and more extensive, such as automatic irrigation of crops, automatic harvesting of crops, automatic monitoring of pests and diseases, etc. A large part of these needs are inseparable from the support of digital image processing technology. For example, the automatic harvesting technology of crops is completely dependent on the accurate extraction of crop targets.
[0003] Many researchers have adopted different target extraction algorithms and improved the algorithms in different directions according to practical factors. Yue Youjun et al. used the improved Cascade RCNN network to detect tomato fruits in the greenhouse, which improved the target recognition rate in this specific environment to a certain extent. Fan Zeze et al. combined deep learning with traditional methods and proposed a fruit detection algorithm that integrates color and fruit diameter features for fruit detection in apple trees. The accuracy of detecting small targets in the image and detecting borders when the lighting is uneven and the fruit color is different is improved to a certain extent. Yin Hong et al. proposed a flower image classification method based on selective convolution feature fusion. This method uses an unsupervised method to locate the salient areas in the flower image, removes the interference of the background and noise on the flower target, and improves the accuracy of flower image classification. Zhang Hongqi et al. [4] introduced the regional information near the threshold point into the segmentation algorithm based on the characteristics of tomato fruit images, and proposed an improved Otsu threshold segmentation method based on two-dimensional histogram, which improved the image segmentation effect.
[0004] According to current research, most existing target extraction methods are mainly targeted at a certain type of flower or fruit target, or even a target of a certain color, and are not universally applicable. Secondly, even targets of the same color may be in different natural backgrounds, and the complex backgrounds cause serious interference to the accurate segmentation of the target. Thirdly, some flowers or fruits have very smooth surfaces, and the reflection is very strong under the sunlight, which also seriously affects the algorithm's recognition of the target area. Therefore, studying how to segment different types and colors of flowers and fruits from various natural backgrounds is of great significance to improving the practicality and universal availability of algorithms. Summary of the invention
[0005] The purpose of the present invention is to overcome the deficiencies of the prior art and provide a method for extracting objects from flower and fruit images based on saliency.
[0006] To achieve the above object, the technical solution adopted by the present invention is:
[0007] A method for extracting objects from flower and fruit images based on saliency, comprising the following steps:
[0008] S1, obtain the saliency map of the image;
[0009] S2, generating an optimal data source according to the saliency map obtained in step S1;
[0010] S3, segmenting the optimal data source obtained in step S2 to obtain a target area and a background area, and marking the obtained target area and background area to obtain a segmentation result map;
[0011] S4. Extract the target area in the original image according to the segmentation result map obtained in step S3, and display the result to obtain the target map.
[0012] Preferably, in step S1, the saliency map of the image is obtained by the following method:
[0013] S11, using a SLIC-like image superpixel segmentation algorithm to segment the image into multiple superpixels;
[0014] S12, presuppose that all superpixels on the four sides of the image belong to the background area, and calculate the features of each superpixel;
[0015] S13, calculating the average distance from each superpixel to all other superpixels in the preset background area, and calculating the total average distance of all average distances, and then excluding the superpixels of suspected targets to obtain the real initial background area;
[0016] S14, calculating the shortest distance from each superpixel in the image to the initial background area, each of the shortest distances represents the saliency of each superpixel, and obtaining a saliency map of the image according to the saliency of each superpixel.
[0017] Further preferably, in step S11, the image segmentation algorithm of the SLIC-like image superpixel segmentation algorithm is performed based on the color similarity and spatial proximity between pixels in the RGB color space, and the color similarity, spatial proximity and comprehensive similarity are calculated by formulas (1)-(3) respectively:
[0018]
[0019]
[0020] dist=d rgb +w*d xy (3)
[0021] Where i represents the i-th pixel point, k is the k-th superpixel center; R i, G i , B i Represents the R, G, and B values of pixel i respectively. Similarly, R k , G k , B k Respectively represent the R, G, and B values of the center of superpixel k; x i ,y i Represent the x and y coordinates of pixel i, respectively. k ,y k denote the x and y coordinates of the center of superpixel k, respectively; d rgb is the color similarity between pixel i and the center of the kth superpixel; d xy is the proximity degree of pixel i to the center of the kth superpixel; dist is the comprehensive similarity of pixel i to the center of the kth superpixel; w represents the weight of the spatial position, xstep is the distance between the centers of two superpixels in the x direction, ystep is the distance between the centers of two superpixels in the y direction, and the original image size is 512*512.
[0022] Further preferably, in step S13, the superpixel of the suspected target needs to satisfy two conditions at the same time, and the two conditions are respectively formulas (4) and (5):
[0023] avg n >sum_avg (4)
[0024] pre_bg n,R >pre_bg n,G
[0025] or
[0026] pre_bg n,B >pre_bg n,G (5)
[0027] Among them, avg n represents the average distance from superpixel n to other superpixels in the background, sum_avg refers to the total average distance of all average distances, pre_bg n,R Represents the R component value of superpixel n, pre_bg n,G Represents the G component value of superpixel n, pre_bg n,B Represents the B component value of superpixel n.
[0028] Preferably, in step S2, the generation of the optimal data source includes the following steps:
[0029] S21, calculating the average value of the saliency of all superpixels according to the saliency map obtained in step S1, and judging whether each superpixel belongs to the target area according to the average value, superpixels with a value greater than the average value belong to the target area, and superpixels with a value less than the average value belong to the background area;
[0030] S22, respectively calculating the average R, G, and B values of the target area and the background area, and finding the color component to which the maximum average value belongs, that is, the optimal component;
[0031] S23. Generate an optimal data source according to the optimal components of the target area and the background area.
[0032] Preferably, in step S3, the generation of the segmentation result map comprises the following steps:
[0033] S31, segmenting the optimal data source obtained in step S2 by using the FCM algorithm to obtain a target area and a background area;
[0034] S32, mark any pixel point in the target area as 1, and mark any pixel point in the background area as 0, so as to mark each pixel point of the optimal data source, and then obtain a segmentation result image marked with 0 and 1 of the same size as the original image.
[0035] Preferably, in step S4, the target graph is obtained by the following method:
[0036] The pixels marked as 1 in the segmentation result image obtained in step S3 are mapped to the original image, and the RGB values of the above pixels are taken out. Then, the RGB values of the pixels marked as 0 are taken as (0,0,0,), that is, black, to obtain a new image, and then the result is displayed to obtain the target image.
[0037] Compared with the prior art, the present invention has the following beneficial effects:
[0038] (1) The present invention combines a SLIC-like algorithm with an optimal data source. In the RGB color space, it can not only fit the edge of the object well when dividing superpixels, but also accurately extract the edge of the target when the edge of the target is relatively complex. At the same time, the optimal data source is segmented by the FCM algorithm to obtain the accurate area where the target is located.
[0039] (2) The present invention verifies the feasibility of the proposed target extraction method by using multiple flower and fruit images. The verification results show that the method of the present invention can accurately and completely extract the target. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 A flowchart of an image target extraction method provided by an embodiment of the present invention;
[0041] Figure 2 A flowchart for obtaining a saliency map of an image in an embodiment of the present invention;
[0042] Figure 3 For images where the target does not touch the edge of the image;
[0043] in: Figure 3 a is the original image; Figure 3 b is a saliency map satisfying formula (4); Figure 3 c is a saliency map that satisfies formulas (4) and (5);
[0044] Figure 4 For images where the target touches the edge of the image;
[0045] in, Figure 4 a is the original image; Figure 4 b is a saliency map satisfying formula (4); Figure 4 c is a saliency map that satisfies formulas (4) and (5);
[0046] Figure 5 It is the average value diagram of the target area and background area of 10 images under R, G, and B components;
[0047] Figure 6 It is the color component map in RGB color space;
[0048] Figure 7 A comparison chart of the effects of SUN, FT algorithm, and SLIC-like image superpixel segmentation algorithm and target extraction method on images 1 to 10 respectively;
[0049] Figure 8 This is a comparison chart of the effects of SUN, FT algorithm and SLIC-like image superpixel segmentation algorithm and target extraction method provided by an embodiment of the present invention on images No. 11 to 14 respectively. DETAILED DESCRIPTION
[0050] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0051] The overall processing flow of the object extraction method for flower and fruit images based on saliency provided by the embodiment of the present invention is as follows: Figure 1 As shown, the specific steps include:
[0052] S1. Obtain the saliency map of the image, such as Figure 2As shown in Figure 2, the saliency map of the image is obtained by the following method:
[0053] S11. Use a SLIC-like image superpixel segmentation algorithm to segment the image into multiple superpixels. The SLIC-like image superpixel segmentation algorithm segments the image based on color similarity and spatial proximity between pixels in RGB color space. The color similarity, spatial proximity and comprehensive similarity are calculated by formulas (1)-(3) respectively:
[0054]
[0055]
[0056] dist=d rgb +w*d xy (3)
[0057] Where i represents the i-th pixel point, k is the k-th superpixel center; R i , G i , B i Represents the R, G, and B values of pixel i respectively. Similarly, R k , G k , B k Respectively represent the R, G, and B values of the center of superpixel k; x i ,y i Represent the x and y coordinates of pixel i, respectively. k ,y k denote the x and y coordinates of the center of superpixel k, respectively; d rgb is the color similarity between pixel i and the center of the kth superpixel; d xy is the proximity degree of pixel i to the center of the kth superpixel; dist is the comprehensive similarity of pixel i to the center of the kth superpixel; w represents the weight of the spatial position, xstep is the distance between the centers of two superpixels in the x direction, ystep is the distance between the centers of two superpixels in the y direction, and the original image size is 512*512.
[0058] S12, presuppose that all superpixels on the four sides of the image belong to the background area, and calculate the features of each superpixel, specifically using the average value of R, G, and B of all points inside the superpixel block as the color feature of the superpixel;
[0059] S13, calculating the average distance from each superpixel to all other superpixels in the preset background area, and calculating the total average distance of all average distances, and then excluding the superpixels of the suspected target to obtain the real initial background area, wherein the superpixels of the suspected target must meet two conditions at the same time, which are formulas (4) and (5):
[0060] avg n >sum_avg (4)
[0061] pre_bg n,R >pre_bg n,G
[0062] or
[0063] pre_bg n,B >pre_bg n,G (5)
[0064] Among them, avg n represents the average distance from superpixel n to other superpixels in the background, sum_avg refers to the total average distance of all average distances, pre_bg n,R Represents the R component value of superpixel n, pre_bg n,G Represents the G component value of superpixel n, pre_bg n,B represents the B component value of superpixel n;
[0065] According to the characteristics of flower and mature fruit targets, their R or B component is usually greater than the G component. If the G component is greater than both the R and B components, it will appear green, which cannot be the target area. Therefore, the purpose of this condition is to avoid mistaking the white sky or other rapidly changing background factors for the target area. If the above two conditions are met, the superpixel is excluded, otherwise the superpixel still belongs to the background.
[0066] S14, calculate the shortest distance (Euclidean distance) from each superpixel in the image to the initial background area, each of the shortest distances represents the saliency of each superpixel, the larger the distance, the higher the saliency value, and obtain the saliency map of the image according to the saliency of each superpixel. The saliency map generated by the algorithm is as follows: Figure 2 and 3 shown.
[0067] Figure 3 For images where the target does not touch the edge of the image, Figure 4 For images where the target touches the edge of the image, Figure 3 b and Figure 4 b is the saliency map that only satisfies formula (4), through Figure 3 b and Figure 4 b It can be seen that the initial background area is not accurate enough, and some mutated background factors are mistakenly identified as targets; Figure 3 c and Figure 4 c is a saliency map that satisfies both formulas (4) and (5). Since a very accurate initial background region is obtained, a very accurate and complete salient region is obtained, which illustrates the important role of formula (5) in generating saliency maps.
[0068] Although the SLIC-like algorithm can better fit the edge of the object when dividing superpixels, its salient area is composed of multiple superpixels after all. Therefore, when the target edge is more complex, the edge of the salient area cannot accurately represent the edge of the target area. Therefore, it is not suitable to extract the target area directly based on the salient map. The accurate extraction of the target edge must be based on the characteristics of each pixel in the image. Therefore, the present invention further optimizes the extraction method through the following steps.
[0069] S2. Generate an optimal data source according to the saliency map obtained in step S1. The generation of the optimal data source specifically includes the following steps:
[0070] S21, calculating the average value of the saliency of all superpixels according to the saliency map obtained in step S1, and judging whether each superpixel belongs to the target area according to the average value, superpixels with a value greater than the average value belong to the target area, and superpixels with a value less than the average value belong to the background area;
[0071] S22, respectively calculate the average R, G, B values of the target area and the background area, and find the color component to which the maximum average value belongs, that is, the optimal component; after experiments, the average values of the target area and the background area of 10 images under R, G, B components are as follows: Figure 5 shown.
[0072] from Figure 5 It can be seen that the maximum component of the target area may be any one of R, G, and B, while the maximum component of the background area is always G. This is because the flower target can present a variety of colors, while the background is usually composed of branches, shadows, soil, and gray factors, which makes its G component value the largest.
[0073] S23, generating an optimal data source according to the optimal components of the target area and the background area;
[0074] In the RGB color space, each color is a mixture of different amounts of R, G, and B. The component with the maximum average value of the target area represents the color bias of the target area.
[0075] When the average value of the target area under the R component is the largest, the target tends to be red; when the maximum average value is obtained under the B component, the target tends to be blue; when the maximum value is obtained under the G component, the target tends to be green. However, this is only an approximate color bias. The actual color of the target depends on the size of the other two components. For example, when R and B are both large, the target appears magenta; when R and G are relatively large, the target appears yellow; when G and B components are large, the target appears cyan; when R, G, and B are all relatively large, the target tends to be white, such as Figure 6 shown.
[0076] The present invention adopts the idea of subtracting the optimal component of the background area from the optimal component of the target area to obtain the optimal data source. For example, the target area is red and the background area is green, which means that the R component of the target area is larger and the G and B components are smaller, while the G component of the background area is larger and the R and B components are smaller. Therefore, subtract G (the maximum background component) from R (the maximum target component). Since the R component of the target area is larger and the G component is smaller, the target area will get a larger number; while the background area has a larger G component and a smaller R component, and will get a smaller number or even a negative number. As a result, the distance between the target and the background becomes larger, the saliency of the target area is improved, and the saliency of the background area is suppressed. The method for obtaining the optimal data source is shown in formulas (6) and (7):
[0077] WrG r,c =(1+wXZ*XZ r,c )(fg*rgb r,c,best -bg*rgb r,c,G )*wR (6)
[0078] if(best==G) fg=1,bg=0,wR=1,wXZ=0.5
[0079]
[0080] Wrgb in formula (6) r,c represents the optimal value of the pixel in the rth row and cth column in the image, wXZ is the significance coefficient, XZ r,c is the saliency value of the pixel in the rth row and cth column, rgb r,c,best Indicates the component to which the point takes the maximum average value (for example, if the target has the largest average value under the R component, then take its R value), fg is the foreground coefficient, bg is the background coefficient, rgb r,c,G It represents its value under the G component (the maximum background component), and wR represents a coefficient used to amplify the value of R in special cases.
[0081] Formula (7) lists the values of various parameters in formula (6) under different conditions. Among them, best represents the component with the maximum average value in each color component of the target area, and G represents the G component.
[0082] When best==G, the optimal component is obtained under the G component. If fg=bg=1, then formula (6) becomes Wrgb r,c =(rgb r,c,g -rgb r,c,g )*wR, at this time Wrgb r,cThe value of is always 0, so when the target obtains the maximum average value under the G component, we take the R component value of the image as its optimal data source. At this time, the value of the foreground coefficient fg is 1, the value of the background coefficient bg is 0, and the value of wR is 1. In order to accurately highlight the target and suppress the background, the saliency is introduced, so the weight of the saliency wXZ=0.5.
[0083] When best! = G, there are three cases:
[0084] (1) When the average value of the foreground under the optimal component is greater than the average value of the background, and both are greater than 110 (that is, there may be a large area of strong reflective area in the target area, and its R, G, and B values are all close to 255, and the color appears white). Where fg is the foreground coefficient; fb is the background coefficient; avg_fg best Indicates the average value of the foreground under the optimal component; avg_bg best is the average value of the background under the optimal component; avg_fg G is the average background value under G component.
[0085] (2) When the average value of the foreground under the optimal component is avg_fg best Smaller than the background average avg_bg best , that is, when the overall background brightness is higher than the target area brightness. At this time, best minus G will make the target area all negative and the background area all positive, so exchanging the numerator and denominator of fg can avoid this, but the darker part of the target area is still less significant. In order to further improve the significance of the target area, the wR coefficient is adjusted at this time, wR=255 / rgb r,c,best , because the value of the target area is smaller than the background area under the best component, so rgb r,c,best The larger the value, the smaller wR, rgb r,c,best The smaller it is, the larger the wR value is, so that the saliency of the darker part of the target area can be effectively improved.
[0086] (3) In other cases: At this time, the value of the foreground coefficient fg is 1, the value of the background coefficient bg is 1, the value of wR is 1, and the value of wXZ is 0.
[0087] S3, segmenting the optimal data source obtained in step S2 to obtain a target area and a background area, and marking the obtained target area and background area to obtain a segmentation result map. The generation of the segmentation result map specifically includes the following steps:
[0088] S31, segmenting the optimal data source obtained in step S2 by using the FCM algorithm to obtain a target area and a background area;
[0089] The FCM algorithm is as follows:
[0090] Given a data set X = {x1, x2, ..., x n}, divide it into c clusters, when the objective function J m When (U, V) reaches the minimum value, the data set is divided and the objective function J m (U,V) can be expressed as:
[0091]
[0092]
[0093] where x i is a data element containing d attributes (1≤i≤n), V=(v1,v2,...,v c ) represents c cluster centers, v j is an element in V (1≤j≤c), m is the fuzzy coefficient, which is used to control the fuzziness of the classification matrix. Generally, m≥1, u ij ∈[0,1](1≤i≤n,1≤j≤c), U=(u ij ) is the membership matrix, which stores the membership values of each data element belonging to c classes.
[0094] In the formula, u ij and v j The value formula of is as follows:
[0095]
[0096]
[0097] The idea of the FCM algorithm is to continuously update the objective function through iteration so that the objective function J m The (U,V) value reaches the minimum. The basic implementation steps of the algorithm are described as follows:
[0098] (1) Parameter setting: number of clusters c, fuzzy coefficient m, iteration stop threshold ε;
[0099] (2) Initialize the cluster center V;
[0100] (3) Update the membership matrix U using formula (3.3);
[0101] (4) Update the cluster center V using formula (3.4);
[0102] (5) If the distance between the updated cluster center and the previous cluster center is less than the stop iteration threshold ε, the algorithm ends, otherwise go to step (3);
[0103] S32, marking any pixel point in the target area as 1, and marking any pixel point in the background area as 0, so as to mark each pixel point of the optimal data source, and then obtaining a segmentation result image marked with 0 and 1 of the same size as the original image;
[0104] S4, extracting the target area in the original image according to the segmentation result map obtained in step S3, and displaying the result, that is, obtaining a target map, which is obtained by the following method:
[0105] The pixels marked as 1 in the segmentation result image obtained in step S3 are mapped to the original image, and the RGB values of the above pixels are taken out. Then the RGB values of the pixels marked as 0 are taken as (0,0,0,), that is, black, to obtain a new image. Then, the new image result is displayed through MATLAB to obtain the target image.
[0106] In order to verify the performance of the extraction method provided by the embodiment of the present invention, a large number of experiments were conducted, and 14 images of targets with different colors and different background factors were selected as experimental representatives. The size of the experimental images was set to 512*512, the programming platform was Visual C++ and MATLAB, the algorithm was implemented by C language coding, and the image display was implemented by MATLAB.
[0107] 1. Experimental results and analysis of flower images
[0108] The experiment first examined the effect of the SLIC-like image superpixel segmentation algorithm provided by the present invention on processing flower targets. The experiment involved the processing of 10 flower images. The target factors, background factors and interference factors in the images are shown in Table 1 below.
[0109] Table 1 Description of objectives, background and interference factors
[0110]
[0111] The SLIC-like image superpixel segmentation algorithm and target extraction method provided by the embodiment of the present invention are used to process images 1 to 10 respectively, and the effects of the two algorithms, SUN and FT, are compared. The experimental results are as follows: Figure 7As shown, the first column of pictures are the original pictures of pictures No. 1 to 10 from top to bottom, the second column of pictures are pictures No. 1 to 10 processed by the FT algorithm from top to bottom, the third column of pictures are pictures No. 1 to 10 processed by the SUN algorithm from top to bottom, the fourth column of pictures are pictures of saliency maps extracted from pictures No. 1 to 10 by the SLIC-like image superpixel segmentation algorithm provided by an embodiment of the present invention from top to bottom, and the fifth column of pictures are pictures extracted from pictures No. 1 to 10 by the target extraction method provided by an embodiment of the present invention from top to bottom.
[0112] pass Figure 7 It can be seen that the saliency map obtained by the algorithm provided by the present invention can highlight the target area more completely and accurately, while suppressing the saliency of the background area, and the flower target extracted by using the target extraction method provided by the present invention has a good effect.
[0113] 2. Fruit Image Experiment Results and Analysis
[0114] In order to verify the universal applicability of the SLIC-like image superpixel segmentation algorithm provided by the present invention, the algorithm is applied to the extraction of fruit targets. The target, background and interference factors in the fruit image are shown in Table 2 below.
[0115] Table 2 Description of objectives, background, and interference factors
[0116]
[0117] The difficulties in the process of fruit target extraction include: reflections on the smooth fruit surface, red branches, the sky, and places where the red component in the background is greater than the green component. The SLIC-like image superpixel segmentation algorithm and target extraction method provided by the embodiment of the present invention are used to process images 11 to 14 respectively, and the results are compared with those of the SUN and FT algorithms. The experimental results of fruit images under natural background are shown in Figure 2. Figure 8 As shown, the first column of pictures are the original pictures of pictures No. 11 to 14 from top to bottom, the second column of pictures are the pictures of pictures No. 11 to 14 processed by the FT algorithm from top to bottom, the third column of pictures are the pictures of pictures No. 11 to 14 processed by the SUN algorithm from top to bottom, the fourth column of pictures are the pictures of saliency maps extracted from pictures No. 11 to 14 by the SLIC-like image superpixel segmentation algorithm provided by an embodiment of the present invention from top to bottom, and the fifth column of pictures are the pictures extracted from pictures No. 11 to 14 by the target extraction method provided by an embodiment of the present invention from top to bottom.
[0118] pass Figure 8It can be seen that the algorithm provided by the present invention can better highlight the fruit area and suppress the background area compared with the other two algorithms. For example, the SLIC-like image superpixel segmentation algorithm provided by the present invention successfully suppresses the reflection of the leaf area in Picture 11; suppresses the prominence of the branches with a large red component and the partial reflection of the fruit surface in Picture 12; suppresses the red reflection of the strawberry fruit on the film in Picture 13; suppresses the dark red apple branches and the brighter sky background in Picture 14. Moreover, the fruit target area extracted by the target extraction method provided by the present invention is also relatively accurate.
[0119] In summary, the image target extraction method provided by the embodiment of the present invention can accurately and completely extract the target areas of flowers and fruits, and has high extraction accuracy.
[0120] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
Claims
1. A method for object extraction of flower and fruit images based on saliency, characterized in that: The following steps are involved: S1. Obtain a saliency map of an image, wherein the saliency map of the image is obtained by the following method: S11, using a SLIC-like image superpixel segmentation algorithm to segment the image into multiple superpixels; S12, presuppose that all superpixels on the four sides of the image belong to the background area, and calculate the features of each superpixel; S13, calculating the average distance from each superpixel to all other superpixels in the preset background area, and calculating the total average distance of all average distances, and then excluding the superpixels of suspected targets to obtain the real initial background area; S14, calculating the shortest distance from each superpixel in the image to the initial background area, each of the shortest distances represents the saliency of each superpixel, and obtaining a saliency map of the image according to the saliency of each superpixel; S2. Generate an optimal data source according to the saliency map obtained in step S1, wherein the generation of the optimal data source comprises the following steps: S21, calculating the average value of the saliency of all superpixels according to the saliency map obtained in step S1, and judging whether each superpixel belongs to the target area according to the average value, superpixels with a value greater than the average value belong to the target area, and superpixels with a value less than the average value belong to the background area; S22, respectively calculating the average R, G, and B values of the target area and the background area, and finding the color component to which the maximum average value belongs, that is, the optimal component; S23, generating an optimal data source according to the optimal components of the target area and the background area; S3, segmenting the optimal data source obtained in step S2 to obtain a target area and a background area, and marking the obtained target area and background area to obtain a segmentation result map; S4. Extract the target area in the original image according to the segmentation result map obtained in step S3, and display the result to obtain the target map.
2. The method for extracting objects from flower and fruit images based on saliency according to claim 1, characterized in that: In step S11, the image segmentation algorithm of the SLIC-like image superpixel segmentation algorithm is based on the color similarity and spatial proximity between pixels in the RGB color space. The color similarity, spatial proximity and comprehensive similarity are calculated by formulas (1)-(3) respectively: dist=d rgb +w*d xy (3) Where i represents the i-th pixel point, k is the k-th superpixel center; R i , G i , B i Represents the R, G, and B values of pixel i respectively. Similarly, R k , G k , B k Respectively represent the R, G, and B values of the center of superpixel k; x i ,y i Represent the x and y coordinates of pixel i, respectively. k ,y k denote the x and y coordinates of the center of superpixel k, respectively; d rgb is the color similarity between pixel i and the center of the kth superpixel; d xy is the proximity degree of pixel i to the center of the kth superpixel; dist is the comprehensive similarity of pixel i to the center of the kth superpixel; w represents the weight of the spatial position, xstep is the distance between the centers of two superpixels in the x direction, ystep is the distance between the centers of two superpixels in the y direction, and the original image size is 512*512.
3. The method for extracting objects from flower and fruit images based on saliency according to claim 1, characterized in that: In step S13, the superpixel of the suspected target must satisfy two conditions at the same time, which are formulas (4) and (5): avg n >sum_avg (4) pre_bg n,R >pre_bg n,G or pre_bg n,B >pre_bg n,G (5) Among them, avg n represents the average distance from superpixel n to other superpixels in the background, sum_avg refers to the total average distance of all average distances, pre_bg n,R Represents the R component value of superpixel n, pre_bg n,G Represents the G component value of superpixel n, pre_bg n,B Represents the B component value of superpixel n.
4. The method for extracting objects from flower and fruit images based on saliency according to claim 1, characterized in that: In step S3, the generation of the segmentation result map includes the following steps: S31, segmenting the optimal data source obtained in step S2 by using the FCM algorithm to obtain a target area and a background area; S32, mark any pixel point in the target area as 1, and mark any pixel point in the background area as 0, so as to mark each pixel point of the optimal data source, and then obtain a segmentation result image marked with 0 and 1 of the same size as the original image.
5. The method for extracting objects from flower and fruit images based on saliency according to claim 1, characterized in that: In step S4, the target graph is obtained by the following method: The pixels marked as 1 in the segmentation result image obtained in step S3 are mapped to the original image, and the RGB values of the above pixels are taken out. Then, the RGB values of the pixels marked as 0 are taken as (0,0,0,), that is, black, to obtain a new image, and then the result is displayed to obtain the target image.
Citation Information
Patent Citations
Target extraction method for flower and fruit images based on saliency
CN114663441A