Image ranging method and system, computer equipment and endoscope system
By using the camera module and light source module in the endoscope to acquire images, calculate the brightness difference to determine the distance, the problem of high cost of the existing endoscope distance measurement hardware is solved, and efficient and low-cost distance measurement and stable travel are achieved.
Patent Information
- Application Number
- CN202311112651.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2025-02-28
AI Technical Summary
The hardware cost of adding distance measuring devices in existing endoscopes is relatively high, and due to the undulation of the inner wall of the cavity, the mirror body is prone to hit the edge of the cavity during travel, causing damage.
The image is acquired under the irradiation of the light source module by the imaging module, the brightness data difference between the first area and the second area in the image is calculated, and the distance between the imaging module and the subject is determined based on the difference data.
Ranging measurement can be achieved without additional hardware equipment, reducing hardware costs, and improving the stability of the endoscope when traveling in the cavity, reducing damage to the cavity.
Smart Images

Figure CN119533295A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image ranging method, system, computer equipment and endoscope system. Background Art
[0002] Endoscope is a common medical device. Under the operation of a doctor, the endoscope can enter the patient's internal cavity to obtain image data inside the cavity, and then determine the location of the patient's lesion, which plays an auxiliary role in the examination and treatment of the lesion.
[0003] In actual applications, due to the ups and downs of the inner wall of the cavity, the mirror body often hits the edge of the cavity during movement, causing damage to the cavity, and the mucus on the inner wall of the cavity will stick to the surface of the mirror body, affecting the imaging. In related technologies, a distance measuring device is added at the end of the mirror body to measure the distance between the mirror body and the inner wall of the cavity, and an alarm is sounded when the distance is close.
[0004] However, in the related art, the method of adding a distance measuring device increases the hardware cost of the distance measurement. Summary of the invention
[0005] Based on this, it is necessary to provide an image ranging method, a system computer device and an endoscope system to address the above technical problems.
[0006] In a first aspect, the present application provides an image ranging method, comprising:
[0007] Acquire an image to be processed including a photographed object, which is taken by the camera module under the illumination of the light source module;
[0008] Calculating difference data between brightness data of a first area and brightness data of a second area in the image to be processed; the second area is arranged around the first area;
[0009] The distance between the camera module and the photographed object is determined according to the difference data of the image to be processed.
[0010] In one embodiment, determining the distance between the camera module and the photographed object according to the difference data of the image to be processed includes:
[0011] Obtaining a reference angle between the optical axis of the light source module and the object being photographed, and the light intensity of the light source module;
[0012] Acquire a first mapping relationship matching a reference angle and light intensity;
[0013] The distance between the camera module and the object is determined according to the first mapping relationship and the difference data of the image to be processed.
[0014] In one embodiment, obtaining a reference angle between an optical axis of a light source module and a photographed object includes:
[0015] Determining the brightness distribution characteristics of the image to be processed according to the brightness distribution information of the image to be processed;
[0016] Acquire a second mapping relationship that matches the light intensity of the light source module;
[0017] A reference angle between the optical axis of the light source module and the object is determined according to the second mapping relationship and the brightness and darkness distribution characteristics of the image to be processed.
[0018] In one embodiment, the brightness distribution information of the image to be processed includes the grayscale value of the image to be processed; and determining the brightness and darkness distribution characteristics of the image to be processed according to the brightness distribution information of the image to be processed includes:
[0019] Acquire an area in the image to be processed whose grayscale value is greater than or equal to a preset grayscale value as a bright side area;
[0020] Acquire an area in the image to be processed whose gray value is less than a preset gray value as a dark side area;
[0021] The brightness and darkness distribution characteristics of the image to be processed are determined according to the grayscale value of the bright side area and the grayscale value of the dark side area.
[0022] In one embodiment, determining the brightness and darkness distribution characteristics of the image to be processed according to the grayscale value of the bright side area and the grayscale value of the dark side area includes:
[0023] Determine the average gray value of the bright side according to the gray value of the bright side area;
[0024] Determine the average gray value of the dark side according to the gray value of the dark side area;
[0025] The ratio of the average gray value on the bright side to the average gray value on the dark side is calculated as the brightness and darkness distribution feature of the image to be processed.
[0026] In one embodiment, calculating difference data between brightness data of a first area and brightness data of a second area in an image to be processed includes:
[0027] Rasterize the image to be processed to determine a first area and a second area in the image to be processed;
[0028] The difference data is determined according to the grayscale value of each pixel in the first area and the second area.
[0029] In one embodiment, determining the difference data according to the grayscale value of each pixel in the first area and the second area includes:
[0030] Determine an intermediate brightness characteristic value according to the grayscale value of each pixel point in the first area;
[0031] Determine an edge brightness characteristic value according to the grayscale value of each pixel point in the second area;
[0032] The difference data is determined based on the middle brightness feature value and the edge brightness feature value.
[0033] In one embodiment, determining the intermediate brightness characteristic value according to the grayscale value of each pixel in the first area includes:
[0034] Determine the grid grayscale value of each grid area in the first area according to the grayscale value of each pixel point in the first area;
[0035] The average grid grayscale value of all grid regions in the first region is obtained as the intermediate brightness feature value.
[0036] In one embodiment, determining the edge brightness characteristic value according to the grayscale value of each pixel in the second area includes:
[0037] Determine the grid grayscale value of each grid area in the second area according to the grayscale value of each pixel point in the second area;
[0038] Grouping the grid areas in the second area, grouping the grid areas belonging to the same boundary into one group, and obtaining at least two groups of boundary grid groups;
[0039] Compare the maximum grid grayscale value in each group of boundary grids, and take the second largest maximum grid grayscale value as the edge brightness feature value.
[0040] In one embodiment, determining difference data according to the middle brightness characteristic value and the edge brightness characteristic value includes:
[0041] The ratio of the edge brightness characteristic value to the middle brightness characteristic value is obtained as the difference data.
[0042] In a second aspect, the present application also provides an image ranging system, comprising:
[0043] An image acquisition unit, used for acquiring an image to be processed including a photographed object, which is taken by the camera module under the illumination of the light source module;
[0044] A brightness analysis unit, used for calculating difference data between brightness data of a first area and brightness data of a second area in the image to be processed; the second area is arranged around the first area;
[0045] The distance determination unit is used to determine the distance between the camera module and the object according to the difference data of the image to be processed.
[0046] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any of the above-mentioned image ranging methods when executing the computer program.
[0047] In a fourth aspect, the present application further provides an endoscope system, comprising: an endoscope, a display, a light source device, and a computer device as in the third aspect;
[0048] The end of the endoscope is provided with a camera module and a light source module as in any of the above-mentioned image ranging methods.
[0049] In a fifth aspect, the present application also provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of any of the above-mentioned image ranging methods when the computer program is executed by a processor.
[0050] In a sixth aspect, the present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned image ranging methods when executed by a processor.
[0051] In the above-mentioned image distance measurement method, system, computer device and endoscope system, by obtaining the image to be processed including the subject captured by the camera module under the illumination of the light source module, the difference data between the brightness data of the first area and the brightness data of the second area in the image to be processed is calculated, and then the distance between the camera module and the subject is determined according to the difference data of the image to be processed. The second area is arranged around the first area. In the above-mentioned method, the distance is measured based on the image obtained by the camera module, without relying on additional hardware equipment, thereby reducing the hardware cost of the distance measurement. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 A diagram showing an application environment of an image ranging method in one embodiment;
[0053] FIG. 2( a ) is a diagram showing an application environment of an image ranging method in another embodiment;
[0054] FIG2( b ) is a diagram showing an application environment of an image ranging method in yet another embodiment;
[0055] Figure 3 A schematic diagram of analyzing the relationship between a light source module, an imaging module and a photographed object in one embodiment;
[0056] Figure 4 is a schematic diagram of the relationship between the angle θ and the light intensity entering the lens module in one embodiment;
[0057] Figure 5 A schematic diagram of the relationship between distance and difference data in one embodiment;
[0058] Figure 6 A diagram showing an application environment of an image ranging method in another embodiment;
[0059] Figure 7 is a schematic diagram of a flow chart of an image ranging method in one embodiment;
[0060] Figure 8 is a schematic structural diagram of an end face of an endoscope in one embodiment;
[0061] Fig. 9 is a schematic structural diagram of an endoscope in one embodiment;
[0062] Fig.10 A schematic diagram of a process for calculating difference data in one embodiment;
[0063] Fig.11 is a schematic diagram of an image to be processed in one embodiment;
[0064] Fig.12 A schematic diagram of a process for determining difference data in another embodiment;
[0065] Fig.13 A schematic diagram of a process for determining an intermediate brightness characteristic value in one embodiment;
[0066] Fig.14 A schematic diagram of a process for determining edge brightness characteristic values in one embodiment;
[0067] Fig.15 is a schematic diagram of an image to be processed in another embodiment;
[0068] Fig.16 A schematic diagram of a process for determining the distance between a camera module and a photographed object in one embodiment;
[0069] Fig.17 A schematic diagram of a process for obtaining a reference angle between an optical axis of a light source module and a photographed object in one embodiment;
[0070] Fig.18 is a schematic diagram of the light and dark distribution of an image to be processed in one embodiment;
[0071] Fig.19 A schematic diagram of a flow chart for determining the light and dark distribution characteristics of an image to be processed in one embodiment;
[0072] Fig. 20 is a schematic diagram of the corresponding relationship between the bright and dark distribution characteristics and the reference angle in one embodiment;
[0073] Fig.21 is a structural block diagram of an image ranging system in one embodiment;
[0074] Fig. 22is a structural block diagram of an endoscope system in one embodiment;
[0075] Fig.23 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0076] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0077] The image ranging method proposed in this application is based on the principle of the first law of illumination (illuminance is proportional to the light intensity of the light source, and inversely proportional to the square of the distance from the illuminated surface to the light source). While ensuring that the volume of the observation device meets the requirements and the image quality, the distance between the observation device and the subject is measured. The method is simple and the calculation is fast.
[0078] The method involves Figure 1 The imaging module and light source module are shown. A device provided with an imaging module can provide an observation function and can be called an observation device. The light source module can irradiate light to the outside by self-luminescence or by light conduction. When the light source module irradiates by self-luminescence, the light source module may include a light source generator; when the light source module irradiates by light conduction, the light source module may include a light guide component, such as an optical fiber.
[0079] When the observation environment is narrow, if the light source module is not large, the light source module can be placed in the observation device as a part of the observation device. Alternatively, the light source module can be placed outside the observation device as a part independent of the observation device.
[0080] The following descriptions are all based on an example in which the light source module irradiates light to the outside through light conduction.
[0081] In the light transmission method, the light source module includes a light guide component, and the light guide component can be placed in an observation device, such as an endoscope.
[0082] The object photographed by the imaging module may be referred to as a photographed object. Before photographing, the light source generator may be controlled to generate light, and the light is conducted to the vicinity of the photographed object via the light guide component to illuminate the photographed object.
[0083] When the light source module illuminates the subject, the imaging module can be controlled to shoot the subject to obtain an image. When the imaging module may include the lens module, image sensor and signal processing module shown in FIG2(a), specifically, after the light is irradiated to the subject, a reflection phenomenon occurs, and after the reflected light passes through the lens module, it is sensed by the image sensor, and the image sensor outputs a corresponding signal, which is processed by the signal processing module to form an image. The processing of the signal processing module may include digital-to-analog conversion processing.
[0084] The surface of the object illuminated by the light source module can be called the illuminated surface. Regardless of the shape of the object, when the area illuminated by the light source module is small, the curvature is also small, and the illuminated surface can be approximately regarded as a plane.
[0085] 2(b), when the angle between the optical axis of the light source module and the illuminated surface becomes smaller, the light intensity entering the lens module becomes weaker, the signal output by the image sensor also weakens, and the pixel value of the image (denoted as P) decreases. When the light source module irradiates by light conduction, the optical axis of the light source module can be the optical axis of the light guide component.
[0086] Reference Figure 3 , the optical axis of the light source module is extended and intersects with the illuminated surface of the subject. The intersection point can be recorded as O, and a point on the optical axis of the light source module is recorded as A. Therefore, the optical axis of the light source module can be represented by line OA. Two points on the optical axis of the lens module are recorded as C and D respectively, and thus, the optical axis of the lens module can be represented by line CD. When the point where the optical axis of the lens module exits the lens module is set to C, the line between point O and the lens module can be represented by line OC. Among them, the optical axis of the light source module is related to the structure of the light source module itself, and the optical axis of the lens module is related to the structure of the lens module itself.
[0087] Angle γ is the angle between line OA and the illuminated surface of the subject, angle β is the angle between line OC and the illuminated surface of the subject, angle α is the angle between line OA and line OC, and angle θ is the angle between line OC and line CD.
[0088] In a scene where the light illuminating the subject is emitted by the light source module, the intensity of the light entering the lens module is affected by the following factors:
[0089] (1) The light intensity of the light source module when irradiating the object (denoted as I);
[0090] (2) Angle γ;
[0091] (3) Angle β;
[0092] (4) The distance from the light source module to the illuminated surface (denoted as d1);
[0093] (5) The distance from the illuminated surface to the lens module (denoted as d2);
[0094] (6) Angle θ.
[0095] Therefore, we can get the factors affecting the intensity of light entering the lens module (I, γ, β, d1, d2, θ). Since the intensity of light entering the lens module is proportional to P, the factors affecting P also include (I, γ, β, d1, d2, θ).
[0096] Assume that the distance between the light source module and the lens module is d3. When the light source module and the lens module are very close, d3 approaches 0, so d1≈d2 can be made, and d=d1=d2 can be made. In addition, when the light source module and the lens module are very close, d3 approaches 0, and the angle α approaches 0, so β=α+γ≈γ. For example, in actual applications, when the light source module and the lens module are both located at the head end of the endoscope, the two are very close to each other (in actual applications, the distance d3 between the light source module and the lens module is often only a few millimeters), while the distance d1 between the object and the light source module, and the distance d2 between the object and the lens module are much larger than d3. At this time, the angle α approaches 0, so the approximate value β=α+γ≈γ can be taken.
[0097] When the angle θ is 0, the light intensity entering the lens module reaches the maximum value. In actual tests, it is found that when the angle θ fluctuates within a small range around 0 degrees, that is, when the angle θ is between (-θ0, +θ0), the difference between the value of the light intensity entering the lens module and the maximum value is very small, such as Figure 4 As shown. Therefore, when the angle θ floats in the range of (-θ0, +θ0), its influence on P can be regarded as a constant. The specific value of (-θ0, +θ0) can be obtained by the technicians according to the actual observation of the equipment. For example, in some embodiments, θ0 can be any value between 5 degrees and 15 degrees.
[0098] When the light source module is very close to the lens module and the angle θ∈(-θ0,+θ0), the influencing factors of P (I, γ, β, d1, d2, θ) can be simplified to (I, γ, d). Among them, d can be d1 or d2 (since d1≈d2, both can be d). P determines the difference data R between the brightness data of the first area and the second area (set around the first area) in the image. When I and γ are fixed, the mapping relationship between d and R can be obtained in advance through calibration experimental tests. When applied, the distance between the observation device and the subject can be obtained based on the mapping relationship between d and R obtained in advance. Since the present application also involves mapping relationships between other quantities, in order to distinguish different mapping relationships, the mapping relationship between d and R is called the first mapping relationship.
[0099] In the test scenario of the calibration experiment, when constructing the first mapping relationship, multiple groups of mapping parameters can be set. Each group of mapping parameters includes angle data and light intensity data, the angle data corresponds to the angle γ, and the light intensity corresponds to the I. The data included in different groups of mapping parameters are not completely the same.
[0100] As shown in Table 1, it is a schematic data of mapping parameters of a first mapping relationship provided by an embodiment of the present application. In the embodiment of the present application, γ1 included in the first group of mapping parameters is different from γ2 included in the second group of mapping parameters, and I1 included in the first group of mapping parameters is different from I2 included in the third group of mapping parameters.
[0101] Mapping Parameters First test data A type of mapping relationship <![CDATA[First group I1, γ1]]> <![CDATA[(R 11 ,d 11 )、(R 12 ,d 12 )、(R 13 ,d 13 )、......]]> <![CDATA[d=f1(P)]]> <![CDATA[Second group I 1, γ2]]> <![CDATA[(R 21 ,d 21 )、(R 22 ,d 22 )、(R 23 ,d 23 )、......]]> <![CDATA[d=f2(P)]]> <![CDATA[The third group I2, γ1]]> <![CDATA[(R 31 ,d 31 )、(R 32 ,d 32 )、(R 33 ,d 33 )、......]]> <![CDATA[d=f3(P)]]> <![CDATA[Group IV I 2, γ2]]> <![CDATA[(R 41 ,d 41 )、(R 42 ,d 42 )、(R 43 ,d 43 )、......]]> <![CDATA[d=f4(P)]]>
[0102] Table 1
[0103] After setting multiple groups of mapping parameters, multiple groups of test data under each group of mapping parameters can be obtained. Since the present application also involves test data when constructing other mapping relationships, in order to distinguish each other, the test data involved in constructing the first mapping relationship is referred to as first test data. Each group of first test data includes: difference data and a distance value, the distance value is the distance d between the observation device and the subject, and the difference data is the difference data between the brightness data of the first area and the second area in the image formed by the imaging module when the light source module illuminates the subject. In the calibration experiment, the values of I and γ can be controlled according to the mapping parameters, and then by adjusting different d values and detecting the corresponding R, multiple groups of first test data (R, d) can be obtained. Referring to Table 1, for the first group of mapping parameters (I1, γ1), multiple groups of first test data (R 11 ,d 11 )、(R 12 ,d 12 )、(R 13 ,d 13 ),.......
[0104] Next, based on the multiple groups of first test data under the same group of mapping parameters, the first mapping relationship corresponding to the group of mapping parameters can be obtained. Specifically, the first mapping relationship corresponding to the group of mapping parameters can be obtained by fitting the multiple groups of first test data under the same group of mapping parameters. The first mapping relationship obtained can be as follows: Figure 5 A monotonic function is shown.
[0105] Referring to Table 1, we can calculate the (R 11 ,d 11 )、(R 12 ,d 12 )、(R 13 ,d 13) and other first test data are fitted to obtain a first mapping relationship d=f1(P) corresponding to the first group of mapping parameters (I1, γ1). Similarly, a first mapping relationship d=f2(P) corresponding to the second group of mapping parameters (I1, γ2), a first mapping relationship d=f3(P) corresponding to the third group of mapping parameters (I2, γ1), and a first mapping relationship d=f4(P) corresponding to the second group of mapping parameters (I2, γ2) can also be obtained. According to the first mapping relationships corresponding to the multiple groups of mapping parameters, a first mapping relationship set can be obtained.
[0106] The image ranging method provided in the embodiment of the present application can be applied to Figure 6 In the application environment shown. The computer device 102 is connected to the endoscope 104 in communication, and a camera module and a light source module are provided at the end of the endoscope 104. The computer device 102 obtains the image to be processed including the object photographed by the camera module under the illumination of the light source module, and calculates the difference data between the brightness data of the first area and the brightness data of the second area in the image to be processed, and then determines the distance between the camera module and the object according to the difference data of the image to be processed. The second area is arranged around the first area.
[0107] The above-mentioned computer device includes the above-mentioned ranging module, which is used to realize image ranging and obtain the distance between the observation device and the object. The embodiment of the present application does not make too many restrictions on the device type of the computer device, which can be an image processor, an AI box, etc., which can be used to realize image ranging. The above-mentioned camera module is the above-mentioned imaging module, and the distance between the camera module and the object obtained by ranging is essentially the distance between the lens module (or light source module, the lens module and the light source module are very close) in the camera module and the object.
[0108] In one embodiment, Figure 7 As shown, an image ranging method is provided, which is applied to Figure 6 Taking the computer device in as an example, the method includes the following steps: S710-S730;
[0109] S710: Acquire an image to be processed that includes a photographed object and is captured by a camera module under illumination by a light source module.
[0110] The camera module and the light source module are located at the end of the endoscope. Figure 8 As shown, the end of the endoscope 104 is provided with a symmetrical light source module S and a light source module S ( Figure 8The lens L in the middle of the endoscope 104 includes two light source modules, and the lens L and the sensor inside the endoscope 104 constitute a camera module. The computer device 102 obtains the acquisition signal of the endoscope 104, processes it based on the internal signal processing module, obtains the image to be processed, and then the distance measurement module performs distance measurement processing based on the image to be processed. Fig. 9 As shown, the light source module S can be arranged on the ring at the end of the endoscope 104, and two light source modules, three light source modules or four light source modules can be arranged, or the light source module S can be directly arranged in a ring shape. In this embodiment, the number of the light source modules S is not specifically limited.
[0111] When the endoscope enters the patient's internal cavity, the user can turn on the light source module by operating the operating end of the endoscope, and control the camera module to shoot under the illumination of the light source module to obtain an image to be processed including the object. The object can be the inner wall of the patient's internal cavity. The computer device then obtains the image captured by the camera module in the endoscope to determine the image to be processed.
[0112] Exemplarily, the computer device may directly use the image acquired from the endoscope as the image to be processed, and may further process the image acquired from the endoscope to use the processed image as the image to be processed. For example, the computer device may remove the boundary area of the acquired image to reduce the influence of the shadows of the four corners of the boundary on subsequent processing, and then use the processed image as the above-mentioned image to be processed.
[0113] S720, calculating difference data between brightness data of a first area and brightness data of a second area in the image to be processed; the second area is arranged around the first area.
[0114] The first area and the second area are different image areas in the image to be processed. The brightness data is used to reflect the brightness of the image. The difference data is used to characterize the brightness difference.
[0115] Optionally, the computer device may adopt a preset division strategy to divide the image to be processed into regions to determine the first region and the second region in the image to be processed, and then obtain the brightness data of the first region and the brightness data of the second region respectively, and calculate the brightness difference between the first region and the second region as the above-mentioned difference data.
[0116] Exemplarily, the computer device may determine the center point of the image to be processed, and expand outward by a preset distance with the center point as the center to form a first area in the image to be processed, and use the remaining area in the image to be processed as the second area. The computer device may also determine the boundary of the image to be processed, and use the boundary as the starting point, extend inward by a preset distance to form the second area in the image to be processed, and use the remaining area in the image to be processed as the first area. In this embodiment, there is no specific restriction on the division method of the first area and the second area in the image to be processed, as long as the second area is set around the first area.
[0117] S730: Determine the distance between the camera module and the object according to the difference data of the image to be processed.
[0118] The difference data of the image to be processed is the brightness difference between the first area and the second area in the image to be processed. The difference in distance between the camera module and the object to be photographed causes different difference data to be presented in the image to be processed.
[0119] When applied to actual endoscope operation scenarios, the illumination area formed by the light source module on the object is small, and the curvature of the surface of the object changes slightly, so the illuminated surface of the object can be approximated as a plane.
[0120] The distance between the camera module and the object will affect the light and dark distribution information of the image to be processed, that is, it will affect the grayscale value of each pixel in the image to be processed, and the grayscale value of each pixel in the image to be processed will directly affect the difference data between the first area and the second area in the image to be processed. Therefore, there is a correlation between the difference data of the image to be processed and the distance between the camera module and the object, which can be used to determine the distance between the camera module and the object based on the difference data of the image to be processed.
[0121] Optionally, after determining the difference data of the image to be processed, the computer device may determine the distance corresponding to the difference data based on the difference data and the association relationship between the camera module and the distance as the distance between the camera module and the object.
[0122] In the embodiment of the present application, the computer device obtains the image to be processed including the subject captured by the camera module under the illumination of the light source module to calculate the difference data between the brightness data of the first area and the brightness data of the second area in the image to be processed, and then determines the distance between the camera module and the subject according to the difference data of the image to be processed. The second area is arranged around the first area. In the above method, the distance is measured based on the image obtained by the camera module, without relying on additional hardware equipment, thereby reducing the hardware cost of the distance measurement.
[0123] In practical applications, the brightness data of an image can be represented by grayscale values. Based on this, in one embodiment, Fig.10 As shown, the calculation of the difference data between the brightness data of the first area and the brightness data of the second area in the image to be processed in the above S720 includes: S1010-S1020;
[0124] S1010 , rasterizing and dividing the image to be processed to determine a first area and a second area in the image to be processed.
[0125] The grid division is used to divide the image to be processed into a plurality of grid areas.
[0126] Optionally, the computer device may use a preset grid template to perform raster division on the image to be processed, so as to determine the first area and the second area in the image to be processed according to the division result.
[0127] For example, Fig.11 As shown, the computer device can use a 5×5 grid template to divide the image to be processed into 25 grid areas, and use the area formed by the outermost grid area as the second area in the image to be processed, and use the grid area located in the outermost grid area as the first area (shadow area) in the image to be processed.
[0128] S1020: Determine difference data according to the grayscale value of each pixel in the first area and the second area.
[0129] The first area and the second area include pixels at corresponding positions.
[0130] Optionally, after determining the first area and the second area in the image to be processed, the computer device can respectively obtain the grayscale value of each pixel in the first area and the grayscale value of each pixel in the second area to determine the difference data between the first area and the second area in the image to be processed.
[0131] For example, the computer device may calculate the average grayscale value of all pixels in the first area, and calculate the average grayscale value of all pixels in the second area, so as to determine the difference data between the first area and the second area in the image to be processed according to the average grayscale value of the first area and the second area. For example, the difference or ratio of the average grayscale value between the first area and the second area is obtained as the difference data.
[0132] In this embodiment, the computer device determines the first area and the second area in the image to be processed by rasterizing the image to be processed, so as to determine the difference data according to the grayscale value of each pixel in the first area and the second area. In the above method, the rasterization division process can divide the image to be processed into regular grid areas, improve the division precision and accuracy of the first area and the second area, and the grayscale value of each pixel in the first area and the second area can intuitively and accurately reflect the brightness and darkness of the first area and the second area, thereby improving the accuracy of the difference data determined based on the grayscale value of each pixel in the first area and the second area.
[0133] The grayscale values of pixels in different regions are different, and the corresponding regions also exhibit different brightness characteristics. Therefore, in one embodiment, Fig.12 As shown, the above S1020, determining difference data according to the grayscale value of each pixel point in the first area and the second area, includes: S1210-S1230;
[0134] S1210. Determine an intermediate brightness characteristic value according to the grayscale value of each pixel in the first area.
[0135] The intermediate brightness characteristic value is used to characterize the brightness characteristic of the first region, and may be the overall brightness characteristic of the first region or the layout brightness characteristic of the first region.
[0136] Optionally, the computer device may determine a brightness characteristic value representing the overall brightness characteristic of the first region according to the grayscale value of each pixel in the first region as the intermediate brightness characteristic value. For example, the average grayscale value of all pixels in the first region is obtained as the intermediate brightness characteristic value Mean.
[0137] Optionally, the computer device may determine a brightness characteristic value representing a local brightness characteristic of the first region according to the grayscale value of each pixel in the first region as an intermediate brightness characteristic value. For example, the maximum grayscale value / minimum grayscale value among the grayscale values of each pixel in the first region is obtained as the intermediate brightness characteristic value Mean.
[0138] S1220. Determine an edge brightness characteristic value according to the grayscale value of each pixel in the second area.
[0139] The edge brightness feature value is used to characterize the brightness feature of the second region, which may be the overall brightness feature of the second region or the layout brightness feature of the second region.
[0140] Optionally, the computer device may determine a brightness feature value representing the overall brightness feature of the second region according to the grayscale value of each pixel in the second region as the edge brightness feature value. For example, the average grayscale value of all pixels in the second region is obtained as the edge brightness feature value Judge.
[0141] Optionally, the computer device may determine a brightness feature value representing a local brightness feature of the second region according to the grayscale value of each pixel in the second region as the edge brightness feature value. For example, the maximum grayscale value / minimum grayscale value among the grayscale values of each pixel in the second region is obtained as the edge brightness feature value Judge.
[0142] S1230: Determine difference data according to the middle brightness characteristic value and the edge brightness characteristic value.
[0143] The computer device may determine the brightness difference, ie, difference data, between the first region and the second region in the image to be processed according to the intermediate brightness characteristic value and the edge brightness characteristic value.
[0144] Exemplarily, the computer device may calculate the difference between the intermediate brightness characteristic value and the edge brightness characteristic value as the above difference data R. The computer device may also calculate the ratio between the intermediate brightness characteristic value and the edge brightness characteristic value as the above difference data R. Specifically, the ratio of the edge brightness characteristic value Judge to the edge brightness characteristic value Mean may be calculated as the difference data R, that is, R=Judge / Mean.
[0145] In the embodiment of the present application, the computer device determines the intermediate brightness characteristic value according to the gray value of each pixel in the first area, and determines the edge brightness characteristic value according to the gray value of each pixel in the second area, so as to determine the difference data according to the intermediate brightness characteristic value and the edge brightness characteristic value. In the above method, the intermediate brightness characteristic value determined based on the gray value of the pixel can accurately quantify the brightness feature of the first area, and the edge brightness characteristic value determined based on the gray value of the pixel can accurately quantify the brightness feature of the second area, thereby improving the accuracy of the difference data determined based on the intermediate brightness characteristic value and the edge brightness characteristic value.
[0146] The intermediate brightness characteristic value can be determined based on the brightness of the grid area in the first area. Based on this, in one embodiment, Fig.13 As shown, the above S1210, determining the intermediate brightness characteristic value according to the grayscale value of each pixel point in the first area, includes: S1310-S1320;
[0147] S1310. Determine the grid grayscale value of each grid area in the first area according to the grayscale value of each pixel point in the first area.
[0148] The grid grayscale value is used to characterize the overall grayscale value of the corresponding grid area, and can be determined based on the grayscale value of each pixel in the corresponding grid area. For example, the grid grayscale value can be the average grayscale value of all pixels in the corresponding grid area, or the grayscale value with the largest number among all pixels.
[0149] Optionally, the computer device may determine the pixel points in each grid area according to the distribution of the grid areas in the first area, and obtain the grayscale value of the corresponding pixel points to calculate the grid grayscale value of each grid area. For example, the average grayscale value of all the pixel points in the corresponding grid area in the first area is calculated as the grid grayscale value of the grid area. For example, Mean represents the intermediate brightness feature value, and value represents the grid grayscale value, such as Fig.11 As shown, the first area (shaded area) includes grid areas 7 to 9, 12 to 14, and 17 to 19. At this time, the intermediate brightness characteristic value can be the average grayscale value of grid areas 7 to 19, that is, Mean = average (value7 + value8 + value9 + value12 + value13 + value14 + value17 + value18 + value19).
[0150] S1320. Obtain an average grid grayscale value of all grid areas in the first area as an intermediate brightness feature value.
[0151] Optionally, after obtaining the grid grayscale values of all grid regions in the first region, the computer device may calculate an average value of the grid grayscale values of all grid regions as the brightness characteristic value of the first region, that is, the intermediate brightness characteristic value.
[0152] In the embodiment of the present application, the computer device determines the grid grayscale value of each grid area in the first area according to the grayscale value of each pixel point in the first area, so as to obtain the average grid grayscale value of all grid areas in the first area as the intermediate brightness feature value. In the above method, the average grid grayscale value of the grid area in the first area is used as the brightness feature value of the first area, that is, the intermediate brightness feature value, so that the intermediate brightness feature value is characterized by a finer-grained average grid grayscale value, which improves the matching degree of the determined intermediate brightness feature value with the actual brightness feature of the first area, thereby improving the accuracy of the intermediate brightness feature value.
[0153] The edge brightness feature value can be determined based on the brightness of the grid area in the second area. Based on this, in one embodiment, Fig.14 As shown, the above S1220, determining the edge brightness characteristic value according to the gray value of each pixel point in the second area, includes: S1410-S1430;
[0154] S1410. Determine the grid grayscale value of each grid area in the second area according to the grayscale value of each pixel point in the second area.
[0155] Optionally, the computer device may determine the pixel points in each grid area according to the distribution of the grid areas in the second area, so as to obtain the grayscale value of the corresponding pixel points to calculate the grid grayscale value of each grid area. For example, the average grayscale value of all the pixel points in the corresponding grid area in the second area is calculated as the grid grayscale value of the grid area.
[0156] S1420: Group the grid areas in the second area, group the grid areas belonging to the same boundary into one group, and obtain at least two boundary grid groups.
[0157] The second area is arranged around the first area, and the second area is a hollow annular area.
[0158] Optionally, the computer device may divide the grid areas on the boundaries of different directions into a group as a group of boundary grid groups according to the distribution of the grid areas in the second area, so as to divide the second area into at least two groups of boundary grid groups. Fig.15 As shown, the image to be processed is a rectangular image, the first area is a rectangular area, and the second area is an annular rectangular area, including four boundaries a to d. The computer device can evenly divide the grid areas in the second area based on the boundaries, and divide the grid areas 1, 2, 3, and 4 on the boundary a into a group, the grid areas 5, 10, 15, and 20 on the boundary b into a group, the grid areas 25, 24, 23, and 22 on the boundary c into a group, and the grid areas 21, 16, 11, and 6 on the boundary d into a group, to obtain four boundary grid groups.
[0159] S1430 , comparing the maximum grid grayscale value in each group of boundary grids, and taking the second largest maximum grid grayscale value as the edge brightness feature value.
[0160] Optionally, after obtaining the grouping of the grid areas in the second region, for each group of boundary grid groups, the computer device may compare the grid grayscale values of each grid area in the boundary grid group to determine the maximum grid grayscale value, further compare the maximum grid grayscale values in each group of boundary grid groups, sort the maximum grid grayscale values in all boundary grid groups, and use the second largest maximum grid grayscale value as the edge brightness feature value. Continuing with the above example, Judge represents the edge brightness feature value, max1, max2, max3, and max4 represent Fig.15 The maximum grid grayscale value in each grid group in the second area, SubMax represents the second largest value, Judge = SubMax{max1, max2, max3, max4}.
[0161] In the embodiment of the present application, the computer device determines the grid grayscale value of each grid area in the second area according to the grayscale value of each pixel point in the second area, and groups the grid areas in the second area, and groups the grid areas belonging to the same boundary into one group, so as to obtain at least two groups of boundary grid groups, so as to compare the maximum grid grayscale value in each group of boundary grid groups, and take the second largest maximum grid grayscale value as the edge brightness feature value. In the above method, the brightness feature value of the second area, i.e., the edge brightness feature value, is determined by using the grid grayscale value of the grid area in the second area, so that the edge brightness feature value is characterized by using a more fine-grained grid grayscale value, which improves the matching degree between the determined edge brightness feature value and the actual brightness feature of the second area, thereby improving the accuracy of the edge brightness feature value.
[0162] In practical applications, when the reference angle between the optical axis of the light source module and the object and the light intensity emitted by the light source module are constant, the difference data between the first area and the second area in the image to be processed is associated with the distance between the camera module and the object. Therefore, the distance between the camera module and the object can be determined based on the association. Based on this, in one embodiment, Fig.16 As shown, the above S730, determining the distance between the camera module and the object according to the difference data of the image to be processed, includes: S1610-S1630;
[0163] S1610: Acquire a reference angle between the optical axis of the light source module and the object, and the illumination intensity of the light source module.
[0164] The reference angle between the optical axis of the light source module and the object is the angle between the optical axis of the light source module and the object.
[0165] Optionally, the computer device may directly obtain pre-stored reference angles and light intensity, or may determine the reference angles and light intensity based on light and dark distribution information of the image to be processed.
[0166] For example, the computer device may determine the correlation between the reference angle and the brightness distribution information of the image to be processed in advance based on a large amount of experimental data to obtain the current brightness distribution information of the image to be processed, and determine the reference angle between the optical axis of the light source module and the subject based on the correlation. The computer device may also obtain the average grayscale value of the image to be processed to determine the illumination intensity of the light source module according to the average grayscale value.
[0167] S1620: Acquire a first mapping relationship that matches the reference angle and the light intensity.
[0168] The first mapping relationship is used to characterize the correlation between the brightness feature of the image to be processed and the distance, where the distance is the distance between the lens module and the subject when the image to be processed is captured.
[0169] Optionally, the computer device stores a first mapping relationship set between the difference data of the image to be processed at different reference angles and different light intensities determined in advance based on a large number of experimental numbers and the distance between the camera module and the subject. After obtaining the difference data of the image to be processed and the light intensity of the light source module, the computer device can traverse the stored first mapping relationship set to determine the first mapping relationship between the difference data and the distance that matches the difference data and the light intensity.
[0170] For example, when the difference data of the image to be processed is the ratio of the edge brightness characteristic value to the middle brightness characteristic value, as Figure 5 As shown, when the illumination intensity I and the angle γ between the incident light and the object are fixed, the difference data R of the image to be processed is negatively correlated with the distance d between the camera module and the object. The larger the difference data R, the smaller the distance d; conversely, the smaller the difference data R, the larger the distance d.
[0171] S1630: Determine the distance between the camera module and the photographed object according to the first mapping relationship and difference data of the image to be processed.
[0172] Optionally, after obtaining the matched first mapping relationship, the computer device may obtain the distance corresponding to the difference data of the image to be processed determined above based on the first mapping relationship, and use the distance as the distance between the camera module and the object.
[0173] In an embodiment of the present application, a computer device obtains a reference angle between an optical axis of a light source module and a photographed object, and the illumination intensity of the light source module, and obtains a first mapping relationship that matches the reference angle and the illumination intensity, and then determines the distance between the camera module and the photographed object based on the first mapping relationship and the difference data of the image to be processed. In the above method, a first mapping relationship between different difference data and distances corresponding to different reference angles and illumination intensities is utilized to determine a first mapping relationship that matches the reference angle and illumination intensity in the current situation, and then the first mapping is used to determine the distance between the camera module and the photographed object, so as to determine the distance based on an accurate correlation relationship, thereby improving the accuracy of the obtained distance between the camera module and the photographed object.
[0174] In one embodiment, if Fig.17 As shown, the step of obtaining a reference angle between the optical axis of the light source module and the object in the above S1610 includes: S1710-S1730;
[0175] S1710. Determine the brightness distribution characteristics of the image to be processed according to the brightness distribution information of the image to be processed.
[0176] The brightness distribution information of the image to be processed includes the grayscale value of each pixel of the image to be processed. The brightness distribution feature of the image to be processed is used to characterize the overall brightness distribution of the image to be processed. Optionally, the brightness distribution feature can be the average grayscale value of the image to be processed, or the ratio or difference of the average grayscale values between different regions in the image to be processed.
[0177] Optionally, the computer device may determine the light and dark distribution characteristics of the image to be processed according to the grayscale value of each pixel in the image to be processed. For example, the average grayscale value of the image to be processed is obtained as the light and dark distribution characteristics of the image to be processed.
[0178] S1720: Acquire a second mapping relationship that matches the illumination intensity of the light source module.
[0179] Optionally, a computer device stores a second mapping relationship set between the brightness and darkness distribution characteristics of the image to be processed under different light intensities and the angle between the optical axis of the light source module and the subject, which is pre-determined based on a large number of experimental numbers. The computer device can traverse the stored second mapping relationship set to determine the second mapping relationship between the brightness and darkness distribution characteristics and the angle that matches the light intensity.
[0180] S1730: Determine a reference angle between the optical axis of the light source module and the object according to the second mapping relationship and the brightness and darkness distribution characteristics of the image to be processed.
[0181] Optionally, after obtaining the matched second mapping relationship, the computer device may obtain the angle corresponding to the brightness distribution characteristics of the image to be processed determined above based on the second mapping relationship, and use the angle as a reference angle between the optical axis of the light source module and the subject.
[0182] In the embodiment of the present application, the computer device determines the light and dark distribution characteristics of the image to be processed based on the brightness distribution information of the image to be processed, and obtains a second mapping relationship that matches the illumination intensity of the light source module, and then determines the reference angle between the optical axis of the light source module and the subject according to the second mapping and the light and dark distribution characteristics of the image to be processed. In the above method, the second mapping relationship between the light and dark distribution characteristics and angles corresponding to different illumination intensities is used to determine the second mapping relationship that matches the illumination intensity under the current situation, and then the second mapping relationship is used to determine the reference angle between the optical axis of the light source module and the subject, so as to determine the angle based on the accurate correlation relationship, thereby improving the accuracy of the reference angle between the optical axis of the light source module and the subject.
[0183] Usually, the subject is not facing the light source module directly, but at a certain tilt angle, such as Fig.18As shown, the image to be processed has one side that is brighter and the other side that is darker, and the grayscale value of the bright side area is generally greater than the grayscale value of the dark side area. Based on this, in one embodiment, as Fig.19 As shown, the above S1710, determining the brightness distribution characteristics of the image to be processed according to the brightness distribution information of the image to be processed, includes: S1910-S1930;
[0184] S1910, obtaining a region in the image to be processed whose grayscale value is greater than or equal to a preset grayscale value as a bright side region.
[0185] The brightness distribution information of the image to be processed includes the grayscale value of the image to be processed. The preset grayscale value is a pre-set fixed grayscale value, or it can be a grayscale value determined based on the brightness distribution information of the image to be processed. For example, the preset grayscale value can be the average grayscale value of the image to be processed.
[0186] Optionally, the computer device can obtain the grayscale value of each pixel in the image to be processed, and compare each grayscale value with a preset grayscale value to determine the size relationship between the grayscale value of each pixel and the preset grayscale value, and use the area formed by the pixels in the image to be processed whose grayscale values are greater than or equal to the preset grayscale value as the bright side area.
[0187] S1920, obtaining a region in the image to be processed whose grayscale value is less than a preset grayscale value as a dark side region.
[0188] Similarly, after obtaining the size relationship between the grayscale value of each pixel in the image to be processed and the preset grayscale value, the computer device can use the area formed by the pixels in the image to be processed whose grayscale value is less than the preset grayscale value as the dark side area.
[0189] S1930, obtaining a ratio of a grayscale average value of the bright side region to a grayscale average value of the dark side region as a light-dark distribution feature of the image to be processed.
[0190] Optionally, after determining the bright side area and the dark side area in the image to be processed, the computer device can determine the grayscale average value of the bright side area based on the grayscale value of each pixel in the bright side area, and determine the grayscale average value of the dark side area based on the grayscale value of each pixel in the dark side area, and then calculate the ratio of the average grayscale values between the bright side area and the dark side area, and use the ratio as the light and dark distribution feature of the image to be processed.
[0191] For example, when the brightness distribution feature of the image to be processed is the ratio of the grayscale average value of the bright side area to the grayscale average value of the dark side area, as Fig. 20As shown, the light intensity I is fixed, and the light and dark distribution feature c of the image to be processed is negatively correlated with the reference angle γ between the incident light and the object. In the case of c = 1, γ = 90°; in the case of c>1, the larger c is, the smaller γ is.
[0192] In the embodiment of the present application, the computer device obtains the area in the image to be processed whose grayscale value is greater than or equal to the preset grayscale value as the bright side area, and obtains the area in the image to be processed whose grayscale value is less than the preset grayscale value as the dark side area, and then obtains the ratio of the grayscale average value of the bright side area to the grayscale average value of the dark side area as the light-dark distribution feature of the image to be processed. In the above method, the ratio between the average grayscale value of the bright side area and the average grayscale value of the dark side area in the image to be processed is used as the light-dark distribution feature, which can accurately reflect the actual positional relationship between the camera module and the subject, and provide an accurate data foundation for the subsequent determination of the distance between the camera module and the subject based on the light-dark distribution feature, thereby improving the accuracy of the determined distance between the camera module and the subject.
[0193] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0194] Based on the same inventive concept, the embodiment of the present application also provides an image ranging system for implementing the above-mentioned image ranging method. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above-mentioned method, so the specific limitations in one or more image ranging system embodiments provided below can refer to the limitations of the image ranging method above, and will not be repeated here.
[0195] In one embodiment, Fig.21 As shown, an image ranging system is provided, comprising: an image acquisition unit 2101, a brightness analysis unit 2102 and a distance determination unit 2103, wherein:
[0196] The image acquisition unit 2101 is used to acquire the image to be processed including the object photographed by the camera module under the illumination of the light source module;
[0197] The brightness analysis unit 2102 is used to calculate the difference data between the brightness data of the first area and the brightness data of the second area in the image to be processed; the second area is arranged around the first area;
[0198] The distance determination unit 2103 is used to determine the distance between the camera module and the object according to the difference data of the image to be processed.
[0199] In one embodiment, the distance determining unit 2103 includes:
[0200] An acquisition submodule, used to acquire a reference angle between the optical axis of the light source module and the object, and the light intensity of the light source module;
[0201] A matching submodule, used to obtain a first mapping relationship that matches a reference angle and light intensity;
[0202] The distance submodule is used to determine the distance between the camera module and the object according to the first mapping relationship and the difference data of the image to be processed.
[0203] In one embodiment, the acquisition submodule includes:
[0204] A distribution feature unit, used to determine the brightness distribution feature of the image to be processed according to the brightness distribution information of the image to be processed;
[0205] A matching relationship unit, used to obtain a second mapping relationship that matches the illumination intensity of the light source module;
[0206] The angle determination unit is used to determine a reference angle between the optical axis of the light source module and the object according to the second mapping relationship and the light and dark distribution characteristics of the image to be processed.
[0207] In one embodiment, the brightness distribution information of the image to be processed includes the grayscale value of the image to be processed; and the distribution feature unit includes:
[0208] A bright side subunit, used to obtain a region in the image to be processed whose gray value is greater than or equal to a preset gray value as a bright side region;
[0209] A dark side subunit, used for acquiring a region in the image to be processed whose gray value is less than a preset gray value as a dark side region;
[0210] The feature subunit is used to obtain the ratio of the grayscale average value of the bright side area to the grayscale average value of the dark side area as the brightness and darkness distribution feature of the image to be processed.
[0211] Each module in the above image ranging system can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0212] In one embodiment, the brightness analysis unit 2102 includes:
[0213] A rasterization submodule, used for performing rasterization division on the image to be processed, and determining a first area and a second area in the image to be processed;
[0214] The difference determination submodule is used to determine difference data according to the grayscale value of each pixel point in the first area and the second area.
[0215] In one embodiment, the difference determination submodule includes:
[0216] An intermediate brightness unit, used to determine an intermediate brightness characteristic value according to the grayscale value of each pixel in the first area;
[0217] An edge brightness unit, used to determine an edge brightness characteristic value according to the grayscale value of each pixel in the second area;
[0218] The brightness difference unit is used to determine difference data according to the middle brightness characteristic value and the edge brightness characteristic value.
[0219] In one embodiment, the intermediate brightness unit includes:
[0220] A first grid subunit, used to determine a grid grayscale value of each grid area in the first area according to the grayscale value of each pixel point in the first area;
[0221] The average grayscale subunit is used to obtain the average grid grayscale value of all grid areas in the first area as the intermediate brightness feature value.
[0222] In one embodiment, the edge brightness unit includes:
[0223] A second grid subunit, used to determine a grid grayscale value of each grid area in the second area according to the grayscale value of each pixel point in the second area;
[0224] A grid grouping subunit, used to group the grid areas in the second area, grouping the grid areas belonging to the same boundary into one group, and obtaining at least two groups of boundary grid groups;
[0225] The edge grayscale subunit is used to compare the maximum grid grayscale value in each group of boundary grids and take the second largest maximum grid grayscale value as the edge brightness feature value.
[0226] In one embodiment, the brightness difference unit includes:
[0227] The ratio subunit is used to obtain the ratio of the edge brightness characteristic value to the middle brightness characteristic value as difference data.
[0228] In one embodiment, Fig. 22 As shown, an endoscope system is also provided, comprising: an endoscope 100 and a control unit 200 communicating with each other. An end of the endoscope 100 is provided with a camera module and a light source module.
[0229] The control unit 200 is used to obtain an image to be processed including a subject, which is taken by a camera module under illumination by a light source module; calculate the brightness data of a first area in the image to be processed and the difference data between the brightness data of a second area; determine the distance between the camera module and the subject according to the difference data of the image to be processed; and the second area is arranged around the first area.
[0230] It should be noted that the control unit 200 in the endoscope system provided in this embodiment is the computer device in the above embodiment, which is used to implement the image ranging method in any of the above embodiments. The specific structure and function of the endoscope 100 and the control unit 200 are detailed in the above embodiment and will not be repeated here.
[0231] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig.23 As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, an image ranging method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0232] Those skilled in the art will understand that Fig.23The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0233] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0234] An image to be processed including a photographed object captured by a camera module under illumination of a light source module is obtained; difference data between brightness data of a first area and brightness data of a second area in the image to be processed is calculated; the second area is arranged around the first area; and the distance between the camera module and the photographed object is determined according to the difference data of the image to be processed.
[0235] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0236] Obtain a reference angle between the optical axis of the light source module and the object, and the illumination intensity of the light source module; obtain a first mapping relationship matching the reference angle and the illumination intensity; and determine the distance between the camera module and the object based on the first mapping relationship and the difference data of the image to be processed.
[0237] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0238] Determine the light and dark distribution characteristics of the image to be processed according to the brightness distribution information of the image to be processed; obtain a second mapping relationship that matches the illumination intensity of the light source module; and determine a reference angle between the optical axis of the light source module and the object according to the second mapping relationship and the light and dark distribution characteristics of the image to be processed.
[0239] In one embodiment, the brightness distribution information of the image to be processed includes the grayscale value of the image to be processed; when the processor executes the computer program, the following steps are also implemented:
[0240] The regions in the image to be processed whose grayscale values are greater than or equal to the preset grayscale values are obtained as the bright side regions; the regions in the image to be processed whose grayscale values are less than the preset grayscale values are obtained as the dark side regions; and the ratio of the grayscale average value of the bright side region to the grayscale average value of the dark side region is obtained as the light-dark distribution feature of the image to be processed.
[0241] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0242] The image to be processed is rasterized and divided to determine a first area and a second area in the image to be processed; and difference data is determined according to the grayscale value of each pixel in the first area and the second area.
[0243] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0244] The intermediate brightness characteristic value is determined according to the gray value of each pixel point in the first area; the edge brightness characteristic value is determined according to the gray value of each pixel point in the second area; and the difference data is determined according to the intermediate brightness characteristic value and the edge brightness characteristic value.
[0245] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0246] Determine the grid grayscale value of each grid area in the first area according to the grayscale value of each pixel point in the first area; obtain the average grid grayscale value of all grid areas in the first area as the intermediate brightness feature value.
[0247] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0248] The grid grayscale value of each grid area in the second area is determined according to the grayscale value of each pixel point in the second area; the grid areas in the second area are grouped, and the grid areas belonging to the same boundary are grouped into one group to obtain at least two groups of boundary grid groups; the maximum grid grayscale value in each group of boundary grid groups is compared, and the second largest maximum grid grayscale value is used as the edge brightness feature value.
[0249] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0250] The ratio of the edge brightness characteristic value to the middle brightness characteristic value is obtained as the difference data.
[0251] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0252] An image to be processed including a photographed object captured by a camera module under illumination of a light source module is obtained; difference data between brightness data of a first area and brightness data of a second area in the image to be processed is calculated; the second area is arranged around the first area; and the distance between the camera module and the photographed object is determined according to the difference data of the image to be processed.
[0253] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0254] Obtain a reference angle between the optical axis of the light source module and the object, and the illumination intensity of the light source module; obtain a first mapping relationship matching the reference angle and the illumination intensity; and determine the distance between the camera module and the object based on the first mapping relationship and the difference data of the image to be processed.
[0255] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0256] Determine the light and dark distribution characteristics of the image to be processed according to the brightness distribution information of the image to be processed; obtain a second mapping relationship that matches the illumination intensity of the light source module; and determine a reference angle between the optical axis of the light source module and the object according to the second mapping relationship and the light and dark distribution characteristics of the image to be processed.
[0257] In one embodiment, the brightness distribution information of the image to be processed includes the grayscale value of the image to be processed; when the computer program is executed by the processor, the following steps are also implemented:
[0258] The regions in the image to be processed whose grayscale values are greater than or equal to the preset grayscale values are obtained as the bright side regions; the regions in the image to be processed whose grayscale values are less than the preset grayscale values are obtained as the dark side regions; and the ratio of the grayscale average value of the bright side region to the grayscale average value of the dark side region is obtained as the light-dark distribution feature of the image to be processed.
[0259] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0260] The image to be processed is rasterized and divided to determine a first area and a second area in the image to be processed; and difference data is determined according to the grayscale value of each pixel in the first area and the second area.
[0261] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0262] The intermediate brightness characteristic value is determined according to the gray value of each pixel point in the first area; the edge brightness characteristic value is determined according to the gray value of each pixel point in the second area; and the difference data is determined according to the intermediate brightness characteristic value and the edge brightness characteristic value.
[0263] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0264] Determine the grid grayscale value of each grid area in the first area according to the grayscale value of each pixel point in the first area; obtain the average grid grayscale value of all grid areas in the first area as the intermediate brightness feature value.
[0265] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0266] The grid grayscale value of each grid area in the second area is determined according to the grayscale value of each pixel point in the second area; the grid areas in the second area are grouped, and the grid areas belonging to the same boundary are grouped into one group to obtain at least two groups of boundary grid groups; the maximum grid grayscale value in each group of boundary grid groups is compared, and the second largest maximum grid grayscale value is used as the edge brightness feature value.
[0267] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0268] The ratio of the edge brightness characteristic value to the middle brightness characteristic value is obtained as the difference data.
[0269] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0270] An image to be processed including a photographed object captured by a camera module under illumination of a light source module is obtained; difference data between brightness data of a first area and brightness data of a second area in the image to be processed is calculated; the second area is arranged around the first area; and the distance between the camera module and the photographed object is determined according to the difference data of the image to be processed.
[0271] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0272] Obtain a reference angle between the optical axis of the light source module and the object, and the illumination intensity of the light source module; obtain a first mapping relationship matching the reference angle and the illumination intensity; and determine the distance between the camera module and the object based on the first mapping relationship and the difference data of the image to be processed.
[0273] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0274] Determine the light and dark distribution characteristics of the image to be processed according to the brightness distribution information of the image to be processed; obtain a second mapping relationship that matches the illumination intensity of the light source module; and determine a reference angle between the optical axis of the light source module and the object according to the second mapping relationship and the light and dark distribution characteristics of the image to be processed.
[0275] In one embodiment, the brightness distribution information of the image to be processed includes the grayscale value of the image to be processed; when the computer program is executed by the processor, the following steps are also implemented:
[0276] The regions in the image to be processed whose grayscale values are greater than or equal to the preset grayscale values are obtained as the bright side regions; the regions in the image to be processed whose grayscale values are less than the preset grayscale values are obtained as the dark side regions; and the ratio of the grayscale average value of the bright side region to the grayscale average value of the dark side region is obtained as the light-dark distribution feature of the image to be processed.
[0277] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0278] The image to be processed is rasterized and divided to determine a first area and a second area in the image to be processed; and difference data is determined according to the grayscale value of each pixel in the first area and the second area.
[0279] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0280] The intermediate brightness characteristic value is determined according to the gray value of each pixel point in the first area; the edge brightness characteristic value is determined according to the gray value of each pixel point in the second area; and the difference data is determined according to the intermediate brightness characteristic value and the edge brightness characteristic value.
[0281] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0282] Determine the grid grayscale value of each grid area in the first area according to the grayscale value of each pixel point in the first area; obtain the average grid grayscale value of all grid areas in the first area as the intermediate brightness feature value.
[0283] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0284] The grid grayscale value of each grid area in the second area is determined according to the grayscale value of each pixel point in the second area; the grid areas in the second area are grouped, and the grid areas belonging to the same boundary are grouped into one group to obtain at least two groups of boundary grid groups; the maximum grid grayscale value in each group of boundary grid groups is compared, and the second largest maximum grid grayscale value is used as the edge brightness feature value.
[0285] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0286] The ratio of the edge brightness characteristic value to the middle brightness characteristic value is obtained as the difference data.
[0287] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0288] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0289] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. An image ranging method, characterized in that: The method comprises: Acquire an image to be processed including a photographed object, which is taken by the camera module under the illumination of the light source module; Calculating difference data between brightness data of a first area and brightness data of a second area in the image to be processed; the second area is arranged around the first area; The distance between the camera module and the photographed object is determined according to the difference data of the image to be processed.
2. The method according to claim 1, characterized in that The step of determining the distance between the camera module and the photographed object according to the difference data of the image to be processed includes: Acquire a reference angle between the optical axis of the light source module and the photographed object, and the illumination intensity of the light source module; Acquire a first mapping relationship matching the reference angle and the light intensity; The distance between the camera module and the photographed object is determined according to the first mapping relationship and the difference data of the image to be processed.
3. The method according to claim 2, characterized in that The obtaining of a reference angle between the optical axis of the light source module and the photographed object comprises: Determining the brightness distribution characteristics of the image to be processed according to the brightness distribution information of the image to be processed; Acquire a second mapping relationship matching the illumination intensity of the light source module; A reference angle between the optical axis of the light source module and the object is determined according to the second mapping relationship and the light and dark distribution characteristics of the image to be processed.
4. The method according to claim 3, characterized in that The brightness distribution information of the image to be processed includes the grayscale value of the image to be processed; and determining the brightness and darkness distribution characteristics of the image to be processed according to the brightness distribution information of the image to be processed includes: Acquire an area in the image to be processed whose grayscale value is greater than or equal to a preset grayscale value as a bright side area; Acquire a region in the image to be processed whose grayscale value is less than the preset grayscale value as a dark side region; The light-dark distribution characteristics of the image to be processed are determined according to the grayscale value of the bright side area and the grayscale value of the dark side area.
5. The method according to any one of claims 1 to 4, characterized in that The calculating the difference data between the brightness data of the first area and the brightness data of the second area in the image to be processed includes: Rasterizing the image to be processed to determine the first region and the second region in the image to be processed; The difference data is determined according to the grayscale value of each pixel in the first area and the second area.
6. The method according to claim 5, characterized in that The determining the difference data according to the grayscale value of each pixel in the first area and the second area includes: Determine an intermediate brightness characteristic value according to the grayscale value of each pixel point in the first area; Determine an edge brightness characteristic value according to the grayscale value of each pixel point in the second area; The difference data is determined according to the middle brightness feature value and the edge brightness feature value.
7. The method according to claim 6, characterized in that Determining the intermediate brightness characteristic value according to the grayscale value of each pixel point in the first area includes: Determine the grid grayscale value of each grid area in the first area according to the grayscale value of each pixel point in the first area; The average grid grayscale value of all grid areas in the first area is obtained as the intermediate brightness feature value.
8. The method according to claim 6, characterized in that The determining the edge brightness characteristic value according to the grayscale value of each pixel point in the second area includes: Determine the grid grayscale value of each grid area in the second area according to the grayscale value of each pixel point in the second area; Grouping the grid areas in the second area, grouping the grid areas belonging to the same boundary into one group, and obtaining at least two boundary grid groups; The maximum grid grayscale value in each group of boundary grids is compared, and the second largest maximum grid grayscale value is used as the edge brightness feature value.
9. The method according to claim 6, characterized in that The determining the difference data according to the intermediate brightness characteristic value and the edge brightness characteristic value comprises: A ratio of the edge brightness characteristic value to the middle brightness characteristic value is obtained as the difference data.
10. An image ranging system, characterized in that: The device comprises: An image acquisition unit, used for acquiring an image to be processed including a photographed object, which is taken by the camera module under the illumination of the light source module; A brightness analysis unit, used for calculating difference data between brightness data of a first area and brightness data of a second area in the image to be processed; the second area is arranged around the first area; The distance determining unit is used to determine the distance between the camera module and the photographed object according to the difference data of the image to be processed.
11. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.
12. An endoscope system, characterized in that: The endoscope system comprises: an endoscope, a display, a light source device and a computer device as claimed in claim 11; The end portion of the endoscope is provided with an imaging module and a light source module according to any one of claims 1 to 9.
Citation Information
Cited By
High-definition digital imaging method suitable for ear-nose-throat endoscope
CN119850495A
Unmanned aerial vehicle itinerant control system and method
CN119960475A
UAV patrol control system and method
CN119960475B