CN116824586A - Image processing method and black garlic production quality online detection system applying same - Google Patents

Image processing method and black garlic production quality online detection system applying same Download PDF

Info

Publication number
CN116824586A
CN116824586A CN202311107879.5A CN202311107879A CN116824586A CN 116824586 A CN116824586 A CN 116824586A CN 202311107879 A CN202311107879 A CN 202311107879A CN 116824586 A CN116824586 A CN 116824586A
Authority
CN
China
Prior art keywords
black spot
component image
initial
spot area
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202311107879.5A
Other languages
Chinese (zh)
Other versions
CN116824586B (en
Inventor
张乾坤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shandong Heiyuan Biotechnology Co ltd
Original Assignee
Shandong Heiyuan Biotechnology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shandong Heiyuan Biotechnology Co ltd filed Critical Shandong Heiyuan Biotechnology Co ltd
Priority to CN202311107879.5A priority Critical patent/CN116824586B/en
Publication of CN116824586A publication Critical patent/CN116824586A/en
Application granted granted Critical
Publication of CN116824586B publication Critical patent/CN116824586B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • G06V20/70Labelling scene content, e.g. deriving syntactic or semantic representations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • G06T7/62Analysis of geometric attributes of area, perimeter, diameter or volume
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/26Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion
    • G06V10/267Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion by performing operations on regions, e.g. growing, shrinking or watersheds
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/762Arrangements for image or video recognition or understanding using pattern recognition or machine learning using clustering, e.g. of similar faces in social networks
    • G06V10/763Non-hierarchical techniques, e.g. based on statistics of modelling distributions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/82Arrangements for image or video recognition or understanding using pattern recognition or machine learning using neural networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • G06V20/60Type of objects
    • G06V20/68Food, e.g. fruit or vegetables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30108Industrial image inspection
    • G06T2207/30128Food products
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V2201/00Indexing scheme relating to image or video recognition or understanding
    • G06V2201/06Recognition of objects for industrial automation

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Computation (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • Databases & Information Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Computational Linguistics (AREA)
  • Quality & Reliability (AREA)
  • Geometry (AREA)
  • Image Analysis (AREA)

Abstract

The invention relates to the technical field of HSI color space image processing, in particular to an image processing method and an online detection system for black garlic production quality by applying the method. The system acquires an initial black spot area in each component image of the black garlic image in the HSI color space; acquiring a set of adjacent black spot areas according to the adjacent initial black spot areas; acquiring the weight of each component image according to the adjacent black spot area set, and correcting the black garlic image of the HSI color space; and acquiring a black spot area in the corrected black garlic image, and further evaluating the quality of the black garlic. According to the invention, the weight of each component image in the HSI color space is determined through the identification condition of the black spot area in the component image, so that the black spot area is accurately identified, and the quality of the black garlic is accurately evaluated.

Description

Image processing method and black garlic production quality online detection system applying same
Technical Field
The invention relates to the technical field of HSI color space image processing, in particular to an image processing method and an online detection system for black garlic production quality by applying the method.
Background
The black garlic is produced by the operations of cleaning, enzymatic treatment, cooking, drying and the like of high-quality garlic, and has various health care effects. In the production process, the black garlic has quality problems, such as quality problems caused by common mildewing. Black garlic generally exhibits a dark brown color, and black spots appear on the surface of the moldy black garlic, wherein the black spots are very similar to the black garlic in the black garlic image and are not easily distinguished.
In the existing method, an image segmentation algorithm is used for acquiring a black spot area in a black garlic image in an HSI color space, however, in the black garlic image in the HSI color space, the black spot is very similar to the black garlic, so that the black spot area in the black garlic image can not be accurately identified, and further the quality of the black garlic can not be accurately evaluated.
Disclosure of Invention
In order to solve the technical problem that black spots and black garlic are very similar in a black garlic image in an HSI color space, so that black spot areas in the black garlic image cannot be accurately identified, and further the quality of the black garlic cannot be accurately evaluated, the invention aims to provide an image processing method and an online detection system for the production quality of the black garlic by applying the method, and the adopted technical scheme is as follows:
An aspect of the present invention provides an image processing method including:
acquiring an initial black spot area of each component image of the black garlic image in the HSI color space;
acquiring an initial black spot area adjacent to each initial black spot area in each component image, and constructing an adjacent black spot area set corresponding to each initial black spot area;
acquiring the total number of initial black spot areas in each component image;
acquiring a black spot area fluctuation value of each component image according to the area of an initial black spot area in each adjacent black spot area set;
acquiring black spot integral areas of each adjacent black spot area set according to the distribution of initial black spot areas in each adjacent black spot area set; acquiring an adjusting factor of each component image according to the area of the initial black spot area and the area of the whole black spot area in each adjacent black spot area set;
acquiring the weight of each component image according to the total quantity of the initial black spot areas, the fluctuation value of the black spot areas and the adjustment factor of each component image; and correcting the black garlic image of the HSI color space according to the weight of each component image.
Further, the method for obtaining the initial black spot area adjacent to each initial black spot area in each component image and constructing the adjacent black spot area set corresponding to each initial black spot area includes:
Selecting any initial black spot area in the component image as a target black spot area;
acquiring the distance from the centroid of the target black spot area to each edge pixel point of any adjacent initial black spot area, taking the minimum target distance as the reference distance between the target black spot area and the adjacent initial black spot area;
obtaining a reference distance between a target black spot area and each adjacent initial black spot area, and taking a normalized result of the reference distance as a reference result;
and when the reference result is smaller than a preset first reference threshold value, constructing all corresponding initial black spot areas and target black spot areas together into a neighboring black spot area set corresponding to the target black spot areas.
Further, the method for obtaining the total number of the initial black spot areas comprises the following steps:
acquiring the number of initial black spot areas in each adjacent black spot area set as a first number;
the result of the accumulation of the first number in each component image is taken as the total number of initial black spot areas of the corresponding component image.
Further, the method for acquiring the fluctuation value of the black spot area comprises the following steps:
taking the variance of the area of the initial black spot region in each adjacent black spot region set as a first variance;
And the result of accumulating the first differences in each component image is taken as a black spot area fluctuation value of the corresponding component image.
Further, the method for obtaining the black spot whole area of each adjacent black spot area set according to the distribution of the initial black spot area in each adjacent black spot area set comprises the following steps:
and acquiring the minimum circumscribed rectangle of all initial black spot areas in each adjacent black spot area set, and taking the minimum circumscribed rectangle as a black spot integral area of the corresponding adjacent black spot area set.
Further, the method for obtaining the adjustment factor of each component image according to the area of the initial black spot area and the area of the whole black spot area in each adjacent black spot area set comprises the following steps:
acquiring the accumulation result of all initial black spot area areas in each adjacent black spot area set as a first area;
taking the ratio of the first area of each adjacent black spot area set to the whole black spot area as a first characteristic value of each corresponding adjacent black spot area set;
and acquiring the average value of the first characteristic values in each component image as an adjusting factor of the corresponding component image.
Further, the method for obtaining the weight of each component image according to the total number of the initial black spot areas, the fluctuation value of the black spot areas and the adjustment factor of each component image comprises the following steps:
Acquiring a product of an adjustment factor of each component image, the reciprocal of the total number of initial black spot areas and the reciprocal of the fluctuation value of the black spot areas as a contribution degree value of each component image;
the result of accumulating the contribution degree value of each component image is used as an overall result;
the ratio of the contribution degree value of each component image to the overall result is taken as the weight of each component image.
Further, the method for acquiring the initial black spot area of each component image of the black garlic image in the HSI color space comprises the following steps:
acquiring an H component image, an S component image and an I component image of a black garlic image in an HSI color space;
and acquiring an initial black spot area in each component image according to the channel value distribution of the pixel points in each component image.
Further, the method for obtaining the initial black spot area in each component image according to the channel value distribution of the pixel points in each component image comprises the following steps:
acquiring a tone channel value of each pixel point in the H component image, taking a pixel point corresponding to a preset first tone channel value as an initial starting point, and carrying out region growth through a region growth algorithm to obtain an initial black spot region in the H component image;
For an S component image or an I component image, obtaining a channel value of each pixel point in the component image, and selecting the mode of the channel value as a first channel value; acquiring the average value of all channel values in the component images, and taking the average value as a channel average value; acquiring the difference between each channel value and the channel mean value in the component image as a first difference; taking the addition result of the maximum first difference and the channel mean value as a second channel value; when the first channel value is smaller than the second channel value, taking a pixel point corresponding to the first channel value as an initial starting point, and carrying out region growth through a region growth algorithm to obtain an initial black spot region in the component image; when the first channel value is larger than the second channel value, taking the pixel point corresponding to the second channel value as an initial starting point, and carrying out region growth through a region growth algorithm to obtain an initial black spot region in the component image.
Another aspect of the present invention provides an on-line detection system for black garlic production quality, comprising a processor and a memory, wherein the processor is used for processing instructions stored in the memory to realize:
acquiring an initial black spot area of each component image of the black garlic image in the HSI color space;
Acquiring an initial black spot area adjacent to each initial black spot area in each component image, and constructing an adjacent black spot area set corresponding to each initial black spot area;
acquiring the total number of initial black spot areas in each component image;
acquiring a black spot area fluctuation value of each component image according to the area of an initial black spot area in each adjacent black spot area set;
acquiring black spot integral areas of each adjacent black spot area set according to the distribution of initial black spot areas in each adjacent black spot area set; acquiring an adjusting factor of each component image according to the area of the initial black spot area and the area of the whole black spot area in each adjacent black spot area set;
acquiring the weight of each component image according to the total quantity of the initial black spot areas, the fluctuation value of the black spot areas and the adjustment factor of each component image; correcting the black garlic image of the HSI color space according to the weight of each component image;
and acquiring a black spot area in the corrected black garlic image, and evaluating the quality of the black garlic according to the size of the black spot area.
The invention has the following beneficial effects:
acquiring an initial black spot area adjacent to each initial black spot area in each component image, constructing an adjacent black spot area set corresponding to each initial black spot area, determining an actual black spot area in a black garlic image, and calculating a weight corresponding to each component image when accurately identifying the black spot area; the method comprises the steps of obtaining the total number of initial black spot areas in each component image, obtaining the fluctuation value and the adjustment factor of the black spot areas of each component image according to each adjacent black spot area set in each component image, accurately reflecting the actual condition of each component image for identifying the black spot areas in the black garlic images, further obtaining the weight of each component image according to the total number of the initial black spot areas, the fluctuation value and the adjustment factor of the black spot areas of each component image, determining the weight of each component image in the HSI color space in accurately identifying the black spot areas in the black garlic images, further accurately correcting the black garlic images in the HSI color space, enabling the black spot areas in the black garlic images to be more obvious, and further accurately obtaining the black spot areas in the black garlic images. And (3) according to the accurately obtained black spot area, further accurately evaluating the quality of the black garlic.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions and advantages of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are only some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of an image processing method according to an embodiment of the present invention;
fig. 2 is a schematic diagram of an online detection system for black garlic production quality according to an embodiment of the present invention.
Detailed Description
In order to further illustrate the technical means and effects adopted by the present invention to achieve the preset purpose, the following is a schematic flow chart of an image processing method and a black garlic production quality online detection system applying the method according to the present invention, and the specific implementation, structure, characteristics and effects thereof are described in detail below. In the following description, different "one embodiment" or "another embodiment" means that the embodiments are not necessarily the same. Furthermore, the particular features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
The following specifically describes a specific scheme of a flow diagram of an image processing method and a black garlic production quality online detection system applying the method provided by the invention with reference to the accompanying drawings.
An object of the present embodiment is to provide an image processing method, as shown in fig. 1, including:
step S1: an initial black spot region in each component image of the black garlic image in the HSI color space is acquired.
And (5) arranging a camera on the black garlic quality detection assembly line to acquire black garlic images. Wherein the black garlic image is an RGB image. The background area which is not the black garlic area exists in the obtained black garlic image, and the background area can influence when the black garlic image is analyzed, so that the embodiment of the invention obtains the black garlic image only of the black garlic by using a semantic segmentation network. The semantic segmentation network in the embodiment of the invention uses DNN neural network, and inputs the DNN neural network into a black garlic image containing black garlic; outputting a black garlic image of only black garlic; the DNN neural network training labeling method comprises the following steps: marking a black garlic area as 1, and marking a background area as 0; the loss function of the DNN neural network is a cross entropy loss function. The DNN neural network is a known technology, and will not be described herein.
The conversion of the black garlic image into the black garlic image of the HSI color space, and the conversion of the RGB image into the HSI image are known techniques, and will not be described herein. The black garlic images appearing later are all HSI images containing only black garlic regions.
The specific scene of the embodiment of the invention is as follows: black garlic images with black spots must exist on the surface of the black garlic.
The aim of the embodiment of the invention is as follows: in practical situations, the black garlic has the quality problem of mildew, black spots appear on the surface of the black garlic, and the black garlic is dark brown, so that in the black garlic image, the color tone (H) and the brightness (I) of the black spots and the black garlic are very close, and the black spots are difficult to accurately identify from the surface of the black garlic. According to the embodiment of the invention, the contribution degree value of each component image to describing the characteristics of the black spot area is obtained according to the channel value of the pixel point in each component image of the black garlic image in the HSI color space, so that the weight of each component image is obtained, the black garlic image is corrected, and the black spot area in the corrected black garlic image is accurately identified.
It is known that the scene for which the embodiment of the present invention is directed is a black garlic image in which black spots exist, and therefore, two areas exist in the black garlic image, namely, a normal black garlic area and a moldy black garlic area, that is, a black spot area. In order to obtain the black spot area more accurately, the embodiment of the invention obtains each component image of the black garlic image in the HSI color space, and obtains the initial black spot area in each component image according to the channel value distribution of the pixel points in each component image. The method for specifically acquiring the initial black spot area in each component image is as follows:
An H-component image, an S-component image, and an I-component image of the black garlic image in the HSI color space are acquired. It is known that the black garlic image includes a normal black garlic region and a moldy black garlic region, i.e., a black spot region, and therefore, only two regions should be divided in each of the H-component image, the S-component image, and the I-component image, which correspond to the normal black garlic region and the initial black spot region, respectively.
(1) An initial black spot region in the H component image is acquired.
Preferably, the method for acquiring the initial black spot region in the H component image is as follows: and acquiring a tone channel value of each pixel point in the H component image, taking the pixel point corresponding to the preset first tone channel value as an initial starting point, and carrying out region growth through a region growth algorithm to obtain an initial black spot region in the H component image. The region growing algorithm is the prior art, and is not described herein.
As an example, it is known that the black garlic surface color in the H-component image is uniformly darker and dark gray, and the corresponding tone channel value is relatively smaller, typically 10 or less; the black spot color is dark brown or black brown in the H component image, and the corresponding tone channel value is large relative to the tone channel value of black garlic, and is between 20 and 40. Therefore, in order to accurately acquire the initial black spot region in the H component image, the embodiment of the present invention sets the preset first tone channel value to 30, and the practitioner may set the size of the first tone channel value according to the actual situation, which is not limited herein. And taking the pixel point corresponding to the first tone channel value as an initial starting point to perform region growing, wherein the growing criterion of the region growing algorithm in the embodiment of the invention is tone channel value similarity, and taking the region obtained by the region growing algorithm as an initial black spot region in the H component image.
When the pixels corresponding to the first tone channel value are adjacent or very close to each other, the pixels corresponding to the first tone channel value should be in the same region and should not be divided into two different regions after passing through the region growing algorithm, so that the embodiment of the invention sets one pixel with the pixels corresponding to the first tone channel value as the centerThe window size of the window is set by the practitioner according to the actual situation, and is not limited herein. When the pixel points corresponding to the other first tone channel values exist in the window, any pixel point corresponding to the first tone channel value in the window is selected as an initial starting point of the region growing algorithm, and region growing is performed. When the pixel point corresponding to the preset first tone channel value does not exist in the H component image, at the moment, the tone channel value closest to the first tone channel value in the H component image is selected to be used as a new first tone channel value.
In another example, an initial black spot region in the H component image may be obtained through a K-means clustering algorithm, for example, it is known that the surface color of black garlic in the H component image is uniformly darker and dark gray, and the corresponding tone channel value is smaller, generally below 10; the black spot color is dark brown or black brown in the H component image, and the corresponding tone channel value is large relative to the tone channel value of black garlic, and is between 20 and 40. Therefore, in order to accurately cluster the pixel points in the H component image, the embodiment of the invention sets the first channel value to 5 and the second channel value to 30, and the first channel value and the second channel value can be set by an implementer according to actual situations, but the sizes of the first channel value and the second channel value are not limited herein, but the first channel value is necessarily smaller than 10, and the second channel value is necessarily between 20 and 40. Setting one pixel point corresponding to the first channel value and the second channel value as the center The window size of the window is set by the practitioner according to the actual situation, and is not limited herein. And screening out a window with the tone channel value of the neighborhood pixel point not being the same as that of the tone channel value of the central pixel point, and taking the window as a target window. The K-means clustering algorithm is a well-known technique and will not be described here.
Setting the first range as [0,10]The second range is [20,40]The first range and the second range may be set by the practitioner according to actual conditions, and are not limited herein. Taking any one target window with the first channel value as the center as an example, obtaining the tone of the pixel point in the target windowThe number of pixel points with the channel value in the first range is taken as a first target number, and the first target number is compared with the first target numberAs the normal duty cycle of the target window; and acquiring the normal duty ratio of each target window taking the first channel value as the center, and taking the center pixel point of the target window corresponding to the maximum normal duty ratio as the first class initial clustering center point. If at least two target windows with the largest normal duty ratio exist, selecting a central pixel point of one target window as a first type initial clustering central point. Taking any one target window with the second channel value as the center as an example, acquiring the number of pixel points with the tone channel value of the pixel points in the target window within a second range as a second target number, and combining the second target number with +. >As the black spot duty cycle of the target window; and acquiring the black spot duty ratio of each target window taking the second channel value as the center, and taking the central pixel point of the target window corresponding to the maximum black spot duty ratio as the second-class initial clustering central point. If at least two target windows with the largest black spot ratio exist, selecting a central pixel point of one target window as a second-class initial clustering central point.
In the embodiment of the invention, the K value in the K-means clustering algorithm is set to be 2, the pixel points in the H component image are clustered according to the acquired first-class initial clustering center point and the second-class initial clustering center point, and the embodiment of the invention constructs a tone similarity formula according to the Euclidean distance between each pixel point to be clustered and the initial clustering center point and the absolute value of the difference value of the tone channel value, and the tone similarity formula is used as a clustering standard in the K-means clustering algorithm, wherein the Euclidean distance acquisition method is the prior art and is not repeated herein. The color tone similarity formula is obtained as follows:
in the method, in the process of the invention,is the tone similarity; />The Euclidean distance between the pixel points to be clustered in the H component image and the initial clustering center point is the Euclidean distance between the pixel points to be clustered in the H component image and the initial clustering center point; />The absolute value of the difference of the hue channel values between the pixel points to be clustered and the initial clustering center point in the H component image.
It should be noted that the number of the substrates,the smaller the pixel points to be clustered are, the closer the distance between the pixel points to be clustered and the initial clustering center point is, the more the pixel points to be clustered are in the category of the initial clustering center point, and the more the pixel points to be clustered are in>The smaller; />The smaller the pixel points to be clustered are, the closer the hue channel values between the pixel points to be clustered and the initial clustering center point are, the more the pixel points to be clustered are in the category of the initial clustering center point, and the +.>The smaller; thus (S)>The smaller the pixel points to be clustered are, the more the pixel points to be clustered are in the category of the initial clustering center point.
And acquiring the tone similarity between any pixel point to be clustered in the H component image and the first type initial clustering center point and the second type initial clustering center point respectively, and dividing the pixel point to be clustered into the type with the small tone similarity and the corresponding initial clustering center point. If the hue similarity between a pixel point to be clustered in the H component image and the first-class initial clustering center point and the second-class initial clustering center point is the same, at the moment,setting one pixel point to be clustered as a centerThe size of the second window may be set by the practitioner according to the actual situation, and is not limited herein. And acquiring the average value of the tone channel values of the pixel points in the second window, respectively acquiring the absolute value of the difference value of the tone channel values of the first average value and the first-class initial clustering center point and the second-class initial clustering center point as a first target difference, and dividing the pixel points to be clustered into the class where the initial clustering center point corresponding to the minimum first target difference is located. Thus, two categories in the H component image are obtained, wherein the category in which the second channel value is located corresponds to a black spot category, and black spots possibly exist at a plurality of positions in the H component image, so that each area corresponding to the black spot category is taken as an initial black spot area in the H component image.
(2) An initial black spot region in the S component image is acquired.
Preferably, the method for acquiring the initial black spot region in the S component image is as follows: acquiring a saturated channel value of each pixel point in the S component image, and selecting the mode of the saturated channel value as a first saturated value; acquiring the average value of all saturated channel values in the S component image, and taking the average value as a saturated average value; acquiring the difference between each saturated channel value and the saturated mean value in the S component image as a first difference; taking the addition result of the maximum first difference and the saturated mean value as a second saturated value; when the first saturation value is smaller than the second saturation value, taking a pixel point corresponding to the first saturation value as an initial starting point, and carrying out region growth through a region growth algorithm to obtain an initial black spot region in the S component image; when the first saturation value is larger than the second saturation value, taking a pixel point corresponding to the second saturation value as an initial starting point, and carrying out region growth through a region growth algorithm to obtain an initial black spot region in the S component image;
as an example, a saturated channel value of each pixel point in the S component image is obtained, and the saturated channel value with the largest occurrence number is the first saturated value. If there are at least two saturated channel values with the largest number of times, the fluctuation range of the saturated channel value with the largest number of times is set to [ -0.2,0.2], and the practitioner can set the fluctuation range of the saturated channel value according to the actual situation, which is not limited herein. And acquiring the total number of pixel points corresponding to any saturated channel value with the largest number of times and the saturated channel value of the saturated channel value in the fluctuation range, and taking the saturated channel value corresponding to the largest total number as a first saturated value. Acquiring the average value of all saturated channel values in the S component image, namely, the saturated average value; acquiring the absolute value of the difference between each saturated channel value and the saturated mean value in the S component image, namely, the first difference; and obtaining the addition result of the maximum first difference and the saturated mean value, namely the second saturated value. When the first saturation value is smaller than the second saturation value, taking a pixel point corresponding to the first saturation value as an initial starting point of a region growing algorithm to perform region growing, wherein a growing criterion of the region growing algorithm in the embodiment of the invention is saturation channel value similarity, and taking a region obtained by the region growing algorithm as an initial black spot region in an S component image.
When the pixels corresponding to the first saturation value are adjacent or are very close to each other, the pixels corresponding to the first saturation value should be in the same region and should not be divided into two different regions after passing through the region growing algorithm, so that the embodiment of the invention sets one pixel corresponding to the first saturation value as a centerThe window size of the window is set by the practitioner according to the actual situation, and is not limited herein. When other pixel points corresponding to the first saturation value exist in the window, any pixel point corresponding to the first saturation value in the window is selected as an initial starting point of the region growing algorithm, and region growing is performed.
When the first saturation value is larger than the second saturation value, taking the pixel point corresponding to the second saturation value as an initial starting point of the region growing algorithm, and if the pixel point corresponding to the second saturation value does not exist in the S component image, taking the pixel point corresponding to the saturation channel value closest to the second saturation value as the initial starting point of the region growing algorithm, namely taking the saturation channel value closest to the second saturation value as a new second saturation value. The growth criterion of the region growing algorithm in the embodiment of the invention is the similarity of saturated channel values, and each region obtained by the region growing algorithm is used as an initial black spot region in the S component image.
When the pixels corresponding to the second saturation value are adjacent or are very close to each other, the pixels corresponding to the second saturation value should be in the same region and should not be divided into two different regions after passing through the region growing algorithm, so that the embodiment of the invention sets one pixel corresponding to the second saturation value as a centerThe window size of the window is set by the practitioner according to the actual situation, and is not limited herein. When other pixel points corresponding to the second saturation value exist in the window, any pixel point corresponding to the second saturation value in the window is selected as an initial starting point of the region growing algorithm, and region growing is performed.
It is known that the embodiment of the present invention is directed to a black garlic image in which black spots exist, and thus the first saturation value and the second saturation value do not exist in the same case.
In another example, an initial black spot region in the S component image may be obtained by a K-means clustering algorithm, for example, a saturated channel value of each pixel point in the S component image is obtained, and the saturated channel value with the largest occurrence number is the first saturated value. If there are at least two saturated channel values with the largest number of times, the fluctuation range of saturated channel values with the largest number of times is set to be [ -0.2,0.2 ]The practitioner can set the fluctuation range of the saturation channel value according to the actual situation, and the limitation is not given here. And acquiring the total number of pixel points corresponding to any saturated channel value with the largest number of times and the saturated channel value of the saturated channel value in the fluctuation range, and taking the saturated channel value corresponding to the largest total number as a first saturated value. Acquiring the average value of all saturated channel values in the S component image, namely, the saturated average value; acquisition SThe absolute value of the difference between each saturated channel value and the saturated mean value in the component image is the first difference; and obtaining the addition result of the maximum first difference and the saturated mean value, namely the second saturated value. Setting one pixel point corresponding to the first saturation value and the second saturation value as the centerThe window size of the window is set by the practitioner according to the actual situation, and is not limited herein. And screening out windows with the saturation channel values of the neighborhood pixel points not being the same as the saturation channel values of the central pixel point, and taking the windows as target windows. And if the pixel point corresponding to the second saturation value does not exist in the S component image, taking the saturation channel value closest to the second saturation value as the second saturation value.
When the first saturation value is smaller than the second saturation value, the target window corresponding to the first saturation value is used as a black spot target window, and the target window corresponding to the second saturation value is used as a normal target window. And acquiring the average value of the absolute value of the difference value between the saturated channel value of each neighborhood pixel point and the saturated channel value of the central pixel point in each black spot target window, taking the average value as a first target average value, and taking the central pixel point of the black spot target window corresponding to the minimum first target average value as the initial clustering center point of the black spot class. If at least two black spot target windows corresponding to the minimum first target mean value exist, selecting a central pixel point of one black spot target window as a black spot type initial clustering central point. And acquiring the average value of the absolute value of the difference value between the saturated channel value of each neighborhood pixel point and the saturated channel value of the central pixel point in each normal target window, taking the average value as a second target average value, and taking the central pixel point of the normal target window corresponding to the minimum second target average value as the initial clustering central point of the normal class. If at least two normal target windows corresponding to the minimum second target mean value exist, optionally selecting a central pixel point of one normal target window as a normal type initial clustering central point.
When the first saturation value is larger than the second saturation value, the target window corresponding to the second saturation value is used as a black spot target window, and the target window corresponding to the first saturation value is used as a normal target window. And acquiring the average value of the absolute value of the difference value between the saturated channel value of each neighborhood pixel point and the saturated channel value of the central pixel point in each black spot target window, taking the average value as a third target average value, and taking the central pixel point of the black spot target window corresponding to the minimum third target average value as the initial clustering center point of the black spot class. If at least two black spot target windows corresponding to the minimum third target mean value exist, selecting a central pixel point of one black spot target window as a black spot type initial clustering central point. And acquiring the average value of the absolute value of the difference value between the saturated channel value of each neighborhood pixel point and the saturated channel value of the central pixel point in each normal target window, taking the average value as a fourth target average value, and taking the central pixel point of the normal target window corresponding to the minimum fourth target average value as the initial clustering central point of the normal class. If at least two normal target windows corresponding to the minimum fourth target mean value exist, optionally selecting a central pixel point of one normal target window as a normal type initial clustering central point.
The embodiment of the invention sets the K value in the K-means clustering algorithm as 2, clusters the pixel points in the S component image according to the acquired initial clustering center point of the black spot type and the initial clustering center point of the normal type, and constructs a saturation similarity formula according to the Euclidean distance between each pixel point to be clustered and the initial clustering center point and the absolute value of the difference value of the saturation channel value, and is used as a clustering standard in the K-means clustering algorithm. The saturation similarity formula is obtained as follows:
in the method, in the process of the invention,is saturation similarity; />The Euclidean distance between the pixel points to be clustered in the S component image and the initial clustering center point is set; />And the absolute value of the difference value of the saturated channel value between the pixel point to be clustered and the initial clustering center point in the S component image.
It should be noted that the number of the substrates,the smaller the pixel points to be clustered are, the closer the distance between the pixel points to be clustered and the initial clustering center point is, the more the pixel points to be clustered are in the category of the initial clustering center point, and the more the pixel points to be clustered are in>The smaller; />The smaller the pixel points to be clustered are, the closer the saturation channel value between the pixel points to be clustered and the initial clustering center point is, the more the pixel points to be clustered are in the category of the initial clustering center point, and the +.>The smaller; thus (S)>The smaller the pixel points to be clustered are, the more the pixel points to be clustered are in the category of the initial clustering center point.
And obtaining the saturation similarity between any pixel point to be clustered in the S component image and the initial clustering center point of the black spot class and the initial clustering center point of the normal class, and dividing the pixel point to be clustered into the class where the corresponding initial clustering center point with small saturation similarity is located. If saturation similarity between a pixel point to be clustered in the S component image and a black spot type initial clustering center point and a normal type initial clustering center point is the same, setting one pixel point to be clustered as a centerThe third window of (2) may be set by the practitioner according to the actual situation, and is not limited herein. Acquiring an average value of saturated channel values of pixel points in a third window as a second average value, and respectively acquiring the second average value and initial clustering of black spot typesAnd dividing the pixel points to be clustered into the category of the initial clustering center point corresponding to the minimum second target difference by taking the absolute value of the difference value of the saturated channel values of the center point and the normal category initial clustering center point as the second target difference. Thus, two categories in the S component image are obtained, wherein a black spot category may exist in the S component image, and each area corresponding to the black spot category is taken as an initial black spot area in the S component image.
(3) An initial black spot region in the I component image is acquired.
Preferably, the method for acquiring the initial black spot region in the I component image is as follows: acquiring a brightness channel value of each pixel point in the I component image, and selecting the mode of the brightness channel value as a first brightness value; acquiring the average value of all brightness channel values in the I component image, and taking the average value as a brightness average value; acquiring the difference between each brightness channel value and the brightness mean value in the I component image as a second difference; taking the addition result of the maximum second difference and the brightness average value as a second brightness value; when the first brightness value is smaller than the second brightness value, taking a pixel point corresponding to the first brightness value as an initial starting point, and carrying out region growth through a region growth algorithm to obtain an initial black spot region in the I component image; when the first brightness value is larger than the second brightness value, taking the pixel point corresponding to the second brightness value as an initial starting point, and carrying out region growth through a region growing algorithm to obtain an initial black spot region in the I component image.
As an example, a luminance channel value of each pixel point in the I component image is obtained, and the luminance channel value with the largest occurrence number is the first luminance value. If there are at least two luminance channel values with the largest number of times, the fluctuation range of the luminance channel value with the largest number of times is set to [ -3,3], and the practitioner can set the fluctuation range of the luminance channel value according to the actual situation, which is not limited herein. And acquiring the total number of pixel points corresponding to any brightness channel value with the largest frequency and the brightness channel value of the brightness channel value in the fluctuation range, and taking the brightness channel value corresponding to the largest total number as the first brightness value. Acquiring the average value of all brightness channel values in the I component image, namely, the average value of the brightness; obtaining the absolute value of the difference between each brightness channel value and the brightness mean value in the I component image, namely, the second difference; and obtaining the addition result of the maximum second difference and the brightness average value, namely the second brightness value. When the first brightness value is smaller than the second brightness value, taking a pixel point corresponding to the first brightness value as an initial starting point of a region growing algorithm to perform region growing, wherein a growing criterion of the region growing algorithm in the embodiment of the invention is brightness channel value similarity, and taking each region obtained by the region growing algorithm as an initial black spot region in an I component image.
When the pixels corresponding to the first brightness value are adjacent or very close to each other, the pixels corresponding to the first brightness value should be in the same region and should not be divided into two different regions after passing through the region growing algorithm, so that the embodiment of the invention sets one pixel corresponding to the first brightness value as the centerThe window size of the window is set by the practitioner according to the actual situation, and is not limited herein. When other pixel points corresponding to the first brightness value exist in the window, any pixel point corresponding to the first brightness value in the window is selected as an initial starting point of the region growing algorithm, and region growing is carried out.
When the first brightness value is larger than the second brightness value, taking the pixel point corresponding to the second brightness value as an initial starting point, and if the pixel point corresponding to the second brightness value does not exist in the I component image, taking the pixel point corresponding to the brightness channel value closest to the second brightness value as an initial starting point of an area growth algorithm, namely taking the brightness channel value closest to the second brightness value as a new second brightness value. The growth criterion of the region growing algorithm in the embodiment of the invention is the similarity of brightness channel values, and the region obtained by the region growing algorithm is used as the initial black spot region in the I component image.
When the pixels corresponding to the second luminance value are adjacent or very close to each other, the pixels corresponding to the second luminance value should be in the same regionThe region growing algorithm should not be followed by dividing the region into two different regions, so that the embodiment of the invention sets one pixel point corresponding to the second brightness value as the centerThe window size of the window is set by the practitioner according to the actual situation, and is not limited herein. When the pixel points corresponding to other second brightness values exist in the window, any one pixel point corresponding to the second brightness value in the window is selected as an initial starting point of the region growing algorithm, and region growing is performed.
It is known that the embodiment of the present invention is directed to a black garlic image in which a black spot exists, and thus the first luminance value and the second luminance value do not exist in an equal condition.
In another example, an initial black spot region in the I component image may be obtained by a K-means clustering algorithm, for example, a luminance channel value of each pixel point in the I component image is obtained, and the luminance channel value with the largest occurrence number is the first luminance value. If there are at least two brightness channel values with the largest number of times, the fluctuation range of the brightness channel value with the largest number of times is set as [ -3,3 ]The range of fluctuation of the luminance channel value can be set by the practitioner according to the actual situation, and is not limited herein. And acquiring the total number of pixel points corresponding to any brightness channel value with the largest frequency and the brightness channel value of the brightness channel value in the fluctuation range, and taking the brightness channel value corresponding to the largest total number as the first brightness value. Acquiring the average value of all brightness channel values in the I component image, namely, the average value of the brightness; obtaining the absolute value of the difference between each brightness channel value and the brightness mean value in the I component image, namely, the second difference; and obtaining the addition result of the maximum second difference and the brightness average value, namely the second brightness value. Setting one pixel point corresponding to the first brightness value and the second brightness value as the centerThe window size of the window is set by the practitioner according to the actual situation, and is not limited herein. Neighborhood pixel pointThe brightness channel value of the pixel point is not screened out by the window which is the same as the brightness channel value of the central pixel point, and the brightness channel value is used as a target window. If the pixel point corresponding to the second luminance value does not exist in the I component image, the luminance channel value closest to the second luminance value is taken as the second luminance value.
When the first brightness value is smaller than the second brightness value, the target window corresponding to the first brightness value is used as a black spot target window, and the target window corresponding to the second brightness value is used as a normal target window. And obtaining the average value of the absolute value of the difference value between the brightness channel value of each neighborhood pixel point and the brightness channel value of the central pixel point in each black spot target window, taking the average value as a fifth target average value, and taking the central pixel point of the black spot target window corresponding to the minimum fifth target average value as the initial clustering center point of the black spot class. If at least two black spot target windows corresponding to the minimum fifth target mean value exist, selecting a central pixel point of one black spot target window as a black spot type initial clustering central point. And obtaining the average value of the absolute value of the difference value between the brightness channel value of each neighborhood pixel point and the brightness channel value of the central pixel point in each normal target window, taking the average value as a sixth target average value, and taking the central pixel point of the normal target window corresponding to the minimum sixth target average value as the initial clustering central point of the normal class. If at least two normal target windows corresponding to the minimum sixth target mean value exist, optionally selecting a central pixel point of one normal target window as a normal type initial clustering central point.
When the first brightness value is larger than the second brightness value, the target window corresponding to the second brightness value is used as a black spot target window, and the target window corresponding to the first brightness value is used as a normal target window. And acquiring the average value of the absolute value of the difference value between the brightness channel value of each neighborhood pixel point and the brightness channel value of the central pixel point in each black spot target window, taking the average value as a seventh target average value, and taking the central pixel point of the black spot target window corresponding to the minimum seventh target average value as the initial clustering center point of the black spot class. If at least two black spot target windows corresponding to the minimum seventh target mean value exist, selecting a central pixel point of one black spot target window as a black spot type initial clustering central point. And acquiring the average value of the absolute value of the difference value between the brightness channel value of each neighborhood pixel point and the brightness channel value of the central pixel point in each normal target window, taking the average value as an eighth target average value, and taking the central pixel point of the normal target window corresponding to the minimum eighth target average value as the initial clustering central point of the normal class. If at least two normal target windows corresponding to the minimum eighth target mean value exist, optionally selecting a central pixel point of one normal target window as a normal class initial clustering central point.
The embodiment of the invention sets the K value in the K-means clustering algorithm as 2, clusters the pixel points in the I component image according to the acquired initial cluster center point of the black spot type and the initial cluster center point of the normal type, and constructs a brightness similarity formula according to the Euclidean distance between each pixel point to be clustered and the initial cluster center point and the absolute value of the difference value of the brightness channel value, and is used as a clustering standard in the K-means clustering algorithm. The luminance similarity formula is obtained as follows:
in the method, in the process of the invention,is the brightness similarity; />The Euclidean distance between the pixel points to be clustered in the component I image and the initial clustering center point is obtained; />The absolute value of the difference value of the brightness channel value between the pixel point to be clustered and the initial clustering center point in the I component image.
It should be noted that the number of the substrates,the smaller the pixel points to be clustered are, the closer the distance between the pixel points to be clustered and the initial clustering center point is, the more the pixel points to be clustered are in the category of the initial clustering center point, and the more the pixel points to be clustered are in>The smaller; />The smaller the pixel points to be clustered are, the closer the brightness channel value between the pixel points to be clustered and the initial clustering center point is, the more the pixel points to be clustered are in the category of the initial clustering center point, and the +.>The smaller; thus (S)>The smaller the pixel points to be clustered are, the more the pixel points to be clustered are in the category of the initial clustering center point.
And acquiring the brightness similarity between any pixel point to be clustered in the I component image and the initial clustering center point of the black spot class and the initial clustering center point of the normal class, and dividing the pixel point to be clustered into the class where the corresponding initial clustering center point with small brightness similarity is located. If the brightness similarity between a pixel point to be clustered in the I component image and the initial clustering center point of the black spot type and the initial clustering center point of the normal type are respectively the same, setting one pixel point to be clustered as the centerThe size of the fourth window may be set by the practitioner according to the actual situation, and is not limited herein. And acquiring the average value of the brightness channel values of the pixel points in the fourth window, respectively acquiring the absolute value of the difference value of the brightness channel values of the third average value and the initial clustering center point of the black spot class and the initial clustering center point of the normal class as a third target difference, and dividing the pixel points to be clustered into the class where the initial clustering center point corresponding to the minimum third target difference is located. Thus, two categories in the I component image are obtained, wherein a black spot category may exist in the I component image, and each area corresponding to the black spot category is taken as an initial black spot area in the I component image.
To this end, each initial black spot region in the H, S, and I component images is acquired.
Step S2: and acquiring an initial black spot area adjacent to each initial black spot area in each component image, and constructing an adjacent black spot area set corresponding to each initial black spot area.
In particular, due to the noise environment, the black spot area in the black garlic image may not be completely identified, so that one complete black spot area is identified as at least two small black spot areas. Therefore, the initial black spot area in each component image acquired in step S1 is analyzed, the initial black spot area belonging to the same black spot area is determined, and the initial black spot area belonging to the same black spot area is constructed as a set of adjacent black spot areas.
Preferably, the method for constructing the adjacent black spot region set is as follows: selecting any initial black spot area in the component image as a target black spot area; acquiring the distance from the centroid of the target black spot area to each edge pixel point of any adjacent initial black spot area, taking the minimum target distance as the reference distance between the target black spot area and the adjacent initial black spot area; obtaining a reference distance between a target black spot area and each adjacent initial black spot area, and normalizing the reference distance to obtain a reference result; when the reference result is smaller than a preset first reference threshold value, constructing all corresponding initial black spot areas and target black spot areas together into a neighboring black spot area set corresponding to the target black spot areas.
As an example, taking the a-th initial black spot area in the H-component image as the target black spot area, and acquiring the centroid of the a-th initial black spot area, wherein the method for acquiring the centroid is the prior art, and will not be described herein. And acquiring edge pixel points of each initial black spot area through a Canny edge detection algorithm. The Canny edge detection algorithm is a well-known technique, and will not be described in detail herein. Taking the ith adjacent initial black spot area of the ith initial black spot area as an example, acquiring the Euclidean distance between the centroid of the ith initial black spot area and each edge pixel point of the ith adjacent initial black spot area, namely the target distance, wherein the acquiring method of the Euclidean distance is in the prior art, and is not repeated herein.
The minimum target distance is taken as the reference distance between the a-th initial black spot region and the i-th adjacent initial black spot region. According to the method for obtaining the reference distance between the a-th initial black spot area and the i-th adjacent initial black spot area, obtaining the reference distance between the a-th initial black spot area and each adjacent initial black spot area, and carrying out normalization processing on the reference distance between the a-th initial black spot area and each adjacent initial black spot area, wherein the normalized reference distance is the reference result. In the embodiment of the invention, the preset first reference threshold value is set to be 0.4, and all the reference results smaller than or equal to the first reference threshold value are combined to construct the adjacent black spot area set corresponding to the a-th initial black spot area, wherein all the adjacent initial black spot areas and the a-th initial black spot area are corresponding to the corresponding initial black spot area. Removing the adjacent black spot area set corresponding to the a-th initial black spot area in the H component image, selecting any one of the remaining initial black spot areas in the H component image as a new target black spot area, and obtaining the adjacent black spot area set corresponding to the target black spot area. And deleting the adjacent black spot area set corresponding to the target black spot area from the H component image, and simultaneously continuously selecting any remaining initial black spot area in the H component image as a new target black spot area until each initial black spot area in the H component image has the corresponding adjacent black spot area set. If a certain initial black spot area in the H component image does not exist adjacent initial black spot areas, the initial black spot areas form an adjacent black spot area set. Thus, a set of adjacent black spot areas corresponding to each initial black spot area in the H component image is acquired.
And acquiring the adjacent black spot area set corresponding to each initial black spot area in the S component image and the I component image according to the method for acquiring the adjacent black spot area set corresponding to each initial black spot area in the H component image.
It should be noted that the initial black spot region in each set of adjacent black spot regions can be regarded as each small region in the same black spot region.
Step S3: the total number of initial black spot areas in each component image is obtained.
Specifically, if the initial black spot areas adjacent to the periphery of each initial black spot area are fewer, the initial black spot areas are basically clustered together, the clustering effect in the corresponding component image is good, the component image is accurate in identifying the black spot areas, and the contribution degree of the component image to describing the characteristics of the black spot areas is larger, namely the possibility of identifying the black spot areas in the black garlic image is larger. In order to accurately acquire the weight of each component image for accurately identifying the black spot region, the total number of initial black spot regions in each component image is first acquired.
Preferably, the method for obtaining the total number of initial black spot areas is as follows: acquiring the number of initial black spot areas in each adjacent black spot area set as a first number; the result of the accumulation of the first number in each component image is taken as the total number of initial black spot areas of the corresponding component image.
As an example, the number of initial black spot areas in each adjacent black spot area set in the H component image, that is, the first number, is obtained, and the result of accumulating all the first numbers in the H component image is obtained, that is, the total number of initial black spot areas in the H component image. And acquiring the total number of the initial black spot areas in the S component image and the I component image according to the method for acquiring the total number of the initial black spot areas in the H component image.
In another example, the initial black spot areas in the H, S, and I component images may be marked by a trained neural network, thereby directly obtaining the total number of initial black spot areas in the H, S, and I component images. The neural network is a prior art, and will not be described herein.
The larger the total number of initial black spot areas in the component image is, the more inaccurate the identification of the black spot areas in the component image is, namely the more inaccurate the component image is for describing the characteristics of the black spot areas, and the smaller the weight occupied by the component image when the black spot areas are identified is.
Step S4: and acquiring the fluctuation value of the black spot area of each component image according to the area of the initial black spot area in each adjacent black spot area set.
Specifically, when the average value of the initial black spot area in each adjacent black spot area set in the component image is larger, the initial black spot area is closer, the more complete the actual black spot area corresponding to the adjacent black spot area set is identified, and the more accurate the characteristic of identifying the black spot area in the component image is. Therefore, the area of each initial black spot area in each component image is obtained, wherein the number of pixel points in each initial black spot area is the area of each initial black spot area. The variance of the initial black spot area in each adjacent black spot area set is obtained, namely the first variance, and the smaller the first variance is, the more uniform the area of the initial black spot area in the corresponding adjacent black spot area set is, and the more accurate the black spot area corresponding to the adjacent black spot area set is identified. In order to analyze each component image, the embodiment of the invention takes the result of the accumulation of the first variance in each component image as the fluctuation value of the black spot area of the corresponding component image. The larger the fluctuation value of the black spot area is, the more inaccurate the initial black spot area in the corresponding component image is identified, and the more inaccurate the component image is for identifying the characteristics of the black spot area.
Thus, the black spot region fluctuation values of the H component image, the S component image, and the I component image are acquired.
Step S5: acquiring black spot integral areas of each adjacent black spot area set according to the distribution of initial black spot areas in each adjacent black spot area set; and acquiring an adjustment factor of each component image according to the area of the initial black spot area and the area of the whole black spot area in each adjacent black spot area set.
Specifically, the initial black spot area in each adjacent black spot area set is known to be an integral black spot area, so that the minimum circumscribing rectangle of the initial black spot area in each adjacent black spot area set is obtained according to the position distribution of the initial black spot area in each adjacent black spot area set, namely the black spot integral area of each adjacent black spot area set. The method for obtaining the minimum circumscribed rectangle is an existing method, and will not be described in detail herein. The black spot entire region of each adjacent black spot region set defaults to each black spot region in the actual component image. In order to further determine the accuracy of black spot area identification in each component image, the embodiment of the invention acquires the adjustment factor of each component image according to the initial black spot area and the whole black spot area in each adjacent black spot area set. The method for acquiring the adjustment factor of each component image is as follows:
(1) A first characteristic value is obtained.
Preferably, the method for acquiring the first characteristic value is as follows: acquiring the minimum circumscribed rectangle of all initial black spot areas in each adjacent black spot area set, and taking the minimum circumscribed rectangle as a black spot integral area of the corresponding adjacent black spot area set; acquiring the accumulation result of all initial black spot area areas in each adjacent black spot area set as a first area; and taking the ratio of the first area of each adjacent black spot area set to the whole black spot area as a first characteristic value of each corresponding adjacent black spot area set.
Taking an f-th adjacent black spot area set in the H component image as an example, according to the position distribution of the initial black spot area in the f-th adjacent black spot area set, acquiring the minimum circumscribed rectangle of the initial black spot area in the f-th adjacent black spot area set, namely, the black spot whole area of the f-th adjacent black spot area set. The method comprises the steps of obtaining the area of each initial black spot area in an f-th adjacent black spot area set, namely obtaining the number of pixel points in each initial black spot area, and obtaining the total area of black spots in the f-th adjacent black spot area set, namely obtaining the total number of all pixel points in the black spot total area of the f-th adjacent black spot area set, wherein the result of accumulating the areas of all initial black spot areas in the f-th adjacent black spot area set is the first area. And obtaining the ratio of the first area of the f-th adjacent black spot area set to the whole black spot area, namely obtaining the first characteristic value of the f-th adjacent black spot area set.
And acquiring the first characteristic value of each adjacent black spot region set in each component image according to the method for acquiring the first characteristic value of the f-th adjacent black spot region set in the H component image.
The larger the first characteristic value is, the more accurate the initial black spot region in the corresponding adjacent black spot region set is identified, and further the more accurate the black spot region is identified in the corresponding component image.
(2) And obtaining the regulating factor.
In order to carry out integral analysis on each component image, further, according to the first characteristic value of the adjacent black spot region set in each component image, the adjusting factor of each component image is obtained, and further, the weight of each component image for accurately identifying the black spot region is accurately obtained. The embodiment of the invention takes the average value of the first characteristic values in each component image as the adjusting factor of each corresponding component image. The larger the adjusting factor is, the larger the contribution degree of the corresponding component image to the accurate identification of the black spot area is, namely the larger the weight of the component image is.
Step S6: acquiring the weight of each component image according to the total quantity of the initial black spot areas, the fluctuation value of the black spot areas and the adjustment factor of each component image; and correcting the black garlic image of the HSI color space according to the weight of each component image.
Specifically, as can be seen from steps S3, S4 and S5, the total number of initial black spot areas, the black spot area fluctuation value and the adjustment factor of each component image have an influence on the weight of each component image for accurately identifying the black spot area, and therefore, the weight of each component image is obtained according to the total number of initial black spot areas, the black spot area fluctuation value and the adjustment factor of each component image.
Preferably, the method for acquiring the weight is as follows: acquiring a product of an adjustment factor of each component image, the reciprocal of the total number of initial black spot areas and the reciprocal of the fluctuation value of the black spot areas as a contribution degree value of each component image; the result of accumulating the contribution degree value of each component image is used as an overall result; the ratio of the contribution degree value of each component image to the overall result is taken as the weight of each component image.
As an example, taking the H-component image as an example, the formula for acquiring the contribution degree value of the H-component image is:
in the method, in the process of the invention,a contribution degree value for the H component image; />An adjustment factor for the H component image; />The total number of initial black spot areas for the H component image; />And the fluctuation value of the black spot area of the H component image.
It should be noted that the number of the substrates,the larger the H component image, the more accurate the initial black spot area identification is, the greater the contribution degree of the H component image to the accurate black spot area identification should be, +.>The larger; />The smaller, the more accurate the identification of the initial black spot region in the H-component image, the closer the number of initial black spot regions to the number of black spot regions in the black garlic image,the bigger the->The larger; />The larger the area distribution of the initial black spot region in the H component image, the more uniform the area distribution, and the more accurate the identification of the black spot region in the H component image, the more accurate the identification of the original black spot region in the H component image, the more accurate the identification of the black spot region in the H component image>The bigger the->The larger; thus (S)>The larger the contribution of the H-component image to the accurate identification of the black spot region, the greater the degree of contribution.
According to the method for acquiring the contribution degree value of the H component image, the contribution degree values of the S component image and the I component image are acquired. And further accurately acquiring the weights of the black spot areas of the H component image, the S component image and the I component image in the black garlic image according to the contribution degree values of the H component image, the S component image and the I component image.
The formula for acquiring the weight of the H component image is as follows:
in the method, in the process of the invention,weights for the H component image; />A contribution degree value for the H component image; / >A contribution degree value for the S component image; />A contribution degree value for the I component image; />As a whole result.
It should be noted that the number of the substrates,the larger the contribution degree of the H-component image to accurately recognize the black spot region is, the greater +.>The larger; thus (S)>The larger the H component image is, the more accurate the characteristic identification of the black spot area in the black garlic image is, and the greater the contribution degree of the H component image to the accurate identification of the black spot area is.
According to the method for acquiring the weight of the H component image, the weights of the S component image and the I component image are acquired. And accurately identifying the black spot area of the black garlic image in the HSI color space according to the weights of the acquired H component image, S component image and I component image. So far, the black spot area in the black garlic image in the HSI color space is accurately identified.
Another object of this embodiment is to provide an on-line detection system for the production quality of black garlic, as shown in fig. 2, comprising:
step S1: an initial black spot region in each component image of the black garlic image in the HSI color space is acquired.
Step S2: and acquiring an initial black spot area adjacent to each initial black spot area in each component image, and constructing an adjacent black spot area set corresponding to each initial black spot area.
Step S3: the total number of initial black spot areas in each component image is obtained.
Step S4: and acquiring the fluctuation value of the black spot area of each component image according to the area of the initial black spot area in each adjacent black spot area set.
Step S5: acquiring black spot integral areas of each adjacent black spot area set according to the distribution of initial black spot areas in each adjacent black spot area set; and acquiring an adjustment factor of each component image according to the area of the initial black spot area and the area of the whole black spot area in each adjacent black spot area set.
Step S6: acquiring the weight of each component image according to the total quantity of the initial black spot areas, the fluctuation value of the black spot areas and the adjustment factor of each component image; and correcting the black garlic image of the HSI color space according to the weight of each component image.
Step S7: and acquiring a black spot area in the corrected black garlic image, and evaluating the quality of the black garlic according to the size of the black spot area.
The steps S1 to S6 have been described in detail in an embodiment of an image processing method, and are not described herein. Step S7 is specifically described below.
Step S7: and acquiring a black spot area in the corrected black garlic image, and evaluating the quality of the black garlic according to the size of the black spot area.
Specifically, considering that a certain fault tolerance phenomenon exists in the actual situation, namely that a slight black spot area can exist in the black garlic image, and the quality and the taste of the black garlic are not affected, the embodiment of the invention evaluates the quality of the black garlic according to the area of the black spot area in the black garlic image, and destroys the black garlic with unqualified quality.
Preferably, the method for evaluating the quality of the black garlic comprises the following steps: dividing the corrected black garlic image by the Ojin method to obtain a black spot area in the black garlic image; acquiring the area of a black spot area as the black spot area; acquiring the area of a black garlic image as the area of the black garlic; obtaining the ratio of the area of the black spot to the area of the black garlic as an evaluation value; when the evaluation value is greater than or equal to a preset evaluation value threshold, the quality of the corresponding black garlic is unqualified; when the evaluation value is smaller than a preset evaluation value threshold, the corresponding black garlic is qualified in quality. The method of the Dajin is the prior art and will not be described here.
The embodiment of the invention takes the total number of the pixel points in all the black spot areas in the corrected black garlic image as the area of the black spot areas in the black garlic image, namely the black spot area, and takes the number of the pixel points in the black garlic image as the area of the black garlic image, namely the black garlic area, so as to obtain the ratio of the black spot area to the black garlic area, namely the evaluation value. In the embodiment of the present invention, the threshold value of the evaluation value is set to 0.2, and the operator can set the evaluation value according to the actual situation, and the evaluation value is not limited herein. When the evaluation value is greater than or equal to a preset evaluation value threshold, the corresponding black garlic quality is unqualified and needs to be picked out for destruction; when the evaluation value is smaller than a preset evaluation value threshold, the corresponding black garlic is qualified in quality.
Thus, the quality evaluation of the black garlic is completed.
In summary, the embodiment of the invention acquires the initial black spot area in each component image of the black garlic image in the HSI color space; acquiring a set of adjacent black spot areas according to the adjacent initial black spot areas; acquiring the weight of each component image according to the adjacent black spot area set, and correcting the black garlic image of the HSI color space; and acquiring a black spot area in the corrected black garlic image, and further evaluating the quality of the black garlic. According to the invention, the weight of each component image in the HSI color space is determined through the identification condition of the black spot area in the component image, so that the black spot area is accurately identified, and the quality of the black garlic is accurately evaluated.
It should be noted that: the sequence of the embodiments of the present invention is only for description, and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments.

Claims (10)

1. An image processing method, the method comprising:
acquiring an initial black spot area of each component image of the black garlic image in the HSI color space;
acquiring an initial black spot area adjacent to each initial black spot area in each component image, and constructing an adjacent black spot area set corresponding to each initial black spot area;
acquiring the total number of initial black spot areas in each component image;
acquiring a black spot area fluctuation value of each component image according to the area of an initial black spot area in each adjacent black spot area set;
acquiring black spot integral areas of each adjacent black spot area set according to the distribution of initial black spot areas in each adjacent black spot area set; acquiring an adjusting factor of each component image according to the area of the initial black spot area and the area of the whole black spot area in each adjacent black spot area set;
acquiring the weight of each component image according to the total quantity of the initial black spot areas, the fluctuation value of the black spot areas and the adjustment factor of each component image; and correcting the black garlic image of the HSI color space according to the weight of each component image.
2. The image processing method according to claim 1, wherein the method for obtaining the initial black spot area adjacent to each initial black spot area in each component image and constructing the adjacent black spot area set corresponding to each initial black spot area comprises the following steps:
Selecting any initial black spot area in the component image as a target black spot area;
acquiring the distance from the centroid of the target black spot area to each edge pixel point of any adjacent initial black spot area, taking the minimum target distance as the reference distance between the target black spot area and the adjacent initial black spot area;
obtaining a reference distance between a target black spot area and each adjacent initial black spot area, and taking a normalized result of the reference distance as a reference result;
and when the reference result is smaller than a preset first reference threshold value, constructing all corresponding initial black spot areas and target black spot areas together into a neighboring black spot area set corresponding to the target black spot areas.
3. The image processing method according to claim 1, wherein the method for obtaining the total number of initial black spot areas is as follows:
acquiring the number of initial black spot areas in each adjacent black spot area set as a first number;
the result of the accumulation of the first number in each component image is taken as the total number of initial black spot areas of the corresponding component image.
4. The image processing method according to claim 1, wherein the black spot region fluctuation value obtaining method comprises the steps of:
Taking the variance of the area of the initial black spot region in each adjacent black spot region set as a first variance;
and the result of accumulating the first differences in each component image is taken as a black spot area fluctuation value of the corresponding component image.
5. The image processing method according to claim 1, wherein the method for obtaining the black spot integral area of each adjacent black spot area set according to the distribution of the initial black spot area in each adjacent black spot area set comprises the following steps:
and acquiring the minimum circumscribed rectangle of all initial black spot areas in each adjacent black spot area set, and taking the minimum circumscribed rectangle as a black spot integral area of the corresponding adjacent black spot area set.
6. The image processing method according to claim 1, wherein the method for acquiring the adjustment factor of each component image based on the area of the initial black spot region and the area of the black spot overall region in each set of adjacent black spot regions is:
acquiring the accumulation result of all initial black spot area areas in each adjacent black spot area set as a first area;
taking the ratio of the first area of each adjacent black spot area set to the whole black spot area as a first characteristic value of each corresponding adjacent black spot area set;
And acquiring the average value of the first characteristic values in each component image as an adjusting factor of the corresponding component image.
7. The image processing method according to claim 1, wherein the method for acquiring the weight of each component image based on the total number of initial black spot areas, the fluctuation value of the black spot areas, and the adjustment factor is as follows:
acquiring a product of an adjustment factor of each component image, the reciprocal of the total number of initial black spot areas and the reciprocal of the fluctuation value of the black spot areas as a contribution degree value of each component image;
the result of accumulating the contribution degree value of each component image is used as an overall result;
the ratio of the contribution degree value of each component image to the overall result is taken as the weight of each component image.
8. The image processing method according to claim 1, wherein the method for acquiring the initial black spot area in each component image of the black garlic image in the HSI color space is as follows:
acquiring an H component image, an S component image and an I component image of a black garlic image in an HSI color space;
and acquiring an initial black spot area in each component image according to the channel value distribution of the pixel points in each component image.
9. The image processing method as claimed in claim 8, wherein the method for obtaining the initial black spot area in each component image according to the channel value distribution of the pixel points in each component image is as follows:
acquiring a tone channel value of each pixel point in the H component image, taking a pixel point corresponding to a preset first tone channel value as an initial starting point, and carrying out region growth through a region growth algorithm to obtain an initial black spot region in the H component image;
for an S component image or an I component image, obtaining a channel value of each pixel point in the component image, and selecting the mode of the channel value as a first channel value; acquiring the average value of all channel values in the component images, and taking the average value as a channel average value; acquiring the difference between each channel value and the channel mean value in the component image as a first difference; taking the addition result of the maximum first difference and the channel mean value as a second channel value; when the first channel value is smaller than the second channel value, taking a pixel point corresponding to the first channel value as an initial starting point, and carrying out region growth through a region growth algorithm to obtain an initial black spot region in the component image; when the first channel value is larger than the second channel value, taking the pixel point corresponding to the second channel value as an initial starting point, and carrying out region growth through a region growth algorithm to obtain an initial black spot region in the component image.
10. The on-line detection system for the production quality of the black garlic is characterized by comprising a processor and a memory, wherein the processor is used for processing instructions stored in the memory so as to realize the following steps:
acquiring an initial black spot area of each component image of the black garlic image in the HSI color space;
acquiring an initial black spot area adjacent to each initial black spot area in each component image, and constructing an adjacent black spot area set corresponding to each initial black spot area;
acquiring the total number of initial black spot areas in each component image;
acquiring a black spot area fluctuation value of each component image according to the area of an initial black spot area in each adjacent black spot area set;
acquiring black spot integral areas of each adjacent black spot area set according to the distribution of initial black spot areas in each adjacent black spot area set; acquiring an adjusting factor of each component image according to the area of the initial black spot area and the area of the whole black spot area in each adjacent black spot area set;
acquiring the weight of each component image according to the total quantity of the initial black spot areas, the fluctuation value of the black spot areas and the adjustment factor of each component image; correcting the black garlic image of the HSI color space according to the weight of each component image;
And acquiring a black spot area in the corrected black garlic image, and evaluating the quality of the black garlic according to the size of the black spot area.
CN202311107879.5A 2023-08-31 2023-08-31 Image processing method and black garlic production quality online detection system applying same Active CN116824586B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311107879.5A CN116824586B (en) 2023-08-31 2023-08-31 Image processing method and black garlic production quality online detection system applying same

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311107879.5A CN116824586B (en) 2023-08-31 2023-08-31 Image processing method and black garlic production quality online detection system applying same

Publications (2)

Publication Number Publication Date
CN116824586A true CN116824586A (en) 2023-09-29
CN116824586B CN116824586B (en) 2023-12-01

Family

ID=88115355

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311107879.5A Active CN116824586B (en) 2023-08-31 2023-08-31 Image processing method and black garlic production quality online detection system applying same

Country Status (1)

Country Link
CN (1) CN116824586B (en)

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102214306A (en) * 2011-06-16 2011-10-12 中国农业大学 Leaf disease spot identification method and device
CN102737367A (en) * 2012-06-17 2012-10-17 四川农业大学 Tea image enhancement and division method based on color characteristic
WO2018086299A1 (en) * 2016-11-11 2018-05-17 广东电网有限责任公司清远供电局 Image processing-based insulator defect detection method and system
WO2019056549A1 (en) * 2017-09-22 2019-03-28 深圳市华星光电半导体显示技术有限公司 Image enhancement method, and image processing device
CN111724383A (en) * 2020-06-30 2020-09-29 重庆盛泰光电有限公司 Camera module black spot detection system based on turntable
CN112070771A (en) * 2020-07-24 2020-12-11 安徽农业大学 Adaptive threshold segmentation method and device based on HS channel and storage medium
CN114881965A (en) * 2022-04-29 2022-08-09 蔡志刚 Wood board joint detection method based on artificial intelligence and image processing
WO2022199583A1 (en) * 2021-03-26 2022-09-29 影石创新科技股份有限公司 Image processing method and apparatus, computer device, and storage medium
WO2022199710A1 (en) * 2021-03-23 2022-09-29 影石创新科技股份有限公司 Image fusion method and apparatus, computer device, and storage medium
CN115266736A (en) * 2022-09-29 2022-11-01 江苏宸洋食品有限公司 Quick identification method for mildew of murcott
CN115601690A (en) * 2022-12-13 2023-01-13 山东常生源生物科技股份有限公司(Cn) Edible fungus environment detection method based on intelligent agriculture
CN116630447A (en) * 2023-07-24 2023-08-22 成都海风锐智科技有限责任公司 Weather prediction method based on image processing

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102214306A (en) * 2011-06-16 2011-10-12 中国农业大学 Leaf disease spot identification method and device
CN102737367A (en) * 2012-06-17 2012-10-17 四川农业大学 Tea image enhancement and division method based on color characteristic
WO2018086299A1 (en) * 2016-11-11 2018-05-17 广东电网有限责任公司清远供电局 Image processing-based insulator defect detection method and system
WO2019056549A1 (en) * 2017-09-22 2019-03-28 深圳市华星光电半导体显示技术有限公司 Image enhancement method, and image processing device
CN111724383A (en) * 2020-06-30 2020-09-29 重庆盛泰光电有限公司 Camera module black spot detection system based on turntable
CN112070771A (en) * 2020-07-24 2020-12-11 安徽农业大学 Adaptive threshold segmentation method and device based on HS channel and storage medium
WO2022199710A1 (en) * 2021-03-23 2022-09-29 影石创新科技股份有限公司 Image fusion method and apparatus, computer device, and storage medium
WO2022199583A1 (en) * 2021-03-26 2022-09-29 影石创新科技股份有限公司 Image processing method and apparatus, computer device, and storage medium
CN114881965A (en) * 2022-04-29 2022-08-09 蔡志刚 Wood board joint detection method based on artificial intelligence and image processing
CN115266736A (en) * 2022-09-29 2022-11-01 江苏宸洋食品有限公司 Quick identification method for mildew of murcott
CN115601690A (en) * 2022-12-13 2023-01-13 山东常生源生物科技股份有限公司(Cn) Edible fungus environment detection method based on intelligent agriculture
CN116630447A (en) * 2023-07-24 2023-08-22 成都海风锐智科技有限责任公司 Weather prediction method based on image processing

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
BRIAN C PETERSON等: "Effects of fasting on circulating IGF-binding proteins, glucose, and cortisol in channel catfish (Ictalurus punctatus)", DOMESTIC ANIMAL ENDOCRINOLOGY *
夏永泉;李耀斌;曾莎;: "基于HSI颜色空间的植物叶片病斑提取方法", 江苏农业科学, no. 08 *
汪建;: "结合颜色和区域生长的茶叶图像分割算法研究", 茶叶科学, no. 01 *
衷佩玮;杨睿;孙恺琦;陈国强;: "基于HSI颜色空间与暗原色先验原理的单幅图像去雾算法", 软件导刊, no. 01 *

Also Published As

Publication number Publication date
CN116824586B (en) 2023-12-01

Similar Documents

Publication Publication Date Title
CN112818827B (en) Method for judging stage temperature control point in tobacco leaf baking process based on image recognition
CN112949663B (en) Tobacco leaf baking control system and method based on image recognition
CN108615239B (en) Tongue image segmentation method based on threshold technology and gray level projection
CN104598886B (en) A kind of method that utilization near-infrared high spectrum image recognizes the oil crops that go mouldy
CN115994907B (en) Intelligent processing system and method for comprehensive information of food detection mechanism
CN117994154B (en) Intelligent image denoising method based on sensor
CN115797352B (en) Tongue picture image processing system for traditional Chinese medicine health-care physique detection
CN117218042B (en) Visual analysis and detection method for hair types
CN111860639A (en) System and method for judging quantized flue-cured tobacco leaf curing characteristics
CN117575953B (en) Detail enhancement method for high-resolution forestry remote sensing image
CN113129300A (en) Drainage pipeline defect detection method, device, equipment and medium for reducing false detection rate
Kapoor et al. Capturing banding in images: Database construction and objective assessment
CN116824586B (en) Image processing method and black garlic production quality online detection system applying same
CN117522862A (en) Image processing method and processing system based on CT image pneumonia recognition
CN116597029B (en) Image re-coloring method for achromatopsia
CN117274405A (en) LED lamp working color detection method based on machine vision
CN115862006B (en) Bran star detection method in flour milling process
CN108629780B (en) Tongue image segmentation method based on color decomposition and threshold technology
Vite-Chávez et al. Improvement Procedure for Image Segmentation of Fruits and Vegetables Based on the Otsu Method
Mosny et al. Cubical gamut mapping colour constancy
CN106709505A (en) Dictionary learning-based grain type classification method and system for corn grains
CN112101377B (en) Online intermittent hollow filter stick detection method based on regional feature analysis
CN118537335B (en) Defect detection method for cloth surface layout printing inaccuracy
CN115797345B (en) Seafood baking abnormality identification method
CN114782682B (en) Agricultural pest image intelligent identification method based on neural network

Legal Events

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