Image ranging method and system, computer equipment and endoscope system

Through the image processing technology of endoscopic shooting, the light intensity and reference angle of the light source module are used, combined with the light and dark characteristics of the image, the distance between the endoscopic and the subject is measured, solving the problems of high hardware costs and imaging interference in the prior art, and achieving efficient and accurate distance measurement.

CN119533294APending Publication Date: 2025-02-28CHANGZHOU UNITED IMAGING HEALTHCARE SURGICAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311109133.8
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

Technical Problem

The existing endoscopic distance measuring device increases hardware cost and easily causes damage when the inner wall of the cavity rises and falls, and the wall mucus sticks to the surface of the insertion part to affect imaging.

Method used

By acquiring the image to be processed by the endoscope, the first mapping relationship is determined using the light intensity of the light source module and the reference angle between the optical axis and the subject, and then the distance between the endoscope and the subject is determined based on the light and dark characteristic data of the image, and finally the distance between the two is calculated.

Benefits of technology

Image ranging can be achieved without additional hardware equipment, reducing hardware costs, and improving the accuracy and reliability of ranging, avoiding cavity damage and imaging interference.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119533294A_ABST
    Figure CN119533294A_ABST
Patent Text Reader

Abstract

The invention relates to an image ranging method and system, computer equipment and an endoscope system. The method comprises the steps that a to-be-processed image which is shot by an endoscope and comprises a shot object is acquired, a first mapping relation is determined according to the illumination intensity of a light source module on the endoscope and a reference included angle between the optical axis of the light source module and the shot object, and the distance state between the endoscope and the shot object is determined according to the to-be-processed image, according to the to-be-processed image, the distance state and the first mapping relation, the distance between the endoscope and the shot object is determined. According to the method, distance measurement is carried out based on the image acquired by the camera module without depending on additional hardware equipment, so that the hardware cost of distance measurement is reduced.
Need to check novelty before this filing date? Find Prior Art

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 insertion part of 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 insertion part often hits the edge of the cavity during movement, causing damage to the cavity, and the wall mucus on the inner wall of the cavity will stick to the surface of the head end of the insertion part (hereinafter referred to as the end), affecting the imaging. In related technologies, a distance measuring device is added to the end of the insertion part to measure the distance between the insertion part 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, system, computer equipment and 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 subject captured by an endoscope;

[0008] Determine a first mapping relationship according to the illumination intensity of the light source module on the endoscope and a reference angle between the optical axis of the light source module and the photographed object;

[0009] Determine the distance between the endoscope and the object according to the image to be processed;

[0010] The distance between the endoscope and the object is determined according to the image to be processed, the far and near state, and the first mapping relationship.

[0011] In one embodiment, determining the distance between the endoscope and the object according to the image to be processed includes:

[0012] Determining light and dark feature data of the image to be processed according to the grayscale value of the image to be processed;

[0013] The distance between the endoscope and the object is determined according to the light and dark feature data of the image to be processed.

[0014] In one embodiment, determining the light and dark feature data of the image to be processed according to the grayscale value of the image to be processed includes:

[0015] Obtain the first pixel point whose grayscale value is greater than the maximum grayscale threshold in the image to be processed;

[0016] Obtain a second pixel point whose grayscale value is less than a minimum grayscale threshold in the image to be processed;

[0017] The light and dark feature data is determined according to the first pixel point and the second pixel point.

[0018] In one embodiment, the light and dark feature data includes a light and dark feature value; determining the distance state between the endoscope and the object according to the light and dark feature data of the image to be processed includes:

[0019] When the light and dark feature value is less than or equal to a preset feature threshold, it is determined that the endoscope and the subject are in a close distance state;

[0020] When the light and dark feature value is greater than the preset feature threshold, it is determined that the endoscope and the subject are in a long-distance state.

[0021] In one embodiment, the first mapping relationship is determined according to the illumination intensity of the light source module on the endoscope and the reference angle between the optical axis of the light source module and the object being photographed, including:

[0022] Determine a first mapping relationship according to distribution data of the lens module and the light source module on the endoscope, reflection data of the object, illumination intensity of the light source module on the endoscope, and a reference angle between the optical axis of the light source module and the object; or,

[0023] The first mapping relationship is determined according to the type of the endoscope, the illumination intensity of the light source module on the endoscope, and the reference angle between the optical axis of the light source module and the photographed object.

[0024] In one embodiment, determining the distance between the endoscope and the object according to the image to be processed, the distance state and the first mapping relationship includes:

[0025] Determine a part of the mapping relationships from the first mapping relationship as the second mapping relationship according to the distance state;

[0026] The distance between the endoscope and the photographed object is determined according to the image to be processed and the second mapping relationship.

[0027] In one embodiment, determining a portion of the mapping relationships from the first mapping relationship as the second mapping relationship according to the distance state includes:

[0028] Obtaining a reference distance corresponding to a peak value in the first mapping relationship;

[0029] The second mapping relationship is determined according to the reference distance and the far-near state.

[0030] In one embodiment, determining the second mapping relationship according to the reference distance and the distance state includes:

[0031] When the distance state is the short distance state, determining a portion of the first mapping relationship whose distance is less than or equal to the reference distance as the second mapping relationship;

[0032] When the near-far state is the long-distance state, a portion of the first mapping relationship whose distance is greater than the reference distance is determined as the second mapping relationship.

[0033] In one embodiment, determining the distance between the endoscope and the object according to the image to be processed, the distance state and the first mapping relationship includes:

[0034] Determine a plurality of distances between the endoscope and the photographed object according to the image to be processed and the first mapping relationship;

[0035] The distance between the endoscope and the subject is determined from a plurality of distances according to the distance state.

[0036] In one embodiment, the multiple distances are two distances; determining the distance between the endoscope and the subject from the multiple distances according to the near and far state includes:

[0037] When the far-near state is the close-distance state, determining the minimum distance among the plurality of distances as the distance between the endoscope and the subject;

[0038] When the distance state is the long distance state, the maximum distance among the plurality of distances is determined as the distance between the endoscope and the object.

[0039] In one embodiment, determining the distance between the endoscope and the object according to the image to be processed and the second mapping relationship includes:

[0040] Calculating difference data between brightness data of a first area and brightness data of a second area in the image to be processed; wherein the second area is arranged around the first area;

[0041] The distance between the endoscope and the object is determined according to the difference data and the second mapping relationship.

[0042] 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:

[0043] Rasterize the image to be processed to determine a first area and a second area in the image to be processed;

[0044] The difference data is determined according to the grayscale value of each pixel in the first area and the second area.

[0045] In one embodiment, determining the difference data according to the grayscale value of each pixel in the first area and the second area includes:

[0046] Determine an intermediate brightness characteristic value according to the grayscale value of each pixel point in the first area;

[0047] Determine an edge brightness characteristic value according to the grayscale value of each pixel point in the second area;

[0048] The difference data is determined based on the middle brightness feature value and the edge brightness feature value.

[0049] In one embodiment, determining the intermediate brightness characteristic value according to the grayscale value of each pixel in the first area includes:

[0050] 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;

[0051] The average grid grayscale value of all grid regions in the first region is obtained as the intermediate brightness feature value.

[0052] In one embodiment, determining the edge brightness characteristic value according to the grayscale value of each pixel in the second area includes:

[0053] 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;

[0054] 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;

[0055] 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.

[0056] In one embodiment, determining difference data according to the middle brightness characteristic value and the edge brightness characteristic value includes:

[0057] The ratio of the edge brightness characteristic value to the middle brightness characteristic value is obtained as the difference data.

[0058] In one embodiment, before determining the light intensity of the light source module on the endoscope and the reference angle between the optical axis of the light source module and the object, the method further comprises:

[0059] Determining the brightness distribution characteristics of the image to be processed according to the brightness distribution information of the image to be processed;

[0060] Acquire a third mapping relationship between a brightness distribution feature and an angle that matches the illumination intensity;

[0061] A reference angle between the optical axis of the light source module and the object is determined according to the third mapping relationship and the brightness and darkness distribution characteristics of the image to be processed.

[0062] 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:

[0063] 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;

[0064] Acquire an area in the image to be processed whose gray value is less than a preset gray value as a dark side area;

[0065] 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.

[0066] In a second aspect, the present application also provides an image ranging system, comprising:

[0067] An image acquisition unit, used for acquiring an image to be processed including a photographed object taken by an endoscope;

[0068] A mapping relationship unit, used to determine a first mapping relationship according to the illumination intensity of the light source module on the endoscope and a reference angle between the optical axis of the light source module and the object;

[0069] A distance determination unit, used to determine the distance state between the endoscope and the object according to the image to be processed;

[0070] The distance determination unit is used to determine the distance between the endoscope and the object according to the image to be processed, the far and near state and the first mapping relationship.

[0071] 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.

[0072] In a fourth aspect, the present application further provides an endoscope system, the endoscope system comprising: an endoscope, a display, a light source device and the above-mentioned computer device;

[0073] The end of the endoscope is provided with a light source module as in any of the above-mentioned image ranging methods.

[0074] 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.

[0075] 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.

[0076] In the above-mentioned image distance measurement method, system, computer device and endoscope system, by obtaining the image to be processed including the subject taken by the endoscope, a first mapping relationship is determined according to the illumination intensity of the light source module on the endoscope and the reference angle between the optical axis of the light source module and the subject, and the distance state of the endoscope and the subject is determined according to the image to be processed, and then the distance between the endoscope and the subject is determined according to the image to be processed, the distance state and the first mapping relationship. 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

[0077] Figure 1 A diagram showing an application environment of an image ranging method in one embodiment;

[0078] FIG. 2( a ) is a diagram showing an application environment of an image ranging method in another embodiment;

[0079] FIG2( b ) is a diagram showing an application environment of an image ranging method in yet another embodiment;

[0080] Figure 3 A schematic diagram of analyzing the relationship between a light source module, an imaging module and a photographed object in one embodiment;

[0081] Figure 4 is a schematic diagram of the relationship between the angle θ and the light intensity entering the lens module in one embodiment;

[0082] Figure 5 A schematic diagram of the relationship between distance and difference data in one embodiment;

[0083] 6(a) to (c) are schematic diagrams of the application of the lens module and the object at different distances;

[0084] Figure 7 is a schematic diagram of an image obtained by close-up photography in one embodiment;

[0085] Figure 8 A diagram showing an application environment of an image ranging method in another embodiment;

[0086] Fig. 9 is a schematic diagram of a flow chart of an image ranging method in one embodiment;

[0087] Fig.10 is a schematic structural diagram of an end face of an endoscope in one embodiment;

[0088] Fig.11 is a schematic structural diagram of an endoscope in one embodiment;

[0089] Fig.12 A schematic diagram of a process for determining a near or far state in one embodiment;

[0090] Fig.13 A schematic diagram of a process for determining light and dark feature data in one embodiment;

[0091] Fig.14 A schematic diagram of a flow chart for determining a far or near state in another embodiment;

[0092] Fig.15 is a schematic diagram of a process for determining the distance between an endoscope and a photographed object in one embodiment;

[0093] Fig.16 A schematic diagram of a process for determining a second mapping relationship in an embodiment;

[0094] Fig.17 A schematic diagram of a flow chart for determining a second mapping relationship in another embodiment;

[0095] Fig.18 is a schematic diagram of a flow chart of determining the distance between an endoscope and a photographed object in another embodiment;

[0096] Fig.19 is a schematic diagram of a flow chart of determining the distance between an endoscope and a photographed object in another embodiment;

[0097] Fig. 20 is a schematic diagram of a process of determining a distance according to a second mapping relationship in another embodiment;

[0098] Fig.21 A schematic diagram of a process for determining difference data in one embodiment;

[0099] Fig. 22 is a schematic diagram of an image to be processed in one embodiment;

[0100] Fig.23 A schematic diagram of a process for determining difference data in another embodiment;

[0101] Fig.24 A schematic diagram of a process for determining an intermediate brightness characteristic value in one embodiment;

[0102] Fig.25 A schematic diagram of a process for determining edge brightness characteristic values ​​in one embodiment;

[0103] Fig.26 is a schematic diagram of an image to be processed in another embodiment;

[0104] Fig. 27 A schematic diagram of a process for determining a reference angle in one embodiment;

[0105] Fig.28 is a schematic diagram of the light and dark distribution of an image to be processed in one embodiment;

[0106] Fig.29 A schematic diagram of a process for determining bright and dark distribution characteristics in one embodiment;

[0107] Fig.30 is a schematic diagram of the corresponding relationship between the bright and dark distribution characteristics and the reference angle in one embodiment;

[0108] Fig.31 is a structural block diagram of an image ranging system in one embodiment;

[0109] Fig.32 is an internal structure diagram of a computer device in one embodiment;

[0110] Fig.33 1 is a structural block diagram of an endoscope system in one embodiment. DETAILED DESCRIPTION

[0111] 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.

[0112] The image ranging method proposed in this application takes 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) as its starting point. 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.

[0113] 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.

[0114] 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.

[0115] The following descriptions are all based on an example in which the light source module irradiates light to the outside through light conduction.

[0116] 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.

[0117] 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.

[0118] 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.

[0119] 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.

[0120] 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.

[0121] 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.

[0122] 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.

[0123] 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:

[0124] (1) The light intensity of the light source module when irradiating the object (denoted as I);

[0125] (2) Angle γ;

[0126] (3) Angle β;

[0127] (4) The distance from the light source module to the illuminated surface (denoted as d1);

[0128] (5) The distance from the illuminated surface to the lens module (denoted as d2);

[0129] (6) Angle θ.

[0130] 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, θ).

[0131] 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.

[0132] 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.

[0133] 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 brightness characteristics of the image, which can be characterized by 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.

[0134] In practical applications, the type of observation device (or the distribution data of the lens module and the light source module on the observation device and the reflection data of the subject) will also affect P. In the test scenario of the calibration experiment, multiple groups of mapping parameters can be set when constructing the first mapping relationship. Each group of mapping parameters includes the type of observation device (or the distribution data of the lens module and the light source module on the observation device and the reflection data of the subject), angle data and light intensity data. The type of observation device corresponds to T, the angle data corresponds to the above angle γ, and the light intensity corresponds to the above I. The data included in different groups of mapping parameters are not exactly the same.

[0135] Taking the mapping parameters including T1, T2 and T3, γ1, γ2 and γ3, I1, I2 and I3 as an example, after permutation and combination, a total of 27 groups of mapping parameters are formed, namely 3*3*3, and each group of mapping parameters corresponds to multiple groups of test data of brightness characteristics and distance values. 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 the first test data. Each group of first test data includes: brightness characteristics and distance values, the brightness characteristics are 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, and the distance value is the distance d between the observation device and the subject. In the calibration experiment, the values ​​of T, 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) corresponding to each group of mapping parameters can be obtained.

[0136] 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 non-monotonic function is shown.

[0137] Next, the reason why the first mapping relationship is a non-monotonic function is analyzed as follows:

[0138] Combination Figure 5 6( a ) to ( c ), an example is given in which the observation device includes two light source modules evenly distributed on both sides of the lens, and the characteristic data of the image is the difference data R between the first area and the second area in the image.

[0139] In the experiment, it was found that, as shown in Figure 6(a), when the distance d between the lens module and the subject is very close (close to 0), due to the influence of the field of view of the lens module, the light intensity received by the middle area of ​​the illuminated surface of the subject is very weak, and only the boundary area receives the reflected light from the light source module. The overall distribution characteristics of the captured image are that the boundary area is bright and the center area is dark (such as Figure 7 As shown in Figure 6(b), as d increases, the brighter boundary area gradually expands inward, while the darker middle area gradually shrinks inward, and the brightness characteristics of the captured image gradually increase. When d increases to d0, the light source module irradiates the object with the strongest illumination, and the captured image as a whole presents a distribution feature in which the central area is the brightest and has the largest area. At this time, the R of the image is the largest. Thereafter, as shown in Figure 6(c), d continues to increase, and the light source intensity decreases as d increases. The captured image as a whole presents a distribution feature in which both the boundary area and the central area become darker, and the R of the image decreases until it no longer changes.

[0140] It can be concluded that when the distance d between the lens module and the subject changes from near to far, the difference data R of the captured image shows a non-monotonic change that first increases and then decreases, and the first mapping relationship representing the correlation between the distance d and the difference data R is Figure 5 The non-monotonic function shown.

[0141] The image ranging method provided in the embodiment of the present application can be applied to Figure 8 In the application environment shown. Among them, 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 camera module on the endoscope 104 captures the image to be processed including the irradiated object under the illumination of the light source module, and the computer device 102 obtains the image to be processed, and determines the first mapping relationship according to the illumination intensity of the light source module on the endoscope and the reference angle between the optical axis of the light source module and the object to be photographed, and determines the distance state between the endoscope and the object to be photographed according to the image to be processed, and then determines the distance between the endoscope and the object to be photographed according to the image to be processed, the distance state and the first mapping relationship.

[0142] The above-mentioned computer device includes the above-mentioned ranging module, which is used to realize image ranging and obtain the distance between the endoscope and the object. The embodiment of the present application does not impose too many restrictions on the device type of the computer device, which can be an image processor, 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 endoscope 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 endoscope and the object.

[0143] In one embodiment, Fig. 9 As shown, an image ranging method is provided, which is applied to Figure 8 Taking the computer device in as an example, the method includes the following steps: S910-S940;

[0144] S910: Acquire an image to be processed that includes a photographed object and is taken through an endoscope.

[0145] The camera module and the light source module are located at the end of the endoscope insertion portion. Fig.10 As shown, the end of the endoscope 104 is provided with a symmetrical light source module S and a light source module S ( Fig.10 The lens module L in the middle of the endoscope 104 includes two light source modules. The lens module 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 based on the image to be processed. Fig.11 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.

[0146] When the insertion portion of the endoscope enters the patient's internal cavity, the user can operate to turn on the light source device including the light source generator. At this time, the endoscope illuminates the internal cavity through the light-guiding component (such as optical fiber) in the light source module, and controls 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, or other objects contained on the inner wall of the cavity, such as polyps, dirt, etc. The computer device then obtains the image captured by the camera module in the endoscope to determine the image to be processed.

[0147] 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.

[0148] S920: Determine a first mapping relationship according to the illumination intensity of the light source module on the endoscope and a reference angle between the optical axis of the light source module and the photographed object.

[0149] 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 illuminated surface of the object. Different illumination intensities and different reference angles correspond to different first mapping relationships.

[0150] 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.

[0151] 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.

[0152] S930: Determine the distance between the endoscope and the object according to the image to be processed.

[0153] The distance state is used to characterize the distance between the endoscope and the object. Exemplarily, the distance state between the endoscope and the object includes a long distance state with a longer distance and a short distance state with a shorter distance, or includes a long distance state with a longer distance, a short distance state with a shorter distance, and an intermediate distance state with a moderate distance. In this embodiment, the division of the distance state is not specifically limited, and multiple levels of distance states may be included.

[0154] The distance between the endoscope and the object is equivalent to the distance between the light source module and the object, and the distance between the light source module and the object will affect the brightness distribution information of the image to be processed. The brightness distribution information of the image to be processed taken at different distances is different.

[0155] Optionally, the computer device can obtain the brightness distribution information of the image to be processed to determine the distance state of the endoscope corresponding to the object to be processed and the object to be photographed based on the brightness distribution information of the image to be processed and the association between the preset brightness distribution information and the distance state.

[0156] S940: Determine the distance between the endoscope and the object according to the image to be processed, the distance state and the first mapping relationship.

[0157] 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.

[0158] The first mapping relationship is used to characterize the correlation between the brightness feature of the image to be processed and the distance, which is the distance between the endoscope and the object when the image to be processed is taken. In actual applications, it is found that the brightness feature and the distance in the first mapping relationship are not one-to-one corresponding, but one-to-many, that is, one brightness feature does not correspond to one distance.

[0159] Optionally, the light and dark distribution information of the image to be processed includes the brightness data of the image to be processed. After obtaining the first mapping relationship, the computer device can determine the brightness characteristics of the image to be processed based on the brightness data of the image to be processed, and use the distance between the light source module and the subject as a constraint to determine the distance corresponding to the brightness characteristics of the image to be processed and consistent with the distance state according to the first mapping relationship as the distance between the endoscope and the subject.

[0160] In the embodiment of the present application, the computer device obtains the image to be processed including the subject taken by the endoscope, determines the first mapping relationship according to the illumination intensity of the light source module on the endoscope and the reference angle between the optical axis of the light source module and the subject, and determines the distance state between the endoscope and the subject according to the image to be processed, and then determines the distance between the endoscope and the subject according to the image to be processed, the distance state and the first mapping relationship. 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.

[0161] In practical applications, the light and dark distribution information of the image to be processed for determining the near and far state can be represented by the gray value of each pixel in the image to be processed. Based on this, in one embodiment, Fig.12 As shown, the above S930, determining the distance state between the endoscope and the object according to the image to be processed, includes: S1210-S1220;

[0162] S1210 , determining light and dark feature data of the image to be processed according to the grayscale value of the image to be processed.

[0163] Among them, the gray value is used to characterize the brightness and darkness of the pixel point, and the light and dark feature data of the image to be processed is used to characterize the overall brightness and darkness of the image to be processed. Among them, the embodiment of the present application does not make too many restrictions on the recording method of the overall brightness and darkness of the image, that is, the data form of the light and dark feature data is not limited. For example, the light and dark feature data can be one or more specific values ​​(which can be called light and dark feature values ​​in this case), or can be recorded in the form of a curve, a matrix, or the like.

[0164] Optionally, the computer device may obtain the grayscale value of each pixel in the image to be processed to determine the light and dark feature data of the image to be processed according to the grayscale value of each pixel. Exemplarily, the computer device may obtain the average grayscale value of all pixels in the image to be processed as the light and dark feature data of the image to be processed.

[0165] S1220, determining the distance between the endoscope and the object according to the light and dark feature data of the image to be processed.

[0166] Optionally, after obtaining the light and dark feature data of the image to be processed, the computer device can determine the distance state corresponding to the light and dark feature data of the image to be processed according to the preset association relationship between the light and dark feature data and the distance state as the distance state between the endoscope and the subject.

[0167] In the embodiment of the present application, the computer device determines the light and dark feature data of the image to be processed according to the grayscale value of the image to be processed, so as to determine the distance state between the endoscope and the object to be photographed according to the light and dark feature data of the image to be processed. In the above method, the distance state between the endoscope and the object to be photographed is obtained based on the light and dark feature data determined by the grayscale value, and the priori that the distance between the endoscope and the object, that is, the distance state, affects the grayscale value of the image to be processed is used to improve the accuracy of the determined distance state.

[0168] The light and dark feature data of the image to be processed can be determined based on a preset maximum grayscale threshold and a preset minimum grayscale threshold. Fig.13 As shown, the above S1210, determining the light and dark feature data of the image to be processed according to the gray value of the image to be processed, includes: S1310-S1330;

[0169] S1310, obtaining the first pixel point whose grayscale value is greater than the maximum grayscale threshold in the image to be processed.

[0170] The maximum grayscale threshold is used to determine the brighter pixels in the image to be processed.

[0171] Optionally, after obtaining the grayscale value of each pixel in the image to be processed, the computer device may compare the grayscale value of each pixel with a preset maximum grayscale threshold to obtain a pixel in the image to be processed whose grayscale value is greater than the maximum grayscale threshold as the first pixel.

[0172] S1320, obtaining a second pixel point whose grayscale value is less than a minimum grayscale threshold in the image to be processed.

[0173] The minimum grayscale threshold is used to determine the darker pixels in the image to be processed.

[0174] Optionally, after obtaining the grayscale value of each pixel in the image to be processed, the computer device may compare the grayscale value of each pixel with a preset minimum grayscale threshold to obtain a pixel in the image to be processed whose grayscale value is less than the minimum grayscale threshold as the second pixel.

[0175] S1330. Determine light and dark feature data according to the first pixel and the second pixel.

[0176] Optionally, after obtaining the brighter first pixel and the darker second pixel in the image to be processed, the computer device determines the light and dark feature data of the image to be processed based on the first pixel and the second pixel. Exemplarily, the computer device may count the number of first pixels and the number of second pixels in the image to be processed, respectively, and calculate the ratio of the number of first pixels to the number of second pixels as the light and dark feature data of the image to be processed. The computer device may also count the grayscale average value of the first pixel and the grayscale average value of the second pixel in the image to be processed, respectively, and calculate the ratio of the grayscale average value of the first pixel to the grayscale average value of the second pixel as the light and dark feature data of the image to be processed.

[0177] In an embodiment of the present application, a computer device obtains a first pixel point in the image to be processed whose grayscale value is greater than a maximum grayscale threshold, and obtains a second pixel point in the image to be processed whose grayscale value is less than a minimum grayscale threshold, so as to determine light and dark feature data based on the first pixel point and the second pixel point. In the above method, the maximum grayscale threshold is used to determine the brighter first pixel point in the image to be processed, and the minimum grayscale threshold is used to determine the darker second pixel point in the image to be processed. The brighter first pixel point and the darker second pixel point can reflect the actual overall light and dark degree of the image to be processed. Therefore, determining the light and dark feature data based on the first pixel point and the second pixel point improves the adaptability between the obtained light and dark feature data and the actual overall light and dark degree of the image to be processed, that is, improves the accuracy of the light and dark feature data.

[0178] In the case where the distance state between the endoscope and the object includes a close distance state and a long distance state, in one embodiment, as Fig.14As shown, the above S1220, determining the distance state between the endoscope and the object according to the light and dark feature data of the image to be processed, includes: S1410-S1420;

[0179] S1410: When the light and dark feature value is less than or equal to a preset feature threshold, determine that the endoscope and the subject are in a close distance state.

[0180] In the embodiment of the present application, the light and dark feature data includes light and dark feature values.

[0181] The preset feature threshold is a critical value for determining the long-distance state and the short-distance state. The light and dark feature value of the image to be processed is used to characterize the degree of light and dark. The larger the light and dark feature value, the brighter the image to be processed. Conversely, the smaller the light and dark feature value, the darker the image to be processed.

[0182] Optionally, after obtaining the light and dark feature value of the image to be processed, the computer device may compare the light and dark feature value with a preset feature threshold value to determine the distance state between the endoscope and the object according to the comparison result.

[0183] It should be noted that, in actual applications, when the endoscope is relatively close to the subject, the image to be processed is captured and obtained. The image to be processed as a whole presents a distribution feature that a large area in the center is dark, while a small area at the edge is bright, and the light and dark characteristic value of the image to be processed is small. As the distance between the endoscope and the subject increases, the captured image to be processed as a whole presents a distribution feature that a large area in the center becomes brighter, while a small area at the edge becomes darker. The light and dark characteristic value of the image to be processed increases with the increase of the distance until it reaches the preset characteristic threshold. As the distance between the endoscope and the subject continues to increase, the image to be processed as a whole presents a distribution feature that both a large area in the center and a small area at the edge become darker, and the light and dark characteristic value of the image to be processed remains slightly increased or unchanged. Therefore, within a limited distance range, the light and dark characteristic value of the image to be processed increases with the increase of the distance between the endoscope and the subject.

[0184] Optionally, when the comparison result is that the light and dark feature value of the image to be processed is less than or equal to a preset feature threshold, it indicates that the image to be processed was captured by the endoscope at a close distance to the subject, and the computer device can determine that the endoscope and the subject are in a close distance state.

[0185] S1420: When the light and dark feature value is greater than a preset feature threshold, determine that the endoscope and the subject are in a long-distance state.

[0186] Optionally, when the comparison result is that the light and dark feature value of the image to be processed is less than or equal to a preset feature threshold, it indicates that the image to be processed is captured by the endoscope at a long distance from the subject, and the computer device can determine that the endoscope and the subject are at a long distance.

[0187] In the embodiment of the present application, the computer device determines that the endoscope and the subject are in a close distance state when the light and dark feature value is less than or equal to the preset feature threshold, and determines that the endoscope and the subject are in a long distance state when the light and dark feature value is greater than the preset feature threshold. In the above method, the change characteristic that the light and dark feature value of the image to be processed increases as the distance between the endoscope and the subject increases is utilized, and the preset feature threshold is used as the judgment condition to determine the distance state of the endoscope and the subject, thereby improving the accuracy of the obtained distance state of the endoscope and the subject.

[0188] The first mapping relationship represents a non-monotonic association relationship. Based on this, in one embodiment, Fig.15 As shown, the above S940, determining the distance between the endoscope and the object according to the image to be processed, the far and near state and the first mapping relationship, includes: S1510-S1520;

[0189] S1510: Determine a portion of the mapping relationships from the first mapping relationships as the second mapping relationship according to the distance state.

[0190] The first mapping relationship can be divided into at least two monotonically changing mapping relationships. The second mapping relationship is a monotonically changing mapping relationship in the first mapping relationship. For example, Figure 5 As shown, part of the mapping relationships in the first mapping relationship corresponding to the distance less than or equal to the distance threshold d0 represents a monotonically increasing association relationship, and part of the mapping relationships corresponding to the distance greater than the distance threshold d0 represents a monotonically decreasing association relationship.

[0191] Optionally, after obtaining the distance state between the endoscope and the photographed object, the computer device may determine, in the first mapping relationship, a partial mapping relationship whose distance matches the distance state and changes monotonically as the second mapping relationship.

[0192] S1520: Determine the distance between the endoscope and the object according to the image to be processed and the second mapping relationship.

[0193] The first mapping relationship represents the correlation between the brightness feature of the image to be processed and the distance, and the second mapping relationship is a partial mapping relationship in the first mapping relationship, and correspondingly also represents the correlation between the brightness feature of the image to be processed and the distance.

[0194] Optionally, after obtaining the first mapping relationship, the computer device may determine the brightness feature of the image to be processed, and determine the distance corresponding to the brightness feature in the second mapping relationship, and use the distance as the distance between the endoscope and the object.

[0195] In the embodiment of the present application, the computer device determines part of the mapping relationship from the first mapping relationship as the second mapping relationship according to the distance state, and determines the distance between the endoscope and the subject according to the image to be processed and the second mapping relationship. In the above method, the distance state between the endoscope and the subject is used as a constraint condition to determine the second mapping relationship that matches it in the first mapping relationship, and then the distance between the endoscope and the subject is determined based on the second mapping relationship, eliminating the problem that the distance between the endoscope and the subject cannot be accurately determined due to the non-monotonic association relationship of the first mapping relationship, so as to obtain a uniquely determined distance, thereby improving the reliability of the result.

[0196] To accurately locate the second mapping relationship, in one embodiment, as Fig.16 As shown, the above S1510, determining a part of the mapping relationship from the first mapping relationship as the second mapping relationship according to the distance state, includes: S1610-S1620;

[0197] S1610: Obtain a reference distance corresponding to a peak value in the first mapping relationship.

[0198] In the case where the first mapping relationship represents the correlation between the brightness feature and the distance of the image to be processed, the peak value in the first mapping relationship is the extreme point of the brightness feature, and the reference distance is the distance corresponding to the extreme point. Figure 5 In the case shown, the peak value in the first mapping relationship is the maximum brightness feature, and the reference distance is the distance d0 corresponding to the maximum brightness feature.

[0199] Optionally, the computer device may analyze the first mapping relationship to determine a brightness feature that is a peak value in the first mapping relationship, and obtain a distance corresponding to the brightness feature as a reference distance.

[0200] S1620: Determine a second mapping relationship according to the reference distance and the distance state.

[0201] Optionally, after obtaining the reference distance of the first mapping relationship, the computer device may divide the first mapping relationship based on the reference distance to divide the first mapping relationship into at least two mapping relationships, and combine the distance state of the endoscope and the subject to determine the partial mapping relationship whose distance matches the distance state in the at least two mapping relationships obtained by division as the second mapping relationship.

[0202] In the embodiment of the present application, the computer device obtains the reference distance corresponding to the peak value in the first mapping relationship to determine the second mapping relationship according to the reference distance and the distance state. In the above method, the second mapping relationship is determined in the first mapping relationship based on the reference distance in the first mapping relationship and the distance state between the endoscope and the subject, so as to accurately locate the second mapping relationship, thereby improving the convenience and accuracy of determining the second mapping relationship.

[0203] In the case where a peak value is included in the first mapping relationship, in one embodiment, as Fig.17 As shown, the above S1620, determining the second mapping relationship according to the reference distance and the far-near state, includes: S1710-S1720;

[0204] S1710: When the distance state is the short distance state, determine a portion of the mapping relationships in the first mapping relationship whose distance is less than or equal to the reference distance as the second mapping relationship.

[0205] The first mapping relationship includes a peak value, which corresponds to a reference distance. The reference distance can divide the first mapping relationship into a partial mapping relationship with a distance less than or equal to the reference distance and a partial mapping relationship with a distance greater than the reference distance. The specific value of the reference distance can be determined according to the actual situation of the first mapping relationship and is not limited here. For example, in the case of Figure 5 In the first mapping relationship shown, the reference distance d0 divides the first mapping relationship into a partial mapping relationship A whose distance is less than or equal to the reference distance d0 and a partial mapping relationship B whose distance is greater than the reference distance d0.

[0206] Optionally, when the computer device determines that the distance state between the endoscope and the object is a close distance state, it determines that part of the mapping relationship in the first mapping relationship whose distance is less than or equal to the reference distance is the second mapping relationship. Figure 5 As shown, when the distance state is a close distance state, the computer device determines that the partial mapping relationship A is the second mapping relationship.

[0207] S1720: When the near-far state is the long-distance state, determine a portion of the first mapping relationship whose distance is greater than the reference distance as a second mapping relationship.

[0208] Optionally, when the computer device determines that the distance state between the endoscope and the photographed object is a long-distance state, it determines that a portion of the mapping relationship in the first mapping relationship whose distance is greater than the reference distance is a second mapping relationship. Figure 5 As shown, when the distance state is a close distance state, the computer device determines that the partial mapping relationship A is the second mapping relationship.

[0209] In the embodiment of the present application, when the distance state is a close distance state, the computer device determines that the portion of the mapping relationship in the first mapping relationship whose distance is less than or equal to the reference distance is the second mapping relationship, and when the distance state is a long distance state, the portion of the mapping relationship in the first mapping relationship whose distance is greater than the reference distance is the second mapping relationship. In the above method, the second mapping relationship between the endoscope and the subject in the close distance state and the second mapping relationship in the long distance state are determined specifically, so that the distance between the endoscope and the subject can be determined based on the second mapping relationships corresponding to different distance states in the future, thereby improving the accuracy of the obtained distance.

[0210] In the case where the first mapping relationship represents a non-monotonic association relationship, other methods may be used to determine the distance between the endoscope and the photographed object. Based on this, in one embodiment, Fig.18 As shown, the above S940, determining the distance between the endoscope and the object according to the image to be processed, the far and near state and the first mapping relationship, includes: S1810-S1820;

[0211] S1810: Determine a plurality of distances between the endoscope and the photographed object according to the image to be processed and the first mapping relationship.

[0212] Optionally, the computer device may determine the brightness feature of the image to be processed based on the brightness data of the image to be processed, and determine the distance corresponding to the brightness feature of the image to be processed according to the first mapping relationship. In the case where the first mapping relationship represents a non-monotonic association relationship, the distance corresponding to the brightness feature of the image to be processed includes multiple distances, that is, multiple distances between the endoscope and the object are obtained. For example, illustratively, Figure 5 As shown, the difference data is used to characterize the brightness feature. Taking the difference data R' as an example, two distances d1 and d2 corresponding to the difference data R' can be determined based on the first mapping relationship.

[0213] S1820. Determine the distance between the endoscope and the subject from a plurality of distances according to the distance state.

[0214] Optionally, the computer device may filter out a distance that matches the distance state from the obtained multiple distances based on the distance state between the endoscope and the subject, as the distance between the endoscope and the subject.

[0215] In an optional embodiment, when the distance state between the endoscope and the object includes a long-distance state and a short-distance state, and the multiple distances obtained are two distances, such as Fig.19 As shown, the above S1820, determining the distance between the endoscope and the subject from multiple distances according to the far and near state, includes: S1910-S1920;

[0216] S1910. When the distance state is the close distance state, determine the minimum distance among the multiple distances as the distance between the endoscope and the subject.

[0217] Optionally, when the distance state between the endoscope and the object is a close distance state, it means that the distance between the endoscope and the object is small, and the computer device accordingly determines the smallest distance among the multiple distances as the distance between the endoscope and the object. For example, the smallest distance among the multiple distances is used as the distance between the endoscope and the object. Continuing with the above example, Figure 5 As shown, when the distance state between the endoscope and the object is a close distance state, the computer device determines that the smallest d1 between d1 and d2 is the distance between the endoscope and the object.

[0218] S1920. When the distance state is the long distance state, determine the maximum distance among the multiple distances as the distance between the endoscope and the subject.

[0219] Optionally, when the distance state between the endoscope and the object is a long distance state, it means that the distance between the endoscope and the object is large, and the computer device accordingly determines the largest distance among the multiple distances as the distance between the endoscope and the object. For example, the largest distance among the multiple distances is used as the distance between the endoscope and the object. Continuing with the above example, Figure 5 As shown, when the distance state between the endoscope and the object is a long distance state, the computer device determines that the largest d2 between d1 and d2 is the distance between the endoscope and the object.

[0220] In an embodiment of the present application, the computer device determines multiple distances between the endoscope and the subject according to the image to be processed and the first mapping relationship, so as to determine the distance between the endoscope and the subject from multiple distances according to the distance state. Wherein, when the distance state between the endoscope and the subject includes a long distance state and a short distance state, and the multiple distances obtained are two distances, it can be determined that the minimum distance among the multiple distances in the short distance state is used as the distance between the endoscope and the subject, and the maximum distance among the multiple distances in the long distance state is used as the distance between the endoscope and the subject. In the above method, multiple distances are first directly obtained based on the first mapping relationship, and then the distance matching the long distance state is screened and determined from multiple distances using the long distance state as a constraint condition as the distance between the endoscope and the subject, thereby eliminating the problem that the distance between the endoscope and the subject cannot be accurately determined due to the fact that the first mapping relationship is a non-monotonic association relationship as a whole, so as to obtain a uniquely determined distance and improve the reliability of the result.

[0221] The first mapping relationship is used to characterize the correlation between the brightness characteristics of the image to be processed and the distance, and the influencing factors of the first mapping relationship include not only the light intensity of the light source module and the reference angle between the optical axis of the light source module and the subject, but also some other influencing factors.

[0222] In actual applications, it is found that the illumination intensity of the light source module on the endoscope, the distribution data of the lens module and the light source module on the endoscope, the reference angle between the optical axis of the light source module and the subject, and the reflection data of the subject will affect the specific situation of the actual first mapping relationship, that is, it will cause the first mapping relationship data to be different. Therefore, in one embodiment, the above-mentioned other influencing factors include the distribution data of the lens module and the light source module on the endoscope, and the reflection data of the subject. Based on this, the above-mentioned S920, according to the illumination intensity of the light source module on the endoscope, and the reference angle between the optical axis of the light source module and the subject, determines the first mapping relationship, including:

[0223] The first mapping relationship is determined according to distribution data of the lens module and the light source module on the endoscope, reflection data of the object, illumination intensity of the light source module on the endoscope, and a reference angle between the optical axis of the light source module and the object.

[0224] The distribution data of the lens module and the light source module on the endoscope is used to reflect the arrangement of the lens module and the light source module on the endoscope. Exemplarily, the distribution data includes the arrangement position or the arrangement quantity of the lens module and the light source module on the endoscope. The reflection data of the subject is used to reflect the reflection of the light by the subject. Exemplarily, the reflection data includes the reflectivity of the light by the subject.

[0225] Optionally, the computer device stores a first mapping relationship set of light and dark distribution characteristics of the image to be processed and the distance between the endoscope and the object under different distribution data, different reflection data, different illumination intensities, and different reference angles determined in advance based on a large amount of experimental data. The computer device can obtain the distribution data of the lens module and the light source module on the endoscope, the reflection data of the object, the illumination intensity of the light source module on the endoscope, and the reference angle between the optical axis of the light source module and the object in the current application scenario, and traverse the stored first mapping relationship set to determine the first mapping relationship that matches the distribution data, reflection data, illumination intensity, and reference angle in the current application scenario.

[0226] Considering the actual application, for a specific single type of endoscope for actual application, the distribution data of the lens module and the light source module on the endoscope are fixed and known data. At the same time, the parts inspected by each type of endoscope are also relatively fixed and known, such as colonoscopes for inspecting the intestines, nasal scopes for inspecting the nasal cavity, etc. When the inspected part is regarded as a whole object, it can be regarded as the reflection data of the subject being photographed is fixed. Based on this, when the type of endoscope is known, the distribution data of the lens module and the light source module on the endoscope and the reflection data of the subject can be regarded as a constant. Therefore, in the actual operation process, these two constants can be replaced by: the type of endoscope to simplify the construction process of the first mapping relationship, reduce the difficulty of application of the embodiment of the present application, and improve the practicality of the embodiment of the present application. Based on this, in another embodiment, the above-mentioned other influencing factors include the type of endoscope. The above-mentioned S920, according to the illumination intensity of the light source module on the endoscope, and the reference angle between the optical axis of the light source module and the subject, determines the first mapping relationship, including:

[0227] The first mapping relationship is determined according to the type of the endoscope, the illumination intensity of the light source module on the endoscope, and the reference angle between the optical axis of the light source module and the photographed object.

[0228] To simplify the processing process, the computer device stores a first mapping relationship set of the light and dark distribution characteristics of the image to be processed and the distance between the endoscope and the subject under different endoscope types, different illumination intensities, and different reference angles, which are determined in advance based on a large amount of experimental data. The computer device can obtain the type of endoscope, the illumination intensity of the light source module on the endoscope, and the reference angle between the optical axis of the light source module and the subject in the current application scenario, and traverse the stored first mapping relationship set to determine the first mapping relationship that matches the type of endoscope, illumination intensity, and reference angle in the current application scenario.

[0229] In an embodiment of the present application, the computer device may determine the first mapping relationship based on the distribution data of the lens module and the light source module on the endoscope, the reflection data of the object, the illumination intensity of the light source module on the endoscope, and the reference angle between the optical axis of the light source module and the object; or determine the first mapping relationship based on the type of the endoscope, the illumination intensity of the light source module on the endoscope, and the reference angle between the optical axis of the light source module and the object. In the above method, the factors affecting the first mapping relationship are fully considered to obtain a first mapping relationship that is highly matched with the current application scenario, thereby improving the accuracy of the distance obtained based on the first mapping relationship.

[0230] The brightness and darkness characteristics of the image to be processed can be represented by the difference data between the brightness data of the first area and the second area in the image to be processed. Based on this, in one embodiment, Fig. 20As shown, the above S1520, determining the distance between the endoscope and the object according to the image to be processed and the second mapping relationship, includes: S2010-S2020;

[0231] S2010, 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.

[0232] 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.

[0233] 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.

[0234] 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.

[0235] S2020: Determine the distance between the endoscope and the object according to the difference data and the second mapping relationship.

[0236] 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 different distances between the endoscope and the object to be photographed result in different difference data being presented in the image to be processed.

[0237] 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 second mapping relationship as the distance between the endoscope and the object.

[0238] In an embodiment of the present application, the computer device 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 endoscope and the subject according to the difference data of the image to be processed and the second mapping relationship. The second area is arranged around the first area. In the above method, the difference data between the brightness data of the first area and the second area in the image to be processed and the monotonous second mapping relationship are used to determine the distance between the endoscope and the subject, thereby improving the accuracy and reliability of the obtained distance.

[0239] The brightness data of the image can be represented by grayscale values. Based on this, in one embodiment, Fig.21 As shown, the above step S2010 of 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: S2110-S2120;

[0240] S2110 , rasterize and divide the image to be processed to determine a first area and a second area in the image to be processed.

[0241] The grid division is used to divide the image to be processed into a plurality of grid areas.

[0242] 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.

[0243] For example, Fig. 22 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.

[0244] S2120: Determine difference data according to the grayscale value of each pixel in the first area and the second area.

[0245] The first area and the second area include pixels at corresponding positions.

[0246] 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.

[0247] 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.

[0248] In the embodiment of the present application, 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.

[0249] The grayscale values ​​of pixels in different regions are different, and the corresponding regions also exhibit different brightness characteristics. Therefore, in one embodiment, Fig.23 As shown, the above S2120, determining difference data according to the grayscale value of each pixel point in the first area and the second area, includes: S2310-S2330;

[0250] S2310. Determine an intermediate brightness characteristic value according to the grayscale value of each pixel in the first area.

[0251] 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.

[0252] 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.

[0253] 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.

[0254] S2320. Determine an edge brightness characteristic value according to the grayscale value of each pixel in the second area.

[0255] 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.

[0256] 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.

[0257] 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.

[0258] S2330: Determine difference data according to the middle brightness characteristic value and the edge brightness characteristic value.

[0259] The computer device may determine the brightness difference between the first region and the second region in the image to be processed, that is, the difference data, according to the intermediate brightness characteristic value and the edge brightness characteristic value.

[0260] 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.

[0261] 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.

[0262] 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.24 As shown, the above S2310, determining the intermediate brightness characteristic value according to the grayscale value of each pixel point in the first area, includes: S2410-S2420;

[0263] S2410. 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.

[0264] 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.

[0265] 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. 22 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).

[0266] S2420. Obtain an average grid grayscale value of all grid areas in the first area as an intermediate brightness feature value.

[0267] 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.

[0268] 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.

[0269] 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.25As shown, the above S2320, determining the edge brightness characteristic value according to the gray value of each pixel point in the second area, includes: S2510-S2530;

[0270] S2510. 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.

[0271] 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.

[0272] S2520: 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.

[0273] The second area is arranged around the first area, and the second area is a hollow annular area.

[0274] 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.26 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.

[0275] S2530 , 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.

[0276] 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.26The maximum grid grayscale value in each grid group in the second area, SubMax represents the second largest value, Judge = SubMax{max1, max2, max3, max4}.

[0277] 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.

[0278] The above method also includes a process of determining a reference angle between the optical axis of the light source module and the object being photographed. Based on this, in one embodiment, if Fig. 27 As shown, before determining the illumination intensity of the light source module on the endoscope and the reference angle between the optical axis of the light source module and the object in the above S920, the above method further includes: S2710-S2730;

[0279] S2710. Determine the brightness distribution characteristics of the image to be processed according to the brightness distribution information of the image to be processed.

[0280] 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.

[0281] 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.

[0282] S2720: Acquire a third mapping relationship that matches the illumination intensity of the light source module.

[0283] Optionally, a computer device stores a third 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 third mapping relationship set to determine the third mapping relationship between the brightness and darkness distribution characteristics and the angle that matches the light intensity.

[0284] S2730: Determine a reference angle between the optical axis of the light source module and the object according to the third mapping relationship and the brightness and darkness distribution characteristics of the image to be processed.

[0285] Optionally, after obtaining the matching third 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 third mapping relationship, and use the angle as a reference angle between the optical axis of the light source module and the subject.

[0286] 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 third 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 third mapping and the light and dark distribution characteristics of the image to be processed. In the above method, the third mapping relationship between the light and dark distribution characteristics and angles corresponding to different illumination intensities is used to determine the third mapping relationship that matches the illumination intensity under the current situation, and then the third 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.

[0287] Usually, the subject is not facing the light source module directly, but at a certain tilt angle, such as Fig.28 As 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.29 As shown, the above S2710, determining the brightness distribution characteristics of the image to be processed according to the brightness distribution information of the image to be processed, includes: S2910-S2930;

[0288] S2910, 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.

[0289] 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.

[0290] 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.

[0291] S2920, obtaining a region in the image to be processed whose grayscale value is less than a preset grayscale value as a dark side region.

[0292] 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.

[0293] S2930, 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.

[0294] 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.

[0295] 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.30 As 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.

[0296] 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.

[0297] 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.

[0298] Based on the same inventive concept, the embodiment of the present application also provides an image ranging device 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 device embodiments provided below can refer to the above-mentioned limitations on the image ranging method, and will not be repeated here.

[0299] In one embodiment, Fig.31 As shown, an image ranging system is provided, including: an image acquisition unit 3101, a mapping relationship unit 3102, a distance determination unit 3103 and a distance determination unit 3104, wherein:

[0300] The image acquisition unit 3101 is used to acquire an image to be processed including a subject photographed by an endoscope;

[0301] The mapping relationship unit 3102 is used to determine a first mapping relationship according to the illumination intensity of the light source module on the endoscope and the reference angle between the optical axis of the light source module and the object;

[0302] The distance determination unit 3103 is used to determine the distance state between the endoscope and the object according to the image to be processed;

[0303] The distance determination unit 3104 is used to determine the distance between the endoscope and the object according to the image to be processed, the far and near state and the first mapping relationship.

[0304] The image ranging system is used to implement any of the above-mentioned image ranging methods. For details, please refer to the above-mentioned embodiments and will not be repeated here.

[0305] 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.32As 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.

[0306] Those skilled in the art will understand that Fig.32 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0307] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of any one of the above-mentioned image ranging methods when executing the computer program.

[0308] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the above-mentioned image ranging methods are implemented.

[0309] In one embodiment, a computer program product is provided, including a computer program, which implements the steps of any of the above-mentioned image ranging methods when executed by a processor.

[0310] In one embodiment, Fig.33 As shown, an endoscope system is also provided, comprising: an endoscope 100, a light source device 200, and a computer device 300 as any one of the above items.

[0311] The end of the endoscope 100 is provided with a light source module as in any of the above-mentioned image ranging methods.

[0312] The light source device 200 may include a light source generator, and the light source module may include a light guide component, such as an optical fiber.

[0313] 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.

[0314] 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.

[0315] 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 subject captured by an endoscope; Determining a first mapping relationship according to the illumination intensity of the light source module on the endoscope and a reference angle between the optical axis of the light source module and the photographed object; Determining the distance between the endoscope and the photographed object according to the image to be processed; The distance between the endoscope and the photographed object is determined according to the image to be processed, the far and near state, and the first mapping relationship.

2. The method according to claim 1, characterized in that The step of determining the distance between the endoscope and the photographed object according to the image to be processed includes: Determining light and dark feature data of the image to be processed according to the grayscale value of the image to be processed; The distance state between the endoscope and the photographed object is determined according to the light and dark feature data of the image to be processed.

3. The method according to claim 2, characterized in that The light and dark feature data includes light and dark feature values; The step of determining the distance between the endoscope and the photographed object according to the light and dark feature data of the image to be processed includes: When the light and dark feature value is less than or equal to a preset feature threshold, determining that the endoscope and the subject are in a close distance state; When the light and dark feature value is greater than the preset feature threshold, it is determined that the endoscope and the subject are in a long-distance state.

4. The method according to claim 1, characterized in that: The determining of the first mapping relationship according to the illumination intensity of the light source module on the endoscope and the reference angle between the optical axis of the light source module and the photographed object comprises: determining the first mapping relationship according to distribution data of the lens module and the light source module on the endoscope, reflection data of the photographed object, illumination intensity of the light source module on the endoscope, and a reference angle between the optical axis of the light source module and the photographed object; or, The first mapping relationship is determined according to the type of the endoscope, the illumination intensity of the light source module on the endoscope, and the reference angle between the optical axis of the light source module and the photographed object.

5. The method according to any one of claims 1 to 4, characterized in that The determining the distance between the endoscope and the photographed object according to the image to be processed, the far-near state and the first mapping relationship includes: Determine a part of the mapping relationships from the first mapping relationships as the second mapping relationship according to the distance state; The distance between the endoscope and the photographed object is determined according to the image to be processed and the second mapping relationship.

6. The method according to claim 5, characterized in that The determining, according to the distance state, a part of the mapping relationships from the first mapping relationships as the second mapping relationships includes: Obtaining a reference distance corresponding to a peak value in the first mapping relationship; The second mapping relationship is determined according to the reference distance and the far-near state.

7. The method according to claim 6, characterized in that The determining the second mapping relationship according to the reference distance and the far-near state includes: When the far-near state is a short-distance state, determining a portion of the mapping relationships in the first mapping relationship whose distance is less than or equal to the reference distance as the second mapping relationship; When the near-far state is the long-distance state, a portion of the mapping relationships in the first mapping relationship whose distance is greater than the reference distance is determined as the second mapping relationship.

8. The method according to any one of claims 1 to 4, characterized in that The determining the distance between the endoscope and the photographed object according to the image to be processed, the far-near state and the first mapping relationship includes: determining a plurality of distances between the endoscope and the photographed object according to the image to be processed and the first mapping relationship; The distance between the endoscope and the object is determined from the plurality of distances according to the distance state.

9. The method according to claim 8, characterized in that The multiple distances are two distances; and determining the distance between the endoscope and the photographed object from the multiple distances according to the far and near state includes: When the far-near state is a close-distance state, determining the minimum distance among the plurality of distances as the distance between the endoscope and the subject; When the near-far state is the long-distance state, a maximum distance among the plurality of distances is determined as the distance between the endoscope and the object.

10. The method according to claim 5, characterized in that The step of determining the distance between the endoscope and the photographed object according to the image to be processed and the second mapping relationship includes: Calculating difference data between brightness data of a first area and brightness data of a second area in the image to be processed; wherein the second area is arranged around the first area; The distance between the endoscope and the photographed object is determined according to the difference data and the second mapping relationship.

11. The method according to any one of claims 1 to 4, characterized in that: Before the illumination intensity of the light source module on the endoscope and the reference angle between the optical axis of the light source module and the photographed object, the method further includes: 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 third mapping relationship between a brightness distribution feature and an angle that matches the illumination intensity; A reference angle between the optical axis of the light source module and the object is determined according to the third mapping relationship and the light and dark distribution characteristics of the image to be processed.

12. An image ranging system, characterized in that: The system comprises: An image acquisition unit, used for acquiring an image to be processed including a photographed object taken by an endoscope; A mapping relationship unit, used to determine a first mapping relationship according to the illumination intensity of the light source module on the endoscope and a reference angle between the optical axis of the light source module and the photographed object; A distance determination unit, used for determining the distance state between the endoscope and the photographed object according to the image to be processed; A distance determination unit is used to determine the distance between the endoscope and the object according to the image to be processed, the far-near state and the first mapping relationship.

13. 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 11 are implemented.

14. An endoscope system, characterized in that: The endoscope system comprises: an endoscope, a light source device and a computer device as claimed in claim 13; The end portion of the endoscope is provided with a light source module according to any one of claims 1 to 11.