Image segmentation method for deflection imaging effective area, medium and equipment
By generating phase-shifted fringe patterns and calculating grayscale distribution features and background light intensity weight matrices, the problems of distorted coding region segmentation and cumbersome threshold parameter tuning are solved, achieving stable and accurate segmentation under different lighting conditions.
Patent Information
- Application Number
- CN202511039402.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-28
- Publication Date
- 2025-11-18
AI Technical Summary
In existing technologies, coding region segmentation methods suffer from edge segmentation distortion and cumbersome threshold parameter tuning, resulting in insufficient contrast in the coding region and an inability to segment quickly and accurately.
By generating several phase-shifted fringe patterns and projecting them onto the object surface, a sinusoidal fringe grating image is acquired. The gray-level distribution characteristics and background light intensity weight matrix are calculated, the modulation intensity map is updated, and the image segmentation threshold is determined for binary segmentation to enhance the contrast between the coded region and the background.
It improves measurement stability and segmentation accuracy under different lighting conditions, ensures stable and reliable measurement results under different lighting conditions, and solves the problems of insufficient contrast in the coding region and difficulty in determining the threshold.
Smart Images

Figure CN120976253A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to an image segmentation method, medium, and device for effective deflection imaging regions. Background Technology
[0002] In the field of mirror defect detection, phase deflection (PMD) possesses significant research value and application potential due to its advantages such as full-field measurement, non-contact operation, and high sensitivity. By analyzing the phase distortion information of the reflection grating, it can achieve sub-micron level surface topography reconstruction, providing technical support for high-precision quality inspection of mirror objects. Within the PMD system, the segmentation quality of the effective coding region has a crucial impact on data processing efficiency and 3D reconstruction accuracy.
[0003] Current mainstream coding region segmentation methods are based on N-step phase-shifting gratings to solve the modulated intensity map and employ a fixed threshold binarization strategy. This method has significant drawbacks: on the one hand, the gradient of the modulated intensity map is discontinuous due to abrupt changes in surface curvature and scattering noise coupling in scene edge regions, which easily leads to edge segmentation distortion; on the other hand, differences in the reflective properties of object materials under different scenes, fluctuations in the lighting environment, and mismatches in the nonlinear response of the system cause significant drifts in the dynamic range and grayscale distribution characteristics of the modulated intensity map. The fixed threshold strategy requires frequent manual parameter tuning to find the optimal threshold, which is very cumbersome and unstable in practical engineering applications.
[0004] Therefore, how to improve the insufficient contrast between the coded and non-coded regions in existing technologies, and the inability to quickly determine the optimal segmentation threshold, which leads to the inability to quickly and accurately segment the coded region, are technical problems that urgently need to be solved in this field. Summary of the Invention
[0005] Based on this, the purpose of this application is to provide an image segmentation method, medium, and device for the effective region of deflection imaging, so as to solve at least one of the technical problems mentioned in the background art.
[0006] Firstly, this application provides an image segmentation method for the effective region of deflection imaging, including:
[0007] Several phase-shifted fringe patterns are generated and projected onto the object surface. Several sinusoidal fringe grating images are obtained by acquiring the current object surface image.
[0008] The gray-level distribution features between each sinusoidal fringe grating image are obtained to obtain the initial modulation intensity map;
[0009] The background light intensity weight matrix is calculated based on each sinusoidal fringe grating image. The initial modulation intensity map is then updated based on the background light intensity weight matrix to obtain the final modulation intensity map.
[0010] Determine the image segmentation threshold, and perform binary segmentation on the final modulation intensity map based on the image segmentation threshold to obtain the effective region of deflection imaging.
[0011] Further, the step of obtaining the gray-level distribution features between each sinusoidal fringe grating image to obtain the initial modulation intensity map includes:
[0012] Using any pair of sinusoidal fringe grating images as initial image pairs, and determining the target image pair based on the phase difference between each initial image pair;
[0013] Based on the phase difference, the gray-level distribution characteristics between each target image pair are obtained, and the absolute gray-level difference between the target image pairs is calculated to obtain several difference maps;
[0014] By superimposing and summing the difference maps, the initial modulation intensity map is obtained.
[0015] Furthermore, the step of determining the target image pair based on the phase difference between each initial image pair includes:
[0016] Obtain the phase difference between each pair of sinusoidal fringe grating images in the initial image pair, and obtain the absolute phase difference between each phase difference and the preset standard value;
[0017] The initial image pairs are sorted according to the absolute difference of each phase, and the initial image pairs with a preset number of pairs are selected as the target image pairs in sequence.
[0018] Furthermore, the method of superimposing and summing the difference maps to obtain the initial modulation intensity map includes:
[0019] The weights of each target image pair are calculated based on the absolute phase difference of each target image pair.
[0020] The initial modulation intensity map is obtained by summing the difference maps of each target image pair according to their weights.
[0021] Further steps to obtain the final modulation intensity map include:
[0022] Obtain the average pixel value of the corresponding pixels in all sinusoidal fringe grating images, and construct the background light intensity weight matrix;
[0023] The background light intensity weight matrix is normalized to obtain the optimized weight matrix;
[0024] The initial modulation intensity map is weighted according to the optimized weight matrix to obtain the final modulation intensity map.
[0025] Further steps in determining the image segmentation threshold include:
[0026] Determine whether the background area in an image of an object's surface is a light-sensitive area;
[0027] If so, then:
[0028] The grayscale values of each pixel in the final modulation intensity map are counted to obtain the initial grayscale histogram;
[0029] Gaussian filtering is applied to the initial histogram to obtain an optimized histogram;
[0030] Obtain the horizontal coordinates of the valleys between the two peaks of the optimized histogram to obtain the image segmentation threshold;
[0031] If not, then:
[0032] Obtain the preset segmentation threshold as the image segmentation threshold.
[0033] Furthermore, the step of performing binary segmentation on the final modulation intensity map based on the image segmentation threshold to obtain the effective region of the deflection imaging includes:
[0034] The final modulation intensity map is binary segmented according to the image segmentation threshold to obtain a binary mask;
[0035] The effective area for deflection imaging is obtained based on a binary mask.
[0036] Further, the step of performing binary segmentation on the final modulation intensity map based on the image segmentation threshold to obtain a binary mask includes:
[0037] The final modulation intensity map is binary segmented according to the image segmentation threshold to obtain the first binary mask;
[0038] Several updated phase-shift fringe patterns are generated according to a set angle. The updated image segmentation threshold and the final modulation intensity map are obtained according to each updated phase-shift fringe pattern. The updated final modulation intensity map is then binary segmented according to the updated image segmentation threshold to obtain the second binary mask.
[0039] Perform a pixel-by-pixel OR operation on the first and second binary masks to obtain the final binary mask.
[0040] Secondly, this application also provides a computer storage medium storing executable program code; the executable program code is used to execute the image segmentation method for the effective region of deflection imaging as described in any one of the first aspects.
[0041] Thirdly, this application also provides a terminal device, including a memory and a processor; the memory stores program code executable by the processor; the program code is used to execute the image segmentation method for the effective region of deflection imaging as described in any one of the first aspects.
[0042] This invention provides an image segmentation method, medium, and device for the effective region of deflection imaging. It generates several phase-shifted fringe patterns and projects them onto an object surface, acquiring current object surface images to obtain several sinusoidal fringe grating images. By obtaining object surface information from different phase angles, rich data is provided for subsequent accurate measurements. Then, the gray-level distribution characteristics between each sinusoidal fringe grating image are acquired to obtain an initial modulation intensity map. Temporal difference technology is used to effectively extract the modulation information of the sinusoidal fringes, and the difference between different phase-shifted images is calculated to enhance the contrast between the modulation region and the background. A background light intensity weight matrix is then calculated based on each sinusoidal fringe grating image to update the initial modulation intensity map, resulting in a final modulation intensity map. By calculating the background light intensity weight matrix, the background light intensity distribution on the object surface can be accurately modeled, reflecting the reflective characteristics of the object surface and ambient lighting conditions, improving robustness to changes in illumination, and ensuring stable and reliable measurement results under different lighting conditions. Finally, an image segmentation threshold is determined, and the final modulation intensity map is binary-segmented based on the image segmentation threshold to obtain the effective region of deflection imaging. This technology solves the problems of insufficient contrast between the encoded and non-encoded regions in existing technologies, and the inability to quickly determine the optimal segmentation threshold, which leads to the inability to quickly and accurately segment the encoded region. Attached Figure Description
[0043] Figure 1 This is a flowchart of the image segmentation method for the effective region of deflection imaging according to an embodiment of the present invention;
[0044] Figure 2 This is a schematic diagram of a sinusoidal fringe grating image with four-step phase shifting according to an embodiment of the present invention.
[0045] Figure 3 This is a schematic diagram illustrating the principle of contrast enhancement in the coding region according to an embodiment of the present invention;
[0046] Figure 4 This is a schematic diagram of the final modulation intensity map in an embodiment of the present invention;
[0047] Figure 5 This is a schematic diagram of an optimized histogram according to an embodiment of the present invention;
[0048] Figure 6 This is a schematic diagram of the final binary mask in an embodiment of the present invention. Detailed Implementation
[0049] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0050] It should be noted that if the embodiments of the present invention involve directional indications, such as up, down, left, right, front, back, etc., these directional indications are only used to explain the relative positional relationships and movement of the components in a specific posture. If the specific posture changes, the directional indications will also change accordingly. Furthermore, if the embodiments of the present invention involve descriptions such as "first," "second," "S1," "S2," "step one," "step two," etc., these descriptions are for descriptive purposes only and should not be construed as indicating or implying their relative importance, or implicitly indicating the number of technical features indicated or the order of method execution. Those skilled in the art will understand that anything that does not violate the inventive concept and is within the scope of the present invention should be included in the protection scope of the present invention.
[0051] like Figure 1 As shown, this invention provides an image segmentation method for the effective region of deflection imaging:
[0052] S1: Generate several phase-shifted fringe patterns and project them onto the object surface; acquire the current object surface image to obtain several sinusoidal fringe grating images.
[0053] Specifically, optional but not limited to using electronic devices to generate several phase-shifted fringe patterns, which are then sequentially projected onto the object's surface via a display device. Reflection data from the current object's surface is then collected to obtain several images of the current object's surface, which are sinusoidal fringe grating images. Taking a four-step phase shift as an example, four sinusoidal fringe grating images can be obtained, such as... Figure 2 As shown. More specifically, the electronic device may be, but is not limited to, a computer, mobile phone, tablet, or other device capable of processing complex computing tasks; the display device may be, but is not limited to, a projector, display screen, or other device capable of generating or displaying patterns; more specifically, the number of phase-shifting fringe patterns and the projection frequency may be arbitrarily set by those skilled in the art. Preferably, the number of phase-shifting fringe patterns is not less than three.
[0054] S2: Obtain the grayscale distribution features between each sinusoidal fringe grating image to obtain the initial modulation intensity map;
[0055] Specifically, but not limited to, obtaining the gray-level distribution features of each pixel in each pair of sinusoidal fringe grating images to obtain several image pairs, obtaining the absolute gray-level difference between each image pair, and obtaining the difference map between each image pair. Through difference calculation, the coded region is highlighted and the gray-level value of the non-coded region is reduced to enhance the contrast between the coded region and the non-coded region. Then, all difference maps are superimposed and summed to obtain the initial modulation intensity map to reflect the changes on the object surface.
[0056] Preferably, the step of obtaining the gray-level distribution features between each sinusoidal fringe grating image to obtain the initial modulation intensity map may include:
[0057] S21: Using any two pairs of sinusoidal fringe grating images as initial image pairs, and determining the target image pair based on the phase difference between each initial image pair;
[0058] Specifically, in the N-step phase shift, as the number of phase shift fringe patterns changes, the phase difference between each pair of sinusoidal fringe grating images may change, and the corresponding grayscale distribution characteristics will also change. Any pair of sinusoidal fringe grating images can be selected as the initial image pair, and the phase difference between each pair of sinusoidal fringe grating images can be obtained to determine the target image pair.
[0059] Preferably, the step of determining the target image pair based on the phase difference between each initial image pair may include:
[0060] S211: Obtain the phase difference between each pair of sinusoidal fringe grating images in the initial image pair, and obtain the absolute phase difference between each phase difference and the preset standard value;
[0061] S212: Sort each initial image pair according to the absolute difference of each phase, and select the initial image pair with a preset number of pairs as the target image pair in sequence.
[0062] Specifically, since the closer the phase difference between two sinusoidal fringe grating images is to π, the greater the change in the corresponding local waveform, the local contrast of the difference map obtained after differential analysis can be enhanced. Therefore, the preset standard value can be selected, but is not limited to, π. Then, the phase difference between two sinusoidal fringe grating images in the initial image pair is obtained, and the absolute value of the difference between each phase difference and the preset standard value is obtained as the absolute phase difference value. Then, each initial image pair is sorted according to each absolute phase difference value, and the initial image pairs with a preset number of pairs are selected in sequence as the target image pairs, providing a data basis for the subsequent steps of calculating the difference map.
[0063] S22: Obtain the gray-level distribution characteristics between each target image pair based on the phase difference, calculate the absolute gray-level difference between the target image pairs, and obtain several difference maps;
[0064] S23: Superimpose and sum the difference maps to obtain the initial modulation intensity map.
[0065] Specifically, background light intensity and modulated light intensity can be selectively acquired to obtain the grayscale values of each phase-shifted fringe pattern according to Equation 2-1. Furthermore, based on the differences between the grayscale values of each phase-shifted fringe pattern, the grayscale distribution characteristics between each target image pair can be obtained.
[0066] In(x,y)=A(x,y)+B(x,y)cos(φ+2π / N*n)(n=0...N)2-1
[0067] Where In(x,y) is the gray value at (x,y) in the phase-shifted fringe pattern, A(x,y) is the background light intensity at (x,y) in the phase-shifted fringe pattern, B(x,y) is the modulation light intensity at (x,y) in the phase-shifted fringe pattern, φ is the initial phase, 2π / N*n is the phase shift of the nth phase-shifted fringe pattern, and N is the number of phase-shifted fringe patterns.
[0068] More specifically, due to the differences in the coding logic of each phase-shift fringe pattern, different difference patterns enhance different regions. Therefore, it is necessary to superimpose and sum the corresponding difference patterns of all target images to enhance the global (coding region) grayscale and obtain the initial modulation intensity map.
[0069] For example, taking a four-step phase shift as an example, the preset number of target image pairs is set to 2. The difference map of each target image pair can be calculated according to Equations 2-2 and 2-3, and all difference maps are superimposed and summed according to Equation 2-4 to obtain the initial modulation intensity map:
[0070] D1(x,y)=abs(I 11 (x,y)-I 12 (x,y)) 2-2
[0071] D2(x,y)=abs(I 21 (x,y)-I 22 (x,y)) 2-3
[0072] M init (x,y)=D1(x,y)+D2(x,y) 2-4
[0073] Where D1(x,y) is the first pair of target images, image I 11 and Image I 12 The absolute difference in gray levels of the corresponding pixel points (x,y) at (x,y) in the second pair of target images, where D2(x,y) is the gray level of the corresponding pixel point (x,y). 21 and Image I 22 The absolute difference in gray levels of the corresponding pixels at (x, y), M init (x,y) represents the grayscale value of the corresponding pixel in the initial modulation intensity map, and abs(ab) represents the absolute difference in grayscale between pixel a and pixel b.
[0074] It is worth noting that the number of difference maps varies with the preset logarithm. When it is a four-step phase shift, the number of difference maps can be selected as 2. The principle for enhancing the contrast of the encoded region during the process of acquiring and summing the difference maps can be selected as follows: Figure 3 As shown.
[0075] Preferably, since the closer the phase difference between any two sinusoidal fringe grating images is to π, the greater the change in the corresponding waveform, and the larger the gray value obtained after differential summation, the stronger the contrast, the importance of the corresponding difference map for calculating the modulation intensity map changes with the change in phase difference. Therefore, the step of superimposing and summing the difference maps to obtain the initial modulation intensity map may optionally further include:
[0076] S231: Calculate the weight of each target image pair based on the absolute phase difference of each target image pair;
[0077] S232: Sum the difference maps of each target image pair according to their weights to obtain the initial modulation intensity map.
[0078] Specifically, since the phase difference between each target image pair may be different, their importance in calculating the initial modulation intensity map also varies. Therefore, the weight of each target image pair can be calculated based on the absolute phase difference between the phase difference of each target image pair and the preset standard value, and the difference map of each target image pair can be summed according to the weight, thereby improving the calculation accuracy, reducing errors, and obtaining the initial modulation intensity map.
[0079] Preferably, the weights of each target image pair are calculated based on equations 2-5, 2-6, and 2-7, as well as the absolute phase difference of each target image pair, to improve calculation accuracy and reduce errors.
[0080] D n (x,y)=abs(I n1 (x,y)-I n2 (x,y)) 2-5
[0081] M init (x,y)=q1D1(x,y)+...+q n D n (x,y) 2-6
[0082]
[0083] Among them, D n For the nth difference plot, D n (x,y) represents image I in the nth pair of target images. n1 and Image I n2 The absolute difference in gray levels of the corresponding pixel at (x,y) in the region (x,y), q n Let be the weight coefficient of the nth target image pair, N be the total number of target image pairs, and Ti be the absolute phase difference of the i-th target image pair.
[0084] S3: Calculate the background light intensity weight matrix based on each sinusoidal fringe grating image, update the initial modulation intensity map based on the background light intensity weight matrix, and obtain the final modulation intensity map;
[0085] S31: Obtain the average pixel value of the corresponding pixels in all sinusoidal stripe raster images and construct the background light intensity weight matrix;
[0086] Specifically, due to uneven projection equipment or ambient lighting, differences in image brightness may occur. Therefore, it is possible to obtain the average pixel value of the corresponding pixels of all sinusoidal stripe raster images and construct a background light intensity weight matrix to eliminate image brightness differences and provide a more uniform lighting basis for subsequent processing.
[0087] For example, the average pixel value of each sinusoidal fringe grating image can be obtained according to Equation 3-1 to further construct the background light intensity weight matrix A:
[0088] A(x,y)=(I1(x,y)+......+I n (x,y)) / n 3-1
[0089] Where A(x,y) is the intensity value at (x,y) in the background light intensity weight matrix, n is the number of sinusoidal fringe grating images, and I i (x,y) represents the intensity value at (x,y) in the i-th sinusoidal fringe grating image, where 0 <i≤n。
[0090] S32: Normalize the background light intensity weight matrix to obtain the optimized weight matrix;
[0091] Specifically, since areas with higher background light intensity usually contain more useful information, which helps improve the accuracy of subsequent processing, it is optional, but not limited to, normalizing the background light intensity weight matrix. The normalization operation eliminates the dimensional differences between different background light intensity values, making subsequent processing more stable and comparable, and obtaining the normalized optimized weight matrix to simplify subsequent weighting operations, making the calculation process more efficient, and providing a calculation basis for subsequent weighting operations.
[0092] For example, the background light intensity weight matrix can be normalized according to Equation 3-2 to obtain the optimized weight matrix W(x,y):
[0093]
[0094] Here, max(A) represents the maximum intensity value of all points in the background light intensity weight matrix A. The background light intensity weight matrix is normalized by dividing the intensity value of each point (x,y) in the background light intensity weight matrix by the maximum intensity value.
[0095] S33: Perform weighted operations on the initial modulation intensity map according to the optimized weight matrix to obtain the final modulation intensity map.
[0096] Specifically, the initial modulation intensity map can be weighted according to the optimized weight matrix, but is not limited to obtaining the final modulation intensity map as shown below. Figure 4 As shown, through weighted operations, the final modulation intensity map can more accurately reflect the modulation information of the object surface, improve the accuracy of measurement, enhance the robustness of the algorithm to changes in illumination, make the results more stable and reliable, and better highlight the modulation area, optimize the contrast between the coded and uncoded areas, which facilitates subsequent segmentation and analysis.
[0097] For example, optionally, the optimized weight matrix 3-2 can be substituted into the weighting formula 3-3 to perform a weighted operation on the initial modulation intensity map, thereby obtaining the final modulation intensity map M. final :
[0098] M final (x,y)=M init (x,y)οW(x,y) 3-3
[0099] The symbol “ο” indicates element-wise multiplication.
[0100] S4: Determine the image segmentation threshold, and perform binary segmentation on the final modulation intensity map according to the image segmentation threshold to obtain the effective area of deflection imaging.
[0101] Specifically, since different colors react differently to light, for example, light-sensitive areas are more sensitive to light, and the intensity of their reflected light changes significantly with changes in lighting conditions. In phase-shifting fringe images, the gray values of light-sensitive areas are lower, and the local gray values still exhibit sinusoidal characteristics. On the other hand, non-light-sensitive areas are relatively insensitive to light, and the intensity of their reflected light is relatively stable. In phase-shifting fringe images, the gray values of non-light-sensitive areas are higher, and the gray values of the background parts in each phase-shifting fringe image are very similar. Therefore, it is possible to determine whether the background area in the object surface image is a light-sensitive area and determine the image segmentation threshold. Then, based on the image segmentation threshold, the final modulation intensity map is binary segmented to obtain the effective area of the deflection imaging, ensuring segmentation accuracy.
[0102] Preferably, the method for determining the image segmentation threshold may include:
[0103] S41: Determine whether the background area in the object surface image is a light-sensitive area. If so, then:
[0104] S411: Calculate the gray values of each pixel in the final modulation intensity map to obtain the initial gray-level histogram;
[0105] S412: Apply Gaussian filtering to the initial histogram to obtain an optimized histogram;
[0106] S413: Obtain the horizontal coordinate of the valley between the two peaks of the optimized histogram to obtain the image segmentation threshold;
[0107] Specifically, those skilled in the art can optionally determine whether the background area in the object surface image is a light-sensitive area. When the background area in the object surface image is a light-sensitive area, the gray values of each pixel in the final modulation intensity map can be statistically analyzed to obtain the distribution of pixels with each gray value, resulting in an initial gray-level histogram. This histogram visually displays the frequency of different gray values in the image, providing basic data support for subsequent image processing and analysis. Then, Gaussian filtering is applied to the initial histogram to remove spikes and fluctuations caused by noise or outliers, making the histogram smoother and highlighting the main gray-level distribution features, resulting in an optimized histogram. Figure 5 As shown, the main peaks and valleys in the histogram are highlighted to make the bimodal feature more obvious, which facilitates threshold calculation. Finally, the horizontal coordinates of the valleys between the two peaks of the optimized histogram are obtained to obtain the image segmentation threshold. Based on the bimodal feature of the histogram, the image can be accurately divided into foreground and background regions, improving the segmentation effect. At the same time, the segmentation threshold can be automatically determined according to the gray-scale distribution of the image, improving data processing efficiency and stability.
[0108] S42: If not, then: obtain the preset segmentation threshold as the image segmentation threshold.
[0109] Specifically, when the background area in the object surface image is not a light-sensitive area, the intensity of its reflected light is relatively stable, resulting in extremely low grayscale values in the non-coding areas. Therefore, a pre-set segmentation threshold γ can be selected. When the background area in the object surface image is a non-light-sensitive area, the pre-set segmentation threshold γ is directly used as the image segmentation threshold γ. The segmentation threshold γ can be arbitrarily set by those skilled in the art. Preferably, based on the prior reflection characteristics of non-black objects to illumination, the segmentation threshold γ is set to 7.
[0110] A further preferred step, which involves binary segmenting the final modulation intensity map based on an image segmentation threshold to obtain the effective region for deflection imaging, may optionally include:
[0111] S43: Perform binary segmentation on the final modulation intensity map according to the image segmentation threshold to obtain a binary mask;
[0112] Specifically, the image segmentation threshold γ and the final modulation intensity map M can be selected as the basis. final Then, iterate through all pixels of the final modulation intensity map, and determine whether the pixel value of the current pixel is less than the image segmentation threshold. If it is, change the pixel value of the corresponding pixel to 0; otherwise, change the pixel value of the corresponding pixel to 1, thus obtaining the binary mask.
[0113] For example, the final modulation intensity map can be binarized according to Equation 4-1 to obtain a binary mask:
[0114]
[0115] Where Mask is a binary mask, M final (x,y) represents the pixel located at coordinates (x,y) in the final modulation intensity map, and γ is the image segmentation threshold.
[0116] Preferably, since projection using only a phase-shifted fringe map in one direction (such as horizontal or vertical) may not accurately capture complete information about the object's surface due to factors such as surface reflection, shape, or image encoding method. For example, some areas may be well imaged and segmented in the horizontal direction but have poor image quality in the vertical direction, or some areas may be clearly segmented in the vertical direction but have lower grayscale values in the horizontal direction. Therefore, it is necessary to generate and project phase-shifted encoded maps in two directions separately to capture the gradient information of the object in different directions, providing a more comprehensive data foundation for subsequent segmentation. Thus, the step of performing binary segmentation on the final modulation intensity map according to the image segmentation threshold to obtain a binary mask may optionally include:
[0117] S431: Perform binary segmentation on the final modulation intensity map according to the image segmentation threshold to obtain the first binary mask;
[0118] S432: Generate several updated phase-shift fringe patterns according to the set angle, obtain the updated image segmentation threshold and the final modulation intensity map according to each updated phase-shift fringe pattern, and perform binary segmentation on the updated final modulation intensity map according to the updated image segmentation threshold to obtain the second binary mask;
[0119] S433: Perform an OR operation on each pixel of the first binary mask and the second binary mask to obtain the final binary mask.
[0120] Specifically, the final modulation intensity map can be segmented according to an image segmentation threshold to obtain a first binary mask. Then, several updated phase-shift fringe maps are generated according to angles arbitrarily set by those skilled in the art, preferably perpendicular to the corresponding angles of the original phase-shift fringe maps. A new final modulation intensity map and a corresponding segmentation threshold are obtained to obtain a second binary mask. This allows for the acquisition of information about the object's surface from another perspective, thereby obtaining surface features that are more easily captured in another direction, or obtaining information complementary to the parallel direction. This avoids the loss of information in certain areas due to projection in a single direction, enriching the perception of the object's surface shape. Finally, a pixel-by-pixel OR operation is performed on the first and second binary masks to obtain the final binary mask, as shown below. Figure 6As shown, this ensures that all pixels correctly segmented in at least one direction are included in the final mask, thereby improving the integrity of the segmentation. For example, a certain coded region in the final modulation intensity map may have a low grayscale value in one direction but be clearly visible in another. By using an "OR" operation, the coded region that is clearly visible in a certain direction can be completely preserved, thus effectively addressing the problem of inaccurate segmentation in a single direction caused by factors such as local illumination changes and surface reflection characteristics, and improving the robustness and reliability of the entire segmentation process.
[0121] S44: Obtain the effective area for deflection imaging based on the binary mask.
[0122] Specifically, based on the binary mask obtained in step S43, the region with a pixel value of 1 in the binary mask can be obtained to obtain the effective region for deflection imaging.
[0123] In this embodiment, an image segmentation method for the effective region of deflection imaging according to the present invention is presented. Several phase-shifted fringe patterns are generated and projected onto the object surface. Several sinusoidal fringe grating images are obtained by acquiring the current object surface image. Object surface information is obtained from different phase angles, providing rich data for subsequent accurate measurements. Then, the gray-level distribution characteristics between each sinusoidal fringe grating image are acquired to obtain an initial modulation intensity map. Temporal difference technology is used to effectively extract the modulation information of the sinusoidal fringes, and the difference between different phase-shifted images is calculated to enhance the contrast between the modulation region and the background. Then, a background light intensity weight matrix is calculated based on each sinusoidal fringe grating image to update the initial modulation intensity map, resulting in a final modulation intensity map. By calculating the background light intensity weight matrix, the background light intensity distribution on the object surface can be accurately modeled, reflecting the reflective characteristics of the object surface and ambient lighting conditions, improving robustness to changes in illumination, and ensuring stable and reliable measurement results under different lighting conditions. Finally, an image segmentation threshold is determined, and the final modulation intensity map is binary-segmented according to the image segmentation threshold to obtain the effective region of deflection imaging. This technology solves the problems of insufficient contrast between the encoded and non-encoded regions in existing technologies, and the inability to quickly determine the optimal segmentation threshold, which leads to the inability to quickly and accurately segment the encoded region.
[0124] On the other hand, the present invention also provides a computer storage medium storing executable program code; the executable program code is used to execute the image segmentation method for any of the above-mentioned deflection imaging effective regions.
[0125] On the other hand, the present invention also provides a terminal device, including a memory and a processor; the memory stores program code that can be executed by the processor; the program code is used to execute the image segmentation method for any of the above-mentioned deflection imaging effective regions.
[0126] For example, the program code can be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units can be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the program code in the terminal device.
[0127] The terminal device can be a desktop computer, laptop, handheld computer, or cloud server, etc. The terminal device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that the terminal device may also include input / output devices, network access devices, buses, etc.
[0128] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0129] The memory can be an internal storage unit of the terminal device, such as a hard drive or RAM. The memory can also be an external storage device of the terminal device, such as a plug-in hard drive, SmartMedia Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, the memory can include both internal and external storage units of the terminal device. The memory is used to store the program code and other programs and data required by the terminal device. The memory can also be used to temporarily store data that has been output or will be output.
[0130] The aforementioned computer storage medium and terminal device are created based on the image segmentation method for the effective region of the deflection imaging described above. Their technical functions and beneficial effects will not be elaborated here. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0131] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this invention patent should be determined by the appended claims.
Claims
1. An image segmentation method for the effective region of deflection imaging, characterized in that, include: Several phase-shifted fringe patterns are generated and projected onto the object surface. Several sinusoidal fringe grating images are obtained by acquiring the current object surface image. The gray-level distribution features between each sinusoidal fringe grating image are obtained to obtain the initial modulation intensity map; The background light intensity weight matrix is calculated based on each sinusoidal fringe grating image. The initial modulation intensity map is then updated based on the background light intensity weight matrix to obtain the final modulation intensity map. Determine the image segmentation threshold, and perform binary segmentation on the final modulation intensity map based on the image segmentation threshold to obtain the effective region of deflection imaging.
2. The method according to claim 1, characterized in that, The steps for obtaining the grayscale distribution features between each sinusoidal fringe grating image to obtain the initial modulation intensity map include: Using any pair of sinusoidal fringe grating images as initial image pairs, and determining the target image pair based on the phase difference between each initial image pair; Based on the phase difference, the gray-level distribution characteristics between each target image pair are obtained, and the absolute gray-level difference between the target image pairs is calculated to obtain several difference maps; By superimposing and summing the difference maps, the initial modulation intensity map is obtained.
3. The method according to claim 2, characterized in that, The step of determining the target image pair based on the phase difference between each initial image pair includes: Obtain the phase difference between each pair of sinusoidal fringe grating images in the initial image pair, and obtain the absolute phase difference between each phase difference and the preset standard value; The initial image pairs are sorted according to the absolute difference of each phase, and the initial image pairs with a preset number of pairs are selected as the target image pairs in sequence.
4. The method according to claim 3, characterized in that, Methods for obtaining an initial modulation intensity map by superimposing and summing the difference maps include: The weights of each target image pair are calculated based on the absolute phase difference of each target image pair. The initial modulation intensity map is obtained by summing the difference maps of each target image pair according to their weights.
5. The method according to claim 1, characterized in that, The steps to obtain the final modulation intensity map include: Obtain the average pixel value of the corresponding pixels in all sinusoidal fringe grating images, and construct the background light intensity weight matrix; The background light intensity weight matrix is normalized to obtain the optimized weight matrix; The initial modulation intensity map is weighted according to the optimized weight matrix to obtain the final modulation intensity map.
6. The method according to claim 1, characterized in that, The steps for determining the image segmentation threshold include: Determine whether the background area in an image of an object's surface is a light-sensitive area; If so, then: The grayscale values of each pixel in the final modulation intensity map are counted to obtain the initial grayscale histogram; Gaussian filtering is applied to the initial histogram to obtain an optimized histogram; Obtain the horizontal coordinates of the valleys between the two peaks of the optimized histogram to obtain the image segmentation threshold; If not, then: Obtain the preset segmentation threshold as the image segmentation threshold.
7. The method according to claim 6, characterized in that, The steps of performing binary segmentation on the final modulation intensity map based on the image segmentation threshold to obtain the effective region of the deflection imaging include: The final modulation intensity map is binary segmented according to the image segmentation threshold to obtain a binary mask; The effective area for deflection imaging is obtained based on a binary mask.
8. The method according to claim 7, characterized in that, The steps of performing binary segmentation on the final modulation intensity map based on the image segmentation threshold to obtain a binary mask include: The final modulation intensity map is binary segmented according to the image segmentation threshold to obtain the first binary mask; Several updated phase-shift fringe patterns are generated according to a set angle. The updated image segmentation threshold and the final modulation intensity map are obtained according to each updated phase-shift fringe pattern. The updated final modulation intensity map is then binary segmented according to the updated image segmentation threshold to obtain the second binary mask. Perform a pixel-by-pixel OR operation on the first and second binary masks to obtain the final binary mask.
9. A computer storage medium, characterized in that, It stores executable program code; the executable program code is used to execute the image segmentation method for the effective region of deflection imaging as described in any one of claims 1-8.
10. A terminal device, characterized in that, It includes a memory and a processor; the memory stores program code that can be executed by the processor; the program code is used to execute the image segmentation method for the effective region of deflection imaging as described in any one of claims 1-8.