Endoscope focusing method, computer device, endoscope system, medium and product

By acquiring the area images at different focal lengths in the zoom endoscope, determining the sharpness and adjusting the focal length, the problem that the field of view changes in the zoom endoscope affects the focus effect, and high-definition image capture is achieved.

CN119157451APending Publication Date: 2024-12-20CHANGZHOU UNITED IMAGING HEALTHCARE SURGICAL TECH CO LTD

Patent Information

Application Number
CN202411216559.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

During the zoom endoscope shooting, the field of view changes caused by clinical operations, physiological tissue movements and changes in the focus object affect the clarity of the image, and it is difficult for the prior art to achieve accurate real-time focus.

Method used

By acquiring the area images taken at different focal lengths, determining the sharpness of the image, and adjusting the imaging focal length according to the clarity, the focus operation is achieved. The specific steps include selecting a focus area from the first image, matching the target object in the second image, adjusting the image size and brightness, determining the sharpness using a single frequency bandpass filter, and adjusting the focus distance according to the sharpness to complete the focus.

Benefits of technology

In the case of changing the field of view angle, ensure that the autofocus effect is better, improve the sharpness of the image, ensure the fairness and comparability of the focus effect, and enhance the accuracy and stability of the focus.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119157451A_ABST
    Figure CN119157451A_ABST
Patent Text Reader

Abstract

The invention relates to an endoscope focusing method and device, computer equipment, an endoscope system, a medium and a product. The method comprises the following steps: acquiring a first area image shot by an endoscope at a first focal length and a second area image shot by the endoscope at a second focal length; the first focal length and the second focal length are different, the second focal length is the current imaging focal length of the endoscope, the first area image and the second area image are consistent in size, and the first area image and the second area image both comprise the same target object; determining a first definition of the first area image and a second definition of the second area image; and performing imaging focal length adjustment on the endoscope according to the first definition and the second definition so as to complete focusing operation. According to the invention, when the focusing operation is carried out according to the two definitions, the two images with the same size and basically the same content are selected for focusing, so that the fairness of image definition comparison can be ensured, and the definition of the image obtained by focusing can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of endoscope technology, and in particular to an endoscope focusing method, computer equipment, endoscope system, medium and product. Background Art

[0002] With the development of medical endoscope technology, zoom endoscopes have gradually entered the market. Zoom endoscopes can use zoom lenses to change the focal length, thereby achieving focus adjustment and improving the clarity of endoscopic images. In the actual endoscopic zoom shooting process, due to clinical operations, physiological tissue movement, and changes in the focus object, the field of view of the endoscope lens often changes dramatically, and the dramatic change in the field of view will affect the focusing effect, thereby affecting the clarity of the image.

[0003] Therefore, how to accurately achieve real-time focusing to improve image clarity has become a technical problem that needs to be urgently solved in the field of zoom endoscopes. Summary of the invention

[0004] Based on this, it is necessary to provide an endoscope focusing method, device, computer equipment, endoscope system, medium and product that can accurately achieve real-time focusing to improve the clarity of the image in response to the above technical problems.

[0005] In a first aspect, the present application provides an endoscope focusing method, comprising:

[0006] Acquire a first area image taken by the endoscope at a first focal length, and a second area image taken by the endoscope at a second focal length; the first focal length and the second focal length are different, the second focal length is the current imaging focal length of the endoscope, the first area image and the second area image have the same size, and the first area image and the second area image both contain the same target object;

[0007] determining a first definition of the first area image and a second definition of the second area image;

[0008] The imaging focal length of the endoscope is adjusted according to the first clarity and the second clarity to complete a focusing operation.

[0009] In one embodiment, the step of acquiring a first area image captured by the endoscope at a first focal length and a second area image captured by the endoscope at a second focal length comprises:

[0010] Selecting a focus area including the target object from the first image to obtain a first target image;

[0011] The second image is matched according to the first target image, and a second target image containing the target object is determined from the second image; wherein, when the first image is an image shot at the first focal length, and the second image is an image shot at the second focal length, the first target image is the first area image, and the second target image is the second area image; when the first image is an image shot at the second focal length, and the second image is an image shot at the first focal length, the first target image is the second area image, and the second target image is the first area image.

[0012] In one embodiment, matching the second image according to the first target image to determine the second target image containing the target object from the second image includes:

[0013] Matching the second image according to the first target image, and determining a third area image containing the target object from the second image;

[0014] The size of the region where the target object is located in the third region image is adjusted to be consistent with the size of the first target image to obtain the second target image.

[0015] In one embodiment, matching the second image according to the first target image to determine the third area image containing the target object from the second image includes:

[0016] Determine a sliding area according to the first target image; the size of the sliding area is consistent with the size of the first target image;

[0017] By moving the sliding area on the second image, a plurality of candidate area images are obtained;

[0018] The candidate region image having the highest similarity to the first target image is determined as the third region image.

[0019] In one embodiment, the step of obtaining a plurality of candidate area images by moving the sliding area on the second image includes:

[0020] Adjusting the size of the second image to obtain second images of various scales;

[0021] Detecting edges of the second image at each scale;

[0022] The plurality of candidate region images are obtained by moving the sliding region within the edge of the second image at each scale.

[0023] In one embodiment, determining a first clarity of the image of the first region includes:

[0024] Using a single frequency bandpass filter to respectively determine the initial clarity of the image in the first region at different frequencies;

[0025] The first definition is determined according to the initial definitions of the different frequencies.

[0026] In one of the embodiments, before determining the first clarity of the first area image and the second clarity of the second area image, the method further includes:

[0027] determining a first brightness of the first area image and a second brightness of the second area image;

[0028] If the first brightness is inconsistent with the second brightness, the second brightness is adjusted to make the first brightness consistent with the second brightness, and after the adjustment, the step of determining the first clarity of the first area image and the second clarity of the second area image is performed.

[0029] In one embodiment, adjusting the imaging focal length of the endoscope according to the first clarity and the second clarity to complete the focusing operation includes:

[0030] determining a focusing direction according to the first clarity and the second clarity;

[0031] Adjusting the imaging focal length of the endoscope according to the focusing direction to determine images corresponding to a plurality of imaging focal lengths;

[0032] The imaging focal length corresponding to the image with the highest definition among the images corresponding to the multiple imaging focal lengths is determined as the target focal length, and the imaging focal length of the endoscope is adjusted to the target focal length to complete the focusing operation.

[0033] In a second aspect, the present application also provides an endoscope focusing device, comprising:

[0034] an acquisition module, used for acquiring a first area image taken by the endoscope at a first focal length, and a second area image taken by the endoscope at a second focal length; the first focal length and the second focal length are different, the second focal length is a current imaging focal length of the endoscope, the first area image and the second area image are of the same size, and the first area image and the second area image both contain the same target object;

[0035] A determination module, configured to determine a first definition of the first area image and a second definition of the second area image;

[0036] A focusing module is used to adjust the imaging focal length of the endoscope according to the first clarity and the second clarity to complete a focusing operation.

[0037] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method in any one of the embodiments of the first aspect are implemented.

[0038] In a fourth aspect, the present application further provides an endoscope system, comprising: a light source device, an endoscope, and the computer device in the third aspect above.

[0039] In a fifth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method in any one of the embodiments of the first aspect are implemented.

[0040] In a sixth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the method in any one of the embodiments of the first aspect are implemented.

[0041] The above-mentioned endoscope focusing method, device, computer equipment, endoscope system, medium and product obtain a first area image taken by the endoscope at a first focal length, and a second area image taken by the endoscope at a second focal length; the first focal length and the second focal length are different, the second focal length is the current imaging focal length of the endoscope, the first area image and the second area image are of the same size, and the first area image and the second area image both contain the same target object; determine a first clarity of the first area image and a second clarity of the second area image; adjust the imaging focal length of the endoscope according to the first clarity and the second clarity to complete the focusing operation. Since the imaging focal lengths of the first area image and the second area image obtained in the embodiment of the present application are different but the sizes are the same, and the first area image and the second area image both contain the same target object, it can be ensured that the contents contained in the first area image and the second area image are basically the same or highly similar. Therefore, when performing a focusing operation according to the first clarity and the second clarity, the present application selects two images of the same size and containing basically the same content for focusing, and will not be affected by drastic changes in the field of view, thereby ensuring the fairness of the image clarity comparison and making the first clarity and the second clarity comparable. Therefore, when the field of view angle changes, the present application can also ensure a better focusing effect of the autofocus, thereby improving the clarity of the focused image. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0043] FIG1 is a diagram showing an application environment of an endoscope focusing method according to an embodiment;

[0044] FIG2 is a schematic diagram of a flow chart of an endoscope focusing method in one embodiment;

[0045] FIG3 is a schematic flow chart of a second region image acquisition step in one embodiment;

[0046] FIG4 is a schematic flow chart of a second region image determination step in one embodiment;

[0047] Figure 5 is a schematic flow chart of a step of determining an image of a third region in one embodiment;

[0048] FIG6 is a schematic flow chart of an endoscope focusing method in another embodiment;

[0049] FIG7 is a schematic flow chart of an endoscope focusing method in an optional embodiment;

[0050] FIG8 is a block diagram of a focusing device for an endoscope in one embodiment;

[0051] FIG. 9 is a diagram showing the internal structure of an endoscope system in one embodiment. DETAILED DESCRIPTION

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

[0053] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by technicians in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" in the specification and claims of this application and the above-mentioned figure descriptions and any variations thereof are intended to cover non-exclusive inclusions.

[0054] In the description of the embodiments of the present application, the technical terms "first", "second", etc. are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number, specific order or primary and secondary relationship of the indicated technical features. In the description of the embodiments of the present application, the meaning of "multiple" is more than two, unless otherwise clearly and specifically defined.

[0055] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0056] When performing close-range observation in medical scenarios, endoscopes can be used to collect medical images. Currently, most endoscopes use fixed-focus lenses or bifocal lenses. However, in actual operation, it is difficult to ensure that the image is always in the focal range. Therefore, when using fixed-focus lenses or bifocal lenses to collect medical images, there is a high probability of defocusing during the change of the endoscope object distance, resulting in blurred images. Even if the bifocal lens has two focal lengths, near and far, it cannot completely ensure that the image is clear.

[0057] With the development of medical endoscope technology, zoom endoscopes have gradually entered the market. Zoom endoscopes can use zoom lenses to change the focal length, thereby achieving focus adjustment and improving the clarity of endoscopic images. Therefore, using zoom lenses to achieve automatic focus is very important for improving image clarity. However, in the actual endoscopic zoom shooting process, due to clinical operations, physiological tissue movement, and changes in the focus object, the field of view of the endoscope lens often changes dramatically, and the dramatic change in the field of view will affect the focusing effect, thereby affecting the clarity of the image.

[0058] For example, since the endoscope has a short shooting distance, the imaging focal length is generally in the millimeter level, and the field of view angle is large. Once the endoscope or the internal tissue shakes, the field of view will change greatly, and the position of the focus object will also change due to the change in the field of view angle. Therefore, there is a need for fast imaging during endoscopic imaging. At this time, if the position of the focus object changes, the clarity of different focus objects is calculated during the focusing process. Since there will be positions with low sharpness values ​​in the clear image, and positions with strong sharpness values ​​in the blurred image, it is impossible to compare the clarity of the image fairly and reasonably according to different focus objects, and thus, the effect of focusing by comparing inaccurate clarity is not good.

[0059] Therefore, how to accurately achieve real-time focusing to improve image clarity has become a technical problem that needs to be urgently solved in the field of zoom endoscopes.

[0060] After the above introduction to the background technology of the endoscope focusing method provided by the embodiment of the present application, the implementation environment involved in the endoscope focusing method provided by the embodiment of the present application will be briefly described below. The endoscope focusing method provided by the embodiment of the present application can be applied to a computer device as shown in Figure 1, for example, an image processing device in an endoscope system. The computer device can be a terminal or a server, and the computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. 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 input / output interface of the computer device is used to exchange information between the processor and an external device. 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, mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, an endoscope focusing method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0061] Those skilled in the art will understand that the structure shown in FIG. 1 is merely a block diagram of a partial 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. A specific terminal may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0062] In one embodiment, as shown in FIG2 , an endoscope focusing method is provided, which is described by taking the method applied to the computer device in FIG1 as an example, and includes the following steps:

[0063] S201, obtaining a first area image taken by the endoscope at a first focal length, and a second area image taken by the endoscope at a second focal length; the first focal length and the second focal length are different, the second focal length is the current imaging focal length of the endoscope, the first area image and the second area image are of the same size, and the first area image and the second area image both contain the same target object.

[0064] Among them, the first focal length is the imaging focal length of the first area image, the second focal length is the imaging focal length of the second area image, the first area image and the second area image are images obtained after imaging and image processing using different imaging focal lengths, and optionally, the image processing process may include at least one of changing the image size and changing the image brightness. It should be noted that the first focal length of the first area image and the second focal length of the second area image are different, the second focal length is the current imaging focal length of the endoscope, the first area image and the second area image are of the same size, and both the first area image and the second area image contain the same target object.

[0065] It is understandable that in actual applications, the image refresh frequency is often high. For example, in the common 60fps and 90fps cases, 60 frames of images and 90 frames of images are captured and refreshed every second. However, the visual reaction speed of the human eye is limited, and it is often difficult to distinguish the image frames displayed in a very short time with the naked eye. Therefore, the actual effect of a slight focus delay for the user is still "real-time focus". Based on this, the concept of "current" or "real-time" in the embodiments of the present application has a certain delay tolerance, that is, it can be the latest or the range that is basically the same as the latest within the human eye perception range. For example, the second focal length is the current imaging focal length of the endoscope. At this time, the second focal length can be the focal length used by the latest image collected, or it can be the focal length used by any image collected within a period of time recently. The most recent time period of this tolerance can be the maximum focus delay time that the user can accept, which can be set according to actual needs. For example, in some embodiments, it can be 1 second or 0.5 seconds, etc., so as to achieve real-time focus within 1 second or 0.5 seconds. In some embodiments, the time can be set to correspond to the reaction speed of the human eye. For example, in some cases, images captured within 0.05 seconds can be used as objects for determining the second focal length, thereby achieving real-time focus within 0.05 seconds to improve the focus speed and enhance the user experience.

[0066] It should be noted that, during image matching, if the second area image has the same size as the first area image, and both the first area image and the second area image contain the same target object, it can be ensured that the size of the same target object contained in the first area image and the second area image is the same, that is, it is ensured that the contents contained in the first area image and the second area image are basically the same or highly similar, and thus, by performing comparative focusing based on the first area image and the second area image, the fairness of image clarity comparison can be guaranteed.

[0067] In an embodiment of the present application, the computer device can obtain a first area image taken by the endoscope at a first focal length, and a second area image taken by the endoscope at a second focal length. Optionally, the computer device can first use the endoscope to perform imaging and image processing at the first focal length to obtain the first area image, and then the computer device can change the focal length, and use the endoscope to perform imaging and image processing at the changed second focal length to obtain the second area image. Alternatively, if the acquired first area image and second area image have been stored in a database in advance, the computer device can also directly obtain the first area image and the second area image from the database. Of course, the embodiment of the present application does not limit the specific implementation method for obtaining the first area image and the second area image.

[0068] S202: Determine a first definition of the first region image and a second definition of the second region image.

[0069] In an embodiment of the present application, the computer device may determine the first clarity of the first area image and the second clarity of the second area image respectively. When determining the first clarity and the second clarity, the computer device may optionally use a single-frequency bandpass filter to determine the first clarity and / or the second clarity; or the computer device may also use a multi-frequency bandpass filter to determine the first clarity and / or the second clarity, wherein the multi-frequency bandpass filter refers to a filter that can obtain multiple frequency ranges in the image. Of course, the embodiment of the present application does not limit the specific implementation method for obtaining the first clarity and the second clarity.

[0070] S203, adjusting the imaging focal length of the endoscope according to the first clarity and the second clarity to complete the focusing operation.

[0071] In the embodiment of the present application, the computer device can adjust the imaging focal length of the endoscope according to the determined first clarity and second clarity, and use the changed new focal length for imaging and image processing to obtain a new regional image, and then calculate the clarity of the new regional image. After that, the computer device can perform a focusing operation according to the first clarity, the second clarity and the clarity of the new regional image to complete the focusing operation. Among them, by continuously changing the focal length for focusing operation, the best focal length position can be determined. When imaging at the best focal length position, the clarity of the image obtained by imaging is the highest.

[0072] In the above-mentioned endoscope focusing method, a first area image taken by the endoscope at a first focal length and a second area image taken by the endoscope at a second focal length are obtained; the first focal length and the second focal length are different, the second focal length is the current imaging focal length of the endoscope, the first area image and the second area image are of the same size, and the first area image and the second area image both contain the same target object; the first clarity of the first area image and the second clarity of the second area image are determined; the imaging focal length of the endoscope is adjusted according to the first clarity and the second clarity to complete the focusing operation. Since the imaging focal lengths of the first area image and the second area image obtained in the embodiment of the present application are different but the sizes are the same, and the first area image and the second area image both contain the same target object, it can be ensured that the contents contained in the first area image and the second area image are basically the same or highly similar. Therefore, when performing a focusing operation according to the first clarity and the second clarity, the present application selects two images of the same size and containing basically the same content for focusing, and will not be affected by drastic changes in the field of view, thereby ensuring the fairness of the image clarity comparison and making the first clarity and the second clarity comparable. Therefore, when the field of view angle changes, the present application can also ensure a better focusing effect of the autofocus, thereby improving the clarity of the focused image.

[0073] In one embodiment, a method for obtaining a first area image and a second area image is provided, that is, "obtaining a first area image taken by an endoscope at a first focal length, and a second area image taken by an endoscope at a second focal length" in the above S201, as shown in FIG3, including:

[0074] S301, selecting a focus area including a target object from a first image to obtain a first target image.

[0075] In an embodiment of the present application, optionally, the computer device may first determine the target object, then select the focus area where the target object is located from the first image, and crop the first image according to the focus area to obtain a first target image; or, the computer device may first determine the image corresponding to the preset area as the first target image, and then select an object content from the first target image as the target object. The first target image refers to the image corresponding to the focus area. Optionally, the focus area may be a single area, or the focus area may be multiple areas; or, a preset number of areas with better image sharpness may be selected from multiple areas, and the preset number of areas may be determined as the focus areas. Of course, the embodiment of the present application does not limit the number of focus areas. It should be noted that the focus area contains the target object.

[0076] S302, matching the second image according to the first target image, and determining a second target image containing the target object from the second image; wherein, when the first image is an image shot at a first focal length, and the second image is an image shot at a second focal length, the first target image is a first area image, and the second target image is a second area image; when the first image is an image shot at a second focal length, and the second image is an image shot at a first focal length, the first target image is a second area image, and the second target image is a first area image.

[0077] The first image and the second image may include but are not limited to any one of a Raw image obtained from a sensor, a YCC image after conversion, an RGB image, etc. The imaging focal length of the first image is different from the imaging focal length of the second image, the imaging focal length of the first image is the same as the imaging focal length of the first area image, and the imaging focal length of the second image is the same as the imaging focal length of the second area image.

[0078] In an embodiment of the present application, optionally, the computer device may match the second image based on the image of the target object, and determine the second target image containing the target object from the second image. Alternatively, the computer device may also match the second image based on the overall first target image, and determine the second target image containing the target object from the second image. Of course, the embodiment of the present application does not limit the specific implementation method for obtaining the second target image by image matching. It should be noted that the matched second target image contains the target object.

[0079] Wherein, optionally, when the first image is an image captured at a first focal length, and the second image is an image captured at a second focal length, that is, the computer device may first use an endoscope to perform imaging at the first focal length to obtain the first image, and then the computer device may change the focal length, and use the endoscope to perform imaging at the changed second focal length to obtain the second image, then the first target image is the first area image, and the second target image is the second area image. When the first image is an image captured at the second focal length, and the second image is an image captured at the first focal length, that is, the computer device may first use an endoscope to perform imaging at the first focal length to obtain the second image, and then the computer device may change the focal length, and use the endoscope to perform imaging at the changed second focal length to obtain the first image, then the first target image is the second area image, and the second target image is the first area image.

[0080] In this embodiment, a focus area containing a target object is selected from the first image to obtain a first target image; the second image is matched according to the first target image, and a second target image containing the target object is determined from the second image. In this way, it can be ensured that the imaging focal lengths of the first area image and the second area image are different but the sizes are consistent, and that the first area image and the second area image both contain the same target object, thereby ensuring the fairness of image clarity comparison.

[0081] In one embodiment, a method for obtaining a second region image is provided, namely, the step of “matching the second image according to the first target image, and determining a second target image containing a target object from the second image” in S302, as shown in FIG4, including:

[0082] S401, matching the second image with the first target image, and determining a third region image containing the target object from the second image.

[0083] In the embodiment of the present application, optionally, the computer device may match the second image based on the image of the target object, and determine the third region image containing the target object from the second image. Alternatively, the computer device may match the second image based on the overall first target image, and determine the third region image containing the target object from the second image. The size of the third region image may be consistent with the size of the first region image, or the size of the third region image may be inconsistent with the size of the first target image. The embodiment of the present application has no limitation on the size of the third region image.

[0084] S402: Adjust the size of the region where the target object is located in the third region image to be consistent with the size of the first target image, so as to obtain a second target image.

[0085] In the embodiment of the present application, if the size of the area where the target object is located in the third area image is consistent with the size of the first target image, the computer device can directly determine the third area image as the second target image. If the size of the area where the target object is located in the third area image is inconsistent with the size of the first target image, the computer device can adjust the size of the area where the target object is located in the third area image to be consistent with the size of the first target image, thereby obtaining the second target image. Among them, the first target image can be understood as the image corresponding to the circumscribed rectangular frame of the target object.

[0086] In this embodiment, the second image is matched according to the first target image, a third region image containing the target object is determined from the second image, and then the size of the region where the target object is located in the third region image is adjusted to be consistent with the size of the first target image to obtain the second target image. In this way, it can be ensured that the second target image obtained from the third region image and the first target image have different imaging focal lengths but consistent sizes, thereby ensuring the fairness of image clarity comparison.

[0087] In one embodiment, a method for obtaining a third region image is provided, namely, the step of “matching the second image according to the first target image, and determining a third region image containing the target object from the second image” in S401 above. Figure 5 As shown, including:

[0088] S501, determining a sliding area according to a first target image; a size of the sliding area is consistent with a size of the first target image.

[0089] S502, obtaining a plurality of candidate region images by moving the sliding region on the second image.

[0090] S503: Determine the candidate region image having the highest similarity to the first target image as the third region image.

[0091] In the embodiment of the present application, the computer device can determine the sliding area according to the size of the first target image, wherein the size of the sliding area is consistent with the size of the first target image. Afterwards, the computer device can obtain multiple candidate area images by moving the sliding area on the second image, and after each movement of the sliding area, determining the image corresponding to the sliding area in the third image as the candidate area image. Then, the computer device can determine the similarity between each candidate area image and the first target image, thereby determining the candidate area image with the highest similarity to the first target image, and determining the candidate area image with the highest similarity to the first target image as the third area image.

[0092] In one embodiment, S502 includes:

[0093] The size of the second image is adjusted to obtain second images of various scales.

[0094] Detect edges of the second image at each scale.

[0095] By moving the sliding region within the edge of the second image at each scale, a plurality of candidate region images are obtained.

[0096] In the embodiment of the present application, after acquiring the second image and the first region image, the first region image can be used as a template, and a multi-scale template matching method is used to match the position of the first region image in the second image, thereby obtaining the second region image. Exemplarily, the specific process of obtaining the second region image is:

[0097] First, the computer device may adjust the size of the second image according to a preset scale range and a preset step size to obtain a second image of each scale. For example, the preset scale range may be between 0.1 and 1.5 times, and the preset step size may be between 0 and 1 times, for example, the preset step size may be 0.1. Of course, the preset scale range and the preset step size are not limited in the embodiment of the present application.

[0098] Secondly, for the second image of each scale, the computer device can use an edge detection algorithm to detect the edge of the second image of each scale. In addition, the computer device can also detect the edge of the first area image, and determine the sliding area according to the size and edge of the first area image, wherein the size of the sliding area is consistent with the size of the first area image, and the edge of the sliding area is consistent with the edge of the first area image. Exemplarily, the edge detection algorithm may include but is not limited to any one of the edge detection algorithms such as the Sobel algorithm and the Canny algorithm.

[0099] Afterwards, the computer device can obtain multiple candidate region images and the position of each candidate region image by moving the sliding region within the edge of the second image of each scale, and after each movement of the sliding region, determining the image corresponding to the sliding region in the second image of each scale as the candidate region image. Then, the computer device can determine the similarity between each candidate region image and the first region image, and determine the candidate region image with the highest similarity to the first region image as the third region image. Finally, the computer device can also crop the third region image from the second image, and use the Resize (image scaling) operation to transform the cropped third region image to the same image size as the first region image, to obtain the processed second region image.

[0100] In this embodiment, the sliding area is determined according to the first target image; the size of the sliding area is consistent with the size of the first target image; by moving the sliding area on the second image, multiple candidate area images are obtained; and the candidate area image with the highest similarity to the first target image is determined as the third area image. In this way, it can be ensured that the third area image is the area image with the highest similarity to the first target image, that is, it can be ensured that the first target image and the third area image both contain the same target object.

[0101] In one embodiment, a method for determining the first definition is provided, that is, the “determining the first definition of the image in the first region” in the above S202, including:

[0102] A single-frequency bandpass filter is used to determine the initial clarity of the first region image at different frequencies.

[0103] A first clarity is determined according to the initial clarity of the different frequencies.

[0104] In an embodiment of the present application, the computer device may use a single-frequency bandpass filter to respectively determine the initial clarity of the first area image at different frequencies. The different frequencies may include high-frequency signals, low-frequency signals, and frequency signals between the two in the first area image to ensure that the image can be focused at positions where the image is flat and the image changes drastically. The formula for determining the initial clarity using a single-frequency bandpass filter is as follows: FV = I[i] * BPFilter[i], where FV represents the initial clarity, i represents the vector index, and I[i] represents a sequence of pixel positions corresponding to i in the first area image, and the length of the sequence is the same as the length of the bandpass filter BPFilter. Exemplarily, the calculation method of the bandpass filter is: given the frequency response of an ideal bandpass filter, the unit impulse response of the bandpass filter is calculated, and then the unit impulse response is truncated into a finite length sequence using a window function. Finally, the finite length sequence is normalized to calculate the clarity of the image.

[0105] Afterwards, the computer device may process the initial definition of different frequencies to obtain the first definition. For example, the computer device may average the initial definition of different frequencies and determine the average of the initial definition as the first definition.

[0106] In this embodiment, a single-frequency bandpass filter can be used to determine the initial clarity of the first area image at different frequencies, and the first clarity can be determined based on the initial clarity at different frequencies. In this way, the first clarity of the first area image can be determined more accurately by calculating signals in different frequency ranges.

[0107] In one embodiment, an implementation method for adjusting the second brightness is provided. As shown in FIG6 , before determining the first clarity of the first area image and the second clarity of the second area image, the endoscope focusing method further includes:

[0108] S204: Determine a first brightness of the first region image and a second brightness of the second region image.

[0109] In the embodiment of the present application, the computer device can respectively determine the first brightness of the first area image and the second brightness of the second area image. Taking the determination of the first brightness of the first area image as an example, the computer device can calculate the sum of all pixels in the first area image, and then average the sum of all pixels in the first area image to obtain the first brightness of the first area image. The specific implementation method of determining the second brightness of the second area image can be obtained in the same way, which will not be described in detail here.

[0110] Thus, the computer device can detect whether the first brightness of the first area image and the second brightness of the second area image are consistent.

[0111] S205, if it is detected that the first brightness is consistent with the second brightness, the computer device may directly execute the step of determining the first clarity of the first area image and the second clarity of the second area image, that is, execute S202.

[0112] S206, if the first brightness is inconsistent with the second brightness, adjusting the second brightness to make the first brightness consistent with the second brightness, and after the adjustment, performing the step of determining a first definition of the first area image and a second definition of the second area image.

[0113] In the embodiment of the present application, if it is detected that the first brightness is inconsistent with the second brightness, the computer device can adjust the second brightness to make the first brightness consistent with the second brightness, and after the adjustment, perform the step of determining the first clarity of the first area image and the second clarity of the second area image, that is, after adjusting the second brightness to be consistent with the first brightness, perform S202. Exemplarily, the step of adjusting the second brightness can be: the computer device can first use the first brightness to subtract the second brightness to obtain a difference, and then add the difference to the second brightness to obtain the adjusted second brightness. At this time, the second brightness is aligned with the first brightness, which can ensure that the first brightness and the second brightness are consistent.

[0114] In this embodiment, by determining the first brightness of the first area image and the second brightness of the second area image, and adjusting the second brightness, the first clarity of the first area image and the second clarity of the second area image are determined after ensuring that the first brightness and the second brightness are consistent. When calculating the clarity, it can be ensured that not only the same target object but also the brightness of the same target object are consistent, thereby ensuring that the subsequent focusing process is more fair and reasonable.

[0115] In one embodiment, a method for implementing a focusing operation is provided, namely, the step of “adjusting the imaging focal length of the endoscope according to the first clarity and the second clarity to complete the focusing operation” in the above S203, including:

[0116] A focusing direction is determined according to the first definition and the second definition.

[0117] The imaging focal length of the endoscope is adjusted according to the focusing direction to determine images corresponding to multiple imaging focal lengths.

[0118] The imaging focal length corresponding to the image with the highest definition is determined as the target focal length from the images corresponding to the multiple focal lengths, and the imaging focal length of the endoscope is adjusted to the target focal length to complete the focusing operation.

[0119] Since the basic principle of autofocus is that the image is clearest at the focal position, and the image becomes blurrier the further it deviates from the focal position, based on this, the focusing process can be likened to a peak-shaped curve, and the peak position is the position where the image is clearest, so the purpose of autofocus is to determine the focal position corresponding to the image with the highest clarity. In an embodiment of the present application, the computer device can compare the first clarity and the second clarity, and determine the greater clarity from the first clarity and the second clarity, so that the direction toward the focal position corresponding to the greater clarity can be determined as the focusing direction. Exemplarily, assuming that the first clarity is less than the second clarity, the direction toward the focal position corresponding to the second clarity can be determined as the focusing direction.

[0120] Afterwards, the lens of the imaging device connected to the computer device can be moved in the focusing direction to change the focal length, and the changed new focal length is used for imaging and image processing to obtain a new regional image, and then the clarity of the new regional image is calculated. Afterwards, the computer device can continue to adjust the imaging focal length of the endoscope according to the second clarity and the clarity of the new regional image, so that multiple images corresponding to the imaging focal lengths can be determined. Then, the computer device can determine the image with the highest clarity from the images corresponding to the multiple imaging focal lengths, and determine the imaging focal length corresponding to the image with the highest clarity as the target focal length, and adjust the imaging focal length of the endoscope to the target focal length to complete the focusing operation. Among them, the imaging device may include but is not limited to an endoscope, etc., and the position of the target focal length is the optimal focal length position. In the process of automatic focusing, the clarity of the image can be calculated using a clarity evaluation function, and optionally, the clarity evaluation function may include but is not limited to any one of the Brenner gradient function, the Tenengrad gradient function, the Laplacian gradient function, etc.

[0121] In this embodiment, the focus direction can be determined according to the first definition and the second definition, and then the imaging focal length of the endoscope can be adjusted according to the focus direction to determine the images corresponding to the multiple imaging focal lengths. Thus, the imaging focal length corresponding to the image with the highest definition can be determined as the target focal length from the images corresponding to the multiple imaging focal lengths, and the imaging focal length of the endoscope can be adjusted to the target focal length to complete the focusing operation. In this way, by performing the focusing operation on the first definition and the second definition of the same target object, the optimal focal length corresponding to the image with the highest definition can be accurately determined.

[0122] In an optional embodiment, as shown in FIG7 , an endoscope focusing method is provided, which is applied to a computer device, and includes:

[0123] S601, acquiring a first image taken by an endoscope at a first focal length, and a second image taken by the endoscope at a second focal length;

[0124] S602, selecting a focus area including a target object from the first image to obtain a first area image;

[0125] S603, determining a sliding area according to the first area image; the size of the sliding area is consistent with the size of the first area image;

[0126] S604, obtaining a plurality of candidate region images by moving the sliding region on the second image;

[0127] Exemplarily, S604 includes: adjusting the size of the second image to obtain second images of various scales; detecting edges of the second images of various scales; and obtaining multiple candidate area images by moving a sliding area within the edges of the second images of various scales;

[0128] S605, determining the candidate region image having the highest similarity to the first region image as the third region image;

[0129] S606, adjusting the size of the region where the target object is located in the third region image to be consistent with the size of the first region image, to obtain an adjusted second region image;

[0130] S607, determining a first brightness of the first region image and a second brightness of the second region image;

[0131] S608, if the first brightness is consistent with the second brightness, directly executing the step of determining the first definition of the image of the first region and the second definition of the image of the second region;

[0132] S609, if the first brightness is inconsistent with the second brightness, adjusting the second brightness to make the first brightness consistent with the second brightness, and after the adjustment, performing a step of determining a first definition of the image of the first region and a second definition of the image of the second region;

[0133] S610, determining a first definition of an image in a first region and a second definition of an image in a second region;

[0134] Wherein, determining the first definition of the image in the first area includes:

[0135] Using a single-frequency bandpass filter to respectively determine the initial clarity of the first region image at different frequencies; determining the first clarity according to the initial clarity at different frequencies;

[0136] S611, determining a focus direction according to the first clarity and the second clarity;

[0137] S612, adjusting the imaging focal length of the endoscope according to the focusing direction, and determining images corresponding to multiple imaging focal lengths;

[0138] S613, determining the imaging focal length corresponding to the image with the highest definition from the images corresponding to the multiple imaging focal lengths as the target focal length, and adjusting the imaging focal length of the endoscope to the target focal length to complete the focusing operation.

[0139] In the above-mentioned endoscope focusing method, since the imaging focal lengths of the first area image and the second area image obtained in the embodiment of the present application are different but the sizes are the same, and the first area image and the second area image both contain the same target object, it can be ensured that the contents contained in the first area image and the second area image are basically the same or highly similar. Therefore, the embodiment of the present application can respectively determine the first clarity of the first area image and the second clarity of the second area image for the same target object. Since the present application can choose to calculate the clarity corresponding to area images with different focal lengths and the same size for the same target object, when performing the focusing operation according to the first clarity and the second clarity, the present application selects two images with the same size and basically the same content for focusing, and will not be affected by drastic changes in the field of view, thereby ensuring the fairness of the image clarity comparison, making the first clarity and the second clarity comparable. Therefore, the present application can also ensure a better focusing effect of the autofocus when the field of view angle changes, and thus can improve the clarity of the image obtained by focusing.

[0140] It should be understood that, although the steps in the flowcharts involved in the above 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 is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may 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 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.

[0141] Based on the same inventive concept, the embodiment of the present application also provides an endoscope focusing device for implementing the endoscope focusing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more endoscope focusing device embodiments provided below can refer to the limitations of the endoscope focusing method above, and will not be repeated here.

[0142] In an exemplary embodiment, as shown in FIG8 , an endoscope focusing device is provided, comprising: an acquisition module 31, a determination module 32 and a focusing module 33, wherein:

[0143] The acquisition module 31 is used to acquire a first area image taken by the endoscope at a first focal length, and a second area image taken by the endoscope at a second focal length; the first focal length and the second focal length are different, the second focal length is the current imaging focal length of the endoscope, the first area image and the second area image are of the same size, and the first area image and the second area image both contain the same target object.

[0144] The determination module 32 is configured to determine a first definition of the first region image and a second definition of the second region image.

[0145] The focusing module 33 is used to adjust the imaging focal length of the endoscope according to the first clarity and the second clarity to complete the focusing operation.

[0146] In one embodiment, the acquisition module 31 includes:

[0147] A first target image determining unit, configured to select a focus area containing a target object from the first image to obtain a first target image;

[0148] A second target image determination unit is used to match the second image according to the first target image, and determine the second target image containing the target object from the second image; wherein, when the first image is an image shot at a first focal length, and the second image is an image shot at a second focal length, the first target image is a first area image, and the second target image is a second area image; when the first image is an image shot at a second focal length, and the second image is an image shot at a first focal length, the first target image is a second area image, and the second target image is a first area image.

[0149] In one embodiment, the second target image acquisition unit includes:

[0150] A third region image acquisition subunit, configured to match the second image according to the first target image, and determine a third region image containing the target object from the second image;

[0151] The second region image acquisition subunit is used to adjust the size of the region where the target object is located in the third region image to be consistent with the size of the first target image, so as to obtain a second target image.

[0152] In one embodiment, the third region image acquisition subunit includes:

[0153] The sliding area determination subunit is used to determine the sliding area according to the first target image; the size of the sliding area is consistent with the size of the first target image;

[0154] A candidate region image acquisition subunit, used to obtain a plurality of candidate region images by moving a sliding region on the second image;

[0155] The third region image determination subunit is configured to determine the candidate region image having the highest similarity to the first target image as the third region image.

[0156] In one embodiment, the candidate region image acquisition subunit is specifically used for:

[0157] Adjusting the size of the second image to obtain second images of various scales;

[0158] detecting edges of the second image at each scale;

[0159] By moving the sliding region within the edge of the second image at each scale, a plurality of candidate region images are obtained.

[0160] In one embodiment, the determination module 32 includes:

[0161] An initial definition determination unit, used to respectively determine the initial definition of the first region image at different frequencies using a single frequency bandpass filter;

[0162] The first definition determining unit is used to determine the first definition according to the initial definitions of different frequencies.

[0163] In one embodiment, the endoscope focusing device further comprises:

[0164] A brightness determination module, used to determine a first brightness of the first area image and a second brightness of the second area image;

[0165] The execution module is used to adjust the second brightness if the first brightness is inconsistent with the second brightness to make the first brightness consistent with the second brightness, and to perform the steps of determining the first clarity of the first area image and the second clarity of the second area image after the adjustment.

[0166] In one embodiment, the focusing module 33 includes:

[0167] A focus direction determining unit, configured to determine a focus direction according to the first clarity and the second clarity;

[0168] A focusing unit, used to adjust the imaging focal length of the endoscope according to the focusing direction, and determine images corresponding to multiple imaging focal lengths;

[0169] The target focal length determination unit is used to determine the imaging focal length corresponding to the image with the highest definition from the images corresponding to the multiple imaging focal lengths as the target focal length, and adjust the imaging focal length of the endoscope to the target focal length to complete the focusing operation.

[0170] Each module in the above-mentioned endoscope focusing device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0171] In an exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG1. ​​The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. 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 may be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, an endoscope focusing method is implemented. The display unit of the computer device is used to form a visually visible picture, which may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

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

[0173] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0174] Acquire a first area image taken by the endoscope at a first focal length, and a second area image taken by the endoscope at a second focal length; the first focal length and the second focal length are different, the second focal length is the current imaging focal length of the endoscope, the first area image and the second area image have the same size, and both the first area image and the second area image contain the same target object;

[0175] determining a first definition of the first region image and a second definition of the second region image;

[0176] The imaging focal length of the endoscope is adjusted according to the first clarity and the second clarity to complete the focusing operation.

[0177] In one embodiment, a first area image captured by an endoscope at a first focal length and a second area image captured by the endoscope at a second focal length are acquired, and when the processor executes the computer program, the following steps are further implemented:

[0178] Selecting a focus area containing a target object from the first image to obtain a first target image;

[0179] The second image is matched according to the first target image, and a second target image containing the target object is determined from the second image; wherein, when the first image is an image shot at a first focal length, and the second image is an image shot at a second focal length, the first target image is a first area image, and the second target image is a second area image; when the first image is an image shot at a second focal length, and the second image is an image shot at a first focal length, the first target image is a second area image, and the second target image is a first area image.

[0180] In one embodiment, the second image is matched according to the first target image, and a second target image containing the target object is determined from the second image. When the processor executes the computer program, the following steps are also implemented:

[0181] Matching the second image according to the first target image, and determining a third area image containing the target object from the second image;

[0182] The size of the region where the target object is located in the third region image is adjusted to be consistent with the size of the first target image to obtain a second target image.

[0183] In one embodiment, the second image is matched according to the first target image, and a third region image containing the target object is determined from the second image. When the processor executes the computer program, the following steps are also implemented:

[0184] Determine a sliding area according to the first target image; the size of the sliding area is consistent with the size of the first target image;

[0185] By moving the sliding area on the second image, a plurality of candidate area images are obtained;

[0186] The candidate region image having the highest similarity to the first target image is determined as the third region image.

[0187] In one embodiment, by moving the sliding area on the second image to obtain multiple candidate area images, the processor further implements the following steps when executing the computer program:

[0188] Adjusting the size of the second image to obtain second images of various scales;

[0189] detecting edges of the second image at each scale;

[0190] By moving the sliding region within the edge of the second image at each scale, a plurality of candidate region images are obtained.

[0191] In one embodiment, when determining the first definition of the first region image, the processor further implements the following steps when executing the computer program:

[0192] Using a single frequency bandpass filter to respectively determine the initial clarity of the first region image at different frequencies;

[0193] A first clarity is determined according to the initial clarity of the different frequencies.

[0194] In one embodiment, before determining the first definition of the first area image and the second definition of the second area image, the method further implements the following steps when the processor executes the computer program:

[0195] Determine a first brightness of the first area image and a second brightness of the second area image;

[0196] If the first brightness is inconsistent with the second brightness, the second brightness is adjusted to make the first brightness consistent with the second brightness, and after the adjustment, the steps of determining the first clarity of the first area image and the second clarity of the second area image are performed.

[0197] In one embodiment, the imaging focal length of the endoscope is adjusted according to the first clarity and the second clarity to complete the focusing operation, and the processor further implements the following steps when executing the computer program:

[0198] determining a focusing direction according to the first clarity and the second clarity;

[0199] Adjusting the imaging focal length of the endoscope according to the focusing direction to determine images corresponding to multiple imaging focal lengths;

[0200] The imaging focal length corresponding to the image with the highest definition among the images corresponding to the multiple imaging focal lengths is determined as the target focal length, and the imaging focal length of the endoscope is adjusted to the target focal length to complete the focusing operation.

[0201] In one embodiment, an endoscope system is provided. The endoscope system includes: a light source device, an endoscope, and a computer device as in any one of the above embodiments.

[0202] As shown in FIG9 , the endoscope system 100 includes a computer device 102, an endoscope 104, and a light source device 106. Optionally, the computer device 102 is directly connected to the endoscope 104 in communication, and the computer device 102 may be an image processing device. In other embodiments, the computer device 102 and the endoscope 104 may also be indirectly connected in communication, for example, the computer device 102 may be connected to the light source device 106 by itself, and the light source device 106 is connected to the endoscope 104 in communication, so as to realize the communication connection between the computer device 102 and the endoscope 104. The doctor may use the endoscope 104 to obtain the internal cavity image of the patient's body, and perform image processing on the collected internal cavity image through the image processing device, and then send the internal cavity image to the display for display by the image processing device, so as to realize the inspection of the internal cavity. The computer device 102 may execute the endoscope focusing method in any of the above embodiments, which will not be described in detail here.

[0203] 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 in the above-mentioned method embodiments are implemented.

[0204] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0205] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments 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 this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. 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, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0206] 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 application.

[0207] The above 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 endoscope focusing method, It is characterized in that The method comprises: Acquire a first area image taken by the endoscope at a first focal length, and a second area image taken by the endoscope at a second focal length; the first focal length and the second focal length are different, the second focal length is the current imaging focal length of the endoscope, the first area image and the second area image have the same size, and the first area image and the second area image both contain the same target object; determining a first definition of the first area image and a second definition of the second area image; The imaging focal length of the endoscope is adjusted according to the first clarity and the second clarity to complete a focusing operation.

2. The method according to claim 1, It is characterized in that The step of acquiring a first area image captured by the endoscope at a first focal length and a second area image captured by the endoscope at a second focal length comprises: Selecting a focus area including the target object from the first image to obtain a first target image; The second image is matched according to the first target image, and a second target image containing the target object is determined from the second image; wherein, when the first image is an image shot at the first focal length, and the second image is an image shot at the second focal length, the first target image is the first area image, and the second target image is the second area image; when the first image is an image shot at the second focal length, and the second image is an image shot at the first focal length, the first target image is the second area image, and the second target image is the first area image.

3. The method according to claim 2, It is characterized in that The matching the second image according to the first target image and determining the second target image containing the target object from the second image includes: Matching the second image according to the first target image, and determining a third area image containing the target object from the second image; The size of the region where the target object is located in the third region image is adjusted to be consistent with the size of the first target image to obtain the second target image.

4. The method according to claim 3, It is characterized in that The matching the second image according to the first target image and determining the third area image containing the target object from the second image includes: Determine a sliding area according to the first target image; the size of the sliding area is consistent with the size of the first target image; By moving the sliding area on the second image, a plurality of candidate area images are obtained; The candidate region image having the highest similarity to the first target image is determined as the third region image.

5. The method according to claim 4, It is characterized in that The step of obtaining a plurality of candidate area images by moving the sliding area on the second image includes: Adjusting the size of the second image to obtain second images of various scales; Detecting edges of the second image at each scale; The plurality of candidate region images are obtained by moving the sliding region within the edge of the second image at each scale.

6. The method according to any one of claims 1 to 5, It is characterized in that The determining a first clarity of the image in the first area includes: Using a single frequency bandpass filter to respectively determine the initial clarity of the image in the first region at different frequencies; The first definition is determined according to the initial definitions of the different frequencies.

7. The method according to any one of claims 1 to 5, It is characterized in that Before determining the first definition of the first area image and the second definition of the second area image, the method further includes: determining a first brightness of the first area image and a second brightness of the second area image; If the first brightness is inconsistent with the second brightness, the second brightness is adjusted to make the first brightness consistent with the second brightness, and after the adjustment, the step of determining the first clarity of the first area image and the second clarity of the second area image is performed.

8. The method according to any one of claims 1 to 5, It is characterized in that The step of adjusting the imaging focal length of the endoscope according to the first definition and the second definition to complete the focusing operation includes: determining a focusing direction according to the first clarity and the second clarity; Adjusting the imaging focal length of the endoscope according to the focusing direction to determine images corresponding to a plurality of imaging focal lengths; The imaging focal length corresponding to the image with the highest definition among the images corresponding to the multiple imaging focal lengths is determined as the target focal length, and the imaging focal length of the endoscope is adjusted to the target focal length to complete the focusing operation.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.

10. An endoscope system, It is characterized in that include: A light source device, an endoscope, and a computer device as claimed in claim 9.

Citation Information

Patent Citations

  • Automatic focusing method and device of microscope, computer equipment and storage medium

    CN113837079A

  • Endoscope apparatus, information storage device, and image processing method

    US20130286172A1

  • Endoscope processor, program, and method for controlling focus lens

    WO2023084706A1

Cited By

  • Endoscope system and image generation method for endoscope system

    CN120360474A

  • Automatic focusing method and endoscope system

    CN120616406A

  • Endoscope with intelligent autofocus and multimodal image processing and adjustable focal length

    TWI940308B

  • Endoscope system and image generation method for endoscope system

    WO2026199120A1