CN115883976A - Endoscope calibration method, device, electronic apparatus, and storage medium - Google Patents
Endoscope calibration method, device, electronic apparatus, and storage medium Download PDFInfo
- Publication number
- CN115883976A CN115883976A CN202211712892.9A CN202211712892A CN115883976A CN 115883976 A CN115883976 A CN 115883976A CN 202211712892 A CN202211712892 A CN 202211712892A CN 115883976 A CN115883976 A CN 115883976A
- Authority
- CN
- China
- Prior art keywords
- image
- gain
- parameter
- function
- value
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Landscapes
- Endoscopes (AREA)
- Closed-Circuit Television Systems (AREA)
Abstract
The present disclosure relates to an endoscope calibration method, apparatus, electronic device, and storage medium, which acquire a sample image set including a plurality of sample images acquired in a dark environment to be all black and a white level image acquired by an endoscope under a condition where brightness, gain, and temperature are all maximized, wherein each sample image has a corresponding gain and temperature. And determining a corresponding black level value according to the pixel value of each sample image, and determining a white level value according to the pixel value of the white level image. And determining a calibration function according to the gain, the temperature and the corresponding black level value of each sample image, and calibrating the image to be calibrated according to the white level value and the calibration function when the endoscope acquires the image to be calibrated. According to the method, the calibration function representing the corresponding relation between the black level value and the gain and the temperature is accurately determined through a plurality of samples, the image collected by the endoscope is calibrated through the calibration function and the white level value in real time, noise caused by the black level in the image is removed, and the image quality is improved.
Description
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to an endoscope calibration method, an endoscope calibration apparatus, an electronic device, and a storage medium.
Background
With the progress of electronic imaging technology, it has become possible to miniaturize imaging apparatuses to form endoscopes and to apply them to the medical field. However, the endoscope system is limited in volume in the human body, the image sensor has a small area and insufficient imaging quality, the environment in the human body for image acquisition is complex, and the imaging quality under the dim light condition is high. 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, so that black-level noise exists in the acquired image, and the image quality is affected.
Disclosure of Invention
In view of the above, the present disclosure provides an endoscope calibration method, apparatus, electronic device and storage medium, which aim to perform black level calibration on an image acquired by an endoscope.
According to a first aspect of the present disclosure, there is provided an endoscope calibration method, the method comprising:
acquiring a sample image set and a white level image, wherein the sample image set comprises a plurality of sample images which are acquired to be completely black under a dark environment, each sample image has corresponding gain, and the white level image is an image acquired by an endoscope under the condition that the brightness and the gain are maximum;
determining a corresponding black level value according to the pixel value of each sample image;
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 sample image and the corresponding black level value;
and responding to the endoscope to acquire an image to be calibrated, and calibrating the image to be calibrated according to the white level value and the calibration function.
In one possible implementation, the acquiring of the sample image set and the white level image includes:
adjusting the gain of a camera of the endoscope for multiple times in a dark environment, and acquiring corresponding sample images after each adjustment to obtain a sample image set;
and acquiring images by the endoscope under the conditions of maximum light source brightness and maximum camera gain to obtain a white level image.
In one possible implementation, each of the sample images also has a corresponding temperature, and the white level image is an image acquired by the endoscope with the brightness, gain, and temperature being maximized.
In one possible implementation, the acquiring of the sample image set and the white level image includes:
adjusting the environmental temperature and the camera gain of the endoscope for multiple times in an iterative manner in a dark environment, and acquiring corresponding sample images after each adjustment to obtain a sample image set;
the endoscope collects images under the conditions of maximum light source brightness, maximum camera gain and maximum environment temperature to obtain a white level image.
In a possible implementation manner, the iteratively adjusting the ambient temperature and the camera gain of the endoscope multiple times in a dark environment, and acquiring a corresponding sample image after each adjustment to obtain a sample image set includes:
adjusting the ambient temperature for multiple times according to a preset temperature adjustment rule in a dark environment;
after adjusting the environmental temperature each time, adjusting the gain of a camera of the endoscope according to a preset gain adjustment rule and collecting a corresponding full black image as a sample image;
in response to the first stop condition being met, ending the gain adjustment process of the camera at the current temperature, and adjusting the ambient temperature again;
and in response to the second stop condition being met, ending the adjustment process of the current environment temperature, and determining a sample image set according to the obtained multiple sample images and the corresponding temperature and gain when each sample image is acquired.
In one possible implementation, the determining a corresponding black level value according to a pixel value of each sample image includes:
and calculating the average value of the pixel values in each sample image to obtain a corresponding black level value.
In one possible implementation, the determining a corresponding white level value according to a pixel value of the white level image includes:
and calculating the average value of the pixel values in the white level image to obtain a corresponding white level value.
In one possible implementation, 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 preset second parameter;
determining a candidate function consisting of a sum of the product of the first parameter and the gain and the second parameter;
inputting the gain of the sample image into the candidate function, and determining a corresponding function value;
inputting a function value and a black level value difference value corresponding to each sample image into a preset cost function, and calculating to obtain a corresponding mean square error as a function error;
in response to the function error not meeting a preset condition, updating the first parameter and the second parameter, and iterating to input the gain of the sample image into the candidate function and then;
and responding to the function error meeting the preset condition, ending the parameter iteration process and determining the current candidate function as the calibration function.
In one possible implementation, the determining a calibration function according to the gain of each sample image and the corresponding black level value includes:
determining a calibration function based on the gain, temperature and corresponding black level value for each of the sample images.
In one possible implementation, the determining a calibration function according to the gain, the temperature, and the corresponding black level value of each sample image includes:
determining a preset first parameter, a preset second parameter and a preset third parameter;
determining a candidate function consisting of a sum of the product of the first parameter and the gain, the product of the third parameter and the temperature, and the second parameter;
inputting the gain and the temperature of the sample image into the candidate function, and determining a corresponding function value;
inputting a function value and a black level value difference value corresponding to each sample image into a preset cost function, and calculating to obtain a corresponding mean square error as a function error;
in response to the function error not meeting a preset condition, updating the first parameter, the second parameter and the third parameter, and iterating again to input the gain and the temperature of the sample image into the candidate function and the subsequent steps;
and responding to the function error meeting the preset condition, ending the parameter iteration process and determining the current candidate function as the calibration function.
In a possible implementation manner, the updating the first parameter and the second parameter includes:
respectively solving partial derivatives of the cost function according to the first parameter and the second parameter to obtain a corresponding first partial derivative result and a corresponding second partial derivative result;
calculating the difference between the first parameter and the product of the first partial derivative result and a preset learning rate to obtain an updated first parameter;
and calculating the difference between the second parameter and the product of the second partial derivative result and the learning rate to obtain an updated second parameter.
In a possible implementation manner, the updating the first parameter, the second parameter, and the third parameter includes:
respectively solving partial derivatives of the cost function according to the first parameter, the second parameter and the third parameter to obtain a corresponding first partial derivative result, a corresponding second partial derivative result and a corresponding third partial derivative result;
calculating the difference between the first parameter and the product of the first partial derivative result and a preset learning rate to obtain an 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 an updated second parameter;
and calculating the difference of the third parameter, the product of the third partial derivative result and the learning rate to obtain an updated third parameter.
In one possible implementation, the method further includes:
acquiring a test image set comprising a plurality of test images which are acquired to be completely black in a dark environment, wherein each test image has corresponding gain and temperature;
and verifying the calibration function according to the test image set.
In one possible implementation, the method further includes:
acquiring a test image set comprising a plurality of test images which are acquired to be completely black in a dark environment, wherein each test image has corresponding gain and temperature;
and verifying the calibration function according to the test image set.
In a possible implementation manner, the calibrating the image to be calibrated according to the white level value and the calibration function includes:
determining a corresponding target gain when the image to be calibrated is obtained;
inputting the target gain into the calibration function to obtain a corresponding target black level value;
and 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.
In a possible implementation manner, the calibrating the image to be calibrated according to the white level value and the calibration function includes:
determining a corresponding target temperature and a target gain when the image to be calibrated is obtained;
inputting the target temperature and the target gain into the calibration function to obtain a corresponding target black level value;
and 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.
In a possible implementation manner, the adjusting a 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:
acquiring a target pixel value of a target pixel in the image to be calibrated;
determining the difference between the target pixel value and the target black level value, and the ratio of the white level value to the target black level difference, and obtaining a calibrated target pixel value according to the product of the ratio and a preset constant;
and updating the original pixel value according to the pixel value of each pixel in the image to be calibrated after calibration to obtain the calibrated image. According to a second aspect of the present disclosure, there is provided an endoscopic calibration device, the device comprising:
the system comprises an image acquisition module, a brightness acquisition module and a brightness acquisition module, wherein the image acquisition module is used for acquiring a sample image set and a white level image, the sample image set comprises a plurality of sample images which are acquired to be completely black under a dark environment, each sample image has corresponding gain, and the white level image is an image acquired by an endoscope under the condition that the brightness and the gain are maximum;
a first level determining module for determining a corresponding black level value according to a pixel value of each of the sample images;
the second level determining module is used for determining a corresponding white level value according to the pixel value of the white level image;
the function fitting module is used for determining a calibration function according to the gain of each sample image and the corresponding black level value;
and the image calibration module is used for responding to the acquisition of the image to be calibrated by the endoscope and calibrating the image to be calibrated according to the white level value and the calibration function.
In one possible implementation, the acquiring of the sample image set and the white level image includes:
adjusting the gain of a camera of the endoscope for multiple times in a dark environment, and acquiring corresponding sample images after each adjustment to obtain a sample image set;
the endoscope collects images under the conditions that the brightness of the light source is maximum and the gain of the camera is maximum, and a white level image is obtained.
In one possible implementation, each of the sample images also has a corresponding temperature, and the white level image is an image acquired by the endoscope with the brightness, gain, and temperature being maximized.
In one possible implementation, the acquiring of the sample image set and the white level image includes:
adjusting the environmental temperature and the camera gain of the endoscope for multiple times in an iterative manner in a dark environment, and acquiring corresponding sample images after each adjustment to obtain a sample image set;
the endoscope collects images under the conditions of maximum light source brightness, maximum camera gain and maximum environment temperature to obtain a white level image.
In a possible implementation manner, the iteratively adjusting the ambient temperature and the camera gain of the endoscope multiple times in a dark environment, and acquiring a corresponding sample image after each adjustment to obtain a sample image set includes:
adjusting the ambient temperature for multiple times according to a preset temperature adjustment rule in a dark environment;
after adjusting the environmental temperature each time, adjusting the gain of a camera of the endoscope according to a preset gain adjustment rule and collecting a corresponding full black image as a sample image;
in response to the first stop condition being met, ending the gain adjustment process of the camera at the current temperature, and adjusting the ambient temperature again;
and in response to the second stop condition being met, ending the adjustment process of the current environment temperature, and determining a sample image set according to the obtained multiple sample images and the corresponding temperature and gain when each sample image is acquired.
In one possible implementation, the determining a corresponding black level value according to a pixel value of each sample image includes:
and calculating the average value of the pixel values in each sample image to obtain a corresponding black level value.
In one possible implementation manner, the determining a corresponding white level value according to a pixel value of the white level image includes:
and calculating the average value of the pixel values in the white level image to obtain a corresponding white level value.
In one possible implementation, 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 preset second parameter;
determining a candidate function consisting of a sum of the product of the first parameter and the gain and the second parameter;
inputting the gain of the sample image into the candidate function, and determining a corresponding function value;
inputting a function value and a black level value difference value corresponding to each sample image into a preset cost function, and calculating to obtain a corresponding mean square error as a function error;
in response to the function error not meeting a preset condition, updating the first parameter and the second parameter, and re-iterating to input the gain of the sample image into the candidate function and then;
and responding to the function error meeting the preset condition, ending the parameter iteration process and determining the current candidate function as the calibration function.
In one possible implementation, the determining a calibration function according to the gain of each sample image and the corresponding black level value includes:
determining a calibration function based on the gain, temperature and corresponding black level value for each of the sample images.
In one possible implementation, the determining a calibration function according to the gain, the temperature, and the corresponding black level value of each sample image includes:
determining a preset first parameter, a preset second parameter and a preset third parameter;
determining a candidate function consisting of a sum of a product of the first parameter and the gain, a product of the third parameter and the temperature, and the second parameter;
inputting the gain and the temperature of the sample image into the candidate function, and determining a corresponding function value;
inputting the function value and the black level value difference value corresponding to each sample image into a preset cost function, and calculating to obtain a corresponding mean square error as a function error;
in response to the function error not meeting a preset condition, updating the first parameter, the second parameter and the third parameter, and iterating again to input the gain and the temperature of the sample image into the candidate function and the subsequent steps;
and responding to the function error meeting the preset condition, ending the parameter iteration process and determining the current candidate function as the calibration function.
In a possible implementation manner, the updating the first parameter and the second parameter includes:
respectively solving partial derivatives of the cost function according to the first parameter and the second parameter to obtain a corresponding first partial derivative result and a corresponding second partial derivative result;
calculating the difference between the first parameter and the product of the first partial derivative result and a preset learning rate to obtain an updated first parameter;
and calculating the difference between the second parameter and the product of the second partial derivative result and the learning rate to obtain an updated second parameter.
In a possible implementation manner, the updating the first parameter, the second parameter, and the third parameter includes:
obtaining partial derivatives of the cost function according 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;
calculating the difference between the first parameter and the product of the first partial derivative result and a preset learning rate to obtain an 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 an updated second parameter;
and calculating the difference of the third parameter, the product of the third partial derivative result and the learning rate to obtain an updated third parameter.
In one possible implementation, the apparatus further includes:
the device comprises a first test image acquisition module, a second test image acquisition module and a third test image acquisition module, wherein the first test image acquisition module is used for acquiring a test image set comprising a plurality of test images which are acquired to be completely black under a dark environment, and each test image has corresponding gain and temperature;
a first verification module for verifying the calibration function according to the set of test images.
In one possible implementation, the apparatus further includes:
the second test image acquisition module is used for acquiring a test image set comprising a plurality of test images which are acquired to be completely black in a dark environment, and each test image has corresponding gain and temperature;
and the second verification module is used for verifying the calibration function according to the test image set.
In a possible implementation manner, the calibrating the image to be calibrated according to the white level value and the calibration function includes:
determining a corresponding target gain when the image to be calibrated is obtained;
inputting the target gain into the calibration function to obtain a corresponding target black level value;
and 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.
In a possible implementation manner, the calibrating the image to be calibrated according to the white level value and the calibration function includes:
determining a corresponding target temperature and a target gain when the image to be calibrated is obtained;
inputting the target temperature and the target gain into the calibration function to obtain a corresponding target black level value;
and 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.
In a possible implementation manner, the adjusting a 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:
acquiring a target pixel value of a target pixel in the image to be calibrated;
determining the difference between the target pixel value and the target black level value and the ratio of the white level value to the target black level difference, and obtaining a calibrated target pixel value according to the product of the ratio and a preset constant;
and updating the original pixel value according to the pixel value of each pixel in the image to be calibrated after calibration to obtain the calibrated image.
According to a third aspect of the present disclosure, there is provided an image acquisition apparatus, the apparatus comprising:
the white level calibration cup comprises an upper bottom surface, a lower bottom surface and a cup wall, a closed space is formed by 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 is provided with an insertion hole, and a heating resistor is arranged in the cup wall;
the endoscope is inserted into the white level calibration cup through the extending hole of the lower bottom surface and is used for acquiring images under the condition of adjusting the temperature of the heating resistor and/or the gain of a camera in the endoscope each time.
In a possible implementation manner, a temperature sensor is further arranged in the cup wall and used for detecting the temperature in the white level calibration cup.
In one possible implementation, the endoscope further comprises a light source.
According to a fourth aspect of the present disclosure, there is provided an electronic device comprising: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to implement the above-described method when executing the memory-stored instructions.
According to a fifth aspect of the present disclosure, there is provided a non-transitory computer readable storage medium having stored thereon computer program instructions, wherein the computer program instructions, when executed by a processor, implement the above-described method.
According to a sixth aspect of the disclosure, there is provided a computer program product comprising computer readable code, or a non-transitory computer readable storage medium carrying computer readable code, which when run in a processor of an electronic device, the processor in the electronic device performs the above method.
In the embodiment of the disclosure, a sample image set including a plurality of sample images acquired in a dark environment is acquired, and a white level image acquired by an endoscope in a case where brightness, gain, and temperature are all maximized, wherein each sample image has a corresponding gain and temperature. And determining a corresponding black level value according to the pixel value of each sample image, and determining a white level value according to the pixel value of the white level image. And determining a calibration function according to the gain, the temperature and the corresponding black level value of each sample image, and calibrating the image to be calibrated according to the white level value and the calibration function when the endoscope acquires the image to be calibrated. According to the method, the calibration function representing the corresponding relation between the black level value and the gain and the temperature is accurately determined through a plurality of samples, the image collected by the endoscope is calibrated through the calibration function and the white level value in real time, noise caused by the black level in the image is removed, and the image quality is improved.
Other features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments, which proceeds with reference to the accompanying drawings.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate exemplary embodiments, features, and aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure.
FIG. 1 illustrates a flow chart of an endoscope calibration method according to an embodiment of the present disclosure;
FIG. 2 is a schematic diagram illustrating a gain versus black level correspondence according to an embodiment of the disclosure;
FIG. 3 is a schematic diagram illustrating temperature versus black level correspondence according to an embodiment of the present disclosure;
FIG. 4 shows a schematic diagram of a process of acquiring a sample image set and a white level image according to an embodiment of the disclosure;
FIG. 5 shows a schematic diagram of a sample image according to an embodiment of the present disclosure;
FIG. 6 illustrates a schematic diagram of an image calibration effect according to an embodiment of the present disclosure;
FIG. 7 shows a schematic diagram of an image capture device according to an embodiment of the present disclosure
FIG. 8 shows a schematic view of an endoscopic calibration device according to an embodiment of the present disclosure;
FIG. 9 shows a schematic diagram of an electronic device according to an embodiment of the disclosure;
FIG. 10 shows a schematic diagram of another electronic device in accordance with an embodiment of the disclosure.
Detailed Description
Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. In the drawings, like reference numbers can indicate functionally identical or similar elements. While the various aspects of the embodiments are presented in drawings, the drawings are not necessarily drawn to scale unless specifically indicated.
The word "exemplary" is used exclusively herein to mean "serving as an example, embodiment, or illustration. Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments.
Furthermore, in the following detailed description, numerous specific details are set forth in order to provide a better understanding of the present disclosure. It will be understood by those skilled in the art that the present disclosure may be practiced without some of these specific details. In some instances, methods, means, elements and circuits that are well known to those skilled in the art have not been described in detail so as not to obscure the subject matter of the present disclosure.
In one possible implementation, the endoscope calibration method of the embodiment of the present disclosure may be executed by an electronic device such as a processor, a terminal device, or a server. The terminal device may be a User Equipment (UE), a mobile device, a User 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, or the like. A fixed or mobile terminal. The server may be a single server or a server cluster of multiple servers. The electronic device may implement the endoscope calibration method of embodiments of the present disclosure by way of the processor invoking computer readable instructions stored in the memory.
FIG. 1 shows a flow chart of an endoscope calibration method according to an embodiment of the present disclosure. As shown in fig. 1, the endoscope calibration method of the embodiments of the present disclosure may include the following steps S10 to S50.
And step S10, acquiring a sample image set and a white level image.
In one possible implementation, the sample set of images may be acquired by an electronic device as white level images. The sample image set comprises a plurality of sample images which are acquired under the dark environment and are all black, each sample image has corresponding gain, and the white level image is an image acquired by the endoscope under the condition that the brightness and the gain are maximum. To further improve calibration accuracy, a temperature variation may also be introduced in the process of acquiring the sample images and the white level image, even if each sample image in the set of sample images has a corresponding gain and temperature, the white level image being the image acquired by the endoscope with maximum brightness, gain and temperature.
Optionally, each sample image and white level image in the sample image set is an image acquired through an endoscope. The gain corresponding to the image collected by the endoscope is the gain of the endoscope camera when the image is collected, and the corresponding temperature is the ambient temperature when the image is collected. The lens of the endoscope comprises a camera and a light source, namely, a sample image is an image collected in a non-light environment with the light source turned off, and a white level image is an image collected in the non-light environment under the condition that the light source is adjusted to be maximum and the gain and the ambient temperature of the camera are also adjusted to be maximum. The electronic device of the embodiment of the disclosure can obtain the sample image set and the white level image in a manner of directly acquiring images through the connected endoscope, and can also acquire images through the connected endoscope and transmit the images to the electronic device.
Fig. 2 is a schematic diagram illustrating a relationship between a gain and a black level according to an embodiment of the disclosure. As shown in fig. 2, when the endoscope performs image acquisition, the gain of the endoscope camera may affect the black level value (i.e., the dark current value) of the acquired image. Meanwhile, the relationship between the gain and the black level value is a direct proportional relationship, that is, the larger the gain of the camera is, the higher the black level value is, that is, the larger the noise generated by the dark current in the acquired image is. Therefore, it is possible to further determine the black level value according to the gain of the endoscope camera at the time of capturing the image after capturing the image.
Fig. 3 is a schematic diagram illustrating a temperature-black level value relationship according to an embodiment of the disclosure. As shown in fig. 3, when the endoscope performs image acquisition, the black level value (i.e., the dark current value) of the acquired image may be affected by the temperature of the acquisition environment. Meanwhile, the relationship between the temperature and the black level value is a direct proportional relationship, that is, the higher the acquisition environment temperature is, the higher the black level value is, that is, the greater the noise generated by the dark current in the acquired image is. Therefore, it is possible to further determine the black level value according to the ambient temperature at the time of capturing the image after capturing the image.
Based on the effects of gain and temperature on the dark current, the electronic device may obtain a plurality of sample images with corresponding gains, or a plurality of sample images with corresponding gains and temperatures, and determine the effects of gain on the sample images according to the black level values of the sample images and the corresponding gains. Or, the influence of the gain and the temperature on the black level value together can also be determined according to the black level value of the sample image and the corresponding gain and temperature. Optionally, the environment in which the sample image and the white level image are obtained in the embodiment of the present disclosure is a dark environment with adjustable temperature, and in order to adjust the ambient temperature conveniently, the endoscope may be placed in a container which is sealed in the dark and is provided with a temperature adjustment device inside, and the sample image is collected after adjusting the temperature and/or adjusting the gain of the camera of the endoscope each time to obtain the sample image set. Meanwhile, after the endoscope light source is adjusted to the maximum under the condition that the temperature adjusting device in the container is adjusted to the maximum and the gain of the endoscope camera is adjusted to the maximum, a white level image is collected.
Optionally, in a case that the sample image set includes a plurality of sample images with corresponding gains, and the white level image is an image acquired by the endoscope under a condition that both brightness and gain are maximum, the process of acquiring the sample image set and the white level image may be to adjust the gain of the camera of the endoscope multiple times in a no-light environment, and acquire the corresponding sample image after each adjustment to obtain the sample image set. The endoscope collects images under the condition that the brightness of the light source is maximum and the gain of the camera is maximum, and a white level image is obtained.
Alternatively, in the case where the sample image set includes a plurality of sample images having corresponding gains and temperatures, and the white level image is an image acquired by the endoscope under the condition that the brightness, the temperature, and the gains are all maximum, the order in which the sample image set and the white level image are acquired in the embodiment of the present disclosure may be determined arbitrarily. For example, the sample image set is acquired first and then the white level image is acquired, or the white level image is acquired first and then the sample image set is acquired. The sample image set can be obtained by repeatedly acquiring sample images in an iterative manner, namely, the ambient temperature and the camera gain of the endoscope are repeatedly adjusted in an iterative manner in a dark environment, and the corresponding sample images are acquired after each adjustment to obtain the sample image set. The acquisition process of the white level image may be to acquire an image of the endoscope under the conditions of maximum brightness of the light source, maximum gain of the camera, and maximum ambient temperature, so as to obtain the white level image.
In a possible implementation manner, the process of repeatedly acquiring the sample image set in an iterative manner may include repeatedly adjusting the ambient temperature according to a preset temperature adjustment rule in a dark environment, and after adjusting the ambient temperature each time, adjusting the gain of the camera of the endoscope according to a preset gain adjustment rule and acquiring a corresponding all-black image as the sample image. And responding to the first stop condition, ending the gain adjustment process of the camera at the current temperature, and adjusting the ambient temperature again. And in response to the second stop condition being met, ending the adjustment process of the current environment temperature, and determining a sample image set according to the acquired plurality of sample images and the corresponding temperature and gain when each sample image is acquired. The preset temperature adjustment rule may be that the adjustment is started from a preset temperature, and the preset temperature is adjusted upwards in each adjustment. The preset gain adjustment rule may be that the adjustment is started from gain 1, and the preset step length is adjusted upwards in each adjustment. 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.
That is, the ambient temperature may be adjusted multiple times, and the camera gain may be adjusted multiple times and a completely black image may be photographed through the endoscope after each temperature adjustment until the temperature is adjusted again until the temperature reaches the preset maximum temperature value under the condition that the camera gain reaches the maximum gain value. The temperature adjustment range may be determined according to an image capturing scene of the endoscope, for example, in the case of capturing an image of the inside of a human body, the preset temperature adjustment range may be determined according to a temperature range inside the human body.
Fig. 4 shows a schematic diagram of a process of acquiring a sample image set and a white level image according to an embodiment of the disclosure. As shown in fig. 4, when the electronic device is configured to obtain the sample image set and the white level image, the electronic device may obtain the sample image set and then obtain the white level image. That is, the initial gain and temperature may be set first, the endoscope is placed in a non-light environment 40, the current environment temperature and the camera gain are acquired, an image is acquired 41, and then it is determined whether the current gain has reached a preset maximum gain value 42. In the case where the current gain is not the maximum value, the gain 43 is increased according to a preset gain adjustment rule and an image is again acquired. In the case where the current gain is at a maximum, it is determined whether the current ambient temperature has reached a preset maximum temperature value 44. In case the current temperature is not the maximum value, the temperature may be increased and the gain value adjusted to the minimum value, i.e. the initial gain value, according to a preset temperature adjustment rule and the image 45 is again acquired. In the case where the current temperature reaches the maximum value, the sample image acquisition process is ended, and the sample image set 46 is determined from all the sample images acquired. And further adjusting a light source used for lighting the camera in the endoscope to the maximum value, adjusting both the gain and the temperature to the maximum value 47, and acquiring an image to obtain a white level image 48. The adjustment sequence of the gain and the temperature can be changed, namely, the temperature is adjusted for many times after the gain is adjusted every time, and images are acquired.
FIG. 5 shows a schematic diagram of a sample image according to an embodiment of the disclosure. As shown in fig. 5, the sample image is a completely black image under visual observation, but the completely black sample images acquired under different temperature and/or gain conditions have substantially a certain difference in pixel value, and the electronic device may calculate the corresponding black level value according to the pixel value of each sample image after acquiring the sample images.
And S20, determining a corresponding black level value according to the pixel value of each sample image.
In a possible implementation manner, after the sample image set is acquired, the electronic device may calculate a corresponding black level value according to a pixel value of each sample image in the sample image set. The black level value can be any characteristic value obtained by calculation according to the pixel value of the sample image and is used for representing the noise influence on the image caused by the dark current of the collected image value. For example, the electronics can calculate an average of the pixel values in each sample image to obtain a corresponding black level value.
And step S30, determining a corresponding white level value according to the pixel value of the white level image.
In a possible implementation manner, after acquiring the white level image, the electronic device may calculate a white level value corresponding to the white level image by a method of calculating black level values of the sample image to be the same. For example, an average value of pixel values in a white level image may be calculated to obtain a corresponding white level value. The white level value characterizes the characteristic value of the image pixel in the case of minimum dark current. In the embodiment 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.
And S40, determining a calibration function according to the gain of each sample image and the corresponding black level value.
In one possible implementation, after determining the black level value of each sample image in the sample image set, the electronic device may determine a calibration function according to the gain of each sample image and the corresponding black level value, where the calibration function is used to characterize the relationship between the black level value and the gain and the temperature at the time of acquiring the corresponding image. The process of determining the calibration function by the electronic device may be to preset a function model, and then adjust parameters of the function model according to a difference between a result obtained after the gain corresponding to the sample image is input to the function model and the black level value, so as to obtain the calibration function.
Optionally, the electronic device may determine a candidate function as a function model according to a plurality of preset parameters, and adjust parameters according to the result of inputting the candidate function of the sample image gain and the temperature to obtain a calibration function. That is, the preset first parameter and the second parameter may be determined, and the candidate function composed of the sum of the product of the first parameter and the gain and the second parameter may be determined. And inputting the gain of the sample image into the candidate function, and determining a corresponding function value. And determining a corresponding function error according to the function value and the black level value corresponding to each sample image, updating the first parameter and the second parameter in response to the fact that the function error does not meet a preset condition, and iterating again to input the gain and the temperature of the sample image into the candidate function and the subsequent steps. And responding to the function error meeting the preset condition, ending the parameter iteration process and determining the current candidate function as the calibration function.
For example, the electronic device may set the first parameter to a and the second parameter to B, and determine the candidate function to be BL = a × gain + B, where gain is a gain and BL is a function value for characterizing an expected black level value at the corresponding gain. The preset initial values of the first parameter a and the second parameter B may be 1.
Optionally, since the function value output after the gain corresponding to the sample image is input to the candidate function represents the expected black level value of the sample image, the function error may 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 function error determining process may input a difference between a function value and a black level value corresponding to each sample image into a preset cost function, and calculate to obtain a corresponding mean square error as the function error. I.e. the cost function may beWhere m is the number of sample images in the sample image set, BL get The actual black level value calculated for the sample image.
Further, in each iteration process, after the electronic device obtains a corresponding function error by inputting the difference value between the function value and the black level value corresponding to all the sample images in the sample image set into the cost function, it can be determined according to preset conditions whether to end the iteration process or enter the next iteration. After the function error is obtained, the electronic device may determine whether the function error satisfies a corresponding preset condition, if not, update the first parameter and the second parameter and recalculate the function error of the candidate function, and if yes, determine that the current candidate function is the calibration function. The preset condition may be that the function error is smaller than or equal to a preset error value.
In a possible implementation manner, the first parameter and the second parameter may be updated according to the cost function when the function error does not satisfy the preset condition. For example, the parameter updating process may be to calculate partial derivatives of the cost function for the first parameter and the second parameter respectively, and obtain corresponding first partial derivative results and second partial derivative results. And calculating the difference between the first parameter and the product of the first partial derivative result and the preset learning rate to obtain an updated first parameter, and calculating the difference between the second parameter and the product of the second partial derivative result and the learning rate to obtain an updated second parameter.
Illustratively, the electronic device performs partial derivation of the cost function for the first parameter and the second parameter respectively to obtain a first partial derivation resultThe second partial derivative result isWhere α is a preset learning rate. That is, the updated first parameter and the updated second parameter may be determined by the following formulas:
in one possible implementation, each sample image in the set of sample images also has a corresponding temperature when a temperature variable is introduced. The electronics can determine a calibration function based on the gain, temperature, and corresponding black level value for each sample image. Optionally, the electronic device may determine a candidate function as a function model according to a plurality of preset parameters, and adjust parameters according to a result of inputting the candidate function according to the sample image gain and the temperature to obtain the calibration function. That is, the preset first parameter, the second parameter and the third parameter may be determined, and the candidate function consisting 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 may be determined. And inputting the gain and the temperature of the sample image into the candidate function, and determining a corresponding function value. And determining a corresponding function error according to the difference value between the function value and the black level value corresponding to each sample image, updating the first parameter, the second parameter and the third parameter in response to the fact that the function error does not meet a preset condition, and iterating again to input the gain and the temperature of the sample image into the candidate function. And responding to the function error meeting the preset condition, ending the parameter iteration process and determining the current candidate function as the calibration function.
Illustratively, the electronic device may set the first parameter to a, the second parameter to B, and the third parameter to C, and determine the candidate function to BL = a × gain + C × characteristic + B, where gain is gain, temperature is temperature, and BL is a function value for characterizing an expected black level value at the corresponding gain and temperature. The preset initial values of the first parameter a, the second parameter B and the third parameter C may be 1.
Alternatively, since the function value output after the gain and temperature corresponding to the sample image are input into the candidate function represents the expected black level value of the sample image, the function error may 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 determining process of the function error may be to input a difference value between a function value and a black level value corresponding to each sample image into a preset cost function, and calculate to obtain a corresponding mean square error as the function error. I.e. the cost function may beWhere m is the number of sample images in the sample image set, BL get The actual black level value calculated for the sample image.
Further, in each iteration process, after the electronic device obtains a corresponding function error by inputting the difference value between the function value and the black level value corresponding to all the sample images in the sample image set into the cost function, it can be determined according to a preset condition whether to end the iteration process or enter the next iteration. After the function error is obtained, the electronic device may determine whether the function error satisfies a corresponding preset condition, if not, update the first parameter, the second parameter, and the third parameter and recalculate the function error of the candidate function, and if yes, determine that the current candidate function is the calibration function. The preset condition may be that the function error is smaller than or equal to a preset error value.
In a possible implementation manner, the first parameter, the second parameter, and the third parameter may be updated according to the cost function when the function error does not satisfy the preset condition. Exemplarily, the parameter updating process may be to calculate partial derivatives of the cost function for the first parameter, the second parameter, and the third parameter, respectively, to obtain corresponding first partial derivative result, second partial derivative result, and third partial derivative result. Calculating the difference between the first parameter and the product of the first partial derivative result and a preset learning rate to obtain an 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 an updated second parameter, and calculating the difference between the third parameter and the product of the third partial derivative result and the learning rate to obtain an updated third parameter.
Exemplarily, the electronic device performs partial derivation on the cost function respectively for the first parameter, the second parameter and the third parameter to obtain a first partial derivation result as A second partial derivative result is +> A third partial derivative result is ^ greater than> Where α is a preset learning rate. That is, the updated first parameter, second parameter and third parameter may be determined by the following formulas:
in a possible implementation manner, after determining the calibration function, the electronic device may further perform a test on the calibration function. For example, a set of test images comprising a plurality of test images acquired in a dark environment in which total black is present may be acquired, each test image having a corresponding gain and temperature. And verifying the calibration function according to the test image set. The method for obtaining the test image set is the same as the process for obtaining the sample image set, and the verification method of the calibration function may be inputting the gain and the temperature of each test image in the test image set into the calibration function, and then determining the function loss according to the difference between the output function value and the black level value corresponding to the test image. The electronic device may determine that the calibration function passes verification if the function loss is less than or equal to a preset loss threshold, and determine that the calibration function does not pass verification if the function loss is greater than the preset loss threshold, and reacquire the sample image set to determine a new calibration function.
And S50, responding to the acquisition of the image to be calibrated by the endoscope, and calibrating the image to be calibrated according to the white level value and the calibration function.
In a possible implementation manner, after obtaining the calibration function and the white level value, the electronic device may calibrate an image acquired by the endoscope according to the calibration function and the white level value, so as to filter noise caused by dark current therein and optimize image quality. The electronic equipment calibrates the image to be calibrated according to the white level value and the calibration function after acquiring the image to be calibrated, which is acquired by the endoscope and needs to be calibrated.
Alternatively, the electronic device may determine a black level value based on a gain of the endoscope camera when acquiring the image to be calibrated, and then perform image calibration. Or determining a black level value based on the gain of the endoscope camera and the temperature of the environment when the image to be calibrated is obtained, and further performing image calibration. That is, the electronic device may first determine a corresponding target gain when acquiring the image to be calibrated, and input the target gain into the calibration function to obtain a corresponding target black level value. And adjusting the pixel value of each pixel in the image to be calibrated according to the target black level value and the target white level value to obtain the calibrated image. Or, determining a target temperature and a target gain corresponding to the image to be calibrated, and inputting the target temperature and the target gain into the calibration function to obtain a corresponding target black level value. And adjusting the pixel value of each pixel in the image to be calibrated according to the target black level value and the target white level value to obtain the calibrated image.
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 the white level value is to obtain a target pixel value of a target pixel in the image to be calibrated, determine a difference between the target pixel value and the target black level value, and a ratio between the white level value and the target black level difference, and obtain the calibrated target pixel value according to a product of the ratio and a preset constant. And finally, updating the original pixel value according to the calibrated pixel value of each pixel in the image to be calibrated to obtain the calibrated image. I.e. each pixel value in the calibrated image can be formulated according to the formulaDetermination of where Pixel get For 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, pixel real Is the calibrated pixel value.
FIG. 6 illustrates a schematic diagram of an image calibration effect according to an embodiment of the disclosure. As shown in fig. 6, the upper part is the image to be calibrated, and the lower part is the calibrated image. The image to be calibrated has low image quality due to the noise generated by the influence of the black level, and the image calibrated according to the calibration function and the white level value has higher image quality because the noise generated by the black level is removed.
Based on the technical characteristics, the calibration function representing the corresponding relation between the black level value and the gain and the temperature can be accurately determined through a plurality of samples, the image collected by the endoscope is calibrated through the calibration function and the white level value in real time, noise caused by the black level in the image is removed, and the image quality is improved. Meanwhile, the accuracy of the obtained calibration function is improved by verifying the calibration function, and noise in the image can be accurately removed.
Fig. 7 shows a schematic diagram of an image acquisition device according to an embodiment of the present disclosure. As shown in fig. 7, an image capturing apparatus of an embodiment of the present disclosure includes a white level calibration cup and an endoscope. The white level calibration cup comprises an upper bottom surface, a lower bottom surface and a cup wall, a closed space is formed by 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 is provided with an insertion hole, and a heating resistor is arranged in the cup wall. The endoscope is inserted into the white level calibration cup through the extension hole in the lower bottom surface of the white level calibration cup and is used for acquiring images under the condition of adjusting the temperature of the heating resistor and/or the gain of a camera in the endoscope each time. And a temperature sensor is further arranged in the wall of the white level calibration cup and used for detecting the temperature in the white level calibration cup and adjusting the heating resistor based on the temperature value detected by the temperature sensor. And the endoscope further comprises a light source for acquiring a white level image with the light source turned on.
Based on the characteristics, the embodiment of the disclosure can acquire the sample image for multiple times in a dark environment where the environmental temperature and the camera gain can be accurately regulated, and then fit to obtain an accurate calibration function to calibrate the image, thereby improving the image quality.
FIG. 8 shows a schematic view of an endoscopic calibration device according to an embodiment of the present disclosure. As shown in fig. 8, the endoscope calibration device of the embodiments of the present disclosure may include:
an image obtaining module 80, configured to obtain a sample image set and a white level image, where the sample image set includes a plurality of sample images that are collected to be completely black in a dark environment, each sample image has a corresponding gain, and the white level image is an image collected by an endoscope under a condition that brightness and gain are maximum;
a first level determining module 81, configured to determine a corresponding black level value according to a pixel value of each sample image;
a second level determining module 82, configured to determine a corresponding white level value according to a pixel value of the white level image;
a function fitting module 83, configured to determine a calibration function according to the gain of each sample image and the corresponding black level value;
and the image calibration module 84 is configured to calibrate the image to be calibrated according to the white level value and the calibration function in response to the image to be calibrated being acquired by the endoscope.
In one possible implementation, the acquiring of the sample image set and the white level image includes:
adjusting the gain of a camera of the endoscope for multiple times in a dark environment, and acquiring corresponding sample images after each adjustment to obtain a sample image set;
and acquiring images by the endoscope under the conditions of maximum light source brightness and maximum camera gain to obtain a white level image.
In one possible implementation, each of the sample images also has a corresponding temperature, and the white level image is an image acquired by the endoscope with the brightness, gain, and temperature being maximized.
In one possible implementation, the acquiring of the sample image set and the white level image includes:
adjusting the environmental temperature and the camera gain of the endoscope for multiple times in an iterative manner in a dark environment, and acquiring corresponding sample images after each adjustment to obtain a sample image set;
the endoscope collects images under the conditions of maximum light source brightness, maximum camera gain and maximum ambient temperature to obtain a white level image.
In a possible implementation manner, the iteratively adjusting the ambient temperature and the camera gain of the endoscope multiple times in a dark environment, and acquiring a corresponding sample image after each adjustment to obtain a sample image set includes:
adjusting the ambient temperature for multiple times according to a preset temperature adjustment rule in a dark environment;
after adjusting the environmental temperature each time, adjusting the gain of a camera of the endoscope according to a preset gain adjustment rule and collecting a corresponding full black image as a sample image;
in response to the first stop condition being met, ending the gain adjustment process of the camera at the current temperature, and adjusting the ambient temperature again;
and in response to the second stop condition being met, ending the adjustment process of the current environment temperature, and determining a sample image set according to the obtained multiple sample images and the corresponding temperature and gain when each sample image is acquired.
In one possible implementation, the determining a corresponding black level value according to a pixel value of each sample image includes:
and calculating the average value of the pixel values in each sample image to obtain a corresponding black level value.
In one possible implementation, the determining a corresponding white level value according to a pixel value of the white level image includes:
and calculating the average value of the pixel values in the white level image to obtain a corresponding white level value.
In one possible implementation, 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 preset second parameter;
determining a candidate function consisting of a sum of the product of the first parameter and the gain and the second parameter;
inputting the gain of the sample image into the candidate function, and determining a corresponding function value;
inputting the difference value of the function value and the black level value corresponding to each sample image into a preset cost function, and calculating to obtain a corresponding mean square error as a function error;
in response to the function error not meeting a preset condition, updating the first parameter and the second parameter, and re-iterating to input the gain of the sample image into the candidate function and then;
and responding to the function error meeting the preset condition, ending the parameter iteration process and determining the current candidate function as the calibration function.
In one possible implementation, the determining a calibration function according to the gain of each sample image and the corresponding black level value includes:
determining a calibration function based on the gain, temperature and corresponding black level value for each of the sample images.
In one possible implementation, the determining a calibration function according to the gain, the temperature, and the corresponding black level value of each sample image includes:
determining a preset first parameter, a preset second parameter and a preset third parameter;
determining a candidate function consisting of a sum of the product of the first parameter and the gain, the product of the third parameter and the temperature, and the second parameter;
inputting the gain and the temperature of the sample image into the candidate function, and determining a corresponding function value;
inputting the difference value of the function value and the black level value corresponding to each sample image into a preset cost function, and calculating to obtain a corresponding mean square error as a function error;
in response to the function error not meeting a preset condition, updating the first parameter, the second parameter and the third parameter, and iterating again to input the gain and the temperature of the sample image into the candidate function and the subsequent steps;
and responding to the function error meeting the preset condition, ending the parameter iteration process and determining the current candidate function as the calibration function.
In a possible implementation manner, the updating the first parameter and the second parameter includes:
respectively solving partial derivatives of the cost function according to the first parameter and the second parameter to obtain a corresponding first partial derivative result and a corresponding second partial derivative result;
calculating the difference between the first parameter and the product of the first partial derivative result and a preset learning rate to obtain an updated first parameter;
and calculating the difference between the second parameter and the product of the second partial derivative result and the learning rate to obtain an updated second parameter.
In a possible implementation manner, the updating the first parameter, the second parameter, and the third parameter includes:
obtaining partial derivatives of the cost function according 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;
calculating the difference between the first parameter and the product of the first partial derivative result and a preset learning rate to obtain an 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 an updated second parameter;
and calculating the difference of the third parameter, the product of the third partial derivative result and the learning rate to obtain an updated third parameter.
In one possible implementation, the apparatus further includes:
the device comprises a first test image acquisition module, a second test image acquisition module and a control module, wherein the first test image acquisition module is used for acquiring a test image set comprising a plurality of test images which are acquired to be completely black under a non-light environment, and each test image has corresponding gain and temperature;
a first verification module for verifying the calibration function according to the set of test images.
In one possible implementation, the apparatus further includes:
the second test image acquisition module is used for acquiring a test image set comprising a plurality of test images which are acquired to be completely black in a dark environment, and each test image has corresponding gain and temperature;
and the second verification module is used for verifying the calibration function according to the test image set.
In a possible implementation manner, the calibrating the image to be calibrated according to the white level value and the calibration function includes:
determining a corresponding target gain when the image to be calibrated is obtained;
inputting the target gain into the calibration function to obtain a corresponding target black level value;
and 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.
In a possible implementation manner, the calibrating the image to be calibrated according to the white level value and the calibration function includes:
determining a corresponding target temperature and a target gain when the image to be calibrated is obtained;
inputting the target temperature and the target gain into the calibration function to obtain a corresponding target black level value;
and 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.
In a possible implementation manner, the adjusting a 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:
acquiring a target pixel value of a target pixel in the image to be calibrated;
determining the difference between the target pixel value and the target black level value, and the ratio of the white level value to the target black level difference, and obtaining a calibrated target pixel value according to the product of the ratio and a preset constant;
and updating the original pixel value according to the pixel value of each pixel in the image to be calibrated after calibration to obtain the calibrated image.
In some embodiments, functions of or modules included in the apparatus provided in the embodiments of the present disclosure may be used to execute the method described in the above method embodiments, and specific implementation thereof may refer to the description of the above method embodiments, and for brevity, will not be described again here.
Embodiments of the present disclosure also provide a computer-readable storage medium having stored thereon computer program instructions, which when executed by a processor, implement the above-mentioned method. The computer readable storage medium may be a volatile or non-volatile computer readable storage medium.
An embodiment of the present disclosure further provides an electronic device, including: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to implement the above-described method when executing the memory-stored instructions.
The disclosed embodiments also provide a computer program product comprising computer readable code or a non-transitory computer readable storage medium carrying computer readable code, which when run in a processor of an electronic device, the processor in the electronic device performs the above method.
Fig. 9 shows a schematic diagram of an electronic device 800 according to an embodiment of the 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, an exercise device, a personal digital assistant, and the like.
Referring to fig. 9, 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.
The processing component 802 generally controls overall operation of the electronic device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operations at the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices 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, magnetic or optical disks.
The power supply component 806 provides power to the various components of the electronic device 800. The power components 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.
The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and a 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 may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the electronic device 800 is in an operation mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the electronic device 800. For example, the sensor assembly 814 may detect an open/closed state of the electronic device 800, the relative positioning of components, such as a display and keypad of the electronic device 800, the sensor assembly 814 may 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, orientation or acceleration/deceleration of the electronic device 800, and a change in the temperature of the electronic device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 may access a wireless network based on a communication standard, such as WiFi,2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives broadcast signals 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 communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the electronic device 800 may 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, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium, such as the memory 804, is also provided that includes computer program instructions executable by the processor 820 of the electronic device 800 to perform the above-described methods.
Fig. 10 shows a schematic diagram of an electronic device 1900 according to an embodiment of the disclosure. For example, electronic device 1900 may be provided as a server or terminal device. Referring to fig. 10, electronic device 1900 includes a processing component 1922 further including one or more processors and memory resources, represented by memory 1932, for storing instructions, e.g., applications, executable by processing component 1922. The application programs stored in memory 1932 may include one or more modules that each correspond to a set of instructions. Further, the processing component 1922 is configured to execute instructions to perform the above-described method.
The electronic device 1900 may also 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 may operate based on an operating system stored in memory 1932, such as Windows Server, mac OS XTM, unixTM, linuxTM, freeBSDTM, or the like.
In an exemplary embodiment, a non-transitory computer readable storage medium, such as the memory 1932, is also provided that includes computer program instructions executable by the processing component 1922 of the electronic device 1900 to perform the above-described methods.
The present disclosure may be systems, methods, and/or computer program products. The computer program product may include a computer-readable storage medium having computer-readable program instructions embodied thereon for causing a processor to implement various aspects of the present disclosure.
The computer readable storage medium may be a tangible device that can hold and store the instructions for use by the instruction execution device. The computer readable storage medium may be, for example, but not limited to, an electronic memory device, a magnetic memory device, an optical memory device, an electromagnetic memory device, a semiconductor memory device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: a portable computer diskette, 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 mechanical coding device, such as a punch card or an in-groove protruding structure with instructions stored thereon, and any suitable combination of the foregoing. Computer-readable storage media as used herein is not to be construed as transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission medium (e.g., optical pulses through a fiber optic cable), or electrical signals transmitted through electrical wires.
The computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to a respective computing/processing device, or to an external computer or external storage device over 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, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. The network adapter card or network interface in each computing/processing device receives computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in the respective computing/processing device.
The computer program instructions for carrying out operations of the present disclosure may be assembler instructions, instruction Set Architecture (ISA) instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the 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 the connection may be made to an external computer (for example, through the Internet using an Internet service provider). In some embodiments, the electronic circuitry that can execute the computer-readable program instructions implements aspects of the present disclosure by utilizing the state information of the computer-readable program instructions to personalize the electronic circuitry, such as a programmable logic circuit, a Field Programmable Gate Array (FPGA), or a Programmable Logic Array (PLA).
Various aspects of the present disclosure are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the disclosure. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer-readable program instructions.
These computer-readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer-readable program instructions may also be stored in a computer-readable storage medium that can direct a computer, programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer-readable medium storing the instructions comprises an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer, other programmable apparatus or other devices implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowchart 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 diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Having described embodiments of the present disclosure, the foregoing description is intended to be exemplary, not exhaustive, and 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 terminology used herein is chosen in order to best explain the principles of the embodiments, the practical application, or improvements made to the technology in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.
Claims (23)
1. A method of endoscopic calibration, the method comprising:
acquiring a sample image set and a white level image, wherein the sample image set comprises a plurality of sample images which are acquired to be completely black under a dark environment, each sample image has corresponding gain, and the white level image is an image acquired by an endoscope under the condition that the brightness and the gain are maximum;
determining a corresponding black level value according to the pixel value of each sample image;
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 sample image and the corresponding black level value;
and responding to the acquisition of the image to be calibrated by the endoscope, and calibrating the image to be calibrated according to the white level value and the calibration function.
2. The method of claim 1, wherein the set of acquired sample images and white level images comprises:
adjusting the gain of a camera of the endoscope for multiple times in a dark environment, and acquiring corresponding sample images after each adjustment to obtain a sample image set;
and acquiring images by the endoscope under the conditions of maximum light source brightness and maximum camera gain to obtain a white level image.
3. The method of claim 1, wherein each of the sample images further has a corresponding temperature, and wherein the white level image is an image acquired by the endoscope with maximum brightness, gain, and temperature.
4. The method of claim 3, wherein the acquiring of the sample image set and the white level image comprises:
adjusting the environmental temperature and the camera gain of the endoscope for multiple times in an iterative manner in a dark environment, and acquiring corresponding sample images after each adjustment to obtain a sample image set;
the endoscope collects images under the conditions of maximum light source brightness, maximum camera gain and maximum environment temperature to obtain a white level image.
5. The method of claim 4, wherein iteratively adjusting the ambient temperature and the camera gain of the endoscope a plurality of times in the absence of light and acquiring corresponding sample images after each adjustment to obtain a set of sample images comprises:
adjusting the ambient temperature for multiple times according to a preset temperature adjustment rule in a dark environment;
after adjusting the environmental temperature each time, adjusting the gain of a camera of the endoscope according to a preset gain adjustment rule and collecting a corresponding full black image as a sample image;
in response to the first stop condition being met, ending the gain adjustment process of the camera at the current temperature, and adjusting the ambient temperature again;
and in response to the second stop condition being met, ending the adjustment process of the current environment temperature, and determining a sample image set according to the obtained multiple sample images and the corresponding temperature and gain when each sample image is acquired.
6. The method according to any one of claims 1-5, wherein determining a corresponding black level value from the pixel values of each of the sample images comprises:
and calculating the average value of the pixel values in each sample image to obtain a corresponding black level value.
7. The method according to any of claims 1-6, wherein said determining a corresponding white level value from pixel values of said white level image comprises:
and calculating the average value of the pixel values in the white level image to obtain a corresponding white level value.
8. The method of claim 1 or 2, wherein determining a calibration function from the gain and corresponding black level value for each of the sample images comprises:
determining a preset first parameter and a preset second parameter;
determining a candidate function consisting of a sum of the product of the first parameter and the gain and the second parameter;
inputting the gain of the sample image into the candidate function, and determining a corresponding function value;
inputting the difference value of the function value and the black level value corresponding to each sample image into a preset cost function, and calculating to obtain a corresponding mean square error as a function error;
in response to the function error not meeting a preset condition, updating the first parameter and the second parameter, and re-iterating to input the gain of the sample image into the candidate function and then;
and responding to the function error meeting the preset condition, ending the parameter iteration process and determining the current candidate function as the calibration function.
9. The method according to any one of claims 3-5, wherein determining a calibration function from the gain and corresponding black level value for each of the sample images comprises:
determining a calibration function based on the gain, temperature and corresponding black level value for each of the sample images.
10. The method of claim 9, wherein determining a calibration function based on the gain, temperature, and corresponding black level value for each of the sample images comprises:
determining a preset first parameter, a preset second parameter and a preset third parameter;
determining a candidate function consisting of a sum of the product of the first parameter and the gain, the product of the third parameter and the temperature, and the second parameter;
inputting the gain and the temperature of the sample image into the candidate function, and determining a corresponding function value;
inputting the difference value of the function value and the black level value corresponding to each sample image into a preset cost function, and calculating to obtain a corresponding mean square error as a function error;
in response to the function error not meeting a preset condition, updating the first parameter, the second parameter and the third parameter, and iterating again to input the gain and the temperature of the sample image into the candidate function and the subsequent steps;
and responding to the function error meeting the preset condition, ending the parameter iteration process and determining the current candidate function as the calibration function.
11. The method of claim 8, wherein the updating the first and second parameters comprises:
respectively solving partial derivatives of the cost function according to the first parameter and the second parameter to obtain a corresponding first partial derivative result and a corresponding second partial derivative result;
calculating the difference between the first parameter and the product of the first partial derivative result and a preset learning rate to obtain an updated first parameter;
and calculating the difference between the second parameter and the product of the second partial derivative result and the learning rate to obtain an updated second parameter.
12. The method of claim 10, wherein updating the first, second, and third parameters comprises:
obtaining partial derivatives of the cost function according 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;
calculating the difference between the first parameter and the product of the first partial derivative result and a preset learning rate to obtain an 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 an updated second parameter;
and calculating the difference of the third parameter, the product of the third partial derivative result and the learning rate to obtain an updated third parameter.
13. The method according to claim 1 or 2, characterized in that the method further comprises:
acquiring a test image set comprising a plurality of test images which are acquired to be completely black in a dark environment, wherein each test image has a corresponding gain;
and verifying the calibration function according to the test image set.
14. The method according to any one of claims 3-5, further comprising:
acquiring a test image set comprising a plurality of test images which are acquired to be completely black in a dark environment, wherein each test image has corresponding gain and temperature;
and verifying the calibration function according to the test image set.
15. The method according to claim 1 or 2, wherein said calibrating the image to be calibrated according to the white level values and the calibration function comprises:
determining a corresponding target gain when the image to be calibrated is obtained;
inputting the target gain into the calibration function to obtain a corresponding target black level value;
and 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.
16. The method according to any of claims 3-5, wherein calibrating the image to be calibrated according to the white level value and the calibration function comprises:
determining a corresponding target temperature and a target gain when the image to be calibrated is obtained;
inputting the target temperature and the target gain into the calibration function to obtain a corresponding target black level value;
and 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.
17. The method according to claim 15 or 16, 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 comprises:
acquiring a target pixel value of a target pixel in the image to be calibrated;
determining the difference between the target pixel value and the target black level value and the ratio of the white level value to the target black level difference, and obtaining a calibrated target pixel value according to the product of the ratio and a preset constant;
and updating the original pixel value according to the pixel value of each pixel in the image to be calibrated after calibration to obtain the calibrated image.
18. An endoscopic alignment device, the device comprising:
the system comprises an image acquisition module, a brightness acquisition module and a brightness acquisition module, wherein the image acquisition module is used for acquiring a sample image set and a white level image, the sample image set comprises a plurality of sample images which are acquired to be completely black under a dark environment, each sample image has corresponding gain, and the white level image is an image acquired by an endoscope under the condition that the brightness and the gain are maximum; a first level determining module for determining a corresponding black level value according to a pixel value of each of the sample images;
the second level determining module is used for determining a corresponding white level value according to the pixel value of the white level image;
the function fitting module is used for determining a calibration function according to the gain of each sample image and the corresponding black level value;
and the image calibration module is used for responding to the acquisition of the image to be calibrated by the endoscope and calibrating the image to be calibrated according to the white level value and the calibration function.
19. The apparatus of claim 18, wherein each of the sample images further has a corresponding temperature, and wherein the white level image is an image acquired by the endoscope with maximum brightness, gain, and temperature.
20. An image acquisition apparatus, characterized in that the apparatus comprises:
the white level calibration cup comprises an upper bottom surface, a lower bottom surface and a cup wall, a closed space is formed by 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 is provided with an insertion hole, and a heating resistor is arranged in the cup wall;
the endoscope is inserted into the white level calibration cup through the extending hole in the lower bottom surface and is used for acquiring images under the condition of adjusting the temperature of the heating resistor and/or the gain of a camera in the endoscope each time.
21. The apparatus of claim 20, wherein a temperature sensor is further disposed within the cup wall for detecting a temperature within the white level calibration cup.
22. An electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to implement the method of any one of claims 1 to 17 when executing the memory-stored instructions.
23. A non-transitory computer readable storage medium having computer program instructions stored thereon, wherein the computer program instructions, when executed by a processor, implement the method of any of claims 1 to 17.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211712892.9A CN115883976A (en) | 2022-12-29 | 2022-12-29 | Endoscope calibration method, device, electronic apparatus, and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211712892.9A CN115883976A (en) | 2022-12-29 | 2022-12-29 | Endoscope calibration method, device, electronic apparatus, and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115883976A true CN115883976A (en) | 2023-03-31 |
Family
ID=85757252
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211712892.9A Pending CN115883976A (en) | 2022-12-29 | 2022-12-29 | Endoscope calibration method, device, electronic apparatus, and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115883976A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116354366A (en) * | 2023-04-11 | 2023-06-30 | 重庆龙健金属制造有限公司 | High-purity sodium fluoride separation and purification device in silicate production |
-
2022
- 2022-12-29 CN CN202211712892.9A patent/CN115883976A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116354366A (en) * | 2023-04-11 | 2023-06-30 | 重庆龙健金属制造有限公司 | High-purity sodium fluoride separation and purification device in silicate production |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR101861093B1 (en) | Method and apparatus for setting brightness of screen | |
CN106408603B (en) | Shooting method and device | |
CN109819229B (en) | Image processing method and device, electronic equipment and storage medium | |
CN112449026B (en) | Ambient light compensation method, device, terminal and storage medium | |
CN107463052B (en) | Shooting exposure method and device | |
CN110569822A (en) | image processing method and device, electronic equipment and storage medium | |
CN107480785B (en) | Convolutional neural network training method and device | |
CN114240882A (en) | Defect detection method and device, electronic equipment and storage medium | |
CN105100764A (en) | Photographing method and device | |
CN107508573B (en) | Crystal oscillator oscillation frequency correction method and device | |
CN107677377B (en) | Method and device for determining color temperature | |
CN106253996B (en) | Sensitivity attenuation test method and device | |
CN115883976A (en) | Endoscope calibration method, device, electronic apparatus, and storage medium | |
CN112669231B (en) | Image processing method, training method, device and medium of image processing model | |
CN112033527B (en) | Ambient brightness detection method, device, equipment and storage medium | |
CN107657608B (en) | Image quality determination method and device and electronic equipment | |
CN111915686B (en) | Calibration method and device and temperature measurement face recognition device | |
CN111294505B (en) | Image processing method and device | |
CN112781832A (en) | Method, apparatus, device and medium for determining ambient light for terminal device | |
CN111131596B (en) | Screen brightness adjusting method and device | |
CN113267785A (en) | Distance detection method and device and electronic equipment | |
CN115914848A (en) | Image processing method, image processing device, electronic equipment and storage medium | |
CN110333903B (en) | Method and device for determining page loading duration | |
CN113689362B (en) | Image processing method and device, electronic equipment and storage medium | |
CN115706750B (en) | Color temperature calibration method, color temperature calibration device and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20230510 Address after: 334000 room 103, No. 1, Xiangyang Avenue, Shaxi Park, Xinzhou Industrial Park, Xinzhou District, Shangrao City, Jiangxi Province Applicant after: Jiangxi Yuansai Medical Technology Co.,Ltd. Address before: Room 202-2, No. 518, Shenchang Road, Minhang District, Shanghai, 201100 Applicant before: Sulai Technology (Shanghai) Co.,Ltd. |
|
TA01 | Transfer of patent application right |