Brightness calibration method, device, image measuring instrument and readable storage medium
By adjusting the light source power coefficient of the image measuring instrument, the problem of inconsistency in measurement results caused by the difference in light source brightness is solved, and the consistency of image brightness and measurement results under different magnifications and equipment is achieved.
Patent Information
- Application Number
- CN202510639859.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-19
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2045-05-19
AI Technical Summary
There are differences in the brightness of light sources of different image measuring instruments, which leads to inconsistent measurement results for the same item. Especially after changing the magnification, the image brightness changes significantly, affecting the accuracy of the measurement results.
By obtaining the target magnification and the corresponding power adjustment ratio, adjusting the light source power coefficient, so that the initial gray value of the target image meets the gray value conditions, and accurately calibration of the light source brightness.
Ensure consistency between image brightness and measurement results after changing the magnification or replacing the measuring device, and achieve accurate calibration of the brightness of the light source.
Smart Images

Figure CN120166304B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of equipment calibration, and in particular to a brightness calibration method, device, image measuring instrument, computer-readable storage medium, and computer program product. Background Art
[0002] As a commonly used precision instrument for 2D surface measurement, image measuring instruments differ from traditional contact measurement methods by capturing an image of an object using a CCD (Charge Coupled Device). A computer then reads the image captured by the CCD to obtain the object's dimensional data (e.g., workpiece parameters). During this non-contact measurement process, the clarity of the camera (lens) image is closely related to the brightness of the light source.
[0003] During actual measurement, even for the same model of image measuring instrument, the light sources configured in different instruments can still differ slightly. Even if other parameters remain unchanged, the brightness of the light source may vary between instruments, potentially leading to inconsistent measurement results for the same object. Alternatively, changing the magnification of the same instrument can produce different image brightness. Therefore, calibrating the brightness of the instrument's light source is crucial. Summary of the Invention
[0004] Based on this, it is necessary to provide a brightness calibration method, device, image measuring instrument, computer-readable storage medium and computer program product that can achieve accurate calibration of light source brightness in response to the above technical problems.
[0005] In a first aspect, the present application provides a brightness calibration method, comprising:
[0006] Obtaining a target magnification and a power adjustment ratio corresponding to the target magnification;
[0007] Acquire a target image according to the target magnification, and determine an initial grayscale value of the target image;
[0008] Under the condition of controlling the power adjustment ratio to remain unchanged, adjusting the light source power coefficient, and determining the light source power coefficient that makes the initial grayscale value of the target image meet the grayscale value condition as the target light source power coefficient; the light source power coefficient is used to represent the range of the actual power of the light source;
[0009] The brightness of the light source is adjusted according to the target light source power coefficient.
[0010] In one embodiment, the grayscale value condition includes that the absolute value of the difference between the initial grayscale value and the target grayscale value is less than a preset threshold; and the method for determining the target grayscale value includes:
[0011] Get candidate grayscale values;
[0012] If the candidate grayscale value is within the grayscale value range corresponding to the linear relationship between the image grayscale value and the actual power of the light source, the candidate grayscale value is used as the target grayscale value.
[0013] In one embodiment, the method further comprises:
[0014] If the target light source power coefficient does not belong to the target power coefficient interval, adjusting the power adjustment ratio to obtain an adjusted power adjustment ratio;
[0015] Under the condition that the adjusted power adjustment ratio remains unchanged, the target light source power coefficient is adjusted so that the light source power coefficient that makes the initial grayscale value of the target image meet the grayscale value condition and fall within the target power coefficient range is used as the adjusted target light source power coefficient;
[0016] The adjusting the brightness of the light source according to the target light source power coefficient includes:
[0017] The brightness of the light source is adjusted according to the adjusted target light source power coefficient.
[0018] In one embodiment, if the target light source power coefficient does not fall within the target power coefficient range, adjusting the power adjustment ratio to obtain an adjusted power adjustment ratio includes:
[0019] If the target light source power coefficient is less than the minimum value of the target power coefficient interval, reducing the power adjustment ratio to obtain an adjusted power adjustment ratio;
[0020] If the target light source power coefficient is greater than the maximum value of the target power coefficient interval, the power adjustment ratio is increased to obtain an adjusted power adjustment ratio.
[0021] In one embodiment, the target magnification includes multiple magnifications; and the method further includes:
[0022] If the multiple target magnifications are discretely distributed, determining the target light source power coefficient corresponding to each target magnification respectively;
[0023] If the multiple target magnifications are continuously distributed, a target number of target magnifications are selected from the multiple target magnifications, the target light source power coefficient corresponding to each target magnification in the target number is determined respectively, and the target light source power coefficients of the target number are interpolated to obtain the target light source power coefficients corresponding to the multiple target magnifications.
[0024] In one embodiment, determining the initial grayscale value of the target image includes:
[0025] Obtaining the pixel grayscale value of each pixel in the target image;
[0026] The average value or median value of the pixel grayscale values of each pixel in the target image is used as the initial grayscale value of the target image.
[0027] In a second aspect, the present application further provides a brightness calibration device, comprising:
[0028] An acquisition module, configured to acquire a target magnification and a power adjustment ratio corresponding to the target magnification;
[0029] a determination module, configured to acquire a target image according to the target magnification and determine an initial grayscale value of the target image;
[0030] An adjustment module is used to adjust the light source power coefficient while controlling the power adjustment ratio to remain unchanged, and determine the light source power coefficient that makes the initial grayscale value of the target image meet the grayscale value condition as the target light source power coefficient; the light source power coefficient is used to characterize the range of the actual power of the light source; and the brightness of the light source is adjusted according to the target light source power coefficient.
[0031] In a third aspect, the present application further provides an image measuring instrument comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the brightness calibration method provided in the first aspect when executing the computer program.
[0032] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the brightness calibration method provided in the first aspect.
[0033] In a fifth aspect, the present application further provides a computer program product, comprising a computer program, which, when executed by a processor, implements the steps of the brightness calibration method provided in the first aspect.
[0034] The brightness calibration method, device, image measuring instrument, computer-readable storage medium, and computer program product described above acquire a target magnification and a power adjustment ratio corresponding to the target magnification, acquire a target image according to the target magnification, determine the initial grayscale value of the target image, and adjust the light source power coefficient while maintaining the power adjustment ratio. The light source power coefficient that ensures the initial grayscale value of the target image meets the grayscale value condition is determined as the target light source power coefficient, and the brightness of the light source is adjusted based on the target light source power coefficient. By correcting the light source power coefficient, the grayscale value of the target image acquired by the image measuring instrument can be ensured to meet the grayscale value condition. Even after changing the magnification or replacing the measuring device, the grayscale value of the acquired image can still meet the grayscale value condition, thereby ensuring consistency in image brightness and measurement results, thus achieving accurate calibration of the light source brightness. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments of the present application or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying any creative work.
[0036] Figure 1 A diagram showing an application environment of a brightness calibration method according to an embodiment;
[0037] Figure 2 1 is a flow chart of a brightness calibration method according to an embodiment;
[0038] Figure 3 is a schematic flow chart of a brightness calibration method according to another embodiment;
[0039] Figure 4 is a structural block diagram of a brightness calibration device in one embodiment;
[0040] Figure 5 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0042] The brightness of images captured by the same image measuring instrument will change when the magnification is changed. Furthermore, even for the same model of image measuring instrument, different instruments may use different light sources. Therefore, even if other conditions remain the same, the corresponding light source brightness may vary. The light source brightness affects the brightness of the captured image, which in turn affects the contour recognition of the measured object in the captured image. This means that differences in image brightness can lead to variations in measurement results. For example, the width of a workpiece may appear smaller under strong light conditions.
[0043] In response to the above-mentioned problem of inconsistent measurement results after changing the magnification or replacing the measuring device, an embodiment of the present application provides a brightness calibration method. By controlling the power adjustment ratio while keeping it unchanged, the light source power coefficient is adjusted so that the grayscale value of the acquired target image meets the grayscale value condition. In this way, even if the magnification is changed or the measuring device is replaced, the brightness of the acquired image can be consistent, thereby achieving consistency in the measurement results, that is, accurate calibration of the light source brightness can be achieved.
[0044] The brightness calibration method provided in the embodiment of the present application can be applied to Figure 1 In the image measuring instrument shown in FIG. , the image measuring instrument can be a terminal or a server.
[0045] In an exemplary embodiment, Figure 2 As shown, a brightness calibration method is provided, which includes the following steps 202 to 208. In which:
[0046] Step 202: Obtain a target magnification and a power adjustment ratio corresponding to the target magnification.
[0047] The target magnification can be any magnification of the image measuring instrument. The magnification is used to characterize the observation capability and measurement accuracy of the measured object. The magnification can be expressed by the optical magnification and the display magnification. For example, the magnification is the product of the optical magnification and the display magnification: that is, magnification = optical magnification × display magnification. Optical magnification is achieved by the objective lens and zoom system, which is a physical magnification without loss of resolution. The optical magnification can be expressed by the ratio of the camera sensor size to the camera field of view. The display magnification is the magnification effect of the image displayed on the screen and is independent of the screen size and resolution. The display magnification can be expressed by the ratio of the screen display size to the sensor target surface size. Typically, an image measuring instrument can switch between multiple magnifications. For example, if the magnification range of an image measuring instrument is 30x to 200x, the target magnification can be any magnification from 30x to 200x. As can be seen, the magnification range can be configured according to the actual application scenario. In practical applications, the magnification can be switched using either motorized or manual zoom. For example, the magnification can be manually adjusted to 2x, 2.5x, 4x, 4.5x, 5x, and so on. Alternatively, the motorized zoom can be used to continuously change or switch the magnification within the range [0.6x, 5x].
[0048] The power adjustment ratio is the ratio by which the light source brightness is adjusted. The power adjustment ratio can be expressed as a percentage (%). The power adjustment ratio can be anywhere in the range [0% to 100%], where 0% represents the lowest adjustable brightness for the light source under the current conditions, and 100% represents the highest adjustable brightness for the light source under the current conditions. A larger power adjustment ratio corresponds to a higher light source brightness, while a smaller power adjustment ratio corresponds to a lower light source brightness.
[0049] Exemplarily, there is a one-to-one correspondence between the magnification and the power adjustment ratio. According to the correspondence between the magnification and the power adjustment ratio, the power adjustment ratio corresponding to the target magnification can be obtained. The larger the magnification, the higher the corresponding power adjustment ratio, and the brightness calibration method involved in the present disclosure can achieve that when the image is at any magnification, if the power adjustment ratio corresponding to the magnification is adjusted to the power adjustment ratio, the image brightness under different magnifications is roughly the same. For example, a magnification of 2x can correspond to a power adjustment ratio of 7%, a magnification of 8x can correspond to a power adjustment ratio of 70%, and so on. It is easy to understand that the correspondence between the magnification and the power adjustment ratio is predetermined, and the correspondence between the magnification and the power adjustment ratio can be determined based on experience or experiments. In an actual application scenario, after determining the target magnification, the power adjustment ratio is controlled to be set to the power adjustment ratio corresponding to the target magnification. For example, if the initial magnification is 8x and the power adjustment ratio is 70%, when the target magnification is selected as 2x, the power adjustment ratio is automatically adjusted to 7%, and the grayscale value of the image is roughly the same as before, thus ensuring roughly the same image brightness. If the user needs to further adjust the light source brightness, the power adjustment ratio can be freely adjusted within the ratio range of [0%, 100%] to achieve the corresponding adjustment of the light source brightness.
[0050] Step 204 : Acquire a target image according to the target magnification, and determine an initial grayscale value of the target image.
[0051] The target image is the image acquired by the image measuring instrument at the target magnification. The initial grayscale value refers to the grayscale value of the target image.
[0052] After obtaining the target magnification, the image measuring instrument can capture the target object and obtain a target image. This target image can be a raw image that has not been processed by the Image Signal Processor (ISP) to ensure that the grayscale values of the target image are closer to the actual grayscale values. In practical applications, image measuring instruments can be equipped with a variety of lighting methods, such as transmitted light, surface light, or coaxial light. For surface light calibration, brightness calibration is performed using a sample with a rough surface (forming diffuse reflection) that covers the field of view. This allows surface light to be reflected back to the camera through the sample. Transmitted light and coaxial light calibration do not require a sample.
[0053] For example, after acquiring a target image, the initial grayscale value of the target image can be determined based on the grayscale values of each pixel in the target image. For example, the average or median of the grayscale values of each pixel can be used as the initial grayscale value. The average value can be a weighted average or an arithmetic mean. If the acquired target image is a color image, the target image can be grayscaled to obtain a corresponding grayscale image, thereby obtaining the grayscale values of each pixel in the grayscale image. Alternatively, multiple images can be acquired for the same measurement scene, with the target image being one of the multiple images. The grayscale value of each image can be determined separately, and the average of the grayscale values of the multiple images can be used as the initial grayscale value of the target image.
[0054] Step 206 , while controlling the power adjustment ratio to remain unchanged, adjust the light source power coefficient, and determine the light source power coefficient that makes the initial grayscale value of the target image meet the grayscale value condition as the target light source power coefficient; the light source power coefficient is used to represent the range of the actual power of the light source.
[0055] Among them, the light source power coefficient is a coefficient used to characterize the actual power range of the light source. The actual power of the light source can characterize the brightness range of the light source. In other words, the light source power coefficient can also be a coefficient used to characterize the brightness range of the light source. For example, the actual current can be divided into multiple levels according to the brightness of the light source, for example, a total of 0-4095 levels, where level 0 corresponds to the light source being off, and level 4095 corresponds to the light source being at the highest brightness. If the light source power coefficient is 1, the actual power range of the light source is 0-4095; if the light source power coefficient is 0.5, the actual power range of the light source is 0-2047; if the light source power coefficient is 0.1, the actual power range of the light source is 0-409, and other light source power coefficients are similar. The larger the light source power coefficient, the larger the corresponding light source brightness range, and the smaller the light source power coefficient, the smaller the corresponding light source brightness range.
[0056] It's easy to understand that after determining the light source power coefficient, the light source brightness range can be limited. The light source brightness can also be adjusted within the light source brightness range corresponding to the light source power coefficient using the power adjustment ratio. For example, if the light source power coefficient is 0.5, if the power adjustment ratio is adjusted to 100%, the corresponding light source brightness is 2047. If the power adjustment ratio is adjusted to 10%, the corresponding light source brightness is 204, and so on.
[0057] Exemplarily, each image measuring instrument has a corresponding default light source power coefficient. While maintaining the control power adjustment ratio, the light source power coefficient is adjusted, starting from the default light source power coefficient, until the initial grayscale value of the target image meets the grayscale value condition. The light source power coefficient at this point serves as the target light source power coefficient. The grayscale value condition refers to the conditions that the initial grayscale value must meet. For example, the grayscale value condition may include the initial grayscale value being equal to the target grayscale value, or the absolute value of the difference between the initial grayscale value and the target grayscale value being less than a preset threshold. The target grayscale value or preset threshold can be set based on the actual application scenario. Exemplarily, the target grayscale value can range from [220, 250]. In actual application scenarios, depending on the actual imaging effect requirements, the target grayscale value can also be 200, 205, 210, 215, 220, 225, 230, 235, 240, 245, 250, etc.
[0058] Step 208: Adjust the brightness of the light source according to the target light source power coefficient.
[0059] During the actual measurement process, the image measuring instrument can adjust the brightness of the light source by correcting the target light source power coefficient, thereby achieving correction of the light source brightness.
[0060] In the brightness correction method described above, a target magnification and a corresponding power adjustment ratio are obtained, a target image is captured according to the target magnification, and an initial grayscale value of the target image is determined. While maintaining the power adjustment ratio constant, the light source power coefficient is adjusted, and the light source power coefficient that ensures the initial grayscale value of the target image meets the grayscale value condition is determined as the target light source power coefficient. The brightness of the light source is then adjusted based on the target light source power coefficient. Correcting the light source power coefficient ensures that the grayscale value of the target image captured by the image measuring instrument meets the grayscale value condition. Even after changing the magnification or replacing the measuring device, the grayscale value of the captured image can still meet the grayscale value condition, thereby ensuring consistency in image brightness and measurement results, thereby achieving accurate calibration of the light source brightness.
[0061] In some embodiments, the grayscale value condition includes that the absolute value of the difference between the initial grayscale value and the target grayscale value is less than a preset threshold; and the target grayscale value is determined by:
[0062] Obtain a candidate grayscale value; if the candidate grayscale value is within a grayscale value range corresponding to a linear relationship between the image grayscale value and the actual power of the light source, use the candidate grayscale value as the target grayscale value.
[0063] The candidate grayscale value can be any grayscale value, for example, a grayscale value input by the user. It is easy to understand that during actual measurement, the actual light source power and the image grayscale value may have a linear relationship within a certain range, but not beyond this range. The image grayscale values corresponding to the linear relationship with the actual light source power can be used as a grayscale value set. The grayscale value range of this grayscale value set can be compared with the candidate grayscale value to obtain a comparison result, and based on this comparison result, it is determined whether to use the candidate grayscale value as the target grayscale value.
[0064] For example, a grayscale value range corresponding to a linear relationship between the image grayscale value and the actual light source power can be predetermined. A candidate grayscale value and a grayscale value range corresponding to a linear relationship between the image grayscale value and the actual light source power are obtained, and the candidate grayscale value is compared with the grayscale value range. If the candidate grayscale value is within the grayscale value range, the candidate grayscale value is used as the target grayscale value; if the candidate grayscale value is not within the grayscale value range, the candidate grayscale value is not used as the target grayscale value.
[0065] For example, if the image grayscale value is within 250 and is linearly related to the actual light source power, the target grayscale value can be set to no greater than 250. The grayscale value range corresponding to the linear relationship between image grayscale value and actual light source power may vary between different image measuring instruments. For example, in some image measuring instruments, the linear relationship between image grayscale value and actual light source power may be within 230, while in others, the linear relationship may be within 220.
[0066] In this embodiment, whether to use the candidate grayscale value as the target grayscale value is determined based on whether the candidate grayscale value is within the grayscale value range corresponding to the linear relationship between the image grayscale value and the actual power of the light source. When the candidate grayscale value is within the grayscale value range corresponding to the corresponding linear relationship, the candidate grayscale value is used as the target grayscale value, which can ensure that after brightness calibration, the actual power of the light source and the image grayscale are still in a linear relationship.
[0067] In some embodiments, the above method further comprises:
[0068] If the target light source power coefficient does not fall within the target power coefficient range, the power adjustment ratio is adjusted to obtain an adjusted power adjustment ratio; while the adjusted power adjustment ratio remains unchanged, the target light source power coefficient is adjusted so that the initial grayscale value of the target image satisfies the grayscale value condition and falls within the target power coefficient range, and the adjusted target light source power coefficient is obtained.
[0069] Step 208 of adjusting the brightness of the light source according to the target light source power coefficient includes:
[0070] The brightness of the light source is adjusted according to the adjusted target light source power coefficient.
[0071] The target power coefficient range belongs to the preset light source power coefficient range. If the image measuring instrument's light source power coefficient falls within this range, both brightness and light source life can be improved, ensuring both brightness and light source life. For example, the target power coefficient range is [0.2, 0.7] or [0.3, 0.8].
[0072] For example, after determining the target light source power coefficient, the image measuring instrument compares the target light source power coefficient with the target power coefficient interval. If the target light source power coefficient does not fall within the target power coefficient interval, the power adjustment ratio is adjusted to obtain an adjusted power adjustment ratio. The adjusted power adjustment ratio is controlled to remain unchanged, and the light source power coefficient is further adjusted, that is, starting from the target light source power coefficient, the adjustment is made so that the initial grayscale value of the target image meets the grayscale value condition and the light source power coefficient falls within the target power coefficient interval. The light source power coefficient at this time is used as the adjusted target light source power coefficient, and then the brightness of the light source is adjusted according to the adjusted target light source power coefficient. If the target light source power coefficient falls within the target power coefficient interval, the brightness of the light source is directly adjusted according to the target light source power coefficient. It is easy to understand that the adjustment of the power adjustment ratio and the adjustment of the light source power coefficient while controlling the adjusted power adjustment ratio to remain unchanged can be performed once or multiple times until the initial grayscale value of the acquired target image meets the grayscale value condition and the light source power coefficient falls within the target power coefficient interval.
[0073] In this embodiment, by comparing the target light source power coefficient with the target power coefficient interval, if the target light source power coefficient does not belong to the target power coefficient interval, the power adjustment ratio is adjusted to obtain the adjusted power adjustment ratio, and then the adjusted power adjustment ratio is controlled to remain unchanged, and the light source power coefficient is readjusted until the initial grayscale value of the acquired target image meets the grayscale value condition and the light source power coefficient belongs to the target power coefficient interval, and the adjusted target light source power coefficient is obtained. The light source brightness is adjusted according to the adjusted target light source power coefficient, which can make the light source in a good working condition, does not affect the lifespan, and can also ensure a certain brightness, thereby improving the performance of the light source.
[0074] In some embodiments, if the target light source power coefficient does not fall within the target power coefficient range, the power adjustment ratio is adjusted to obtain an adjusted power adjustment ratio, including:
[0075] If the target light source power coefficient is less than the minimum value of the target power coefficient interval, the power adjustment ratio is reduced to obtain the adjusted power adjustment ratio; if the target light source power coefficient is greater than the maximum value of the target power coefficient interval, the power adjustment ratio is increased to obtain the adjusted power adjustment ratio.
[0076] When the target light source power coefficient does not fall within the target power coefficient interval, the power adjustment ratio can be adjusted. If the target light source power coefficient is less than the minimum value of the target power coefficient interval, the power adjustment ratio can be reduced according to the preset proportional amplitude to obtain the adjusted power adjustment ratio. If the target light source power coefficient is greater than the maximum value of the target power coefficient interval, the power adjustment ratio can be increased according to the preset proportional amplitude to obtain the adjusted power adjustment ratio. Among them, the preset proportional amplitude is used to characterize the adjustment step of the power adjustment ratio, and the preset proportional amplitude can be set according to the actual application scenario. For example, the preset proportional amplitude is 0.05, 0.1 or 0.2, etc.
[0077] For example, assuming the target power coefficient range is [0.2, 0.7] and the power adjustment ratio is 50%, if the target light source power coefficient is 0.1, the power adjustment ratio can be reduced by 10% according to the preset ratio, resulting in an adjusted power adjustment ratio of 40%. If the target light source power coefficient is 0.8, the power adjustment ratio can be increased by 10% according to the preset ratio, resulting in an adjusted power adjustment ratio of 60%.
[0078] In this embodiment, the power adjustment ratio adjustment direction is determined by the magnitude relationship between the target light source power coefficient and the maximum or minimum value in the target power coefficient interval. This allows for accurate adjustment of the power adjustment ratio, enabling faster acquisition of the adjusted power adjustment ratio, thereby improving brightness correction efficiency. The preset ratio amplitude can be related to the difference between the target light source power coefficient and the endpoints of the target power coefficient interval. In other words, the further the calculated target light source power coefficient is from the target power coefficient interval, the larger the preset ratio amplitude. This reduces the number of repeated calculations of the target power coefficient.
[0079] In some embodiments, the target magnification includes multiple magnifications; and the method further includes:
[0080] If multiple target magnifications are discretely distributed, the target light source power coefficient corresponding to each target magnification is determined separately; if multiple target magnifications are continuously distributed, a target number of target magnifications are selected from the multiple target magnifications, the target light source power coefficient corresponding to each target magnification in the target number is determined separately, and the target light source power coefficients of the target number are interpolated to obtain the target light source power coefficients corresponding to the multiple target magnifications.
[0081] In practical applications, the same image measuring instrument can have multiple target magnifications. For example, the magnification of the image measuring instrument can be manually controlled to obtain multiple discrete target magnifications, such as 2x, 2.5x, 4x, 4.5x, and 5x. Alternatively, a motorized continuous magnification control can be used to obtain multiple continuously distributed target magnifications, such as continuously changing the target magnification within the magnification range [0.6x, 5x].
[0082] For example, if multiple target magnifications are discretely distributed, the target light source power coefficient corresponding to each target magnification is determined separately by the above-mentioned method for determining the target light source power coefficient, that is, the light source power coefficient corresponding to each target magnification is calibrated. If multiple target magnifications are continuously distributed, a target number of target magnifications can be selected from the multiple target magnifications. The target number can be set according to the actual application scenario and is not specifically limited here. The target magnifications can be selected from the multiple target magnifications at evenly spaced preset magnifications, for example, the preset magnification is 0.5x or 1x. The target magnifications can also be selected at unevenly spaced preset magnifications, that is, the target magnifications can be randomly selected. Then, the target light source power coefficient corresponding to each target magnification in the selected target number is determined separately according to the above-mentioned method for determining the target light source power coefficient, so as to obtain the target number of target light source power coefficients. The target number of target light source power coefficients are subjected to data interpolation processing to obtain the target light source coefficients corresponding to the multiple target magnifications.
[0083] In this embodiment, the target light source power coefficients corresponding to the corresponding multiple target magnifications are determined according to the distribution of multiple target magnifications. For multiple target magnifications with discrete distribution, the target light source power coefficients corresponding to each target magnification are determined respectively. For multiple target magnifications with continuous distribution, a target number of target magnifications are first selected, and the target light source power coefficients corresponding to the selected target number of target magnifications are determined respectively to obtain the target light source power coefficients of the target number. Then, the target light source power coefficients of the target number are interpolated to obtain the target light source power coefficients corresponding to the multiple target magnifications. This can achieve calibration of the light source power coefficient for each target magnification, thereby achieving consistency in light source brightness when the magnification is changed, and further achieving consistency in the measurement results.
[0084] In some embodiments, determining an initial grayscale value of a target image includes:
[0085] Obtain the pixel grayscale value of each pixel in the target image; and use the average or median of the pixel grayscale values of each pixel in the target image as the initial grayscale value of the target image.
[0086] The target image can be a color image or a grayscale image. If the target image is a color image, it is necessary to first grayscale the color image to obtain the corresponding grayscale image.
[0087] For example, the image measuring instrument obtains the grayscale value of each pixel in the grayscale image corresponding to the target image and uses the average or median of the grayscale values of each pixel as the initial grayscale value of the target image. The average value can be an arithmetic mean or a weighted average. For example, weights can be set according to the position of the pixel in the target image, and the weighted average of the weights and the pixel grayscale values of each pixel can be used to obtain the initial grayscale value of the target image.
[0088] In this embodiment, by taking the average value or median value of the grayscale values of each pixel in the target image as the initial grayscale value of the target image, the initial grayscale value of the target image can be obtained quickly and conveniently.
[0089] In some exemplary embodiments, Figure 3 As shown, the brightness calibration method includes the following steps 302 to 312.
[0090] Step 302 , obtaining a candidate grayscale value; if the candidate grayscale value is within the grayscale value range corresponding to the linear relationship between the image grayscale value and the actual power of the light source, the candidate grayscale value is used as the target grayscale value.
[0091] Step 304: Obtain a target magnification and a power adjustment ratio corresponding to the target magnification.
[0092] Step 306 : Acquire a target image according to the target magnification, and determine an initial grayscale value of the target image.
[0093] Step 308 , while keeping the power adjustment ratio unchanged, adjust the light source power coefficient, and determine the light source power coefficient that makes the absolute value of the difference between the initial grayscale value and the target grayscale value of the target image smaller than a preset threshold as the target light source power coefficient.
[0094] Step 310 : There are multiple target magnifications. Each target magnification is traversed according to the process from step 304 to step 308 to determine the target light source power coefficient corresponding to each target magnification.
[0095] Step 312 : adjusting the brightness of the light source at the target magnification according to the target light source power coefficient corresponding to the target magnification.
[0096] In the above embodiment, by acquiring the target image corresponding to the target magnification, the light source power coefficient is adjusted while controlling the power adjustment ratio to remain unchanged, and the light source power coefficient that makes the absolute value of the difference between the initial grayscale value of the target image and the target grayscale value less than a preset threshold is determined as the target light source power coefficient. The target light source power coefficient corresponding to each target magnification is determined respectively, and then the light source brightness at the corresponding target magnification is adjusted according to the target light source power coefficient corresponding to the target magnification, so that after changing the magnification or replacing the measuring device, the grayscale value of the acquired image can still remain unchanged, thereby ensuring the consistency of the image brightness and the consistency of the measurement results, that is, achieving accurate calibration of the light source brightness.
[0097] It should be understood that, although the steps in the flowcharts of the above embodiments are shown in sequence as indicated by the arrows, these steps are not necessarily performed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the flowcharts of the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily to be performed in sequence, but can be performed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0098] Based on the same inventive concept, embodiments of the present application also provide a brightness calibration device for implementing the aforementioned brightness calibration method. The solution provided by this device is similar to the solution described in the aforementioned method. Therefore, the specific limitations of one or more brightness calibration device embodiments provided below can be found in the above-described limitations of the brightness calibration method and will not be further elaborated here.
[0099] In an exemplary embodiment, Figure 4 As shown, a brightness calibration device 400 is provided, comprising: an acquisition module 402, a determination module 404 and an adjustment module 406, wherein:
[0100] An acquisition module 402 acquires a target magnification and a power adjustment ratio corresponding to the target magnification;
[0101] The determination module 404 acquires a target image according to a target magnification and determines an initial grayscale value of the target image;
[0102] Adjustment module 406 adjusts the light source power coefficient while controlling the power adjustment ratio to determine the light source power coefficient that makes the initial grayscale value of the target image meet the grayscale value condition as the target light source power coefficient; the light source power coefficient is used to characterize the range of the actual power of the light source; and the brightness of the light source is adjusted according to the target light source power coefficient.
[0103] In some embodiments, the grayscale value condition includes that the absolute value of the difference between the initial grayscale value and the target grayscale value is less than a preset threshold; the above-mentioned brightness calibration device 400 also includes a target grayscale value determination module for obtaining a candidate grayscale value; if the candidate grayscale value is within the grayscale value range corresponding to the linear relationship between the image grayscale value and the actual power of the light source, the candidate grayscale value is used as the target grayscale value.
[0104] In some embodiments, the brightness calibration device 400 further includes a power coefficient interval detection module configured to adjust the power adjustment ratio if the target light source power coefficient does not fall within the target power coefficient interval to obtain an adjusted power adjustment ratio; and, while controlling the adjusted power adjustment ratio to remain unchanged, adjust the target light source power coefficient so that the initial grayscale value of the target image satisfies the grayscale value condition and falls within the target power coefficient interval, using the light source power coefficient as the adjusted target light source power coefficient.
[0105] The adjustment module 406 is further configured to adjust the brightness of the light source according to the adjusted target light source power coefficient.
[0106] In some embodiments, the power coefficient interval detection module is also used to reduce the power adjustment ratio to obtain an adjusted power adjustment ratio if the target light source power coefficient is less than the minimum value of the target power coefficient interval; if the target light source power coefficient is greater than the maximum value of the target power coefficient interval, increase the power adjustment ratio to obtain an adjusted power adjustment ratio.
[0107] In some embodiments, the target magnification includes multiple; the above-mentioned brightness calibration device 400 also includes a light source power coefficient determination module, which is used to determine the target light source power coefficient corresponding to each target magnification if the multiple target magnifications are discretely distributed; if the multiple target magnifications are continuously distributed, a target number of target magnifications are selected from the multiple target magnifications, and the target light source power coefficient corresponding to each target magnification in the target number is determined respectively, and the target light source power coefficients of the target number are interpolated to obtain the target light source power coefficients corresponding to the multiple target magnifications.
[0108] In some embodiments, the determination module 404 is further configured to obtain the pixel grayscale value of each pixel in the target image; and use the average or median of the pixel grayscale values of each pixel in the target image as the initial grayscale value of the target image.
[0109] Each module in the brightness calibration device described above can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in hardware form, or can be stored in a computer device memory in software form, so that the processor can call and execute the corresponding operations of each module.
[0110] In an exemplary embodiment, a computer device is provided. The computer device may be an image measuring instrument, and its internal structure diagram may be as shown in FIG. Figure 5 As shown. The computer device includes a processor, memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals via wired or wireless means, and the wireless means can be implemented via Wi-Fi, a mobile cellular network, near-field communication (NFC), or other technologies. When executed by the processor, the computer program implements a brightness calibration method. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse.
[0111] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0112] In an exemplary embodiment, an image measuring instrument is provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps of the brightness calibration method in the above embodiment when executing the computer program.
[0113] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the brightness calibration method in the above embodiment are implemented.
[0114] In one embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the steps of the brightness calibration method in the above embodiment are implemented.
[0115] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0116] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the various embodiments provided herein may be, but are not limited to, general-purpose processors, central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), programmable logic devices (PLDs), quantum computing-based data processing logic devices, artificial intelligence (AI) processors, and the like.
[0117] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, 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 application.
[0118] The above embodiments merely illustrate several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art may make various modifications and improvements without departing from the spirit of the present invention, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. A brightness calibration method, characterized in that: Applied to an image measuring instrument, the method includes: Obtaining a target magnification and obtaining a power adjustment ratio corresponding to the target magnification based on a correspondence between the magnification and the power adjustment ratio; the power adjustment ratio refers to an adjustment ratio for the brightness of the light source; Acquire a target image according to the target magnification, and determine an initial grayscale value of the target image; Under the condition of controlling the power adjustment ratio to remain unchanged, adjusting the light source power coefficient, and determining the light source power coefficient that makes the initial grayscale value of the target image meet the grayscale value condition as the target light source power coefficient; the light source power coefficient is used to represent the range of the actual power of the light source; The brightness of the light source is adjusted according to the target light source power coefficient.
2. The method according to claim 1, characterized in that The grayscale value condition includes that the absolute value of the difference between the initial grayscale value and the target grayscale value is less than a preset threshold; the method for determining the target grayscale value includes: Get candidate grayscale values; If the candidate grayscale value is within the grayscale value range corresponding to the linear relationship between the image grayscale value and the actual power of the light source, the candidate grayscale value is used as the target grayscale value.
3. The method according to claim 1 or 2, characterized in that The method further comprises: If the target light source power coefficient does not belong to the target power coefficient interval, adjusting the power adjustment ratio to obtain an adjusted power adjustment ratio; Under the condition that the adjusted power adjustment ratio remains unchanged, the target light source power coefficient is adjusted so that the light source power coefficient that makes the initial grayscale value of the target image meet the grayscale value condition and fall within the target power coefficient range is used as the adjusted target light source power coefficient; The adjusting the brightness of the light source according to the target light source power coefficient includes: The brightness of the light source is adjusted according to the adjusted target light source power coefficient.
4. The method according to claim 3, characterized in that If the target light source power coefficient does not fall within the target power coefficient range, adjusting the power adjustment ratio to obtain an adjusted power adjustment ratio includes: If the target light source power coefficient is less than the minimum value of the target power coefficient interval, reducing the power adjustment ratio to obtain an adjusted power adjustment ratio; If the target light source power coefficient is greater than the maximum value of the target power coefficient interval, the power adjustment ratio is increased to obtain an adjusted power adjustment ratio.
5. The method according to claim 1, characterized in that The target magnification includes multiple magnifications; the method further includes: If the multiple target magnifications are discretely distributed, determining the target light source power coefficient corresponding to each target magnification respectively; If the multiple target magnifications are continuously distributed, a target number of target magnifications are selected from the multiple target magnifications, the target light source power coefficient corresponding to each target magnification in the target number is determined respectively, and the target light source power coefficients of the target number are interpolated to obtain the target light source power coefficients corresponding to the multiple target magnifications.
6. The method according to any one of claims 1 to 5, characterized in that Determining the initial grayscale value of the target image includes: Obtaining the pixel grayscale value of each pixel in the target image; The average value or median value of the pixel grayscale values of each pixel in the target image is used as the initial grayscale value of the target image.
7. A brightness calibration device, characterized in that: Applied to an image measuring instrument, the device comprises: An acquisition module, configured to acquire a target magnification and, based on a correspondence between the magnification and the power adjustment ratio, acquire a power adjustment ratio corresponding to the target magnification; the power adjustment ratio refers to an adjustment ratio for the brightness of the light source; a determination module, configured to acquire a target image according to the target magnification and determine an initial grayscale value of the target image; An adjustment module is used to adjust the light source power coefficient while controlling the power adjustment ratio to remain unchanged, and determine the light source power coefficient that makes the initial grayscale value of the target image meet the grayscale value condition as the target light source power coefficient; the light source power coefficient is used to characterize the range of the actual power of the light source; and the brightness of the light source is adjusted according to the target light source power coefficient.
8. An image measuring instrument comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Light supplementing control method and device for image collection device and image collection system
CN108900781A
Shooting method and system, and terminal
CN109672825A