Castor seed oil impurity detection method based on image recognition
By constructing a transmission imaging environment and performing multi-dimensional feature fusion analysis, the problem of distinguishing between bubbles and solid impurities in castor oil was solved, achieving efficient and accurate impurity detection and meeting the needs of industrial production.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-31
- Publication Date
- 2026-04-14
AI Technical Summary
Existing technologies struggle to distinguish visual mimicry between bubbles and solid impurities in castor oil, leading to high false alarm and false negative rates, and failing to meet the industrial-grade requirements for high precision and stability.
A transmission imaging environment adapted to the optical properties of oil is constructed, and narrowband red light is used for imaging. By combining adaptive thresholding and statistical analysis, multi-dimensional features such as edge gradient, curvature, gray-scale distribution and optical refraction properties are extracted. Impurities and bubbles are distinguished through cluster analysis.
It achieves efficient identification and accurate removal of impurities in castor oil, reduces false alarm and false negative rates, adapts to complex flow field detection, improves detection accuracy and stability, and ensures production safety and product quality.
Smart Images

Figure CN121860992A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image data processing technology. More specifically, this invention relates to a method for detecting impurities in castor seed oil based on image recognition. Background Technology
[0002] Castor seed oil, as a key industrial raw material, is highly susceptible to contamination with solid particulate impurities such as shell fragments and silt during its preparation, refining, and pipeline transportation. Furthermore, the high-speed shearing of the fluid and pumping pressure often generate numerous tiny air bubbles within the oil. If these foreign matter are not effectively removed, they not only severely affect the purity of the oil but may also cause blockages or damage to downstream precision processing equipment. Therefore, employing non-contact machine vision technology for real-time online monitoring and precise removal of impurities from flowing oil has become a necessary step in ensuring production safety and product quality.
[0003] Existing technologies typically rely on industrial cameras to capture fluid images and utilize traditional image processing algorithms for identification. Their core logic lies in extracting shallow features of the target area in isolation, such as geometric shape, grayscale mean, or texture gradient. These features are then superimposed by setting a fixed grayscale threshold or simple logical rules to distinguish impurities from the background. For example, simply identifying an impurity based on a grayscale value below a certain threshold, or identifying a bubble based on roundness, can achieve basic detection functions in simple scenarios with static or low-speed operation and minimal interference.
[0004] However, the aforementioned methods have significant drawbacks in the fluid detection scenario of castor oil. Due to the high viscosity and flow shear effect of the oil, bubbles often undergo non-spherical rheological changes, exhibiting irregular shapes. Furthermore, under specific lighting conditions, the dark areas generated by refraction at the bubble edges are easily confused with the grayscale characteristics of solid impurities, resulting in visual mimicry. Traditional algorithms sever the inherent physical connection between rheological morphology, material density, and optical properties, making it difficult to effectively distinguish between solid impurities and deformed bubbles with similar appearances in complex flow fields. This leads to a high false alarm rate in high-throughput production, failing to meet the high-precision and high-stability detection requirements of industrial applications. Summary of the Invention
[0005] To address the challenge of traditional algorithms failing to distinguish impurities from shallow features extracted in isolation due to the visual mimicry formed by bubble rheology and refractive dark areas and solid impurities, this invention provides an image recognition-based method for detecting impurities in castor seed oil, comprising: A transmission imaging acquisition environment adapted to the optical properties of oil is constructed to acquire raw oil images. The raw oil images are preprocessed, and combined with adaptive thresholding and statistical analysis to obtain the foreground target set and background noise level. Contour information of the foreground targets is extracted, and the gradient and curvature properties of the edges are calculated based on differential geometry principles. The edge gradient and curvature information are fused to construct a joint curvature gradient feature value reflecting the morphological abrupt changes of impurities. The gray-level distribution characteristics and geometric dimensions of the connected domains of the foreground targets are statistically analyzed to obtain basic physical parameters. Based on regional gray-level contrast and geometric area, a basic optical density saturation energy characterizing the degree of light obstruction is constructed. Combining the basic optical density saturation energy, the rheological characteristics and morphological characteristics of the connected domains of the foreground targets, a rheological weighted energy value reflecting material properties is calculated. The optical refraction characteristics of the connected domains of the foreground targets are analyzed, and the refraction deviation index is calculated by combining material energy and environmental noise. All refraction deviation indices are clustered, and screening and elimination controls are performed based on the clustering results.
[0006] This invention acquires clear images under specific optical conditions, avoiding imaging interference caused by oil color and bubble refraction. It employs an adaptive image processing method to accommodate variations in the transmittance of different batches of oil, reducing the impact of background noise. By extracting and fusing multi-dimensional features such as edges, size, and color, it deeply captures the essential differences between impurities and bubbles, overcoming the limitations of single-feature judgment. Furthermore, by utilizing differences in optical properties and cluster analysis, it further suppresses bubble interference, improving the accuracy of differentiation. This invention effectively reduces false alarms and false negatives.
[0007] Preferably, acquiring the original image of the oil includes: A red LED backlight is installed on one side of the conveying pipe section. The light source is configured to emit narrow-band red light with a wavelength range of 620-630nm. The high penetration of this wavelength of light into yellow castor oil is used to establish a transmission light path. A high-speed industrial camera is installed on the opposite side of the conveying pipe section. The camera's optical axis is calibrated to face the backlight for transmission imaging, and the original image of the oil flow process is collected and recorded as the original oil image.
[0008] Preferably, obtaining the foreground target set and background noise level includes: The original oil image is processed by Gaussian filtering. The Gaussian-filtered image is then binarized using the Otsu adaptive thresholding method, and the resulting image is denoted as the binarized image. The gray-level threshold with the largest inter-class variance in the binarized image is automatically calculated, dividing the binarized image into background and foreground regions. Connectivity analysis is performed on the foreground region to extract all independent foreground target connected components, which are denoted as the foreground target set. Simultaneously, the standard deviation of the gray-level values of all pixels in the background region is calculated and denoted as the background noise level.
[0009] Preferably, calculating the gradient and curvature properties of the edge includes: Extract the edge contour of any connected component of a foreground object in the foreground object set, count the number of pixels contained in the edge contour, and denote it as the edge perimeter; for the th edge contour... For each pixel, calculate its edge gradient magnitude and edge curvature. Further, calculate the arithmetic mean of the absolute values of curvature of all pixels on the edge contour, denoted as the average edge curvature.
[0010] Preferably, the joint eigenvalues of the curvature gradient satisfy the following expression: ; In the formula, Represents the joint eigenvalues of the curvature gradient; Indicates the magnitude of the edge gradient; Indicates edge curvature; Indicates the average edge curvature; It is an exponential function with the natural constant as its base; It is the first smallest positive number, and the denominator is guaranteed to be non-zero.
[0011] This invention combines the clarity of the edge with the characteristics of its curvature to amplify the differences in edge characteristics between impurities and bubbles. This makes the features of impurities with rough edges more prominent, while the features of bubbles with smooth edges remain flat, thus making it easier to distinguish between the two, reducing confusion caused by similar appearances, and improving the effectiveness of feature recognition.
[0012] Preferably, obtaining the fundamental physical parameters includes: The total number of pixels within a single foreground target connected region is counted and denoted as the target area; the average gray level of all pixels within the foreground target connected region is calculated and denoted as the target gray level; the average gray level of pixels in the background region of the original oil image is calculated and denoted as the background gray level.
[0013] Preferably, the basic optical density saturation energy satisfies the following expression: ; In the formula, Indicates the saturation energy of the basic optical density; Indicates the target area; Indicates the target grayscale; Indicates the background grayscale; If it is the second smallest positive number, the denominator is guaranteed to be non-zero; This represents the natural logarithm function.
[0014] This invention combines the color depth and size of the target for calculation, which can reasonably assess the degree to which the target blocks light. It will not misjudge due to the target being too large but light-colored, nor will it miss the target being too small but dark-colored. It balances the influence of the two factors of size and color, making the assessment of the degree of harm of the target more objective and improving the accuracy of detection.
[0015] Preferably, the rheologically weighted energy value satisfies the following expression: ; In the formula, This represents the rheological weighted energy value; Indicates the saturation energy of the basic optical density; Indicates the edge rheological response characteristics; Indicates the perimeter of the edge; Indicates the target area; It is the third smallest positive number, ensuring that the denominator is not zero.
[0016] This invention integrates the light obstruction, edge roughness, and shape characteristics of the target for calculation, which can comprehensively amplify the differences between impurities and bubbles, making the characteristics of impurities more obvious and the interference of bubbles further reduced. Even when encountering irregularly shaped bubbles or small impurities, it can effectively distinguish them, reduce the errors that may occur in judging by a single feature, and improve the accuracy of detection.
[0017] Preferably, calculating the refractive deviation index includes: Obtain the geometric center coordinates of the connected region of the foreground target and the gray-weighted centroid coordinates of the original oil image. Calculate the Euclidean distance between the geometric center coordinates of the connected region of the foreground target and the gray-weighted centroid coordinates of the original oil image, denoted as the refraction offset distance. Multiply the refraction offset distance by the background gray level, divide by the sum of the square root of the target area and a minimum positive number, square the result, and then add it to the square of the background noise level. Take the square root of the sum as the denominator. Use the rheologically weighted material energy as the numerator. The ratio of the numerator to the denominator is used as the refraction deviation index.
[0018] This invention, by calculating the deviation of the target center position and combining previously obtained energy data and environmental noise, can effectively utilize the essential differences in optical properties between bubbles and impurities, further suppress the interference caused by bubbles, make the characteristics of impurities more prominent, reduce the influence of environmental factors on the judgment, make the final detection index more discriminative, and improve the reliability of the judgment.
[0019] Preferably, all refractive deviation indices are clustered, including: The refractive index of each connected region of the foreground target is obtained. Cluster analysis is performed on all refractive indexes. Based on the natural distribution characteristics of the refractive index values, the connected regions of the foreground target are divided into two categories: high index clusters and low index clusters. The connected regions of the foreground target corresponding to the high index cluster are identified as solid impurities. The system immediately generates an alarm signal and drives the downstream pneumatic rejection valve to operate. The connected regions of the foreground target corresponding to the low index cluster are identified as bubbles or fluid disturbances. The system ignores these and does not perform any action.
[0020] The beneficial effects of this invention are as follows: By optimizing the imaging environment and data processing methods, this invention achieves efficient identification and accurate removal of impurities in oil. This method can adapt to complex scenarios in industrial production, completing detection in real time during oil flow without affecting production efficiency. The detection process does not require contact with the oil, avoiding secondary contamination of the product and reducing wear and tear caused by contact between the detection equipment and the oil. Through multi-dimensional feature fusion and intelligent classification, the adaptability and accuracy of the detection are improved, effectively ensuring product quality and preventing oil containing impurities from flowing downstream and causing equipment damage. At the same time, this method has a high degree of automation, reducing manual intervention, lowering errors in human judgment, and improving the stability and consistency of the production process, providing strong support for enterprises to reduce production costs and ensure production safety. Attached Figure Description
[0021] Figure 1 This is a flowchart illustrating an image recognition-based method for detecting impurities in castor seed oil according to the present invention. Figure 2 This is a schematic diagram illustrating the oil imaging effect in this invention; Figure 3 This is a schematic diagram illustrating the rheological weighted energy value analysis in this invention. Detailed Implementation
[0022] This invention discloses a method for detecting impurities in castor seed oil based on image recognition, referring to... Figure 1 This includes steps S1-S4: S1: Construct a transmission imaging acquisition environment adapted to the optical properties of oil and acquire the original image of the oil.
[0023] It should be noted that in the industrial transportation of castor oil, the oil exhibits high viscosity and a deep yellow color, and under pumping pressure, it easily traps tiny air bubbles. Traditional white light detection methods, due to their complex spectral composition, produce significant dispersion and scattering when penetrating the yellow oil layer, resulting in excessive background noise and difficulty in capturing deep impurities. Red light with a wavelength of 620-630nm, located within the spectral transmission window of yellow oil, can minimize the medium's absorption rate. Furthermore, considering the optical characteristics of impurities and bubbles, solid impurities primarily act as opaque absorbers, while bubbles are transparent refractors. However, under the complex light field of high-speed flow, the edges of bubbles often exhibit dark rings due to total internal reflection, easily confused with solid impurities. Therefore, constructing an optical environment based on the transmission principle of a specific wavelength, utilizing the high penetration of red light to suppress the oil background, and leveraging the difference in transmission imaging to enhance the contrast between solid black and hollow gray, is the physical basis for achieving high signal-to-noise ratio imaging and a crucial prerequisite for subsequent algorithms to accurately separate bubble interference.
[0024] Specifically, a transmission imaging acquisition environment adapted to the optical properties of oil is constructed, and raw images of the oil are acquired, including: A red LED backlight is installed on one side of the conveying pipe section. The light source is configured to emit narrow-band red light with a wavelength range of 620-630nm. The high penetration of this wavelength of light into yellow castor oil is used to establish a transmission light path. A high-speed industrial camera is installed on the opposite side of the conveying pipe section. The camera's optical axis is calibrated to face the backlight for transmission imaging, and the original image of the oil flow process is collected and recorded as the original oil image.
[0025] It should be noted that, based on the oil imaging acquisition environment constructed according to the present invention, the background of the acquired image is a bright area, the opaque solid impurities appear as black silhouettes, and the semi-transparent bubbles appear as grayscale shapes with refracted light spots.
[0026] It should be noted that, Figure 2 The image provided illustrates the imaging effect of oil, showcasing the detection image obtained by red light transmission imaging at a specific wavelength according to this invention, a reference image obtained by traditional white light imaging, and a schematic diagram of the actual working conditions in the corresponding scenario. In complex flow fields containing bubbles and solid impurities, traditional white light imaging images exhibit significant background noise, with dark rings at the edges of bubbles overlapping with the grayscale features of solid impurities, making it difficult to distinguish the target. In contrast, the detection image obtained by this invention shows a relatively bright and uniform background, with opaque solid impurities forming clear black silhouettes, and semi-transparent bubbles displaying unique refracted light spots. The grayscale morphology is distinctly different from that of the impurities, visually demonstrating the technical characteristics of this invention in suppressing background interference and enhancing target contrast through optical environment optimization.
[0027] At this point, the original image of the oil was obtained.
[0028] S2: Preprocess the original oil image and combine adaptive thresholding and statistical analysis to obtain the foreground target set and background noise level; extract the contour information of the foreground targets and calculate the gradient and curvature properties of the edges based on the principle of differential geometry; fuse the edge gradient and curvature information to construct a curvature gradient joint feature value that reflects the morphological changes of impurities.
[0029] It should be noted that during the high-speed transport of fluids in pipelines, the images acquired are often accompanied by high-frequency random noise due to the influence of fluid pulsation and slight changes in external light. Due to batch differences in castor oil, the transmittance of the oil is not constant, which causes the background grayscale value to fluctuate within a certain range. If a fixed threshold segmentation is used, it is very easy to misjudge normal oil as impurities when the oil color is dark, or to miss small particles when the oil color is light. The adaptive thresholding method can dynamically find the optimal segmentation point based on the current gray-level histogram, thereby overcoming the influence of fluctuations in oil transmittance. Furthermore, background noise level is not only an indicator of image quality but also a crucial benchmark for subsequently determining the significance of impurity signals. In low signal-to-noise ratio environments, a slight decrease in gray level may simply be a noise fluctuation, while in high-purity environments, the same decrease may represent minute impurities. Therefore, this invention needs to evaluate the background noise level to provide a dynamic environmental noise floor parameter for subsequently constructing an interference-resistant detection index, ensuring that the detection standard adaptively adjusts with the environment.
[0030] Specifically, the original oil image is preprocessed, and combined with adaptive thresholding and statistical analysis, to obtain the foreground target set and background noise level, including: The original oil image is processed by Gaussian filtering. The Gaussian-filtered image is then binarized using the Otsu adaptive thresholding method, and the resulting image is denoted as the binarized image. The gray-level threshold with the largest inter-class variance in the binarized image is automatically calculated, dividing the binarized image into background and foreground regions. Connectivity analysis is performed on the foreground region to extract all independent foreground target connected components, which are denoted as the foreground target set. Simultaneously, the standard deviation of the gray-level values of all pixels in the background region is calculated and denoted as the background noise level.
[0031] Thus, the foreground target set and background noise level of the preprocessed original oil image were obtained.
[0032] It should be noted that in distinguishing between bubbles and solid impurities, relying solely on contour shape often fails because fluid shear forces stretch bubbles into elliptical or irregular shapes, making them difficult to distinguish macroscopically from sheet-like impurities. However, from a microscopic fluid dynamics perspective, bubbles are constrained by surface tension, and the transition at their gas-liquid interface is always continuous and smooth. Even with overall shape deformation, the curvature changes at their local edges still exhibit regularity. In contrast, solid impurities have rough surfaces with sharp abrupt changes and irregular serrations at their edges. Therefore, this invention introduces two differential features—edge gradient magnitude and edge curvature—to delve into the pixel-level microscopic level, capturing the essential differences in mathematical expression between tension smoothness and fracture roughness, laying a data foundation for subsequently constructing deep features capable of penetrating macroscopic shape camouflage.
[0033] Preferably, the contour information of the foreground target is extracted, and the gradient and curvature properties of the edges are calculated based on the principles of differential geometry, including: Extract the edge contour of any connected component of a foreground object in the foreground object set, count the number of pixels contained in the edge contour, and denote it as the edge perimeter; for the th edge contour... For each pixel, calculate its edge gradient magnitude and edge curvature. Further, calculate the arithmetic mean of the absolute values of curvature of all pixels on the edge contour, denoted as the average edge curvature.
[0034] Thus, the calculation and acquisition of edge perimeter, edge gradient magnitude, edge curvature, and average edge curvature have been completed.
[0035] It should be noted that in image feature extraction, there exists an antagonistic relationship between strong gradient-low curvature variation and strong gradient-high curvature variation. Although the edges of bubbles have high contrast, their curvature is gradual due to surface tension, with minimal deviation from the average curvature at each point. In contrast, the edges of solid impurities exhibit not only high contrast but also drastic abrupt changes in curvature. Using only a single feature is insufficient to effectively differentiate between the two. The curvature-gradient joint feature value designed in this invention is essentially a nonlinear signal amplifier. It uses curvature deviation as an exponential term to modulate the gradient energy. For bubbles, the exponential term approaches 1, preserving the original gradient; for impurities, the exponential term increases rapidly, amplifying the roughness energy at their edges. This design, starting from the essence of physical morphology, transforms minute differences in material surface into significant numerical differences.
[0036] Preferably, edge gradient and curvature information are fused to construct a joint curvature gradient feature value reflecting the morphological abrupt changes of impurities, including: The joint eigenvalues of curvature gradients satisfy the following expression: ; In the formula, Represents the joint eigenvalues of the curvature gradient; Indicates the magnitude of the edge gradient; Indicates edge curvature; Indicates the average edge curvature; It is an exponential function with the natural constant as its base; It is the first smallest positive number, and the denominator is guaranteed to be non-zero.
[0037] In the formula, This represents the normalized deviation of the curvature at the current point from the overall average curvature. For bubbles under surface tension, the edges are smooth and the curvature changes uniformly. Approximately equal to When the deviation approaches 0 and the exponential term is 1, the gradient energy remains in its original state. For solid impurities, their edges exhibit irregular, sharp abrupt changes. The exponent term is significantly increased, and the exponent term is much greater than 1, thereby nonlinearly amplifying the gradient energy at the sharp corner and highlighting the abrupt morphological changes of the impurities.
[0038] Thus, the joint eigenvalues of curvature gradients reflecting the morphological abrupt changes of impurities were obtained.
[0039] S3: Statistically analyze the gray-level distribution characteristics and geometric dimensions of the connected domains of the foreground target to obtain basic physical parameters; based on the regional gray-level contrast and geometric area, construct the basic optical density saturation energy to characterize the degree of light obstruction.
[0040] It's important to note that to construct a complete model describing the physical properties of a target, it's necessary to consider not only the microscopic texture of the edges but also macroscopic statistical information. The area of the connected region of the foreground target directly correlates with the physical size and potential hazard of the impurity, serving as the basis for determining whether it needs to be removed. The grayscale difference between the connected region of the foreground target and the background region directly reflects optical density. In transmission imaging, grayscale values are not simply a matter of color depth but a physical mapping of light transmittance. Bubbles, due to their internal cavity structure, allow light to partially pass through or refract, resulting in relatively high grayscale; while solid impurities, typically composed of dense materials, exhibit strong light absorption and extremely low grayscale. Obtaining these fundamental statistical quantities provides normalized data support for subsequent calculations of optical density saturation, ensuring the algorithm can adapt to detection scenarios under different lighting intensities and avoiding misjudgments caused by fluctuations in the light source.
[0041] Specifically, by statistically analyzing the gray-level distribution characteristics and geometric dimensions of the connected components of the foreground target, basic physical parameters are obtained, including: The total number of pixels within a single foreground target connected region is counted and denoted as the target area; the average gray level of all pixels within the foreground target connected region is calculated and denoted as the target gray level; the average gray level of pixels in the background region of the original oil image is calculated and denoted as the background gray level.
[0042] At this point, the target area, target grayscale, and background grayscale have been obtained.
[0043] It should be noted that in actual testing, two extreme cases are often encountered: large, shallow bubble spots and small, dark impurity particles. If only area thresholds are used for screening, small impurities will be missed; if only grayscale thresholds are used, the edges of dark bubbles may cause false alarms. Physically, the harmfulness of impurities depends on both their size and density. This invention establishes a two-dimensional evaluation index that combines the geometric quantity of area with the optical quantity of grayscale. By logarithmically compressing the area, the numerical weight of oversized bubbles is reduced, while the grayscale ratio is used as a multiplier to greatly increase the weight of highly dark objects. This mathematical construction simulates the human eye's sensitivity mechanism to glaring black spots, ensuring that even a tiny metal shaving, due to its extremely high optical density, can generate a sufficiently large energy value in the calculation results, thereby avoiding the risk of missed detection.
[0044] Preferably, based on regional grayscale contrast and geometric area, a fundamental optical density saturation energy characterizing the degree of light obstruction is constructed, including: The fundamental optical density saturation energy satisfies the following expression: ; In the formula, Indicates the saturation energy of the basic optical density; Indicates the target area; Indicates the target grayscale; Indicates the background grayscale; If it is the second smallest positive number, the denominator is guaranteed to be non-zero; This represents the natural logarithm function.
[0045] In the formula, It characterizes the relative blackness contrast of the connected components of the foreground target; The area is logarithmically compressed to prevent large bubbles from having excessive weight, and at the same time, blackness information is combined to calculate the degree to which light is physically blocked. By combining blackness contrast and area compression, the actual hazard level of the connected domain of the foreground target is assessed. The smaller, The larger the value, the stronger the absorption or blocking of light by the connected regions of the foreground target.
[0046] For example, The impurities are small and black. ,but The bubble target is large and gray. ,but . Round to two decimal places. Round to one decimal place.
[0047] Thus, the basic optical density saturation energy, which characterizes the degree of light obstruction, was obtained.
[0048] S4: Calculate the rheological weighted energy value reflecting material properties by combining the basic optical density saturation energy, the rheological characteristics and morphological characteristics of the connected domain of the foreground target; analyze the optical refraction characteristics of the connected domain of the foreground target, and calculate the refraction deviation index by combining the material energy and environmental noise; cluster all refraction deviation indices, and perform screening and elimination control based on the clustering results.
[0049] It should be noted that single features often have exceptions. For example, a cluster of extremely irregularly shaped bubbles may score highly on edge features, or a sheet-like impurity may score low on optical density. To achieve zero false alarms in industrial-grade detection, all the aforementioned dimensions—optical, geometric, and micro-textural—must be comprehensively integrated. This invention introduces the classic isoperimeter quotient formula as the morphological density gain, utilizing the geometric axiom that a circle has the shortest circumference for the same area, naturally suppressing the score of circular bubbles, and using rheological features as the gain coefficient for cascaded amplification. From a materials science perspective, the edge roughness of impurities is their most fundamental fingerprint. Through this multi-physics feature fusion, the constructed rheological weighted material energy is no longer a simple numerical value, but a highly sensitive material discriminator that can amplify the impurity signal by several orders of magnitude in the numerical space, creating a significant gap with other interference terms.
[0050] It should be noted that, from the perspective of frequency domain analysis, the contour features of an object correspond to different frequency components. Bubbles, governed by fluid dynamics, primarily exhibit low-frequency shape information in their contours, while solid impurities, governed by fracture mechanics, have edges filled with high-frequency noise and jagged edges. While time-domain eigenvalues are intuitive, they may not be sensitive enough when dealing with extremely small impurities. This invention introduces a Fast Fourier Transform (FFT) to map the edge feature sequences from the spatial domain to the frequency domain, effectively focusing these tiny, coarse signals in the high-frequency band for energy statistics.
[0051] Specifically, by combining the basic optical density saturation energy, the rheological characteristics and morphological characteristics of the connected domains of the foreground target, the rheological weighted energy value reflecting the material properties is calculated, including: Calculate the joint feature value of curvature gradient of each pixel of the edge contour of the connected domain of the foreground target, and perform fast Fourier transform to divide and extract the energy of high frequency components, which is denoted as edge rheological response feature.
[0052] The rheological weighted energy value satisfies the following expression: ; In the formula, This represents the rheological weighted energy value; Indicates the saturation energy of the basic optical density; Indicates the edge rheological response characteristics; Indicates the perimeter of the edge; Indicates the target area; It is the third smallest positive number, ensuring that the denominator is not zero.
[0053] In the formula, It is the classic isoperiod quotient formula, used as the morphological density gain coefficient. For round bubbles, this coefficient is close to 1; for impurities with irregular shapes, this coefficient is significantly greater than 1. This indicates that rheological characteristics are used as a linear gain, which, in conjunction with morphological compactness, affects... Perform cascade amplification; By combining the basic optical density saturation energy, rheological characteristics, and morphological density, the signal of impurities is amplified, while the signal of bubbles remains at a low level.
[0054] For example, for bubbles, for , for , for ,but Regarding impurities, for , , for ,but This significantly amplifies the impurity signal. , All values are rounded to one decimal place.
[0055] Thus, the rheological weighted energy value, which reflects the material properties, was obtained.
[0056] It's important to note that in transmission imaging systems, bubbles and impurities exhibit a fundamental optical difference: refraction. A bubble, a transparent sphere filled with gas, deflects light as it passes through, causing a shift in the positions of bright spots and dark rings in the image. This means its luminosity center often deviates from its geometric center. Solid impurities, on the other hand, are opaque solids, forming a silhouette due to physical occlusion, where their luminosity center coincides closely with their geometric center. This centroid shift is a unique optical characteristic of bubbles. Converting this characteristic into a distance parameter and introducing background noise as a stable term in the denominator addresses the incomparability of absolute values under different environments.
[0057] Preferably, the optical refraction characteristics of the connected domains of the foreground target are analyzed, and the refraction deviation index is calculated by combining material energy and environmental noise, including: Obtain the geometric center coordinates of the connected region of the foreground target and the gray-weighted centroid coordinates of the original oil image. Calculate the Euclidean distance between the geometric center coordinates of the connected region of the foreground target and the gray-weighted centroid coordinates of the original oil image, denoted as the refraction offset distance. Multiply the refraction offset distance by the background gray level, divide by the sum of the square root of the target area and a minimum positive number, square the result, and then add it to the square of the background noise level. Take the square root of the sum as the denominator. Use the rheologically weighted material energy as the numerator. The ratio of the numerator to the denominator is used as the refraction deviation index.
[0058] Thus, the refractive deviation index was obtained.
[0059] It should be noted that the core requirements of automated industrial production lines are the certainty of decision-making and the real-time nature of execution. Through the aforementioned calculations, this invention maps the originally blurry image features into a refraction deviation index with high discriminative power. In numerical space, normal bubbles and impurities are now clearly distinguished. At this stage, the system no longer needs to perform complex logical reasoning; it only needs to perform simple numerical comparisons. This binary decision-making mechanism, namely the K-means clustering algorithm used in this invention, not only matches the millisecond-level response requirements of the high-speed rejection mechanism but also effectively prevents actuator malfunctions caused by parameter fluctuations. This ensures that every drop of rejected oil actually contains impurities, maximizing the balance between product quality assurance and raw material loss control.
[0060] Preferably, all refractive deviation indices are clustered, and screening and elimination controls are performed based on the clustering results, including: The refractive index of each connected region of the foreground target is obtained. Cluster analysis is performed on all refractive indexes. Based on the natural distribution characteristics of the refractive index values, the connected regions of the foreground target are divided into two categories: high index clusters and low index clusters. The connected regions of the foreground target corresponding to the high index cluster are identified as solid impurities. The system immediately generates an alarm signal and drives the downstream pneumatic rejection valve to operate. The connected regions of the foreground target corresponding to the low index cluster are identified as bubbles or fluid disturbances. The system ignores these and does not perform any action.
[0061] It should be noted that, Figure 3The rheological weighted energy value analysis chart shows a comparison of energy values between typical bubbles and typical impurities, along with a detection threshold reference line. Under the same detection scenario, the rheological weighted energy value of a typical bubble is only 13.7, far below the set detection threshold. Its core parameters—edge rheological feature (8.3), morphological compactness (isope ratio = 1.1), and basic optical density (0.5)—are all at low levels, reflecting the bubble's inherent characteristics of smooth edges and weak light obstruction. In contrast, the rheological weighted energy value of a typical impurity is as high as 982.5, far exceeding the detection threshold. Its edge rheological feature (39.3), morphological compactness (isope ratio = 5.0), and basic optical density (4.0) are all significantly higher, reflecting the impurity's core characteristics of rough edges, irregular shape, and strong light obstruction. This numerical difference clearly demonstrates the technical advantage of this invention—amplifying the essential differences between impurities and bubbles through multi-feature fusion calculation. Even in complex sample tests containing irregular bubbles and tiny impurities, this energy value can still stably distinguish between the two types of targets, verifying the reliability of the logic that values below the threshold indicate bubbles and values above the threshold indicate impurities.
[0062] This completes the impurity testing of castor oil.
[0063] While various embodiments of the invention have been shown and described in this specification, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will occur to those skilled in the art without departing from the spirit and essence of the invention.
Claims
1. A method for detecting impurities in castor seed oil based on image recognition, characterized in that, include: Construct a transmission imaging acquisition environment adapted to the optical properties of oil and acquire raw images of the oil; The original oil image is preprocessed and combined with adaptive thresholding and statistical analysis to obtain the foreground target set and background noise level; Extract the contour information of the foreground target and calculate the gradient and curvature properties of the edge based on the principles of differential geometry; By fusing edge gradient and curvature information, a joint feature value of curvature gradient reflecting the morphological abrupt changes of impurities is constructed; By analyzing the gray-scale distribution characteristics and geometric dimensions of the connected components of the foreground target, basic physical parameters can be obtained. Based on regional grayscale contrast and geometric area, a basic optical density saturation energy is constructed to characterize the degree of light obstruction. By combining the basic optical density saturation energy, the rheological characteristics and morphological characteristics of the connected domains of the foreground target, the rheological weighted energy value reflecting the material properties is calculated; the optical refraction characteristics of the connected domains of the foreground target are analyzed, and the refraction deviation index is calculated by combining the material energy and environmental noise; all refraction deviation indices are clustered, and screening and elimination controls are performed based on the clustering results.
2. The method for detecting impurities in castor seed oil based on image recognition according to claim 1, characterized in that, The acquisition of the original oil image includes: A red LED backlight is installed on one side of the conveying pipe section. The light source is configured to emit narrow-band red light with a wavelength range of 620-630nm. The high penetration of this wavelength of light into yellow castor oil is used to establish a transmission light path. A high-speed industrial camera is installed on the opposite side of the conveying pipe section. The camera's optical axis is calibrated to face the backlight for transmission imaging, and the original image of the oil flow process is collected and recorded as the original oil image.
3. The method for detecting impurities in castor seed oil based on image recognition according to claim 1, characterized in that, The process of obtaining the foreground target set and background noise level includes: The original oil image is processed by Gaussian filtering. The Gaussian-filtered image is then binarized using the Otsu adaptive thresholding method, and the resulting image is denoted as the binarized image. The gray-level threshold with the largest inter-class variance in the binarized image is automatically calculated, dividing the binarized image into background and foreground regions. Connectivity analysis is performed on the foreground region to extract all independent foreground target connected components, which are denoted as the foreground target set. Simultaneously, the standard deviation of the gray-level values of all pixels in the background region is calculated and denoted as the background noise level.
4. The method for detecting impurities in castor seed oil based on image recognition according to claim 1, characterized in that, The calculation of the gradient and curvature properties of the edge includes: Extract the edge contour of any connected component of a foreground object in the foreground object set, count the number of pixels contained in the edge contour, and denote it as the edge perimeter; for the th edge contour... For each pixel, calculate its edge gradient magnitude and edge curvature. Further, calculate the arithmetic mean of the absolute values of curvature of all pixels on the edge contour, denoted as the average edge curvature.
5. The method for detecting impurities in castor seed oil based on image recognition according to claim 1, characterized in that, The joint eigenvalues of the curvature gradient satisfy the following expression: ; In the formula, Represents the joint eigenvalues of the curvature gradient; Indicates the magnitude of the edge gradient; Indicates edge curvature; Indicates the average edge curvature; It is an exponential function with the natural constant as its base; It is the first smallest positive number, and the denominator is guaranteed to be non-zero.
6. The method for detecting impurities in castor seed oil based on image recognition according to claim 1, characterized in that, The acquisition of basic physical parameters includes: The total number of pixels within a single foreground target connected region is counted and denoted as the target area; the average gray level of all pixels within the foreground target connected region is calculated and denoted as the target gray level; the average gray level of pixels in the background region of the original oil image is calculated and denoted as the background gray level.
7. The method for detecting impurities in castor seed oil based on image recognition according to claim 1, characterized in that, The fundamental optical density saturation energy satisfies the following expression: ; In the formula, Indicates the saturation energy of the basic optical density; Indicates the target area; Indicates the target grayscale; Indicates the background grayscale; If it is the second smallest positive number, the denominator is guaranteed to be non-zero; This represents the natural logarithm function.
8. The method for detecting impurities in castor seed oil based on image recognition according to claim 1, characterized in that, The rheological weighted energy value satisfies the following expression: ; In the formula, This represents the rheological weighted energy value; Indicates the saturation energy of the basic optical density; Indicates the edge rheological response characteristics; Indicates the perimeter of the edge; Indicates the target area; It is the third smallest positive number, ensuring that the denominator is not zero.
9. The method for detecting impurities in castor seed oil based on image recognition according to claim 1, characterized in that, The calculation of the refractive deviation index includes: Obtain the geometric center coordinates of the connected region of the foreground target and the gray-weighted centroid coordinates of the original oil image. Calculate the Euclidean distance between the geometric center coordinates of the connected region of the foreground target and the gray-weighted centroid coordinates of the original oil image, denoted as the refraction offset distance. Multiply the refraction offset distance by the background gray level, divide by the sum of the square root of the target area and a minimum positive number, square the result, and then add it to the square of the background noise level. Take the square root of the sum as the denominator. Use the rheologically weighted material energy as the numerator. The ratio of the numerator to the denominator is used as the refraction deviation index.
10. The method for detecting impurities in castor seed oil based on image recognition according to claim 1, characterized in that, The clustering of all refractive deviation indices includes: The refractive index of each connected region of the foreground target is obtained. Cluster analysis is performed on all refractive indexes. Based on the natural distribution characteristics of the refractive index values, the connected regions of the foreground target are divided into two categories: high index clusters and low index clusters. The connected regions of the foreground target corresponding to the high index cluster are identified as solid impurities. The system immediately generates an alarm signal and drives the downstream pneumatic rejection valve to operate. The connected regions of the foreground target corresponding to the low index cluster are identified as bubbles or fluid disturbances. The system ignores these and does not perform any action.
Citation Information
Patent Citations
Visual inspection method for edible oil impurities
CN107316297A
Hydraulic oil impurity identification method based on machine vision
CN116597392A
Raw oil impurity detection method based on machine vision
CN116862912A
PCBA board defect detection method and system based on image processing
CN120823430A