Partitioned light source control methods, systems, devices, and media for photometric stereo
By constructing a defect type knowledge base and using linear weighted calculation, the problem of low search efficiency of partitioned light source combination in existing photometric stereo technology is solved, enabling rapid acquisition of the optimal light source combination, improving detection effect and efficiency, and adapting to the detection needs of different defects and surface types.
Patent Information
- Application Number
- CN202611592609.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-15
- Publication Date
- 2026-11-24
AI Technical Summary
Existing photometric stereo technology fails to effectively combine the mapping relationship between defect type and the combination of zoned light sources in defect detection. This results in the need to search for the optimal combination again before each detection, which reduces the search efficiency of the zoned light source combination. Furthermore, existing technologies often prioritize reconstruction quality over the detection effect of specific defects.
A knowledge base of defect types is constructed. By acquiring the defect type and surface type of the object to be tested, and using the existing zoned light source combination scoring information in the knowledge base, combined with the features of the normal vector map and curvature map, the defect score and quality score are calculated. The contrast score is obtained by linear weighted calculation, and the optimal zoned light source combination is quickly obtained.
It enables the direct acquisition of the optimal combination of partitioned light sources when the same type of defect reappears, improves the acquisition efficiency of partitioned light source combinations, ensures the detection effect of specific defect types, and maintains the numerical stability of the photometric stereo normal vector solution, adapting to the actual needs of frequent product changes on the production line.
Smart Images

Figure CN123160752A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of machine vision, and particularly relates to a method, system, device and medium for controlling partitioned light sources for photometric stereoscopic imaging. Background Technology
[0002] Photometric Stereo is a technique that reconstructs the three-dimensional shape of an object's surface using multiple images acquired under illumination from multiple directions. It is widely used in the field of surface defect detection for industrial products. By acquiring images under illumination from different directions, the photometric stereo algorithm can reconstruct the normal vector map of the object's surface, thereby enhancing the visibility of three-dimensional surface defects such as scratches, pits, and bumps, effectively compensating for the shortcomings of traditional two-dimensional imaging in detecting low-contrast defects.
[0003] In existing technologies, multi-segment light sources have been applied to photometric stereo systems, allowing users to independently control the on / off state of each segment. However, in practical applications, the single optimization objective is often to maximize the sharpness of the surface image of the object under test, which is not suitable for the defect detection requirements of the application scenario. The defect detection performance of the resulting segmented light source combination still needs improvement. Furthermore, existing technologies do not consider the accumulated mapping relationship between defect types and segmented light source combinations, requiring a re-search for the optimal combination before each detection, thus reducing the search efficiency of segmented light source combinations. Summary of the Invention
[0004] This application proposes a method, system, device, and medium for controlling partitioned light sources in photometric stereo, which improves the search efficiency of partitioned light source combinations while ensuring the detection effect of the combination on defects.
[0005] To achieve the above objectives, this application proposes the following technical solutions: In a first aspect of this application, a method for controlling a zoned light source for photometric stereo is provided, comprising: Obtain the defect type and surface type of the object under test; Determine if a field with the same defect type and surface type exists in the preset knowledge base; if so, obtain the partition light source combination with the highest contrast score as the target light source combination; if not, select the partition light source combination with the highest contrast score from the fields with the same defect type as the target light source combination. The knowledge base consists of a collection of multiple fields, each including defect type, zone light source combination, and contrast score; the zone light source combination indicates the on / off status of the light source in each zone. If no field with the same defect type exists in the knowledge base, then obtain the normal vector map and / or curvature map of the surface of the object under test under each candidate partition light source combination; wherein, the candidate partition light source combination is the partition light source combination selected from all partition light source combinations with the illumination matrix condition number within a preset range; the illumination matrix condition number is calculated based on the three-dimensional direction vector of each partition light source; Based on the image features of the defect region and background region in the normal vector map and / or curvature map, calculate the defect score reflecting the detectability of the defect; based on the normal vector map and / or curvature map, calculate the quality score reflecting the reconstruction quality; obtain the illumination matrix condition number under the corresponding zone light source combination; The defect score, quality score, and the reciprocal of the illumination matrix condition number are linearly weighted and calculated to form the contrast score. The candidate light source combination with the highest contrast rating is selected as the target light source combination.
[0006] Optionally, before acquiring the normal vector map and / or curvature map of the surface of the object under test under each candidate zone light source combination, the zone light source control method further includes: The set of three-dimensional direction vectors for each zone light source is predetermined; Calculate the lighting matrix condition number for each set of three-dimensional direction vectors, and select the partition light source combinations whose lighting matrix condition number is within a preset range as candidate partition light source combinations.
[0007] Optionally, after calculating the illumination matrix condition number for each set of three-dimensional direction vectors, the partitioned light source control method further includes: With the goal of satisfying a preset range of illumination matrix condition numbers, a preset search algorithm is used to obtain the partition light source combinations whose illumination matrix condition numbers are within the preset range from all partition light source combinations, as candidate partition light source combinations; wherein, the search algorithm includes: branch and bound algorithm, greedy algorithm, genetic algorithm, and simulated annealing algorithm.
[0008] Optionally, based on a preset search algorithm, select from all combinations of zone light sources those where the illumination matrix condition number falls within a preset range, including: Following a hierarchical search strategy from quadrant level to zone level, combinations of zone light sources with illumination matrix condition numbers within a preset range are obtained sequentially; wherein, each zone light source is independently set and distributed in four quadrants.
[0009] Optionally, a linear weighted average is calculated from the defect score, quality score, and the reciprocal of the illumination matrix condition number to obtain the contrast score, including: A contrast score is calculated based on a preset weighting formula; where the preset weighting formula is: Score = α·C + β·b -1+γ·R Where Score represents the contrast score; C represents the defect score, which is obtained by selecting any one of the following values: the grayscale difference between the defect and the background, the contrast ratio between the defect and the background, or the average gradient magnitude of the defect edge; b -1 α represents the reciprocal of the illumination matrix condition number b; R represents the quality score, which is obtained by selecting the reciprocal of any value from normal vector smoothness, gradient field continuity, or illumination consistency; α, β, and γ represent preset weight coefficients.
[0010] Optionally, based on the image features of the defect region and background region in the normal vector map and / or curvature map, a defect score reflecting the detectability of the defect is calculated; based on the normal vector map and / or curvature map, a quality score reflecting the reconstruction quality is calculated; and the illumination matrix condition number under the corresponding zone light source combination is obtained and replaced with: Calculate the contrast-to-noise ratio in the normal vector map and / or curvature map, and obtain the illumination matrix condition number under the corresponding zone light source combination; The partitioned light source control method further includes: The contrast-to-noise ratio and the reciprocal of the illumination matrix condition number are linearly weighted and used as the contrast score. The candidate light source combination with the highest contrast rating is selected as the target light source combination.
[0011] Optionally, after obtaining the target light source combination, the following may also be included: Based on the target light source combination, the normal vector map and / or curvature map of the surface of the object under test are re-acquired; The contrast score and the accuracy of defect identification results are recalculated by normal vector plots and / or curvature plots; Determine whether the contrast score and accuracy are both within the preset verification range; if so, use the target light source combination as the final partition light source combination and update it in the knowledge base; if not, discard the current target light source combination and obtain a new target light source combination.
[0012] In a second aspect of this application, a zoned light source control system for photometric stereo is provided, comprising: The type acquisition module is used to acquire the defect type and surface type of the object under test. The defect judgment module is used to determine whether there is a field in the preset knowledge base that has the same defect type and surface type. If so, it retrieves the partition light source combination with the highest contrast score from the knowledge base field as the target light source combination. If not, it selects the partition light source combination with the highest contrast score from the field with the same defect type as the target light source combination. The knowledge base is a collection of multiple fields, each field including defect type, partition light source combination, and contrast score. The partition light source combination represents the on / off state of the light source in each partition. The image processing module is used to obtain the normal vector map and / or curvature map of the surface of the object under test under various candidate partition light source combinations if no field with the same defect type exists in the knowledge base. The candidate partition light source combination is a partition light source combination selected from all partition light source combinations with an illumination matrix condition number within a preset range. The illumination matrix condition number is calculated based on the three-dimensional direction vector of each partition light source. The scoring calculation module is used to calculate a defect score reflecting the detectability of defects based on the image features of the defect area and the background area in the normal vector map and / or curvature map; calculate a quality score reflecting the reconstruction quality based on the normal vector map and / or curvature map; and obtain the illumination matrix condition number under the corresponding partition light source combination. The weighted calculation module is used to perform a linear weighted calculation on the defect score, quality score, and the reciprocal of the lighting matrix condition number to obtain the contrast score; The light source acquisition module is used to acquire the light source combination of the candidate zone with the highest contrast score, and use it as the target light source combination.
[0013] In a third aspect of this application, an electronic device is provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory are connected via the communication bus; Memory, used to store computer programs; The processor, when executing a program stored in memory, implements the partitioned light source control method described in any of the first aspects.
[0014] In a fourth aspect of this application, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when executed by a processor, the computer program implements the partitioned light source control method described in any of the first aspects.
[0015] The beneficial effects of this application are as follows: This application provides a method for controlling a zoned light source in a photometric stereo system, including: The system acquires the defect type and surface type of the object under test; it then determines whether a field with the same defect type and surface type exists in the preset knowledge base; if so, it acquires the partition light source combination with the highest contrast score as the target light source combination; otherwise, it selects the partition light source combination with the highest contrast score from the fields with the same defect type as the target light source combination; the knowledge base is a collection of multiple fields, each field including defect type, partition light source combination, and contrast score; the partition light source combination represents the on / off state of the light source in each partition. If no field with the same defect type exists in the knowledge base, the normal vector map and / or curvature map of the surface of the object under test are obtained under each candidate partition light source combination. The candidate partition light source combination is selected from all partition light source combinations, with the illumination matrix condition number falling within a preset range. The illumination matrix condition number is calculated based on the three-dimensional direction vector of each partition light source. A defect score reflecting the detectability of the defect is calculated based on the image features of the defect area and background area in the normal vector map and / or curvature map. A quality score reflecting the reconstruction quality is calculated based on the normal vector map and / or curvature map. The illumination matrix condition number under the corresponding partition light source combination is obtained. A linear weighted calculation is performed on the defect score, quality score, and the reciprocal of the illumination matrix condition number to obtain the contrast score. The candidate partition light source combination with the highest contrast score is selected as the target light source combination.
[0016] Based on the above processing, this application constructs a knowledge base of defect types. When the same type of defect reappears, the optimal combination of partitioned light sources can be directly obtained from the knowledge base, avoiding repeated searches and effectively improving the efficiency of obtaining partitioned light source combinations. This application obtains a contrast score by weighting the defect score, quality score, and illumination matrix condition number. Thus, it optimizes based on the detection effect (contrast, detection confidence) of the surface defects of the object under test. Unlike existing technologies that optimize based on the image quality of the surface of the object under test, the target light source combination obtained in this application has the optimal detection effect for specific defect types. It ensures that the optimal partitioned light source combination can be obtained in a single screening without the need for secondary iterative comparison. While improving the detection effect of the target light source combination, it also simultaneously optimizes the screening efficiency of the target light source combination.
[0017] Furthermore, in the process of calculating the contrast score, this application introduces an additional variable of the illumination matrix condition number on the basis of the defect score and the quality score. This can ensure that the obtained target light source combination maintains the numerical stability of the photometric stereo normal vector solution while ensuring the accuracy of defect identification, and avoids getting trapped in local optima.
[0018] The zoned light source control method provided in this application can quickly switch between different defect types (scratches / dents / bubbles) and different surface types (metal / plastic / glass), adapting to the actual production needs of frequent product changes on the production line. Attached Figure Description
[0019] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings: Figure 1 This is a flowchart of a zoned light source control method provided in this application; Figure 2This is a structural diagram of a zoned light source control system provided in this application; Figure 3 This is a schematic diagram of the structure of an electronic device provided in this application. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are some embodiments of this application, but not all embodiments.
[0021] In existing technologies, multi-zone light sources (such as 4 quadrants × 10 zones, for a total of 40 zones) have been applied to photometric stereo systems, allowing users to independently control the on / off state of each zone. Previous research has proposed methods for optimizing zone brightness, but the issues of time consumption and optimal effect in multi-zone lighting optimization have not been resolved.
[0022] The disclosed solution in Chinese Patent CN118138864A uses the clarity of the target object image as a basis and performs evolutionary calculations on the brightness of each zone in a multi-zone light source based on a genetic algorithm to obtain the optimal brightness of each zone. Its core concept is to optimize the brightness value of each zone (continuous adjustment), rather than selecting the optimal on / off combination from a large number of zones (discrete data), which is different from the improvement approach and technical means of this application.
[0023] The scheme disclosed in Chinese CN119665813A involves setting up uniformly distributed zoned light sources (4 independently controlled light sources) in the vertical direction of the sample to be tested. Only one light source is illuminated at a time to acquire images, and a pseudo-depth map and contour map are calculated by combining images directly facing two light sources. The improvement of that scheme lies in the imaging method and device structure, rather than the automatic optimization selection of the lighting combination, which is different from this application.
[0024] Specifically, existing technologies often have the following shortcomings: First, existing technologies prioritize optimal reconstruction quality (the sharpness of the target object image) as the sole optimization objective, while the actual need in industrial inspection is to achieve optimal detection of specific defects. For different tasks such as scratch detection, dent detection, and bubble detection, the optimal light source combination may differ drastically—scratches exhibit the highest contrast under specific directional illumination, while dents may be more easily identified under uniform illumination. Therefore, the aforementioned optimization focused on reconstruction quality cannot guarantee optimal detection of specific defects.
[0025] Furthermore, existing technologies lack a systematic accumulation of mapping relationships between defect types and optimal lighting methods. In scenarios where product types frequently switch on production lines (such as alternating inspection of different workpiece models), re-searching for the optimal combination each time is inefficient and cannot meet the real-time requirements of industrial online inspection.
[0026] Furthermore, existing technologies do not fully consider the accumulation and reuse of prior knowledge. In long-term production inspection processes, the optimal lighting scheme for the same type of defect is transferable, but existing methods optimize from scratch each time, resulting in a waste of computational resources and experience.
[0027] To address the aforementioned problems, this invention proposes a zoned light source control method for photometric stereoscopic imaging. Guided by the detection effect of target defects, it achieves rapid adaptive selection of light source combinations, such as... Figure 1 As shown, this application provides a method for controlling a zoned light source for photometric stereo, comprising the following steps: S1. Obtain the defect type and surface type of the object to be tested.
[0028] S2. Determine if there are fields in the preset knowledge base that have the same defect type and surface type; if so, obtain the partition light source combination with the highest contrast score as the target light source combination; if not, select the partition light source combination with the highest contrast score from the fields with the same defect type as the target light source combination.
[0029] The knowledge base is a collection of multiple fields, each of which includes defect type, zone light source combination, and contrast score; the zone light source combination indicates the on / off status of the light source in each zone.
[0030] S3. If no field with the same defect type exists in the knowledge base, obtain the normal vector map and / or curvature map of the surface of the object under test under each candidate partition light source combination. The candidate partition light source combination is selected from all partition light source combinations, choosing those with an illumination matrix condition number within a preset range; the illumination matrix condition number is calculated based on the three-dimensional direction vector of each partition light source.
[0031] S4. Calculate a defect score reflecting the detectability of defects based on the image features of the defect region and background region in the normal vector map and / or curvature map; calculate a quality score reflecting the reconstruction quality based on the normal vector map and / or curvature map; obtain the illumination matrix condition number under the corresponding partition light source combination.
[0032] S5. Perform a linear weighted calculation on the defect score, quality score, and the reciprocal of the illumination matrix condition number to obtain the contrast score.
[0033] S6. Obtain the candidate zone light source combination with the highest contrast score as the target light source combination.
[0034] Based on the above processing, this application constructs a knowledge base of defect types. When the same type of defect reappears, the optimal combination of partitioned light sources can be directly obtained from the knowledge base, avoiding repeated searches and effectively improving the efficiency of obtaining partitioned light source combinations. This application obtains a contrast score by weighting the defect score, quality score, and illumination matrix condition number. Thus, it optimizes based on the detection effect (contrast, detection confidence) of the surface defects of the object under test. Unlike existing technologies that optimize based on the image quality of the surface of the object under test, the target light source combination obtained in this application has the optimal detection effect for specific defect types. It ensures that the optimal partitioned light source combination can be obtained in a single screening without the need for secondary iterative comparison. While improving the detection effect of the target light source combination, it also simultaneously optimizes the screening efficiency of the target light source combination.
[0035] Furthermore, in the process of calculating the contrast score, this application introduces an additional variable of the illumination matrix condition number on the basis of the defect score and the quality score. This can ensure that the obtained target light source combination maintains the numerical stability of the photometric stereo normal vector solution while ensuring the accuracy of defect identification, and avoids getting trapped in local optima.
[0036] For step S1, defect types include, but are not limited to, scratches, bubbles, dents, bumps, cracks, dirt, and burrs. Surface types include, but are not limited to, metal, plastic, glass, and ceramic. For obtaining defect types and surface types, users can input instructions to indicate the defect types and surface types of the object under test, such as scratches on a plastic surface. Alternatively, one or more preview images of the object's surface can be acquired, and a pre-trained defect classification network can be used to identify and obtain the main defect types and surface types of the object's surface.
[0037] For step S2, specifically, for the preset knowledge base, all fields that are the same as the defect type and surface type are obtained, and the combination of light sources with the highest contrast score among the fields is obtained as the target light source combination.
[0038] If there are no all partition light source combinations that are the same as the surface type, then obtain all fields that are the same as the defect type, and select the partition light source combination with the highest contrast score from them as the target light source combination.
[0039] That is, the obtained defect type and surface type are searched and matched in a preset knowledge base. If the knowledge base contains fields with the same defect type and the same surface type, the combination of light sources with the highest contrast score is directly selected as the target light source for the partition; if the knowledge base contains records with the same defect type but different surface types, the combination of light sources with the highest contrast score for that defect type is recommended as the target light source for the partition; if the knowledge base does not contain records for that defect type, the process proceeds to step S3 to search for the target light source combination based on the contrast score.
[0040] In this application, the knowledge base is a collection of multiple fields, each including defect type, partition light source combination, and contrast score. Fields may also include the illumination matrix condition number for the partition light source combination. The knowledge base can be constructed by obtaining historically detected defect types and their corresponding optimal partition light source combinations, as well as the illumination matrix condition number and contrast score records under the optimal partition light source combination. The partition light source combination is represented by a partition ID list; the partition light source corresponding to the ID number in the partition ID list is enabled, and light sources not in the partition ID list are disabled.
[0041] In the zoned light source provided in this application, the on / off state of each zone can be controlled independently, and theoretically, N zoned light sources can form 2 N Various light source combinations. For the light source combination search process in steps S4 to S7, with the development of light source hardware, the total number of light source partitions used in photometric stereo scenes is getting higher and higher (for example, 4 quadrants × 10 partitions, a total of 40 light source partitions).
[0042] If the total number of zone light sources is small, all zone light source combinations can be directly used as candidate zone light source combinations.
[0043] If the total number of light sources in a given area is too high, the resulting combination space of light sources in that area becomes too large (when N=40, the number of combinations exceeds 1 trillion), making exhaustive screening impractical in terms of time and computational resources.
[0044] To address the aforementioned issues, before performing step S3, the partitioned light source control method provided in this application further includes the following steps to obtain a candidate partitioned light source combination.
[0045] S7. Predetermine the set of three-dimensional direction vectors for each zone light source.
[0046] S8. Calculate the illumination matrix condition number of each three-dimensional direction vector set, and select the partition light source combinations whose illumination matrix condition number is within the preset range as candidate partition light source combinations.
[0047] Photometric stereo technology reconstructs surface normal vectors by analyzing the changes in reflection intensity of an object's surface under illumination from different directions. For the unit direction vector v of the i-th zone light source... i for Where i represents the sorting value of the zoned light source; v ix v iy and v iz These represent the unit direction vector v. i Components in the X, Y, and Z axes of the coordinate system.
[0048] The aforementioned unit direction vector is the image gray value I at a pixel (x,y) in the image.i(x,y) With surface normal vector n (x,y) and surface reflectivity f (x,y) The Lambertian reflection model is satisfied between them:
[0049] Where (x,y) represents the pixel coordinates on the image plane, x represents the horizontal coordinate, and y represents the vertical coordinate; i(x,y) This represents the grayscale value captured at pixel (x, y) when the i-th light source is lit alone; n (x,y) This represents the unit normal vector of the object surface point corresponding to pixel (x, y), in the form of a three-dimensional column vector; the superscript T indicates the transpose of the vector or matrix, such as... This indicates that the column vector n (x,y) Transpose to row vector; f (x,y) The diffuse reflectance of the object surface point corresponding to pixel (x,y) is a scalar quantity used to reflect the reflective characteristics of the surface point.
[0050] For K light sources, a system of linear equations can be constructed:
[0051] in, I1 represents the grayscale value when the first light source is lit alone; I k This represents the grayscale value when the k-th light source is lit alone; I (x,y) This represents a gray-level column vector composed of the gray-level values of the same pixel (x,y) illuminated by K light sources respectively; L is a K×3 illumination matrix, where K represents the number of selected light sources in the light source combination; v1 represents the unit direction vector of the first light source; v k This represents the unit direction vector of the Kth light source. Therefore, the core of light source direction calibration is to obtain the three-dimensional direction vector of each row in the lighting matrix.
[0052] For step S7, the three-dimensional direction vector set V can be obtained by means of the high-gloss metal ball calibration method, the standard whiteboard calibration method, and the LED light source position calibration method based on stereo vision.
[0053] Taking the LED light source position calibration method based on stereo vision as an example, the calibration process is as follows: First, a binocular stereo vision system is used to simultaneously capture images of the LED beads in each light source zone from two different perspectives. Then, a stereo matching algorithm is used to calculate the coordinates P of the LED beads in three-dimensional space. i, Right now Among them, X i Represents the coordinate components of the i-th light source along the X-axis; Y iZ represents the coordinate component of the i-th light source in the Y-axis direction; i This represents the coordinate component of the i-th light source in the Z-axis direction.
[0054] Since the coordinates of the camera's optical center position D are known to be D=(0,0,0)ᵀ, the direction vector v of the i-th light source can be obtained. i for .in, Represents vector (P) i The Euclidean norm of -D) is used, and this method is more suitable for scenarios where LED beads are densely arranged and the distance between the light source and the object is relatively close.
[0055] Perform the above calculations on each of the N partitioned light sources to obtain the candidate light source direction vector set V={v1,v2,...,v...} N}. Where, v N This represents the direction vector of the Nth light source, and each vector has been normalized to a unit vector.
[0056] For step S8, the calculation process of the lighting matrix condition number is as follows: For a partitioned light source combination consisting of any K light sources (K≥3), construct a K×3 illumination matrix L, which is composed of the unit direction vectors of the K light sources arranged in rows:
[0057] v represents the unit direction vector of the light source in the i-th partition. k The transposed vector; v kx v ky and v kz These represent the unit direction vector v. k Components in the X, Y, and Z axes of the coordinate system.
[0058] Then, calculate the condition number b(L) of the matrix, i.e. , where σ max (L) and σ min (L) represents the maximum and minimum singular values of matrix L, respectively.
[0059] Taking a four-zone light source (one each at 0°, 90°, 180°, and 270°) as an example, the calculation process of the lighting matrix condition number is as follows: In a photometric solid, assume the camera is shooting vertically downwards along the Z-axis, and the object's surface faces Z. The direction of the light source is defined as a unit vector pointing from the object to the light source.
[0060] Assume that 4 subregions are evenly distributed on a cone with an inclination angle of 45° (i.e., an angle of 45° with the vertical direction), and their azimuth angles are 0°, 90°, 180°, and 270°, respectively. Since sin45°=0.707 and cos45°=0.707, the direction vectors corresponding to each subregion are [0.707,0,0.707], [0,0.707,0.707], [-0.707,0,0.707], and [0,-0.707,0.707].
[0061] After stacking the aforementioned four direction vectors, a 4×3 matrix L is obtained. Then, SVD decomposition (singular value decomposition) is performed on the matrix L to obtain the maximum singular value and the minimum singular value, and finally their ratio is calculated to obtain the illumination matrix condition number b which is approximately 1.414.
[0062] For step S8, after obtaining the illumination matrix condition numbers after combining the subregion light sources, the subregion light source combinations with an illumination matrix condition number lower than m can be screened as candidate subregion light source combinations. That is, the preset range is 0 to m. In practical work, the value range of m is usually 1<m≤30; preferably, the preferred value is 10.
[0063] In some embodiments, in step S8, the acquisition of the candidate subregion light source combination can also be implemented in the following manner. That is, with the goal of making the illumination matrix condition number meet the preset range, based on a preset search algorithm, the subregion light source combinations with the illumination matrix condition number within the preset range are acquired from all subregion light source combinations as candidate subregion light source combinations. Wherein, the search algorithm includes: branch and bound algorithm, greedy algorithm, genetic algorithm, and simulated annealing algorithm.
[0064] Specifically, with minimizing the condition number as the optimization objective, search algorithms such as branch and bound algorithm, greedy algorithm, genetic algorithm, and simulated annealing algorithm are adopted to search the subregion light source combinations meeting the condition number threshold being less than m in the candidate combination space, so as to obtain candidate subregion light source combinations.
[0065] In some embodiments, the process of screening out the subregion light source combinations with the illumination matrix condition number within the preset range from all subregion light source combinations based on the preset search algorithm may be as follows: According to the hierarchical search strategy from the quadrant level to the subregion level, the subregion light source combinations with the illumination matrix condition number within the preset range are acquired successively. Wherein, each subregion light source is independently arranged and distributed in four quadrants.
[0066] Specifically, when the subregion light source has a quadrant hierarchical structure (for example, 4 quadrants × 10 subregions): The first-level search strategy is quadrant-level combination optimization, which treats each quadrant as a whole unit (each quadrant contains multiple partitioned light sources), selects q quadrants from the 4 quadrants (usually q≥3), and has a total of C(4,q) combinations.
[0067] The second-level search strategy is partition-level combination generation: within the selected q quadrants, select p partitions (p=K / q) from the 10 partitions in each quadrant to generate partition light source combinations within each quadrant.
[0068] Then, the selection results at each level are combined to form a complete light source combination. Thus, the aforementioned hierarchical search strategy reduces the search space from C(40,K) to C(4,p)×[C(10,k)]^p, which can effectively reduce the computational load in the process.
[0069] In step S3, photometric stereo acquisition and reconstruction are performed for each candidate light source combination. That is, for each candidate light source combination, the corresponding zone light source is lit sequentially, multiple photometric stereo images are acquired, and the normal vector map and / or curvature map of the object surface are reconstructed.
[0070] For step S4, in the normal vector map and / or curvature map, for the defect region and the background region, calculate any one or more of the following indicators as the defect score C. These indicators include the grayscale difference between the defect and the background, the contrast ratio between the defect and the background, or the average gradient magnitude of the defect edge, etc.
[0071] Specifically, the formula for calculating the grayscale difference ΔI between the defect and the background is: ΔI = |I| defect -I background |. Among them, I defect I represents the average gray level of the defect area. background The average gray level of the adjacent background area; The formula for calculating the Cratio (defect to background contrast ratio) is: Cratio = |I defect -I background | / (I defect +I background +ε), where ε is a very small positive number to prevent division by zero.
[0072] The gradient magnitude ΔG at the defect edge is obtained by calculating the average gradient magnitude at the defect edge.
[0073] Alternatively, a deep learning object detection network can be used, and the detection confidence score output by the network can be used as a defect score.
[0074] For step S4, the quality score is usually the reciprocal of indicators such as the smoothness of the normal vector in the normal vector map and / or curvature map, the continuity of the gradient field, or the consistency of illumination.
[0075] Taking normal vector smoothness as an example, an ideal physical surface is typically smooth and continuous, and the normal vector should not exhibit abrupt changes between neighboring pixels. This metric is used to reflect salt-and-pepper noise or unrealistic textures in the normal vector map caused by poor combination of local light sources. A smaller normal vector smoothness value indicates a smoother transition of the normal vectors, corresponding to higher reconstruction quality in the image.
[0076] The normal vector smoothness is calculated as follows: for each pixel in the normal vector map, calculate the angle difference between its normal vector and the normal vectors of its four neighboring areas (top, bottom, left, and right).
[0077] In this application, the reciprocal of the smoothness of the normal vector is taken as the quality score.
[0078] For step S5, this application calculates the contrast score based on a preset weighting formula. The preset weighting formula is as follows: Score = α·C + β·b -1 +γ·R Where C is the defect score, b is the illumination matrix condition number, R is the quality score, and α, β, and γ are preset weight coefficients that can be adjusted according to the actual working scenario.
[0079] In some embodiments, step S4 can be replaced by the following step: S9. Calculate the contrast-to-noise ratio in the normal vector map and / or curvature map, and obtain the illumination matrix condition number under the corresponding zone light source combination.
[0080] Based on step S9, the zoned light source control method provided in this application further includes the following steps: S10. Perform a linear weighted calculation on the contrast-to-noise ratio and the reciprocal of the illumination matrix condition number to obtain the contrast score.
[0081] S6. Obtain the candidate zone light source combination with the highest contrast score as the target light source combination.
[0082] For step S10, in this application, the contrast-to-noise ratio (CNR) can be obtained by dividing the grayscale difference ΔI between the defect and the background by the background standard deviation.
[0083] For step S10, the weighted calculation formula for the contrast score is as follows: Score = α·CNR + β·b -1 In some embodiments, after obtaining the target light source combination in step S5, the partitioned light source control method provided in this application may further include the following steps: S11. Based on the target light source combination, re-acquire the normal vector map and / or curvature map of the surface of the object to be tested.
[0084] S12. Recalculate the contrast score and obtain the accuracy of defect identification results using the normal vector map and / or curvature map.
[0085] S13. Determine whether the contrast score and accuracy are both within the preset verification range; if yes, then use the target light source combination as the final partition light source combination and update it in the knowledge base; if no, then abandon the current target light source combination and obtain a new target light source combination.
[0086] For step S13, if the contrast score or accuracy of the current target light source combination is not within the preset verification range, then the second-highest contrast score partition light source combination matching the defect type needs to be selected from the knowledge base as the target light source combination. If no field with the same defect type exists in the knowledge base, then the weights of each item in the contrast score calculation are adjusted, and the partition light source combination with the highest contrast score is recalculated, and this new target light source combination is different from the previously discarded target light source combination. Furthermore, regarding the recalculation of the contrast score, the calculation methods for the two iterations can be consistent or different; no specific limitations are imposed here.
[0087] Based on the aforementioned processing, this application verifies the actual detection results of the target light source combination by calculating the contrast score and accuracy. If both are within the verification range and meet the requirements, the defect type, surface type, target light source combination, illumination matrix condition number, and contrast score of this detection are used as new fields and stored in the knowledge base for continuous updating. Simultaneously, the target light source combination is output to the light source control system for formal photometric stereo imaging acquisition and defect detection. If the calculated contrast score or accuracy does not meet the requirements, the target light source combination needs to be recalculated until a satisfactory target light source combination is obtained.
[0088] Based on the aforementioned incremental update mechanism for the knowledge base, the knowledge base can continuously accumulate fields during actual use, and as the usage time increases, the accuracy and robustness of the recommendation schemes within the knowledge base will continuously improve.
[0089] In some embodiments, this application also provides a zoned light source control system for photometric stereo, such as... Figure 2 As shown, the system includes: The type acquisition module 201 is used to acquire the defect type and surface type of the object to be tested.
[0090] The defect judgment module 202 is used to determine whether there are fields in the preset knowledge base that have the same defect type and surface type. If so, the module obtains the partition light source combination with the highest contrast score from the knowledge base field as the target light source combination. If not, the module selects the partition light source combination with the highest contrast score from the fields with the same defect type as the target light source combination. The knowledge base is a collection of multiple fields, each field including defect type, partition light source combination and contrast score. The partition light source combination represents the on / off state of the light source in each partition.
[0091] The image processing module 203 is used to obtain the normal vector map and / or curvature map of the surface of the object under test under various candidate partition light source combinations if no field with the same defect type exists in the knowledge base. The candidate partition light source combinations are selected from all partition light source combinations, with the illumination matrix condition number falling within a preset range; the illumination matrix condition number is calculated based on the three-dimensional direction vector of each partition light source.
[0092] The scoring calculation module 204 is used to calculate a defect score reflecting the detectability of defects based on the image features of the defect area and the background area in the normal vector map and / or curvature map; calculate a quality score reflecting the reconstruction quality based on the normal vector map and / or curvature map; and obtain the illumination matrix condition number under the corresponding partition light source combination.
[0093] The weighted calculation module 205 is used to perform linear weighted calculations on the defect score, quality score, and the reciprocal of the illumination matrix condition number to obtain the contrast score.
[0094] The light source acquisition module 206 is used to acquire the candidate zone light source combination with the highest contrast score as the target light source combination.
[0095] This application also provides an electronic device, such as... Figure 3 As shown, it includes a processor 301, a communication interface 302, a memory 303, and a communication bus 304, wherein the processor 301, the communication interface 302, and the memory 303 communicate with each other through the communication bus 304. Memory 303 is used to store computer programs; The processor 301, when executing the program stored in the memory 303, implements any of the above-mentioned partition light source control methods.
[0096] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not indicate that there is only one bus or one type of bus.
[0097] The communication interface is used for communication between the aforementioned electronic devices and other devices.
[0098] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0099] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be 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, or discrete hardware components.
[0100] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements any of the steps of the above-described partitioned light source control method.
[0101] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the partition light source control method steps in the above embodiments.
[0102] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A method for controlling a zoned light source for photometric stereo, characterized in that, include: Obtain the defect type and surface type of the object under test; Determine if a field exists in the preset knowledge base that has the same defect type and surface type; If yes, then the zone light source combination with the highest contrast score is obtained as the target light source combination; otherwise, the zone light source combination with the highest contrast score is selected from the fields of the same defect type as the target light source combination. The knowledge base consists of a collection of multiple fields, each including defect type, zone light source combination, and contrast score; the zone light source combination indicates the on / off status of the light source in each zone. If no field with the same defect type exists in the knowledge base, then obtain the normal vector map and / or curvature map of the surface of the object under test under each candidate partition light source combination; wherein, the candidate partition light source combination is the partition light source combination selected from all partition light source combinations with the illumination matrix condition number within a preset range; the illumination matrix condition number is calculated based on the three-dimensional direction vector of each partition light source; Based on the image features of the defect region and background region in the normal vector map and / or curvature map, calculate the defect score reflecting the detectability of the defect; based on the normal vector map and / or curvature map, calculate the quality score reflecting the reconstruction quality; obtain the illumination matrix condition number under the corresponding zone light source combination; The defect score, quality score, and the reciprocal of the illumination matrix condition number are linearly weighted and calculated to form the contrast score. The candidate light source combination with the highest contrast rating is selected as the target light source combination.
2. The zoned light source control method according to claim 1, characterized in that, Before acquiring the normal vector map and / or curvature map of the surface of the object under test under each selected zone light source combination, the zone light source control method further includes: The set of three-dimensional direction vectors for each zone light source is predetermined; Calculate the lighting matrix condition number for each set of three-dimensional direction vectors, and select the partition light source combinations whose lighting matrix condition number is within a preset range as candidate partition light source combinations.
3. The zoned light source control method according to claim 2, characterized in that, After calculating the illumination matrix condition number for each set of three-dimensional direction vectors, the partitioned light source control method further includes: With the goal of satisfying a preset range of illumination matrix condition numbers, a preset search algorithm is used to obtain the partition light source combinations whose illumination matrix condition numbers are within the preset range from all partition light source combinations, as candidate partition light source combinations; wherein, the search algorithm includes: branch and bound algorithm, greedy algorithm, genetic algorithm, and simulated annealing algorithm.
4. The zoned light source control method according to claim 3, characterized in that, Based on a preset search algorithm, select the light source combinations whose illumination matrix condition number is within a preset range from all light source combinations, including: Following a hierarchical search strategy from quadrant level to zone level, combinations of zone light sources with illumination matrix condition numbers within a preset range are obtained sequentially; wherein, each zone light source is independently set and distributed in four quadrants.
5. The zoned light source control method according to claim 1, characterized in that, The defect score, quality score, and the reciprocal of the lighting matrix condition number are linearly weighted to form the contrast score, which includes: A contrast score is calculated based on a preset weighting formula; where the preset weighting formula is: Score=a·C+b·b -1 +γ·R Where Score represents the contrast score; C represents the defect score, which is obtained by selecting any one of the following values: the grayscale difference between the defect and the background, the contrast ratio between the defect and the background, or the average gradient magnitude of the defect edge; b -1 α represents the reciprocal of the illumination matrix condition number b; R represents the quality score, which is obtained by selecting the reciprocal of any value from normal vector smoothness, gradient field continuity, or illumination consistency; α, β, and γ represent preset weight coefficients.
6. The zoned light source control method according to claim 1, characterized in that, Based on the image features of the defect region and background region in the normal vector map and / or curvature map, calculate a defect score reflecting the detectability of the defect; based on the normal vector map and / or curvature map, calculate a quality score reflecting the reconstruction quality; obtain the illumination matrix condition number under the corresponding zone light source combination and replace it with: Calculate the contrast-to-noise ratio in the normal vector map and / or curvature map, and obtain the illumination matrix condition number under the corresponding zone light source combination; The partitioned light source control method further includes: The contrast-to-noise ratio and the reciprocal of the illumination matrix condition number are linearly weighted and used as the contrast score. The candidate light source combination with the highest contrast rating is selected as the target light source combination.
7. The zoned light source control method according to claim 1 or 5, characterized in that, After obtaining the target light source combination, it also includes: Based on the target light source combination, the normal vector map and / or curvature map of the surface of the object under test are re-acquired; The contrast score and the accuracy of defect identification results are recalculated by normal vector plots and / or curvature plots; Determine whether the contrast score and accuracy are both within the preset verification range; if so, use the target light source combination as the final partition light source combination and update it in the knowledge base; if not, discard the current target light source combination and obtain a new target light source combination.
8. A zoned light source control system for photometric stereo, characterized in that, include: The type acquisition module is used to acquire the defect type and surface type of the object under test. The defect judgment module is used to determine whether there are fields in the preset knowledge base that have the same defect type and surface type; If yes, then the highest contrast rating combination of the partition light sources is obtained from the knowledge base fields and used as the target light source combination; otherwise, the highest contrast rating combination of the partition light sources is selected from the fields of the same defect type and used as the target light source combination. The knowledge base is a collection of multiple fields, each field including defect type, partition light source combination, and contrast rating; the partition light source combination indicates the on / off state of the light sources in each partition. The image processing module is used to obtain the normal vector map and / or curvature map of the surface of the object under test under various candidate partition light source combinations if no field with the same defect type exists in the knowledge base. The candidate partition light source combination is a partition light source combination selected from all partition light source combinations with an illumination matrix condition number within a preset range. The illumination matrix condition number is calculated based on the three-dimensional direction vector of each partition light source. The scoring calculation module is used to calculate a defect score reflecting the detectability of defects based on the image features of the defect area and the background area in the normal vector map and / or curvature map; calculate a quality score reflecting the reconstruction quality based on the normal vector map and / or curvature map; and obtain the illumination matrix condition number under the corresponding partition light source combination. The weighted calculation module is used to perform a linear weighted calculation on the defect score, quality score, and the reciprocal of the lighting matrix condition number to obtain the contrast score; The light source acquisition module is used to acquire the light source combination of the candidate zone with the highest contrast score, and use it as the target light source combination.
9. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory are connected through the communication bus; Memory, used to store computer programs; The processor, when executing a program stored in memory, implements the partitioned light source control method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the partitioned light source control method according to any one of claims 1-7.
Citation Information
Patent Citations
Brightness adjusting method and device for multi-partition light source, equipment, medium and product
CN118138864A
Photometric three-dimensional imaging method and high-speed photometric three-dimensional imaging device
CN119665813A
