Research on image recognition and detection method of sapphire bubbles

Sapphire crystals are used in the manufacture of LEDs, optical window materials, etc. The presence of air bubbles in the crystal affects the optical properties of the material. If the position of the bubble is determined, the bubble can be bypassed for subsequent slicing to obtain pure high quality sapphire crystal. At present, the detection and identification of bubbles in sapphire crystals still rely on human eye observation and empirical judgment, which is inefficient and easily harmful to the human eye. It is necessary to propose a highly efficient method of machine vision detection instead of human eye detection. Based on the machine vision detection technology, this paper uses the laser as the light source to enter the ingot from the bottom, which produces the laser scattering effect. With this effect as the imaging principle, the image is collected by CCD . The image is analyzed by image processing means to achieve detection of bubbles, this paper proposes and elaborates the following two steps: edge detection based on edge pixels and locking the target area based on the calibration connected domain. The experimental results show that compared with the human eye detection method, the detection method greatly improves the detection rate and accuracy of identifying the bubble in the sapphire and determining its position.

: Sapphire crystals are used in the manufacture of LEDs, optical window materials, etc. The presence of air bubbles in the crystal affects the optical properties of the material. If the position of the bubble is determined, the bubble can be bypassed for subsequent slicing to obtain pure high quality sapphire crystal. At present, the detection and identification of bubbles in sapphire crystals still rely on human eye observation and empirical judgment, which is inefficient and easily harmful to the human eye. It is necessary to propose a highly efficient method of machine vision detection instead of human eye detection. Based on the machine vision detection technology, this paper uses the laser as the light source to enter the ingot from the bottom, which produces the laser scattering effect. With this effect as the imaging principle, the image is collected by CCD. The image is analyzed by image processing means to achieve detection of bubbles, this paper proposes and elaborates the following two steps: edge detection based on edge pixels and locking the target area based on the calibration connected domain. The experimental results show that compared with the human eye detection method, the detection method greatly improves the detection rate and accuracy of identifying the bubble in the sapphire and determining its position.

K
: Detection of defects; Image processing; Data analysis; Radiation and optical windows 1Corresponding author.

Introduction
Sapphire is the key material for making LED lamps [1]. It is also an important window material for infrared military equipment, satellite space technology [2], and high-intensity laser [3]. Cutting sapphire ingots is a very important process step in material manufacturing. Whether sapphire ingots contain bubbles and the position of bubbles directly affects the cutting of sapphire crystals and the quality of products, therefore the testing of sapphire bubbles' positions can reduce production costs and increase rate of finished products [4]. In recent years, machine vision has been widely used in industry [5][6][7], agriculture [8], medicine [9], military testing [10] and other fields. Because machine vision technology has the advantages of high detection accuracy and fast detection rate in defect detection, this paper will make use of machine vision to realize the detection of sapphire bubbles. The current technology is still manual detection, that is, the green laser is used to illuminate the sapphire ingot, and the position of the bubble is observed by the eye to complete the detection of the bubble in the whole sapphire [11]. In order to improve the detection rate and detection precision of the bubbles in the sapphire ingot, and to liberate the labor force, this paper makes use of the machine vision detection method to detect the bubbles of the sapphire crystal rods. The detection method applies a high power green laser to illuminate the sapphire ingot to produce the light scattering effect. The scattered light is detected by a color CCD camera and then transmitted to a computer [12]. The image is extracted and analyzed by image processing methods such as image filtering, image segmentation, image enhancement and image feature extraction. First, the specific explanation of the principle of light scattering effect imaging is elaborated, and the selection of the light source is determined in this paper; then, the obtained sapphire crystal bubble image is subjected to median filtering, binarization filtering and dilating ("grow" or "roughen" objects in the binary image), and then the edge detection method based on edge pixels is used to find and -1 -calibrate a plurality of connected domains to remove the light source from both ends of the ingot and achieve a lock on the position of the bubble or group of bubbles from the resulting spots; finally, the sapphire crystal rod samples are detected by the above method, and the reliability and feasibility of the research method in this paper are verified according to the detection accuracy. This test combines the light scattering effect method and the machine vision method produced by high power green laser irradiation, which not only realizes the determination of the bubble position in the sapphire ingot, but also greatly improves the detection efficiency and detection accuracy, and greatly liberates the labor force. The remainder of the paper organization is shown as follows: the section 2 presents light scattering effect imaging principle and determination of the wavelength of the light source. The section 3 provides the analyzation of image processing. The section 4 shows the result and analyzation to verify the realiability and accuracy of the machine vision detection method. The section 5 gives the overall conclusion.

Light scattering effect imaging principle
The background of the detection method proposed in this paper is the darkroom environment, which avoids unnecessary background interference with sunlight. So it is not necessary to use pulsed laser, and continuous laser is selected [13]. The detection method utilizes the principle of light scattering effect imaging, that is, the laser is transmitted to the target to be measured, the target is irradiated, and the laser scattered by the target is returned to the camera to form an image to be tested.
Optically, sapphire crystals are translucent materials. The structure of the material itself and the bubbles contained in it are scattering centers, which cause considerable light attenuation. Therefore, an effective and high-power laser source is necessary for detecting sapphire crystal bubbles. Since it is desirable to receive photons from the illumination area as much as possible in order to increase the signal-to-noise ratio, the laser source must illuminate the entire target to be measured, so the laser source must have high energy and high power [14].
The degree of light propagation and attenuation can only be analyzed using the absorption and scattering properties of sapphire crystals. The maximum propagation through the sapphire crystal has only a very narrow window in the green portion of the spectrum. From the transmission spectrum of the sapphire crystal and the transmission spectrum of the visible spectrum of the sapphire crystal, the wavelength near 530 nm matches the absorption characteristics of the sapphire crystal. In summary, this paper selects high-power green continuous laser as the detection source of this detection method.

Light scattering effect
In the medium with uniform optical properties or at the interface of two uniform media with different refractive indices, regardless of the collineation, reflection or refraction of light, it is limited to certain directions, while in other directions the light intensity is equal to zero. Light should not be visible when viewed from the side of the beam. But when the beam passes through a substance that is not optically homogeneous, light can be seen from the lateral direction. This phenomenon is called scattering of light. Scattering will weaken the light intensity of the original direction of propagation, and it follows the following exponential law [15]:

JINST 14 P12013
Where α a is the absorption coefficient and α s is the scattering coefficient. The d is the transmission distance of the incident light in the medium. The I 0 is the initial light intensity emitted by the laser source. The sum α of the two is called the attenuation coefficient, which is characterized by the extent to which the light intensity is attenuated by the combined action of absorption and scattering of the medium as it passes through the medium.
Unevenness of the optical properties of the substance is caused by a large amount of fine particles in which a uniform substance is dispersed with other substances having a refractive index different from it, or due to irregular aggregation of constituents (particles) of the substance itself.
According to the size relationship between the particle size of the scattering material and the wavelength of the light, we divide the scattering of light into Rayleigh scattering and Mie scattering or macromolecular scattering [16]. The phenomenon of scattering of incident light by particles having a size smaller than the wavelength of light is generally referred to as Rayleigh scattering, and the scattering of incident light by particles having a size greater than or equal to the wavelength of light is generally referred to as Mie scattering or macromolecular scattering.
The characteristic of sapphire crystals is that the crystallinity of the crystal structure particles is generally shorter than the wavelength of light and the distance between adjacent particles is longer than the wavelength and they are with the irregular arrangement. Therefore, their vibrations under the action of light have no fixed phase relationship with each other. At any observation point, we always see the incoherent superposition of the secondary radiation they emit, and they will not disappear everywhere, thus form scattering light. The substantial scattering of the sapphire crystal rod belongs to Rayleigh scattering [17]. If the distribution of incident light intensity by wavelength can be expressed by f (λ), the intensity of the scattered light is in the form of f (λ) λ −4 , which is the conclusion of Rayleigh's precise study of particle scattering. The relationship between the intensity of this scattered light and the fourth power of the wavelength is called Rayleigh's law. It can be used as a preliminary explanation by the intensity formula (2.2) of the scattering center generated by the scattered center under the action of the incident light. When viewed in a direction at an angle θ to the x-axis as shown in figure 1, the intensity of the scattered light is proportional to the fourth power of the vibration frequency. Since the frequency of the forced vibration is the same as the frequency of the incident light, the intensity of the secondary wave (which is superposed as scattered light) is inversely proportional to the fourth power of the incident light wavelength. -3 -Scattered light intensity in the CO direction [18]: In the above formula, R represents the distance from the observer to the scattering center. The intensity of side scattered light is inversely proportional to λ 4 , which is The refractive index of the bubble or group of bubbles inside the sapphire ingot is different from the refractive index of the sapphire crystal. Bubble and bubble groups exist in an irregular shape in a certain region, therefore also form scattered light different from the essence of the sapphire ingot. The Mie scattering theory is an exact solution of the uniform spherical particles derived from Maxwell's equations to the scattering of plane waves in an electromagnetic field. The scattering caused by the particles whose particle diameter is equivalent to the wavelength of the incident light is generally called Mie scattering. Mie scattering is suitable for any particle scale, but uses Rayleigh scattering when the particle diameter is small relative to the wavelength.
The scattering of bubbles or bubble group impurities in a sapphire ingot belongs to Mie scattering or macromolecular scattering. Since the size of the particles can be even larger than the wavelength, the phase of the incident wave is non-uniform on the particles, causing the phase difference of each wavelet in space and time. Where a phase difference occurs, interference will occur. These interferences depend on the wavelength of the incident wave, the size of the particles, the refractive index, and the scattering angle. As the particles increase, the interference that causes the change in the scattering intensity also increases. Therefore, the relationship between the scattered light intensity and these parameters is not as simple as Rayleigh scattering, but is represented by a complex series. In 1908, Mie solved a strict solution to light scattering through the Maxwell equation of electromagnetic waves, and obtained the scattering law of uniform particles of arbitrary diameter and arbitrary composition, which is the famous Mie theory. The scattered light intensity is [19]: 2n + 1 n (n + 1) g n (a n τ n + b n π n ) 2 (2.4) The intensity of side scattered light is proportional to λ 2 , which is From the above equations, it can be seen that for the incident light of the same wavelength, the scattered light intensity of the sapphire crystal is significantly different from the scattered light intensity of the bubble or the bubble group impurity. Their scattered light is taken up by a CCD camera, and the image is expressed as the difference in the brightness of a sapphire crystal and an internal bubble or a bubble group impurity, which is, the light scattering effect imaging.

Determination of the wavelength of the light source
Theoretically, as analyzed by section 2.1, the scattered light intensity difference between the sapphire crystal substance and the bubble impurity increases as the wavelength λ of the incident light -4 - increases. When λ is large enough, the scattered light intensity difference will take a large value, then the difference in brightness characteristics of the sapphire crystal and the bubble impurity will be obvious in the scattered light image captured by the CCD camera. This is what we want the result of. But in fact, the scattered light intensity of the sapphire crystal obeys I (λ) ∝ 1/λ 4 . If λ takes a large value, the scattered light intensity of the sapphire crystal will become very weak, which is caused by the transmission spectrum window restrictions of the sapphire crystal [20]. As shown in figure 2, in the optical band with a wavelength greater than 4 µm, the transmittance of the sapphire crystal drops sharply, the light captured by the CCD camera is drastically reduced, and the signal-to-noise ratio of the resulting image becomes too small to be detected [21]. Considering that we are testing bubbles in sapphire crystals, it is not enough to simply select the high transmission band of the sapphire crystal. Therefore, we also need to compare the transmittance of light in the bubble to find the best detection band.
The formation process of bubbles contained in the sapphire crystal is: during the crystal growth process, as the solid-liquid interface changes, the gas dissolved in the melt is excluded from the solid-liquid interface, but if the crystal growth rate is too fast and the gas is too late to diffuse, the gas will be trapped and wrapped into the crystal from the solid-liquid interface [22]. After the detection source illuminates the sapphire crystal, the light passing through the bubble impurity is derived from the transmitted light of the laser irradiation and the scattered light of the surrounding sapphire crystal, and the transmittance of the laser in the colorless gas is close to 100% [23], so the bubble impurity light is stronger than the sapphire crystal [24].
From the cost and condition of the imaging device, we give priority to the study of the visible light band. It can be seen from figure 2 that the transmittance of sapphire crystal is greater than 85% in the visible range of 0.3-0.8 µm. For this band, we need to conduct a more detailed study of transmittance. As shown in figure 3, it shows the transmission spectrum of the sapphire crystal in the visible light band [25], which is a spectral amplification of the 0.3-0.7 µm band in figure 2. It can be seen from figure 3 that the sapphire crystal has a narrow valley between the wavelength range of 490-550 nm, and this band corresponds to the green light band. In the visible light band, the difference between the sapphire crystal substance and the bubble impurity scattering intensity corresponding to this band takes a maximum value, so light with a wavelength around 530 nm can be used as the optimum wavelength band of the laser source. In the experiment, we used a 532 nm laser source as the detection source.

Detection image acquisition
The selection of the light source and the imaging principle have been discussed in the second section. Here we study and analyze the positional relationship between the light source and the CCD camera. Requirements for the positional relationship between the light source and the CCD camera: always keep the incident light, the capture plane of the camera, and the axial direction of the sapphire ingot horizontally. We built an image acquisition experiment platform as shown in figure 4. The position of the light source and the CCD camera were set according to the above requirements, and the laser source, the object to be tested, and the CCD camera were placed in a black paint-coated black box. When acquiring images, we need to close the darkroom door to create a dark environment for image acquisition, thus reducing the interference of the background environment. The laser source is turned on and off directly by the laser source's on-off control, and the CCD camera is turned on and off and the shooting parameters are controlled by a computer. The detected image acquired by the CCD camera will be transferred to the computer and saved in the specified file [26].
The light source enters and exits the sapphire ingot to create two spots on both ends of the sapphire ingot. If the incident light, the capture plane of the camera, and the axial direction of the sapphire ingot remain horizontal, the line of the two source spots coincides with the incident ray, and the distance between the two bright spots is only related to the perimeter of the ingot and the image size. Therefore, the position of the two bright spots can be used as the reference position of the detected image. If the upper side of the sapphire crystal in figure 5(a) is used as the reference position, since the incident light is not parallel to the capturing plane, the reference position is distorted, so its size is unreliable.
The image of the target that we capture with a CCD camera usually includes: a darkroom environment background, a sapphire crystal rod background, and a bubble or bubble group in the sapphire crystal rod. For the dark room environment background and the sapphire crystal rod -6 -  background, we use image processing methods to remove these two parts as much as possible [27]. If there are bubbles in the sapphire crystal rod, then there are two states in the remaining part: a single bubble and a group of bubbles composed of many bubbles. Therefore, there are three types of images of the detection target captured by the CCD camera: no bubbles, single bubbles, and bubble groups, as shown in figure 5. For better readers' observation, we use a red circle to mark the individual bubbles in the sapphire crystal, and mark the contained bubble group with a yellow circle, as shown in figure 5: the sapphire ingot in figure 5(a) has two groups of bubbles of different sizes; the sapphire ingot in figure 5(b) contains a single bubble with a small diameter; the sapphire crystal in figure 5(c) has -7 -no bubbles. Next, we will introduce the image processing analysis process of the bubble group in detail. The processing analysis process of the other two types of detection images is also consistent. If there are no bubbles in the sapphire crystal, we do not need to determine the position of the bubble.

Image Processing Process
The processing flow of the captured image is as shown in figure 6, and the color image to be detected is converted into a grayscale image before image processing. The image to be detected is subjected to median filtering to remove the laser speckle, the appropriate threshold is selected according to the histogram for binarization and the binarized image is dilated. The above three steps are the basic operational steps in the image processing method [28]. According to the gray image in figure 7(a), we can see that the pixel area occupied by the darkroom background and the substantial part of the sapphire crystal (the part without the spot) occupy a larger pixel area, but the pixel area of bright spot portion (source spot and bubble spot) is relatively small. The gray levels of the three are increased in turn. Corresponding to the gray histogram of figure 7(b), the larger intervals of the first two peaks correspond to the darkroom environment and the substantial part of the sapphire crystal respectively, and the part with the gray level of more than 145 corresponds to the bright spot portion. According to the above analysis, we take a threshold value of 0.57 to binarize the grayscale image, thereby removing the background portion of the darkroom and the substantial portion of the sapphire crystal, leaving only the bright spot portion, as shown in figure 7(c).
One of the simplest applications of dilation is bridging cracks, which "grow" or "roughen" objects in a binary image, thereby joining discrete pixels into a single area [29]. The dilation in this paper, on the one hand, causes the light source spot and the sparse small spot around it to form a connected domain to eliminate the light source spot in the latter stage, and on the other hand, the discrete bubble group spot forms a connected domain, so as to later perform the overall operation of the connected domain of the bubble group. The result of the detected image being expanded is shown in figure 7(d). As shown in figure 7(c), the image includes light source spots and bubble spots. The light source spot is surrounded by sparsely scattered small spots, and the bubble spot is discrete and sparse. If each pixel is processed separately, the operation is complicated and wastes time. Therefore, it is very necessary to form the source spot and the bubble spot respectively into a connected domain and to perform overall processing on the pixel set in the connected domain. For the last three steps of the image processing flow, we propose a ROI detection method based on edge pixels. By using the method to find the connected domain, it is not necessary to determine each pixel in the connected domain, and only edge pixels of the connected domain need to be detected to determine a connected domain. This greatly saves the running time of the program and improves the detection efficiency. Next, the ROI detection method based on edge pixels is introduced in detail. Figure 8 is a schematic diagram of the target boundary area. When performing the ROI detection, the lower left corner of the edge map is taken as the origin o, and the right and upward directions are the positive direction of the y-axis and the positive direction of the x-axis, respectively. The initial coordinate O is (0,0), and the specific processing flow is as figure 9.   For a detected continuous boundary region, the edge pixels Q 1 , Q r , Q 1 1 , Q 1 r , . . . Q m 1 , Q m r belong to the boundary pixel of the boundary region, and constitute a boundary chain of the connected domain. Use this boundary chain to determine the area where the connected domain is located and calibrate its attributes. After finding the connected domain, we will macro programming the connected domain. First, use the found edge pixel to find the center of the connected domain. The -10 - formula for the center is Where n is the number of edges of a connected domain edge, x 1 , x 2 , . . . x n are the abscissas of the respective edge pixel points, and y 1 , y 2 , . . . y n are the ordinates of the respective edge pixel points. Next, find the distance from each edge pixel of the connected domain to the center according to the following formula: The information about the connected fields obtained above is stored in the form of a matrix in a specified file for direct invocation during the last two steps of the image processing flow.
As shown in figure 7(d), the light source spots are located near both ends of the bottom surface of the sapphire crystal rod, and correspond to the connected domains at the left and right ends of the image detected, therefore, in the two connected domains, the connected domain on the left has the smallest abscissa and the connected domain on the right has the largest abscissa.
In the above formula, Q L and Q R respectively represent the central pixel points of the connected domains corresponding to the two light source spots, and k is the number of connected domains in the detected image subjected to the expansion processing. According to the above formula, macro programming of figure 7(d) is performed, and the connected domain where the light source spot is located is removed as a whole, and the result is as shown in figure 10(a). The remaining connected -11 -

JINST 14 P12013
domains are the connected domains where the bubble or the bubble groups are located. In order to easily observe the position of the bubble or bubble group, we set the locking circle. The center of the locking circle is the center of the connected domain where the bubble spot is located. The radius of the locking circle is the maximum distance from the center to the edge of the connected domain. This distance is represented by the formula (3.4).
Call the relevant data to set the lock circle and mark the bubble spot as shown in figure 10(b). Then we can use the locked circle directly in the original image to fix the position of the bubble or bubble group, as shown in figure 10(c).

Experimental results and analysis
The 100 sapphire crystal rod samples used in the experiment were marked by multiple inspections by 10 experienced workers, including 50 bubble-containing samples and 50 bubble-free samples.
The 100 samples were mixed and then re-sorted, and a single test was performed on the samples by using the machine vision detection method and a worker's master.
The data such as test results and detection time are read into the computer memory and compared with the human eye detection method, so that the machine vision detection method of this paper has certain effectiveness and practicability in the detection effect. The worker master missed a total of 12 pieces using the traditional human eye detection method, and it took nearly 2 hours to test 100 samples. A total of 5 pieces were missed using the machine vision inspection method in this paper, which took 30 minutes. The results of the machine vision inspection method are shown in figure 11.
In the above figures, the abscissa indicates the order of arrangement of 100 samples. The scale values of the ordinate are 0 and 1, which indicate that the corresponding sample contains no bubbles and bubbles. The circle mark indicates the status of 100 samples.
According to the experimental results of figure 10, the detected data is statistically summarized. The manual detection method and the machine vision detection method are compared from the aspects of the erroneous detection rate and the detection speed. The comparison results are shown in table 1.
In table 1, the number of erroneous detections means that the presence of bubbles in the sapphire ingot sample is incorrectly detected, that is, the sample of the sapphire crystal ingot containing bubbles is judged to be free of bubbles, and the sample of the sapphire crystal in which the bubble is not contained is judged to contain bubbles. In the two detection methods, the sample  containing bubbles is judged as not containing bubbles, and the sample without bubbles is not misjudged as containing bubbles; the erroneous detection rate means that the number of erroneous detections accounts for the total number of samples originally belonged to the sample, which is the ratio of the number of erroneous detections to 50; the detection rate is the average time taken to detect each sample, the unit is Min/.

JINST 14 P12013
The above experimental content shows that the machine vision detection method proposed in the present paper can detect whether or not bubbles are contained in the sapphire ingot. And compared with the manual detection method, it is proved that the machine vision detection method has superiority in detection accuracy and detection rate. Next, we will further explain that the machine vision detection method can not only determine whether the sapphire crystal contains bubbles, but also determine the location of the bubble or bubble group.
By locking the position of the bubble spot in the detected image, guiding us at what position to cut the sapphire ingot, it is necessary to determine the relationship between the position of the bubble in the actual position and the position at which the bubble is locked in the image.
The axial length of each sapphire crystal rod sample to be tested is determined, denoted as L, which corresponds to the distance between the centers of the left and right light source spots in the detected image, denoted as l.
Where x L and x R respectively represent the abscissa of the center of the left source spot and the abscissa of the center of the right source spot, the unit is pixels. The distance between the center of the bubble spot and the center of the left source spot is expressed by Where x Bubble is the abscissa of the center of the bubble spot. From the equations (4.1) and (4.2), the specific position at which the sapphire ingot is cut can be deduced, that is, the portion containing the bubble or the group of bubbles is cut off by two planes perpendicular to the axial direction of the sapphire ingot.
In the above formula, S L and S R are the positions for cutting the sapphire ingot, respectively, corresponding to the length of the left side of the bubble or bubble group from the left side of the sapphire ingot, the unit is cm. After testing 100 sapphire crystal rod samples using the machine vision inspection method in this paper, 45 samples of sapphire crystal rods containing bubbles were correctly detected. According to the number of locked circles in the detected images of the 45 samples, the 45 samples are divided into three categories: the number of locked circles is 1, the number of locked circles is 2, and the number of locked circles is greater than 2. They contain 11 samples with a locked circle number of 1, 15 samples with a locked circle number of 2, and 19 samples with a locked circle number greater than 2. All detected images have the same size 2976 (H) × 3968 (V) pixels, and we only need to study the pixel position in the horizontal direction of the image, the coordinate of the position varies from 1-2976.
According to table 2, we can cut 11 samples with a locked circle. Remove the part between S L and S R .
According to table 3, we can cut 15 samples with two locking circles. The position of the locked circle at the center of X Bubble1 corresponds to S L1 and S R1 , and the position of the locked circle at the center of X Bubble2 corresponds to S L2 and S R2 . If S L2 -S R1 ≥ 2 cm, the cutting position is S L1 , S R1 , -14 - S L2 and S R2 , and the two parts corresponding to the interval [S L1 , S R1 ] and the interval [S L2 , S R2 ] are removed; if S L2 -S R1 < 2 cm, the cutting position is S L1 and S R2 , the part corresponding to the [S L1 , S R2 ] section is completely removed. The last 4 columns of table 3 only indicate the cutting position. For 19 samples containing more than two locked circles, it will be judged as a severe defective product, and it is not necessary to cut it, and it needs to be returned to the furnace.

Conclusion
Sapphire crystals are used in the manufacture of LEDs, optical window materials, etc. Cutting sapphire ingots is a very important process step in material manufacturing. Whether sapphire -15 -ingots contain bubbles and the position of bubbles directly affects the cutting of sapphire crystals and the quality of products. This paper proposes a machine vision detection method, which replaces the current manual detection method to detect whether a sapphire crystal rod contains bubbles and determine the position of the bubbles. This method mainly studies the selection of light source, the imaging principle, the acquisition of detection images and the processing and analysis process of images. In the process of image processing and analysis, an edge pixel-based ROI detection method is proposed to remove the light source spot and lock the bubble spot in the detected image, and then to determine whether or not the sapphire ingot contains bubbles and the location of the bubble or group of bubbles. The experimental results show that the machine vision detection method of this paper not only greatly liberates the labor, but also has obvious advantages in detection accuracy and detection efficiency.