Endoscope calibration method, device, electronic device and storage medium
By acquiring sample images and white level images and establishing calibration functions, the black level noise problem caused by dark current changes in the image sensor under dark light conditions is solved, and the image quality is improved.
Patent Information
- Application Number
- CN202211712892.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-29
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2042-12-29
AI Technical Summary
After the endoscope is used for a period of time, the dark current level of the image sensor changes, resulting in black level noise in the image, affecting the imaging quality, especially in low light conditions.
By obtaining the sample image set and the white level image, determining the black level value and white level value, establishing a calibration function, and using this function to calibrate the calibrated image to remove black level noise.
The imaging quality of the endoscope under dark light conditions is improved, and the black level noise in the image is removed, which improves the image quality.
Smart Images

Figure CN115883976B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, and in particular, to an endoscope calibration method, apparatus, electronic device, and storage medium. Background Art
[0002] With the progress of electronic imaging technology, it has become possible to miniaturize a camera device to form an endoscope and apply it in the medical field. However, due to the volume limitation of the endoscope system inside the human body, the area of the image sensor is small and the imaging quality is insufficient. The internal environment of the human body where image acquisition is performed is relatively complex, and there are high requirements for the imaging quality under low-light conditions. Therefore, after the endoscope is used for a period of time, the dark current level, i.e., the black level, of the image sensor changes, resulting in black level noise in the captured images and affecting the image quality. Summary of the Invention
[0003] In view of this, the present disclosure provides an endoscope calibration method, apparatus, electronic device, and storage medium, aiming to perform black level calibration on the images captured by the endoscope.
[0004] According to a first aspect of the present disclosure, there is provided an endoscope calibration method, the method including:
[0005] Obtaining a set of sample images and a white level image, where the set of sample images includes a plurality of all-black sample images captured in a lightless environment, each of the sample images having a corresponding gain, and the white level image is an image captured by the endoscope under the conditions of maximum brightness and maximum gain;
[0006] Determining a corresponding black level value according to the pixel values of each of the sample images;
[0007] Determining a corresponding white level value according to the pixel values of the white level image;
[0008] Determining a calibration function according to the gain of each of the sample images and the corresponding black level value;
[0009] In response to the endoscope obtaining an image to be calibrated, calibrating the image to be calibrated according to the white level value and the calibration function.
[0010] In a possible implementation manner, the obtaining the set of sample images and the white level image includes:
[0011] Adjusting the camera gain of the endoscope multiple times in a lightless environment, and capturing corresponding sample images each time after adjustment to obtain the set of sample images;
[0012] Causing the endoscope to capture an image under the conditions of maximum light source brightness and maximum camera gain to obtain the white level image.
[0013] In a possible implementation, each of the sample images also has a corresponding temperature, and the white level image is an image acquired by the endoscope when the brightness, gain, and temperature are all at their maximum values.
[0014] In a possible implementation, the acquisition of the set of sample images and the white level image includes:
[0015] Adjusting the ambient temperature and the camera gain of the endoscope iteratively in a lightless environment, and acquiring corresponding sample images after each adjustment to obtain a set of sample images;
[0016] Causing the endoscope to acquire an image when the light source brightness is at its maximum, the camera gain is at its maximum, and the ambient temperature is at its maximum, to obtain a white level image.
[0017] In a possible implementation, the adjusting of the ambient temperature and the camera gain of the endoscope iteratively in a lightless environment, and acquiring corresponding sample images after each adjustment to obtain a set of sample images includes:
[0018] Adjusting the ambient temperature multiple times according to a preset temperature adjustment rule in a lightless environment;
[0019] After each adjustment of the ambient temperature, adjusting the camera gain of the endoscope according to a preset gain adjustment rule and acquiring a corresponding all-black image as a sample image;
[0020] In response to satisfying a first stop condition, ending the gain adjustment process of the camera at the current temperature and adjusting the ambient temperature again;
[0021] In response to satisfying a second stop condition, ending the adjustment process of the current ambient temperature, and determining a set of sample images according to the multiple acquired sample images and the corresponding temperature and gain when each sample image is acquired.
[0022] In a possible implementation, the determining of the corresponding black level value according to the pixel value of each sample image includes:
[0023] Calculating the average value of the pixel values in each sample image to obtain the corresponding black level value.
[0024] In a possible implementation, the determining of the corresponding white level value according to the pixel value of the white level image includes:
[0025] Calculating the average value of the pixel values in the white level image to obtain the corresponding white level value.
[0026] In a possible implementation, the determining of the calibration function according to the gain of each sample image and the corresponding black level value includes:
[0027] Determine a preset first parameter and a second parameter;
[0028] Determine a candidate function composed of the sum of the product of the first parameter and the gain and the second parameter;
[0029] Input the gain of the sample image into the candidate function and determine the corresponding function value;
[0030] Input the difference between the function value corresponding to each sample image and the black level value into a preset cost function, and calculate the corresponding mean square error as the function error;
[0031] In response to the function error not meeting the preset condition, update the first parameter and the second parameter, and re-iteratively execute the steps of inputting the gain of the sample image into the candidate function and subsequent steps;
[0032] In response to the function error meeting the preset condition, end the parameter iteration process and determine the current candidate function as the calibration function.
[0033] In a possible implementation manner, the determining the calibration function according to the gain and the corresponding black level value of each sample image includes:
[0034] Determine the calibration function according to the gain, temperature and the corresponding black level value of each sample image.
[0035] In a possible implementation manner, the determining the calibration function according to the gain, temperature and the corresponding black level value of each sample image includes:
[0036] Determine a preset first parameter, a second parameter and a third parameter;
[0037] Determine a candidate function composed of the sum of the product of the first parameter and the gain, the product of the third parameter and the temperature and the second parameter;
[0038] Input the gain and temperature of the sample image into the candidate function and determine the corresponding function value;
[0039] Input the difference between the function value corresponding to each sample image and the black level value into a preset cost function, and calculate the corresponding mean square error as the function error;
[0040] In response to the function error not meeting the preset condition, update the first parameter, the second parameter and the third parameter, and re-iteratively execute the steps of inputting the gain and temperature of the sample image into the candidate function and subsequent steps;
[0041] In response to the function error meeting the preset condition, end the parameter iteration process and determine the current candidate function as the calibration function.
[0042] In one possible implementation, updating the first parameter and the second parameter includes:
[0043] Taking the partial derivatives of the cost function with respect to the first parameter and the second parameter respectively to obtain corresponding first partial derivative results and second partial derivative results;
[0044] Calculating the difference between the first parameter and the product of the first partial derivative result and a preset learning rate to obtain the updated first parameter;
[0045] Calculating the difference between the second parameter and the product of the second partial derivative result and the learning rate to obtain the updated second parameter.
[0046] In one possible implementation, updating the first parameter, the second parameter and the third parameter includes:
[0047] Taking the partial derivatives of the cost function with respect to the first parameter, the second parameter and the third parameter respectively to obtain corresponding first partial derivative results, second partial derivative results and third partial derivative results;
[0048] Calculating the difference between the first parameter and the product of the first partial derivative result and a preset learning rate to obtain the updated first parameter;
[0049] Calculating the difference between the second parameter and the product of the second partial derivative result and the learning rate to obtain the updated second parameter;
[0050] Calculating the difference between the third parameter and the product of the third partial derivative result and the learning rate to obtain the updated third parameter.
[0051] In one possible implementation, the method further includes:
[0052] Obtaining a test image set including a plurality of all - black test images collected in a light - less environment, each of the test images having a corresponding gain and temperature;
[0053] Verifying the calibration function according to the test image set.
[0054] In one possible implementation, the method further includes:
[0055] Obtaining a test image set including a plurality of all - black test images collected in a light - less environment, each of the test images having a corresponding gain and temperature;
[0056] Verifying the calibration function according to the test image set.
[0057] In one possible implementation, calibrating the image to be calibrated according to the white - level value and the calibration function includes:
[0058] Determine the target gain corresponding to obtaining the image to be calibrated;
[0059] Input the target gain into the calibration function to obtain the corresponding target black level value;
[0060] Adjust the pixel value of each pixel in the image to be calibrated according to the target black level value and the white level value to obtain the calibrated image.
[0061] In a possible implementation manner, the calibration of the image to be calibrated according to the white level value and the calibration function includes:
[0062] Determine the target temperature and target gain corresponding to obtaining the image to be calibrated;
[0063] Input the target temperature and the target gain into the calibration function to obtain the corresponding target black level value;
[0064] Adjust the pixel value of each pixel in the image to be calibrated according to the target black level value and the white level value to obtain the calibrated image.
[0065] In a possible implementation manner, the adjustment of the pixel value of each pixel in the image to be calibrated according to the target black level value and the white level value to obtain the calibrated image includes:
[0066] Obtain the target pixel value of the target pixel in the image to be calibrated;
[0067] Determine the ratio of the difference between the target pixel value and the target black level value to the difference between the white level value and the target black level, and obtain the calibrated target pixel value according to the product of the ratio and a preset constant;
[0068] Update the original pixel value according to the calibrated pixel value of each pixel in the image to be calibrated to obtain the calibrated image. According to the second aspect of the present disclosure, an endoscope calibration device is provided, and the device includes:
[0069] An image acquisition module, configured to acquire a sample image set and a white level image, where the sample image set includes a plurality of all-black sample images collected in a lightless environment, each of the sample images has a corresponding gain, and the white level image is an image collected by the endoscope when the brightness and gain are both maximum;
[0070] A first level determination module, configured to determine the corresponding black level value according to the pixel value of each of the sample images;
[0071] A second level determination module, configured to determine the corresponding white level value according to the pixel value of the white level image;
[0072] A function fitting module, configured to determine a calibration function according to the gain of each of the sample images and the corresponding black level value;
[0073] An image calibration module, configured to, in response to the endoscope acquiring an image to be calibrated, calibrate the image to be calibrated according to the white level value and the calibration function.
[0074] In a possible implementation, the acquired set of sample images and the white level image include:
[0075] Adjust the camera gain of the endoscope multiple times in a lightless environment, and acquire the corresponding sample images after each adjustment to obtain a set of sample images;
[0076] Cause the endoscope to acquire an image under the condition that the light source brightness is the maximum and the camera gain is the maximum, to obtain a white level image.
[0077] In a possible implementation, each of the sample images further has a corresponding temperature, and the white level image is an image acquired by the endoscope under the conditions that the brightness, the gain, and the temperature are all the maximum.
[0078] In a possible implementation, the acquired set of sample images and the white level image include:
[0079] Adjust the ambient temperature and the camera gain of the endoscope multiple times in an iterative manner in a lightless environment, and acquire the corresponding sample images after each adjustment to obtain a set of sample images;
[0080] Cause the endoscope to acquire an image under the conditions that the light source brightness is the maximum, the camera gain is the maximum, and the ambient temperature is the maximum, to obtain a white level image.
[0081] In a possible implementation, the adjusting the ambient temperature and the camera gain of the endoscope multiple times in an iterative manner in a lightless environment, and acquiring the corresponding sample images after each adjustment to obtain a set of sample images includes:
[0082] Adjust the ambient temperature multiple times according to a preset temperature adjustment rule in a lightless environment;
[0083] After each adjustment of the ambient temperature, adjust the camera gain of the endoscope according to a preset gain adjustment rule and acquire the corresponding all-black image as a sample image;
[0084] In response to satisfying a first stop condition, end the gain adjustment process of the camera at the current temperature, and adjust the ambient temperature again;
[0085] In response to satisfying the second stop condition, the adjustment process of the current ambient temperature is ended, and a set of sample images is determined according to the acquired multiple sample images and the corresponding temperature and gain when each of the sample images is acquired.
[0086] In a possible implementation manner, the determining the corresponding black level value according to the pixel value of each of the sample images includes:
[0087] Calculating the average value of the pixel values in each of the sample images to obtain the corresponding black level value.
[0088] In a possible implementation manner, the determining the corresponding white level value according to the pixel value of the white level image includes:
[0089] Calculating the average value of the pixel values in the white level image to obtain the corresponding white level value.
[0090] In a possible implementation manner, the determining the calibration function according to the gain of each of the sample images and the corresponding black level value includes:
[0091] Determining a preset first parameter and a second parameter;
[0092] Determining a candidate function composed of the product of the first parameter and the gain and the sum of the second parameter;
[0093] Inputting the gain of the sample image into the candidate function and determining the corresponding function value;
[0094] Inputting the difference between the function value corresponding to each of the sample images and the black level value into a preset cost function, and calculating the corresponding mean square error as the function error;
[0095] In response to the function error not satisfying the preset condition, updating the first parameter and the second parameter, and re-iteratively executing the steps of inputting the gain of the sample image into the candidate function and subsequent steps;
[0096] In response to the function error satisfying the preset condition, ending the parameter iteration process and determining the current candidate function as the calibration function.
[0097] In a possible implementation manner, the determining the calibration function according to the gain of each of the sample images and the corresponding black level value includes:
[0098] Determining the calibration function according to the gain, temperature and corresponding black level value of each of the sample images.
[0099] In a possible implementation manner, the determining the calibration function according to the gain, temperature and corresponding black level value of each of the sample images includes:
[0100] Determine preset first parameter, second parameter, and third parameter;
[0101] Determine a candidate function composed of the product of the first parameter and the gain, the sum of the product of the third parameter and the temperature and the second parameter;
[0102] Input the gain and temperature of the sample image into the candidate function, and determine the corresponding function value;
[0103] Input the difference between the function value corresponding to each sample image and the black level value into a preset cost function, and calculate the corresponding mean square error as the function error;
[0104] In response to the function error not satisfying the preset condition, update the first parameter, second parameter, and third parameter, and re-iteratively execute the steps of inputting the gain and temperature of the sample image into the candidate function and subsequent steps;
[0105] In response to the function error satisfying the preset condition, end the parameter iteration process and determine the current candidate function as the calibration function.
[0106] In a possible implementation manner, the updating of the first parameter and the second parameter includes:
[0107] Respectively take the partial derivatives of the cost function with respect to the first parameter and the second parameter to obtain corresponding first partial derivative result and second partial derivative result;
[0108] Calculate the difference between the first parameter and the product of the first partial derivative result and the preset learning rate to obtain the updated first parameter;
[0109] Calculate the difference between the second parameter and the product of the second partial derivative result and the learning rate to obtain the updated second parameter.
[0110] In a possible implementation manner, the updating of the first parameter, second parameter, and third parameter includes:
[0111] Respectively take the partial derivatives of the cost function with respect to the first parameter, second parameter, and third parameter to obtain corresponding first partial derivative result, second partial derivative result, and third partial derivative result;
[0112] Calculate the difference between the first parameter and the product of the first partial derivative result and the preset learning rate to obtain the updated first parameter;
[0113] Calculate the difference between the second parameter and the product of the second partial derivative result and the learning rate to obtain the updated second parameter;
[0114] Calculate the difference between the third parameter and the product of the third partial derivative result and the learning rate to obtain the updated third parameter.
[0115] In a possible implementation, the device further includes:
[0116] A first test image acquisition module, configured to acquire a test image set including a plurality of test images that are all black and acquired in a lightless environment, each of the test images having a corresponding gain and temperature;
[0117] A first verification module, configured to verify the calibration function according to the test image set.
[0118] In a possible implementation, the device further includes:
[0119] A second test image acquisition module, configured to acquire a test image set including a plurality of test images that are all black and acquired in a lightless environment, each of the test images having a corresponding gain and temperature;
[0120] A second verification module, configured to verify the calibration function according to the test image set.
[0121] In a possible implementation, calibrating the image to be calibrated according to the white level value and the calibration function includes:
[0122] Determining a target gain corresponding to when the image to be calibrated is acquired;
[0123] Inputting the target gain into the calibration function to obtain a corresponding target black level value;
[0124] Adjusting the pixel value of each pixel in the image to be calibrated according to the target black level value and the white level value to obtain a calibrated image.
[0125] In a possible implementation, calibrating the image to be calibrated according to the white level value and the calibration function includes:
[0126] Determining a target temperature and a target gain corresponding to when the image to be calibrated is acquired;
[0127] Inputting the target temperature and the target gain into the calibration function to obtain a corresponding target black level value;
[0128] Adjusting the pixel value of each pixel in the image to be calibrated according to the target black level value and the white level value to obtain a calibrated image.
[0129] In a possible implementation, adjusting the pixel value of each pixel in the image to be calibrated according to the target black level value and the white level value to obtain a calibrated image includes:
[0130] Obtaining a target pixel value of a target pixel in the image to be calibrated;
[0131] Determine the ratio of the difference between the target pixel value and the target black level value to the difference between the white level value and the target black level, and obtain the calibrated target pixel value according to the product of the ratio and a preset constant;
[0132] Update the original pixel values according to the calibrated pixel values of each pixel in the image to be calibrated, and obtain the calibrated image.
[0133] According to a third aspect of the present disclosure, there is provided an image acquisition device, the device includes:
[0134] A white level calibration cup, including an upper bottom surface, a lower bottom surface and a cup wall, and forming a sealed space through the upper bottom surface, the lower bottom surface and the cup wall. The upper bottom surface and the lower bottom surface are made of elastic materials. The lower bottom surface has an insertion hole, and a heating resistor is arranged inside the cup wall;
[0135] An endoscope is inserted into the white level calibration cup through the insertion hole of the lower bottom surface for image acquisition each time the temperature of the heating resistor and / or the camera gain in the endoscope is adjusted.
[0136] In a possible implementation manner, a temperature sensor is further arranged inside the cup wall for detecting the temperature inside the white level calibration cup.
[0137] In a possible implementation manner, the endoscope further includes a light source.
[0138] According to a fourth aspect of the present disclosure, there is provided an electronic device, including: a processor; a memory for storing instructions executable by the processor; wherein, the processor is configured to implement the above method when executing the instructions stored in the memory.
[0139] According to a fifth aspect of the present disclosure, there is provided a non-volatile computer-readable storage medium, on which computer program instructions are stored, wherein the computer program instructions implement the above method when executed by a processor.
[0140] According to a sixth aspect of the present disclosure, there is provided a computer program product, including computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in the processor of an electronic device, the processor in the electronic device executes the above method.
[0141] In an embodiment of the present disclosure, a sample image set including a plurality of sample images that are completely black and collected in a lightless environment, and a white level image collected by an endoscope under the condition that the brightness, gain, and temperature are all at their maximum values are obtained. Each sample image has a corresponding gain and temperature. The corresponding black level value is determined according to the pixel value of each sample image, and the white level value is determined according to the pixel value of the white level image. A calibration function is determined according to the gain, temperature, and corresponding black level value of each sample image. When the endoscope obtains an image to be calibrated, the image to be calibrated is calibrated according to the white level value and the calibration function. The present disclosure accurately determines the calibration function representing the corresponding relationship between the black level value and the gain and temperature through a plurality of samples, and calibrates the images collected by the endoscope in real time through the calibration function and the white level value, removing the noise brought by the black level in the images and improving the image quality.
[0142] Other features and aspects of the present disclosure will become clear from the following detailed description of exemplary embodiments with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0143] The accompanying drawings, which are included in and constitute a part of this specification, illustrate exemplary embodiments, features, and aspects of the present disclosure together with the specification, and are used to explain the principles of the present disclosure.
[0144] Figure 1 A flowchart showing an endoscope calibration method according to an embodiment of the present disclosure;
[0145] Figure 2 A schematic diagram showing the corresponding relationship between gain and black level value according to an embodiment of the present disclosure;
[0146] Figure 3 A schematic diagram showing the corresponding relationship between temperature and black level value according to an embodiment of the present disclosure;
[0147] Figure 4 A schematic diagram showing the process of obtaining a sample image set and a white level image according to an embodiment of the present disclosure;
[0148] Figure 5 A schematic diagram showing a sample image according to an embodiment of the present disclosure;
[0149] Figure 6 A schematic diagram showing the image calibration effect according to an embodiment of the present disclosure;
[0150] Figure 7 A schematic diagram showing an image acquisition device according to an embodiment of the present disclosure
[0151] Figure 8 A schematic diagram showing an endoscope calibration device according to an embodiment of the present disclosure;
[0152] Figure 9 Schematic diagram showing an electronic device according to an embodiment of the present disclosure;
[0153] Figure 10 Schematic diagram showing another electronic device according to an embodiment of the present disclosure. Detailed implementation manners
[0154] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the drawings denote elements having the same or similar functions. Although various aspects of the embodiments are shown in the drawings, the drawings are not necessarily drawn to scale unless otherwise specified.
[0155] The term "exemplary" used herein means "serving as an example, embodiment, or illustration". Any embodiment described herein as "exemplary" is not necessarily to be construed as superior or better than other embodiments.
[0156] In addition, for a better description of the present disclosure, numerous specific details are given in the following detailed implementation manners. Those skilled in the art should understand that the present disclosure can be implemented without some specific details. In some instances, methods, means, elements, and circuits well-known to those skilled in the art are not described in detail so as to highlight the gist of the present disclosure.
[0157] In a possible implementation manner, the endoscope calibration method according to an embodiment of the present disclosure can be executed by an electronic device such as a processor, a terminal device, or a server. Among them, the terminal device can be a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. A fixed or mobile terminal. The server can be a single server or a server cluster composed of multiple servers. The electronic device can implement the endoscope calibration method according to an embodiment of the present disclosure by the processor calling computer-readable instructions stored in the memory.
[0158] Figure 1 Flowchart showing an endoscope calibration method according to an embodiment of the present disclosure. As Figure 1 shown, the endoscope calibration method according to an embodiment of the present disclosure can include the following steps S10-S50.
[0159] Step S10, obtaining a sample image set and a white level image.
[0160] In a possible implementation, a white level image of a set of sample images can be obtained by an electronic device. The set of sample images includes multiple sample images that are completely black and collected in a lightless environment, and each sample image has a corresponding gain. The white level image is an image collected by the endoscope when both the brightness and the gain are at their maximum. To further improve the calibration accuracy, a temperature variable can also be introduced during the process of collecting the sample images and the white level image, such that each sample image in the set of sample images has a corresponding gain and temperature, and the white level image is an image collected by the endoscope when the brightness, the gain, and the temperature are all at their maximum.
[0161] Optionally, each sample image in the set of sample images and the white level image are both images collected by the endoscope. The gain corresponding to the image collected by the endoscope is the gain of the endoscope camera when collecting the image, and the corresponding temperature is the ambient temperature when collecting the image. The lens of the endoscope includes a camera and a light source, that is, the sample image is an image collected in a lightless environment with the light source turned off, and the white level image is an image collected in a lightless environment when the light source is adjusted to the maximum, and the camera gain and the ambient temperature are also adjusted to the maximum. The electronic device according to the embodiments of the present disclosure can obtain the set of sample images and the white level image by directly collecting images through the connected endoscope, or can obtain the images collected by the endoscope connected to other devices and sent to the electronic device.
[0162] Figure 2 FIG. shows a schematic diagram of a correspondence relationship between gain and black level value according to an embodiment of the present disclosure. As Figure 2 shown, when the endoscope performs image collection, the gain of the endoscope camera can affect the black level value (i.e., the dark current value) of the collected image. At the same time, the relationship between the gain and the black level value is a proportional relationship, that is, the higher the camera gain, the higher the black level value, that is, the greater the noise generated by the dark current in the collected image. Therefore, after the image is collected, the black level value can be further determined according to the gain of the endoscope camera when collecting the image.
[0163] Figure 3 FIG. shows a schematic diagram of a correspondence relationship between temperature and black level value according to an embodiment of the present disclosure. As Figure 3 shown, when the endoscope performs image collection, the temperature of the collection environment can affect the black level value (i.e., the dark current value) of the collected image. At the same time, the relationship between the temperature and the black level value is a proportional relationship, that is, the higher the collection environment temperature, the higher the black level value, that is, the greater the noise generated by the dark current in the collected image. Therefore, after the image is collected, the black level value can be further determined according to the ambient temperature when collecting the image.
[0164] Based on the influence of gain and temperature on dark current, an electronic device can obtain multiple sample images with corresponding gains, or multiple sample images with corresponding gains and temperatures, and determine the influence of gain on the sample images according to the black level values of the sample images and the corresponding gains. Alternatively, the influence of gain and temperature on the black level value can also be determined according to the black level values of the sample images and the corresponding gains and temperatures. Optionally, the environments for obtaining the sample images and the white level image in the embodiments of the present disclosure are both dark environments with adjustable temperatures. To facilitate the adjustment of the environmental temperature, the endoscope can be placed in a container that is sealed and dark and has a temperature control device, and sample images are collected after each adjustment of the temperature and / or the gain of the endoscope camera to obtain a set of sample images. At the same time, after adjusting the temperature control device in the container to the maximum and the gain of the endoscope camera to the highest, the endoscope light source is adjusted to the maximum, and then the white level image is collected.
[0165] Optionally, in the case where the set of sample images includes multiple sample images with corresponding gains and the white level image is an image collected when the endoscope has the maximum brightness and gain, the process of obtaining the set of sample images and the white level image can be to adjust the gain of the endoscope camera multiple times in a lightless environment, and collect the corresponding sample images after each adjustment to obtain the set of sample images. The endoscope is made to collect an image when the light source brightness is the maximum and the camera gain is the maximum to obtain the white level image.
[0166] Optionally, in the case where the set of sample images includes multiple sample images with corresponding gains and temperatures and the white level image is an image collected when the endoscope has the maximum brightness, temperature, and gain, the order of obtaining the set of sample images and the white level image in the embodiments of the present disclosure can be determined arbitrarily. For example, the set of sample images can be obtained first and then the white level image, or the white level image can be obtained first and then the set of sample images. Among them, the set of sample images can be obtained by collecting sample images multiple times in an iterative manner, that is, adjusting the environmental temperature and the gain of the endoscope camera multiple times in an iterative manner in a lightless environment, and collecting the corresponding sample images after each adjustment to obtain the set of sample images. The process of obtaining the white level image can be to make the endoscope collect an image when the light source brightness is the maximum, the camera gain is the maximum, and the environmental temperature is the maximum to obtain the white level image.
[0167] In a possible implementation, the process of collecting a set of sample images iteratively may include adjusting the ambient temperature multiple times according to a preset temperature adjustment rule in a lightless environment, and after each adjustment of the ambient temperature, adjusting the camera gain of the endoscope according to a preset gain adjustment rule and collecting the corresponding all-black image as a sample image. In response to satisfying a first stop condition, the gain adjustment process of the camera at the current temperature is ended, and the ambient temperature is adjusted again. In response to satisfying a second stop condition, the adjustment process of the current ambient temperature is ended, and a set of sample images is determined based on the obtained multiple sample images and the corresponding temperature and gain when each sample image is collected. Among them, the preset temperature adjustment rule may start from a preset temperature and increase by a preset number of degrees Celsius each time it is adjusted. The preset gain adjustment rule may start from a gain of 1 and increase by a preset step each time it is adjusted. The first stop condition may be that the gain value reaches a preset maximum gain value, and the second stop condition may be that the ambient temperature reaches a preset maximum temperature value.
[0168] That is to say, the ambient temperature can be adjusted multiple times, and the camera gain can be adjusted multiple times by the endoscope after each temperature adjustment and an all-black image can be captured until the temperature is adjusted again until the temperature reaches the preset maximum temperature value when the camera gain reaches the maximum gain value. The temperature adjustment range can be determined according to the image acquisition scenario of the endoscope. For example, in the case of collecting internal images of the human body, the preset temperature adjustment range can be determined according to the temperature range inside the human body.
[0169] Figure 4 FIG. shows a schematic diagram of a process for obtaining a set of sample images and a white level image according to an embodiment of the present disclosure. As Figure 4As shown, when the electronic device is in the sample image set and the white level image, it can first obtain the sample image set and then obtain the white level image. That is, it can first set the initial gain and temperature, place the endoscope in a lightless environment for 40, obtain the current ambient temperature, camera gain and collect images 41, and then determine whether the current gain has reached the preset maximum gain value 42. When the current gain is not the maximum value, increase the gain according to the preset gain adjustment rule 43 and collect images again. When the current gain is the maximum value, determine whether the current ambient temperature has reached the preset maximum temperature value 44. When the current temperature is not the maximum value, the temperature can be increased according to the preset temperature adjustment rule and the gain value can be adjusted to the minimum value, that is, the initial gain value, and images are collected again 45. When the current temperature reaches the maximum value, the sample image acquisition process ends, and the sample image set is determined according to all the collected sample images 46. Further, the light source used to illuminate the camera in the endoscope is adjusted to the maximum value, and at the same time, the gain and temperature are both adjusted to the maximum value 47, and then image acquisition is performed to obtain the white level image 48. Among them, the adjustment order of the gain and temperature can be swapped, that is, the temperature is adjusted multiple times and images are collected after each adjustment of the gain.
[0170] Figure 5 FIG. shows a schematic diagram of a sample image according to an embodiment of the present disclosure. As Figure 5 shown, the sample image is a completely black image under naked-eye observation, but the pixel values of the completely black sample images collected under different temperature and / or gain conditions are substantially different. The electronic device can calculate the corresponding black level value according to the pixel value of each sample image after collecting the sample image.
[0171] Step S20: Determine the corresponding black level value according to the pixel value of each of the sample images.
[0172] In a possible implementation manner, after obtaining the sample image set, the electronic device can calculate the corresponding black level value according to the pixel value of each sample image in the sample image set. The black level value can be any characteristic value calculated according to the pixel value of the sample image, and is used to characterize the magnitude of the noise influence caused by the dark current of the collected image value on the image. Exemplarily, the electronic device can calculate the average value of the pixel values in each sample image to obtain the corresponding black level value.
[0173] Step S30: Determine the corresponding white level value according to the pixel value of the white level image.
[0174] In a possible implementation, after obtaining the white-level image, the electronic device can calculate the white-level value corresponding to the white-level image by calculating the same method as the black-level value of the sample image. For example, the average value of the pixel values in the white-level image can be calculated to obtain the corresponding white-level value. The white-level value represents the characteristic value of the image pixels in the case of the minimum dark current. In the embodiments of the present disclosure, the order in which the electronic device calculates the white-level value corresponding to the white-level image and the black-level value corresponding to each sample image may not be limited.
[0175] Step S40: Determine a calibration function according to the gain of each of the sample images and the corresponding black-level value.
[0176] In a possible implementation, after determining the black-level value of each sample image in the sample image set, the electronic device can determine a calibration function according to the gain of each sample image and the corresponding black-level value. The calibration function is used to represent the relationship between the black-level value, the gain, and the temperature when collecting the corresponding image. Among them, the process for the electronic device to determine the calibration function can be to preset a function model, and then adjust the parameters of the function model according to the difference between the result obtained by inputting the gain corresponding to the sample image into the function model and the black-level value, so as to obtain the calibration function.
[0177] Optionally, the electronic device can first determine a candidate function as the function model according to a plurality of preset parameters, and then adjust the parameters according to the result of inputting the gain and temperature of the sample image into the candidate function to obtain the calibration function. That is, the first parameter and the second parameter preset can be determined first, and a candidate function composed of the product of the first parameter and the gain and the sum of the second parameter can be determined. The gain of the sample image is input into the candidate function, and the corresponding function value is determined. The corresponding function error is determined according to the function value and the black-level value corresponding to each sample image. In response to the function error not meeting the preset condition, the first parameter and the second parameter are updated, and the steps of inputting the gain and temperature of the sample image into the candidate function and subsequent steps are iteratively executed again. In response to the function error meeting the preset condition, the parameter iteration process is ended and the current candidate function is determined as the calibration function.
[0178] Exemplarily, the electronic device can set the first parameter as A and the second parameter as B, and determine the candidate function as BL = A * gain + B, where gain is the gain and BL is the function value, which is used to represent the expected black-level value at the corresponding gain. The initial values of the preset first parameter A and second parameter B can be 1.
[0179] Optionally, since the function value output after the gain input candidate function corresponding to the sample image represents the expected black level value of the sample image, the function error can be determined according to the difference between the expected black level value and the actual black level value of each sample image in the sample image set. The process of determining the function error can be to input the difference between the function value and the black level value corresponding to each sample image into a preset cost function, and calculate the corresponding mean square error as the function error. That is, the cost function can be where m is the number of sample images in the sample image set, and BL get is the actual black level value calculated for the sample image.
[0180] Furthermore, in each iteration process, after the electronic device obtains the corresponding function error by inputting the difference between the function values and the black level values corresponding to all the sample images in the sample image set into the cost function, it can determine whether to end the iteration process or enter the next iteration according to a preset condition. That is, after obtaining the function error, the electronic device can determine whether the function error meets the corresponding preset condition. If it does not meet the condition, the first parameter and the second parameter are updated and the function error of the candidate function is recalculated. If it meets the condition, the current candidate function is determined as the calibration function. Among them, the preset condition can be that the function error is less than or equal to a preset error value.
[0181] In a possible implementation manner, when the function error does not meet the preset condition, the first parameter and the second parameter can be updated according to the cost function. Exemplarily, the parameter update process can be to respectively calculate the partial derivatives of the cost function with respect to the first parameter and the second parameter to obtain the corresponding first partial derivative result and second partial derivative result. Calculate the difference between the first parameter and the product of the first partial derivative result and the preset learning rate to obtain the updated first parameter, and calculate the difference between the second parameter and the product of the second partial derivative result and the learning rate to obtain the updated second parameter.
[0182] Exemplarily, the first partial derivative result obtained by the electronic device calculating the partial derivatives of the cost function with respect to the first parameter and the second parameter respectively is The second partial derivative result is where α is a preset learning rate. That is, the updated first parameter and second parameter can be determined by the following formulas respectively:
[0183]
[0184]
[0185] In a possible implementation, when a temperature variable is introduced, each sample image in the sample image set also has a corresponding temperature. The electronic device can determine a calibration function based on the gain, temperature, and corresponding black level value of each sample image. Optionally, the electronic device can first determine a candidate function as a function model according to a plurality of preset parameters, and then adjust the parameters according to the results of inputting the sample image gain and temperature into the candidate function to obtain the calibration function. That is, the preset first parameter, second parameter, and third parameter can be determined first, and a candidate function composed of the product of the first parameter and the gain, the product of the third parameter and the temperature, and the sum of the second parameter is determined. The gain and temperature of the sample image are input into the candidate function, and the corresponding function value is determined. According to the difference between the function value corresponding to each sample image and the black level value, the corresponding function error is determined. In response to the function error not meeting the preset condition, the first parameter, second parameter, and third parameter are updated, and the steps of inputting the gain and temperature of the sample image into the candidate function and subsequent steps are iteratively executed again. In response to the function error meeting the preset condition, the parameter iteration process is ended and the current candidate function is determined as the calibration function.
[0186] Exemplarily, the electronic device can set the first parameter as A, the second parameter as B, and the third parameter as C, and determine the candidate function as BL = A * gain + C * temperature + B, where gain is the gain, temperature is the temperature, and BL is the function value, which is used to represent the expected black level value at the corresponding gain and temperature. The initial values of the preset first parameter A, second parameter B, and third parameter C can be 1.
[0187] Optionally, since the function value output after inputting the gain and temperature corresponding to the sample image represents the expected black level value of the sample image, the function error can be determined according to the difference between the expected black level value and the actual black level value of each sample image in the sample image set. The process of determining the function error can be to input the difference between the function value corresponding to each sample image and the black level value into a preset cost function, and calculate the corresponding mean square error as the function error. That is, the cost function can be where m is the number of sample images in the sample image set, and BL get is the actual black level value calculated for the sample image.
[0188] Further, in each iteration process, after the electronic device obtains the corresponding function error by inputting the difference between the function values and the black level values corresponding to all the sample images in the sample image set into the cost function, it can determine whether to end the iteration process or enter the next iteration according to a preset condition. That is, after obtaining the function error, the electronic device can determine whether the function error satisfies the corresponding preset condition. If not, it updates the first parameter, the second parameter, and the third parameter and recalculates the function error of the candidate function. If satisfied, it determines the current candidate function as the calibration function. The preset condition may be that the function error is less than or equal to a preset error value.
[0189] In a possible implementation manner, when the function error does not satisfy the preset condition, the first parameter, the second parameter, and the third parameter can be updated according to the cost function. Exemplarily, the parameter update process may be to respectively calculate the partial derivatives of the cost function with respect to the first parameter, the second parameter, and the third parameter to obtain the corresponding first partial derivative result, second partial derivative result, and third partial derivative result. Calculate the difference between the first parameter and the product of the first partial derivative result and the preset learning rate to obtain the updated first parameter, calculate the difference between the second parameter and the product of the second partial derivative result and the learning rate to obtain the updated second parameter, and calculate the difference between the third parameter and the product of the third partial derivative result and the learning rate to obtain the updated third parameter.
[0190] Exemplarily, the first partial derivative result obtained by the electronic device calculating the partial derivative of the cost function with respect to the first parameter, the second parameter, and the third parameter respectively is The second partial derivative result is The third partial derivative result is where α is a preset learning rate. That is, the updated first parameter, second parameter, and third parameter can be determined by the following formulas respectively:
[0191]
[0192]
[0193]
[0194] In a possible implementation, after determining the calibration function, the electronic device can also test the calibration function. Exemplarily, a test image set including a plurality of test images that are all black and collected in a lightless environment can be obtained, and each test image has a corresponding gain and temperature. Then, the calibration function is verified according to the test image set. Among them, the method of obtaining the test image set is the same as the process of obtaining the sample image set. The verification method of the calibration function can be to input the gain and temperature of each test image in the test image set into the calibration function, and then determine the function loss according to the difference between the output function value and the black level value corresponding to the test image. When the function loss is less than or equal to the preset loss threshold, the electronic device can determine that the calibration function passes the verification. When the function loss is greater than the preset loss threshold, the electronic device determines that the calibration function fails the verification, and re-obtains the sample image set to determine a new calibration function.
[0195] Step S50: In response to the endoscope obtaining a to-be-calibrated image, calibrate the to-be-calibrated image according to the white level value and the calibration function.
[0196] In a possible implementation, after obtaining the calibration function and the white level value, the electronic device can calibrate the image collected by the endoscope according to the calibration function and the white level value to filter out the noise caused by dark current and optimize the image quality. That is, after the electronic device obtains the to-be-calibrated image that needs to be calibrated and collected by the endoscope, it calibrates the to-be-calibrated image according to the white level value and the calibration function.
[0197] Optionally, the electronic device can determine the black level value based on the gain of the endoscope camera when obtaining the to-be-calibrated image, and then perform image calibration. Or determine the black level value jointly based on the gain of the endoscope camera and the temperature of the environment when obtaining the to-be-calibrated image, and then perform image calibration. That is, the electronic device can first determine the target gain corresponding to obtaining the to-be-calibrated image, input the target gain into the calibration function to obtain the corresponding target black level value. Then, according to the target black level value and the white level value, adjust the pixel value of each pixel in the to-be-calibrated image to obtain the calibrated image. Or, first determine the target temperature and target gain corresponding to obtaining the to-be-calibrated image, input the target temperature and target gain into the calibration function to obtain the corresponding target black level value. Then, according to the target black level value and the white level value, adjust the pixel value of each pixel in the to-be-calibrated image to obtain the calibrated image.
[0198] Optionally, the process of adjusting the pixel value of each pixel in the image to be calibrated according to the target black level value and white level value is to obtain the target pixel value of the target pixel in the image to be calibrated, determine the difference between the target pixel value and the target black level value, the ratio of the white level value to the target black level difference, and obtain the calibrated target pixel value according to the product of the ratio and the preset constant. Finally, update the original pixel value according to the calibrated pixel value of each pixel in the image to be calibrated to obtain the calibrated image. That is, each pixel value in the calibrated image can be calculated according to the formula determined, where Pixel get is the pixel value in the image to be calibrated, BL is the target black level value, WL is the white level value, N is the preset constant, and Pixel real is the calibrated pixel value.
[0199] Figure 6 FIG. shows a schematic diagram of an image calibration effect according to an embodiment of the present disclosure. As Figure 6 shown, the image to be calibrated is above, and the calibrated image is below. The noise generated by the image to be calibrated due to the influence of the black level makes the image quality low. The image calibrated according to the calibration function and the white level value removes the noise generated by the black level, and the image quality is higher.
[0200] Based on the above technical features, the embodiment of the present disclosure can accurately determine the calibration function representing the correspondence between the black level value, gain, and temperature through multiple samples, and calibrate the image collected by the endoscope in real time through the calibration function and the white level value, removing the noise brought by the black level in the image and improving the image quality. At the same time, the accuracy of the obtained calibration function is improved by verifying the calibration function, and the noise in the image can be accurately removed.
[0201] Figure 7 FIG. shows a schematic diagram of an image acquisition device according to an embodiment of the present disclosure. As Figure 7 shown, the image acquisition device of the embodiment of the present disclosure includes a white level calibration cup and an endoscope. Among them, the white level calibration cup includes an upper bottom surface, a lower bottom surface, and a cup wall, and forms a closed space through the upper bottom surface, the lower bottom surface, and the cup wall. The upper bottom surface and the lower bottom surface are made of elastic materials, the lower bottom surface has an insertion hole, and a heating resistor is arranged inside the cup wall. The endoscope is inserted into the white level calibration cup through the insertion hole on the lower bottom surface of the white level calibration cup for image acquisition each time the temperature of the heating resistor and / or the gain of the camera in the endoscope is adjusted. Further, a temperature sensor is also arranged inside the cup wall of the white level calibration cup for detecting the temperature inside the white level calibration cup and adjusting the heating resistor based on the temperature value detected by the temperature sensor. And the endoscope also includes a light source for collecting a white level image when the light source is turned on.
[0202] Based on the above features, the embodiments of the present disclosure can collect sample images multiple times in a dark environment where the ambient temperature and the camera gain can be accurately adjusted, and then fit an accurate calibration function to calibrate the images, thereby improving the image quality.
[0203] Figure 8 FIG. shows a schematic diagram of an endoscope calibration device according to an embodiment of the present disclosure. As Figure 8 shown, the endoscope calibration device of the embodiment of the present disclosure may include:
[0204] An image acquisition module 80, configured to acquire a sample image set and a white level image, where the sample image set includes a plurality of all-black sample images acquired in a lightless environment, each of the sample images having a corresponding gain, and the white level image is an image acquired by the endoscope when both the brightness and the gain are at the maximum;
[0205] A first level determination module 81, configured to determine a corresponding black level value according to the pixel values of each of the sample images;
[0206] A second level determination module 82, configured to determine a corresponding white level value according to the pixel values of the white level image;
[0207] A function fitting module 83, configured to determine a calibration function according to the gain of each of the sample images and the corresponding black level value;
[0208] An image calibration module 84, configured to calibrate the to-be-calibrated image according to the white level value and the calibration function in response to the endoscope acquiring the to-be-calibrated image.
[0209] In a possible implementation manner, the acquired sample image set and white level image include:
[0210] Adjust the camera gain of the endoscope multiple times in a lightless environment, and acquire corresponding sample images after each adjustment to obtain a sample image set;
[0211] Cause the endoscope to acquire an image when the light source brightness and the camera gain are both at the maximum to obtain a white level image.
[0212] In a possible implementation manner, each of the sample images further has a corresponding temperature, and the white level image is an image acquired by the endoscope when the brightness, the gain, and the temperature are all at the maximum.
[0213] In a possible implementation manner, the acquired sample image set and white level image include:
[0214] Adjust the environmental temperature and the camera gain of the endoscope iteratively multiple times in a lightless environment, and collect corresponding sample images after each adjustment to obtain a set of sample images;
[0215] Make the endoscope collect an image under the conditions of maximum light source brightness, maximum camera gain, and maximum environmental temperature to obtain a white level image.
[0216] In a possible implementation manner, the adjusting the environmental temperature and the camera gain of the endoscope iteratively multiple times in a lightless environment, and collecting corresponding sample images after each adjustment to obtain a set of sample images includes:
[0217] Adjust the environmental temperature multiple times according to a preset temperature adjustment rule in a lightless environment;
[0218] After each adjustment of the environmental temperature, adjust the camera gain of the endoscope according to a preset gain adjustment rule and collect the corresponding all-black image as a sample image;
[0219] In response to satisfying a first stop condition, end the gain adjustment process of the camera at the current temperature, and adjust the environmental temperature again;
[0220] In response to satisfying a second stop condition, end the adjustment process of the current environmental temperature, and determine the set of sample images according to the obtained multiple sample images and the corresponding temperature and gain when each sample image is collected.
[0221] In a possible implementation manner, the determining the corresponding black level value according to the pixel value of each sample image includes:
[0222] Calculate the average value of the pixel values in each sample image to obtain the corresponding black level value.
[0223] In a possible implementation manner, the determining the corresponding white level value according to the pixel value of the white level image includes:
[0224] Calculate the average value of the pixel values in the white level image to obtain the corresponding white level value.
[0225] In a possible implementation manner, the determining the calibration function according to the gain of each sample image and the corresponding black level value includes:
[0226] Determine a preset first parameter and a second parameter;
[0227] Determine a candidate function composed of the product of the first parameter and the gain and the sum of the second parameter;
[0228] Input the gain of the sample image into the candidate function and determine the corresponding function value;
[0229] Input the difference between the function value corresponding to each of the sample images and the black level value into a preset cost function, and calculate the corresponding mean square error as the function error;
[0230] In response to the function error not satisfying a preset condition, update the first parameter and the second parameter, and re-iteratively execute the steps of inputting the gain of the sample image into the candidate function and subsequent steps;
[0231] In response to the function error satisfying the preset condition, end the parameter iteration process and determine the current candidate function as the calibration function.
[0232] In a possible implementation manner, the determining the calibration function according to the gain of each of the sample images and the corresponding black level value includes:
[0233] Determine the calibration function according to the gain, temperature, and corresponding black level value of each of the sample images.
[0234] In a possible implementation manner, the determining the calibration function according to the gain, temperature, and corresponding black level value of each of the sample images includes:
[0235] Determine preset first, second, and third parameters;
[0236] Determine a candidate function composed of the product of the first parameter and the gain, the sum of the product of the third parameter and the temperature and the second parameter;
[0237] Input the gain and temperature of the sample image into the candidate function, and determine the corresponding function value;
[0238] Input the difference between the function value corresponding to each of the sample images and the black level value into a preset cost function, and calculate the corresponding mean square error as the function error;
[0239] In response to the function error not satisfying a preset condition, update the first, second, and third parameters, and re-iteratively execute the steps of inputting the gain and temperature of the sample image into the candidate function and subsequent steps;
[0240] In response to the function error satisfying the preset condition, end the parameter iteration process and determine the current candidate function as the calibration function.
[0241] In a possible implementation manner, the updating the first parameter and the second parameter includes:
[0242] Respectively take the partial derivatives of the cost function with respect to the first parameter and the second parameter to obtain corresponding first and second partial derivative results;
[0243] Calculate the difference between the first parameter and the product of the first partial derivative result and a preset learning rate to obtain the updated first parameter;
[0244] Calculate the difference between the second parameter and the product of the second partial derivative result and the learning rate to obtain the updated second parameter.
[0245] In a possible implementation, updating the first parameter, the second parameter, and the third parameter includes:
[0246] Respectively take the partial derivatives of the cost function with respect to the first parameter, the second parameter, and the third parameter to obtain the corresponding first partial derivative result, second partial derivative result, and third partial derivative result;
[0247] Calculate the difference between the first parameter and the product of the first partial derivative result and a preset learning rate to obtain the updated first parameter;
[0248] Calculate the difference between the second parameter and the product of the second partial derivative result and the learning rate to obtain the updated second parameter;
[0249] Calculate the difference between the third parameter and the product of the third partial derivative result and the learning rate to obtain the updated third parameter.
[0250] In a possible implementation, the device further includes:
[0251] A first test image acquisition module, configured to acquire a test image set including a plurality of all-black test images acquired in a lightless environment, each of the test images having a corresponding gain and temperature;
[0252] A first verification module, configured to verify the calibration function according to the test image set.
[0253] In a possible implementation, the device further includes:
[0254] A second test image acquisition module, configured to acquire a test image set including a plurality of all-black test images acquired in a lightless environment, each of the test images having a corresponding gain and temperature;
[0255] A second verification module, configured to verify the calibration function according to the test image set.
[0256] In a possible implementation, calibrating the image to be calibrated according to the white level value and the calibration function includes:
[0257] Determine the target gain corresponding to when the image to be calibrated is acquired;
[0258] Input the target gain into the calibration function to obtain the corresponding target black level value;
[0259] Adjust the pixel value of each pixel in the image to be calibrated according to the target black level value and the white level value to obtain a calibrated image.
[0260] In a possible implementation, the calibration of the image to be calibrated according to the white level value and the calibration function includes:
[0261] Determine the target temperature and target gain corresponding to the acquisition of the image to be calibrated;
[0262] Input the target temperature and the target gain into the calibration function to obtain the corresponding target black level value;
[0263] Adjust the pixel value of each pixel in the image to be calibrated according to the target black level value and the white level value to obtain a calibrated image.
[0264] In a possible implementation, the adjustment of the pixel value of each pixel in the image to be calibrated according to the target black level value and the white level value to obtain a calibrated image includes:
[0265] Obtain the target pixel value of the target pixel in the image to be calibrated;
[0266] Determine the ratio of the difference between the target pixel value and the target black level value to the difference between the white level value and the target black level, and obtain the calibrated target pixel value according to the product of the ratio and a preset constant;
[0267] Update the original pixel value according to the calibrated pixel value of each pixel in the image to be calibrated to obtain a calibrated image.
[0268] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the methods described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments. For the sake of brevity, it will not be repeated here.
[0269] The embodiments of the present disclosure also propose a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the above methods are implemented. The computer-readable storage medium can be a volatile or non-volatile computer-readable storage medium.
[0270] The embodiments of the present disclosure also propose an electronic device, including: a processor; a memory for storing instructions executable by the processor; wherein, the processor is configured to implement the above methods when executing the instructions stored in the memory.
[0271] Embodiments of the present disclosure also provide a computer program product, including computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.
[0272] Figure 9 FIG. 4 shows a schematic diagram of an electronic device 800 according to an embodiment of the present disclosure. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0273] Referring Figure 9 , the electronic device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input / output (I / O) interface 812, a sensor component 814, and a communication component 816.
[0274] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, telephone calls, data communication, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0275] The memory 804 is configured to store various types of data to support the operation of the electronic device 800. Examples of these data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk.
[0276] The power component 806 provides power to various components of the electronic device 800. The power component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 800.
[0277] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can sense not only the boundaries of the touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the electronic device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have a focal length and optical zoom capabilities.
[0278] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC) that is configured to receive external audio signals when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, the audio component 810 further includes a speaker for outputting audio signals.
[0279] The I / O interface 812 provides an interface between the processing component 802 and a peripheral interface module, which can be a keyboard, a click wheel, buttons, etc. These buttons can include but are not limited to: a home button, a volume button, a power button, and a lock button.
[0280] The sensor component 814 includes one or more sensors for providing status assessments of various aspects of the electronic device 800. For example, the sensor component 814 can detect the on / off state of the electronic device 800, the relative positioning of components, such as the display and the keypad of the electronic device 800. The sensor component 814 can also detect a change in the position of the electronic device 800 or a component of the electronic device 800, the presence or absence of user contact with the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor component 814 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor component 814 can also include a light sensor, such as a CMOS or a CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 814 can further include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0281] The communication component 816 is configured to facilitate communication between the electronic device 800 and other devices in a wired or wireless manner. The electronic device 800 can access a communication standard-based wireless network, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0282] In an exemplary embodiment, the electronic device 800 can be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above method.
[0283] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 804 including computer program instructions, and the computer program instructions can be executed by a processor 820 of the electronic device 800 to complete the above method.
[0284] Figure 10 A schematic diagram of an electronic device 1900 according to an embodiment of the present disclosure is shown. For example, the electronic device 1900 can be provided as a server or a terminal device. Referring to Figure 10 , the electronic device 1900 includes a processing component 1922, which further includes one or more processors, and memory resources represented by a memory 1932 for storing instructions executable by the processing component 1922, such as application programs. The application programs stored in the memory 1932 can include one or more modules each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.
[0285] The electronic device 1900 may further include a power component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input / output (I / O) interface 1958. The electronic device 1900 can operate based on an operating system stored in the memory 1932, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, or the like.
[0286] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions, and the computer program instructions can be executed by a processing component 1922 of the electronic device 1900 to complete the above method.
[0287] The present disclosure may be a system, a method, and / or a computer program product. The computer program product may include a computer-readable storage medium having thereon computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.
[0288] A computer-readable storage medium may be a tangible device that can retain and store instructions for use by an instruction execution device. A computer-readable storage medium may be, for example, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disc (DVD), a memory stick, a floppy disk, a mechanically encoded device such as a punch card or raised structures in a groove having instructions stored thereon, and any suitable combination of the foregoing. The computer-readable storage medium used herein is not construed as being a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagated through a waveguide or other transmission medium (e.g., an optical pulse through an optical fiber cable), or an electrical signal transmitted through a wire.
[0289] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to various computing / processing devices, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network may include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in each computing / processing device.
[0290] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine - related instructions, microcode, firmware instructions, state - setting data, or source code or object code written in any combination of one or more programming languages, including object - oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The computer - readable program instructions may be executed entirely on the user's computer, partially on the user's computer, executed as a stand - alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider). In some embodiments, by using the state information of the computer - readable program instructions to customize an electronic circuit, such as a programmable logic circuit, a field - programmable gate array (FPGA), or a programmable logic array (PLA), the electronic circuit can execute the computer - readable program instructions to implement various aspects of the present disclosure.
[0291] Aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present disclosure. It should be understood that each block of the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts and / or block diagrams, can be implemented by computer - readable program instructions.
[0292] These computer - readable program instructions can be provided to a processor of a general - purpose computer, a special - purpose computer, or other programmable data - processing apparatus to produce a machine such that the instructions, when executed by the processor of the computer or other programmable data - processing apparatus, create a means for implementing the functions / acts specified in one or more blocks of the flowchart and / or block diagram. These computer - readable program instructions can also be stored in a computer - readable storage medium, which causes a computer, a programmable data - processing apparatus, and / or other devices to operate in a particular manner, so that the computer - readable medium storing the instructions includes a manufacture that includes instructions for implementing various aspects of the functions / acts specified in one or more blocks of the flowchart and / or block diagram.
[0293] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device, causing a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process such that the instructions executed on the computer, other programmable data processing apparatus, or other device implement the functions / acts specified in one or more boxes of the flowchart and / or block diagram.
[0294] The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a segment of code, or a portion of an instruction, which contains one or more executable instructions for implementing the specified logical function. In some alternative implementations, the functions noted in the blocks may occur out of the order noted in the figures. For example, two consecutive blocks may in fact be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending upon the functionality involved. It should also be noted that each block of the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented by a dedicated hardware-based system that performs the specified function or act, or by a combination of dedicated hardware and computer instructions.
[0295] The embodiments of the present disclosure have been described above. The above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The choice of terms used herein is intended to best explain the principles of the embodiments, the practical application, or improvements made to the technology in the marketplace, or to enable other ordinary skilled artisans in the art to understand the embodiments disclosed herein.
Claims
1. An endoscope calibration method, characterized in that, The method includes: Obtaining a set of sample images and a white-level image, where the set of sample images includes multiple sample images that are all black collected in a lightless environment, each of the sample images having a corresponding gain and temperature, and the white-level image is an image collected by the endoscope when the brightness, temperature, and gain are all at their maximum; Determining a corresponding black-level value according to the pixel value of each of the sample images; Determining a corresponding white-level value according to the pixel value of the white-level image; Determining a calibration function according to the gain of each of the sample images and the corresponding black-level value; In response to the endoscope obtaining an image to be calibrated, calibrating the image to be calibrated according to the white-level value and the calibration function; Wherein, the temperature corresponding to each of the sample images is within the temperature range of the human body; the temperature corresponding to the white-level image is the maximum value of the temperature range of the human body; Wherein, the determining the calibration function according to the gain of each of the sample images and the corresponding black-level value includes: Determining a calibration function according to the gain, temperature, and corresponding black-level value of each of the sample images; Wherein, the determining the calibration function according to the gain, temperature, and corresponding black-level value of each of the sample images includes: Determining a preset first parameter, second parameter, and third parameter; Determining a candidate function composed of the product of the first parameter and the gain, the product of the third parameter and the temperature, and the sum of the second parameter; Inputting the gain and temperature of the sample image into the candidate function, and determining the corresponding function value; Inputting the difference between the function value corresponding to each of the sample images and the black-level value into a preset cost function, and calculating the corresponding mean square error as the function error; In response to the function error not meeting the preset condition, updating the first parameter, second parameter, and third parameter, and re-iteratively executing the steps of inputting the gain and temperature of the sample image into the candidate function and subsequent steps; In response to the function error meeting the preset condition, ending the parameter iteration process and determining the current candidate function as the calibration function.
2. The method according to claim 1, wherein The obtaining of the set of sample images and the white-level image includes: Adjusting the camera gain of the endoscope multiple times in a lightless environment, and collecting corresponding sample images after each adjustment to obtain the set of sample images; Making the endoscope collect an image when the light source brightness is at its maximum and the camera gain is at its maximum to obtain the white-level image.
3. The method according to claim 1, characterized in that The obtaining of the set of sample images and the white-level image includes: Adjusting the environmental temperature and the camera gain of the endoscope multiple times in an iterative manner in a lightless environment, and collecting corresponding sample images after each adjustment to obtain the set of sample images; Making the endoscope collect an image when the light source brightness is at its maximum, the camera gain is at its maximum, and the environmental temperature is at its maximum to obtain the white-level image.
4. The method according to claim 3, characterized in that The adjusting the environmental temperature and the camera gain of the endoscope multiple times in an iterative manner in a lightless environment, and collecting corresponding sample images after each adjustment to obtain the set of sample images includes: Adjusting the environmental temperature multiple times in a lightless environment according to a preset temperature adjustment rule; After adjusting the ambient temperature each time, adjust the camera gain of the endoscope according to a preset gain adjustment rule and collect a corresponding all-black image as a sample image; In response to satisfying a first stop condition, end the gain adjustment process of the camera at the current temperature and adjust the ambient temperature again; In response to satisfying a second stop condition, end the adjustment process of the current ambient temperature and determine a sample image set according to the obtained multiple sample images and the corresponding temperature and gain when each sample image is collected.
5. The method according to any one of claims 1-4, characterized in that The determining the corresponding black level value according to the pixel value of each sample image includes: Calculating the average value of the pixel values in each sample image to obtain the corresponding black level value.
6. The method according to any one of claims 1-4, characterized in that, The determining the corresponding white level value according to the pixel value of the white level image includes: Calculating the average value of the pixel values in the white level image to obtain the corresponding white level value.
7. The method according to claim 1 or 2, characterized in that, The determining a calibration function according to the gain of each sample image and the corresponding black level value includes: Determining a preset first parameter and a second parameter; Determining a candidate function composed of the product of the first parameter and the gain plus the second parameter; Inputting the gain of the sample image into the candidate function and determining the corresponding function value; Inputting the difference between the function value corresponding to each sample image and the black level value into a preset cost function, and calculating the corresponding mean square error as the function error; In response to the function error not satisfying a preset condition, updating the first parameter and the second parameter, and re-iteratively executing the steps of inputting the gain of the sample image into the candidate function and subsequent steps; In response to the function error satisfying the preset condition, ending the parameter iteration process and determining the current candidate function as the calibration function.
8. The method according to claim 7, wherein The updating the first parameter and the second parameter includes: Respectively taking the partial derivatives of the cost function with respect to the first parameter and the second parameter to obtain corresponding first partial derivative results and second partial derivative results; Calculating the difference between the first parameter and the product of the first partial derivative result and a preset learning rate to obtain the updated first parameter; Calculating the difference between the second parameter and the product of the second partial derivative result and the learning rate to obtain the updated second parameter.
9. The method according to claim 1, wherein The updating the first parameter, the second parameter and the third parameter includes: Respectively taking the partial derivatives of the cost function with respect to the first parameter, the second parameter and the third parameter to obtain corresponding first partial derivative results, second partial derivative results and third partial derivative results; Calculating the difference between the first parameter and the product of the first partial derivative result and a preset learning rate to obtain the updated first parameter; Calculating the difference between the second parameter and the product of the second partial derivative result and the learning rate to obtain the updated second parameter; Calculating the difference between the third parameter and the product of the third partial derivative result and the learning rate to obtain the updated third parameter.
10. The method according to claim 1 or 2, characterized in that, The method further includes: Obtaining a test image set including a plurality of all-black test images collected in a lightless environment, each test image having a corresponding gain; Verifying the calibration function according to the test image set.
11. The method according to any one of claims 1, 3 - 4, characterized in that, The method further includes: Obtain a test image set including a plurality of all - black test images collected in a light - free environment, each of the test images having a corresponding gain and temperature; Verify the calibration function according to the test image set.
12. The method according to claim 1 or 2, characterized in that, The calibrating the image to be calibrated according to the white - level value and the calibration function includes: Determine the target gain corresponding to obtaining the image to be calibrated; Input the target gain into the calibration function to obtain a corresponding target black - level value; Adjust the pixel value of each pixel in the image to be calibrated according to the target black - level value and the white - level value to obtain a calibrated image.
13. According to the method described in any one of claims 1, 3 - 4, characterized in that, The calibrating the image to be calibrated according to the white - level value and the calibration function includes: Determine the target temperature and target gain corresponding to obtaining the image to be calibrated; Input the target temperature and the target gain into the calibration function to obtain a corresponding target black - level value; Adjust the pixel value of each pixel in the image to be calibrated according to the target black - level value and the white - level value to obtain a calibrated image.
14. The method according to claim 12, wherein The adjusting the pixel value of each pixel in the image to be calibrated according to the target black - level value and the white - level value to obtain a calibrated image includes: Obtain the target pixel value of a target pixel in the image to be calibrated; Determine the ratio of the difference between the target pixel value and the target black - level value to the difference between the white - level value and the target black - level value, and obtain the calibrated target pixel value according to the product of the ratio and a preset constant; Update the original pixel value according to the calibrated pixel value of each pixel in the image to be calibrated to obtain a calibrated image.
15. The method according to claim 13, wherein The adjusting the pixel value of each pixel in the image to be calibrated according to the target black - level value and the white - level value to obtain a calibrated image includes: Obtain the target pixel value of a target pixel in the image to be calibrated; Determine the ratio of the difference between the target pixel value and the target black - level value to the difference between the white - level value and the target black - level value, and obtain the calibrated target pixel value according to the product of the ratio and a preset constant; Update the original pixel value according to the calibrated pixel value of each pixel in the image to be calibrated to obtain a calibrated image.
16. An endoscope calibration device, characterized in that, The device includes: An image acquisition module, configured to acquire a sample image set and a white - level image, the sample image set including a plurality of sample images that are all - black and collected in a light - free environment, each of the sample images having a corresponding gain and temperature, the white - level image being an image acquired by the endoscope under the conditions of maximum brightness, temperature, and gain; a first level determination module, configured to determine a corresponding black - level value according to the pixel value of each sample image; A second level determination module, configured to determine a corresponding white - level value according to the pixel value of the white - level image; A function fitting module, configured to determine a calibration function according to the gain of each sample image and the corresponding black - level value; An image calibration module, configured to, in response to the endoscope acquiring an image to be calibrated, calibrate the image to be calibrated according to the white - level value and the calibration function; Among them, the temperature corresponding to each of the sample images is within the temperature range of the human body; the temperature corresponding to the white level image is the maximum value of the temperature range of the human body; Among them, the determining the calibration function according to the gain of each of the sample images and the corresponding black level value includes: Determining the calibration function according to the gain, temperature, and corresponding black level value of each of the sample images; Among them, the determining the calibration function according to the gain, temperature, and corresponding black level value of each of the sample images includes: Determining a preset first parameter, second parameter, and third parameter; Determining a candidate function composed of the product of the first parameter and the gain, the product of the third parameter and the temperature, and the sum of the second parameter; Inputting the gain and temperature of the sample image into the candidate function and determining the corresponding function value; Inputting the difference between the function value corresponding to each of the sample images and the black level value into a preset cost function, and calculating the corresponding mean square error as the function error; In response to the function error not satisfying the preset condition, updating the first parameter, second parameter, and third parameter, and re-iteratively executing the steps of inputting the gain and temperature of the sample image into the candidate function and subsequent steps; In response to the function error satisfying the preset condition, ending the parameter iteration process and determining the current candidate function as the calibration function.
17. An image acquisition device, characterized in that, The device includes: A white level calibration cup, including an upper bottom surface, a lower bottom surface, and a cup wall, and forming a sealed space through the upper bottom surface, the lower bottom surface, and the cup wall. The upper bottom surface and the lower bottom surface are made of elastic materials. The lower bottom surface has an insertion hole, and a heating resistor is provided inside the cup wall; An endoscope, inserted into the white level calibration cup through the insertion hole of the lower bottom surface, for image acquisition each time the temperature of the heating resistor and / or the gain of the camera in the endoscope is adjusted, so as to obtain each of the sample images in the sample image set according to any one of claims 1-15; Among them, the endoscope further includes a light source to obtain the white level image according to any one of claims 1-15 when the light source is turned on; Among them, a temperature sensor is further provided inside the cup wall for detecting the temperature inside the white level calibration cup to be used as the temperature corresponding to the acquired sample image or white level image.
18. An electronic device, characterized in that, Includes: A processor; A memory for storing instructions executable by the processor; Among them, the processor is configured to implement the method according to any one of claims 1 to 15 when executing the instructions stored in the memory.
19. A non-volatile computer-readable storage medium having computer program instructions stored thereon, characterized in that, The computer program instructions, when executed by the processor, implement the method according to any one of claims 1 to 15.
Citation Information
Patent Citations
Adaptive black level correction method
CN105578082A
Method and device for adjusting pixel brightness and electronic equipment
CN111953953A
Non-uniformity correction method without shutter
CN113514155A
Apparatus and method for improving image quality in image sensor
CN1717006A
Image capturing device with automatic white balance and automatic white balance correction method
US20170272721A1