A method and device for measuring target size

Through multi-target detection and computer vision processing of endoscopic operation images, combined with deep learning technology, the problem of low accuracy in target size measurement under endoscopic surgery is solved, accurate calculation and automated judgment of background targets and abnormal targets are achieved, and simplified system structure and reduce costs.

CN112580437BActive Publication Date: 2024-09-06ZHONGSHAN HOSPITAL FUDAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011344780.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-26
Publication Date
2024-09-06
Estimated Expiration
2040-11-26

AI Technical Summary

Technical Problem

Existing abnormal target identification methods are not very accurate when measuring target size under endoscopy, and the system is complex and costly. It cannot accurately judge the size of background targets and abnormal targets, especially in non-geometric environments, and lacks human-machine integration. and automated judgment.

Method used

By acquiring endoscopic operation images, we use multi-target detection and computer vision processing methods to determine the opening and closing status of the open-and-close tool, calculate the size of the target, including edge detection, line detection and Huffman transformation, combined with deep learning technology, dynamic recognition and record target status.

Benefits of technology

It achieves precise calculation and automated judgment of target size during endoscopy, improves judgment accuracy, and can identify and record the size of background targets and abnormal targets in real time under endoscopy, simplifying the system structure and reducing costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112580437B
    Figure CN112580437B
Patent Text Reader

Abstract

One technical solution of the present invention is to provide a method for measuring the size of a target. Another technical solution of the present invention is to provide a device for measuring the size of a target. The present invention uses deep learning and computer vision technology to dynamically identify reference objects and measurement target states, and automatically measure and record the size of reference objects and measurement target states. For example, the size of reference objects (such as biopsy forceps), background targets (such as colon bands, pyloric orifices, cardia orifices, descending duodenal papillae, ileocecal valves and other normal target tissues in the background) and / or abnormal targets (such as flat polyps, abnormal vascular fractals, atypical hyperplasia, inflammation, bleeding, fecal residues, tumors, advanced cancer and other abnormal target tissues) in the endoscopic examination process is judged, and accurate and specific values ​​are output.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a method for measuring the size of a target and a device for measuring the size of a target, and is particularly suitable for measuring the size of a target under an endoscope. Background Art

[0002] The existing methods for identifying abnormal targets mainly include: 1) Human identification: The size judgment depends on the operator's physical strength, attention, memory, inspection time and operation experience. The reported size judgment is not accurate. Most operators' judgments are not accurate enough, and the size of abnormal targets in the report is an estimate. 2) Physical identification: Through laser light source or laser radar, the pulse emission and reflection echo delay are proportional to the imaging distance. The reflection echo pulse delay is measured to obtain the imaging distance, and then the lesion size is obtained. However, this method requires additional pulse emission and detection units, and the system structure is complex and the cost is high. 3) Software identification: It can only calculate the size of the overlapping bounding box reference object, but cannot judge the distance between the two. The size judgment accuracy is not enough. Even if deep learning technology is used in the current monocular camera, it completely relies on computer vision technology. In a non-geometric environment, it is also a challenging task to identify the size of a non-Lambertian body; fully automatic judgment, there is no human experience and judgment in the process, and no human-machine combination is achieved. As a medical device, it is not rigorous enough; the target can only be a specific lesion, and it cannot be selected during the inspection process. Summary of the invention

[0003] The purpose of the present invention is to provide a method and a device which can be used at least in endoscopic examination, and can judge and accurately calculate the size of background objects and / or abnormal objects in endoscopic examination images.

[0004] In order to achieve the above object, a technical solution of the present invention is to provide a method for measuring the size of a target, characterized in that it includes the following steps:

[0005] Acquiring an operational image of an opening and closing tool;

[0006] Perform multi-target detection on the operation image to obtain the opening and closing tools and the target to be detected in the same frame of the operation image;

[0007] Determine the open and closed status of the opening and closing tools;

[0008] The sizes of other objects in the same frame operation image are calculated according to the opening and closing status of the opening and closing tool.

[0009] Preferably, the multi-target detection is performed on the operation image to obtain the enclosing frames of the opening and closing tool and the target to be detected in the same frame of the operation image respectively;

[0010] The targets to be detected include background targets and / or abnormal targets.

[0011] Preferably, the open and closed state of the open and close tool is determined by a computer vision processing method.

[0012] Preferably, determining the open / closed state of the open / close tool comprises:

[0013] Performing edge detection on the operation image to obtain a boundary map of the opening and closing tool;

[0014] A straight line detection is performed on a boundary image of the openable tool within the enclosing frame of the openable tool, thereby determining the open and closed state of the openable tool.

[0015] Preferably, before performing edge detection on the operation image, the method for measuring the size of the target further comprises:

[0016] The operation image is subjected to denoising processing.

[0017] Preferably, before performing denoising processing on the operation image, the method for measuring the size of the target further includes:

[0018] A portion of the operation image excluding the opening and closing tool is captured.

[0019] Preferably, performing denoising processing on the operation image comprises the following steps:

[0020] De-noising the operation image by using a non-local mean denoising algorithm;

[0021] Convert the denoised operation image to the HSV color space, adjust the color area of ​​the opening and closing tool, and obtain a binary mask image, wherein black is the background and white is the opening and closing tool;

[0022] The binary mask image is eroded and then expanded to remove the final noise.

[0023] Preferably, performing straight line detection on the boundary graph of the openable tool within the enclosing frame of the openable tool to determine the open and closed state of the openable tool comprises the following steps:

[0024] Within the obtained enclosing frame of the openable tool, straight line detection is performed by Huffman transformation, and the shortest span distance of the straight line is set to obtain a plurality of straight lines;

[0025] Through the hyperplane algorithm, the starting and ending coordinate points of multiple straight lines are divided into two parts, and then the coordinate points of the two categories are averaged to obtain two points, and then the unique Huffman line is obtained;

[0026] According to the coordinates of any two points (x1, y1) and (x2, y2) on the unique Huffman line, we get the slope k = (y2-y1) / (x2-x1), and the corresponding radian r is obtained by the inverse tangent of the slope k;

[0027] Calculate the angle angle of the four quadrants:

[0028] If the calculated angle angle is less than 0, the calculated angle angle minus 180° is used as the final angle; otherwise, the calculated angle angle is used as the final angle.

[0029] The open and closed state of the opening and closing tool is determined according to the size of the final angle.

[0030] Preferably, determining the open and closed state of the opening and closing tool according to the size of the final angle comprises the following steps:

[0031] If the angles in the first quadrant and the second quadrant are respectively 0°<angle<60° or 150°<angle<180°, it is determined that the opening and closing tool is in the open state;

[0032] If the angle between the first quadrant and the second quadrant is 70°<angle<120°, it is determined that the opening and closing tool is in the closed state.

[0033] Preferably, calculating the sizes of other objects in the operation image of the same frame according to the opening and closing states of the opening and closing tools respectively includes:

[0034] Cache the labels of background objects and / or abnormal objects;

[0035] Cache the bounding boxes of background objects and / or abnormal objects;

[0036] Cache the temporary variables of the open and close states of the opening and closing tool;

[0037] Acquire the actual size of the open and close tool in the open and close state, and accordingly obtain the size of the background object and / or abnormal object in the bounding box, and cache the size;

[0038] When the opening and closing tool is in a closed state or a horizontally opened state, the cache of the sizes of background targets and / or abnormal targets in the closed state is classified according to the label cache of the background targets and / or abnormal targets, and the average width and average height of each classification are calculated to obtain the size of the background targets and / or abnormal targets;

[0039] When the opening and closing tool is in a vertically open state, the cache of the sizes of background targets and abnormal targets in the open state is classified according to the label cache of the background targets and / or abnormal targets, and the size of the last element in each classification is used as the size of the background target and / or abnormal target.

[0040] Preferably, obtaining a cache of the size of the background object and / or the abnormal object in the bounding box includes the following:

[0041] Recording the starting point and end point coordinates of all Hoffman lines of the opening and closing tool, and dividing the coordinates into two decision regions by a hyperplane;

[0042] According to the coordinates of the starting points of all Huffman lines and the properties of the hyperplane, the final Huffman line equation is obtained;

[0043] If the opening and closing tool is in the closed state, all coordinates in the Hoffman line starting coordinate point array are traversed to obtain all coordinate points in the area above the Hoffman line equation and record them in the coordinate array; the coordinate array is traversed to record the leftmost coordinate point and the rightmost coordinate point, and the Euclidean distance between the two is calculated to obtain the screen pixel width of the opening and closing tool in the closed state; or, the coordinate array is traversed to record the leftmost coordinate point and the uppermost coordinate point on the left, and the average of the two coordinates is taken to obtain the left coordinate of the opening and closing tool; the rightmost coordinate point and the uppermost coordinate point on the right are recorded, and the average of the two coordinates is taken to obtain the right coordinate of the opening and closing tool; then, the Euclidean distance between the left coordinate of the opening and closing tool and the right coordinate of the opening and closing tool is calculated to obtain the screen pixel width of the opening and closing tool in the closed state;

[0044] If the opening and closing tool is in the open state, traverse all coordinates in the Huffman line starting coordinate point array, record the leftmost coordinate point and the rightmost coordinate point, calculate the Euclidean distance between the two, and obtain the screen pixel width of the opening state of the opening and closing tool;

[0045] Get the width of the open and closed state of the opening and closing tool, and divide the screen pixel width of the open and closing tool in the open and closing state and the screen pixel width of the closed state respectively; then multiply it with the width and height in the bounding box coordinates of the background target and the abnormal target to obtain the size of the background target and the abnormal target in the bounding box, and store it in the cache.

[0046] Another technical solution of the present invention is to provide a device for measuring the size of a target, characterized in that it includes:

[0047] An operation image acquisition module is configured to acquire an operation image of the opening and closing tool;

[0048] A multi-target detection module is configured to perform multi-target detection on the operation image, and obtain the opening and closing tools and the target to be detected in the same frame of the operation image respectively;

[0049] an opening and closing tool state detection module, configured to determine an opening and closing state of the opening and closing tool;

[0050] The target size calculation module is configured to calculate the size of other targets in the same frame operation image according to the opening and closing state of the opening and closing tool.

[0051] Preferably, multi-target detection is performed on the operation image to obtain the enclosing frames of the opening and closing tool and the target to be detected in the same frame of the operation image respectively;

[0052] The targets to be detected include background targets and / or abnormal targets.

[0053] Preferably, the open-and-close tool state detection module determines the open and closed state of the open-and-close tool by a computer vision processing method.

[0054] Preferably, the opening and closing tool state detection module comprises:

[0055] an edge detection unit, configured to perform edge detection on the operation image to obtain a boundary map of the opening and closing tool;

[0056] The straight line detection unit is configured to perform straight line detection on the boundary map of the openable tool within the enclosing frame of the openable tool, so as to determine the open or closed state of the openable tool.

[0057] Preferably, the opening and closing tool state detection module further includes:

[0058] The denoising unit is configured to perform denoising processing on the operation image before performing the edge detection.

[0059] Preferably, the opening and closing tool state detection module further includes:

[0060] The cutting unit is configured to cut out a portion of the operation image that does not include the opening and closing tool before the denoising process.

[0061] Preferably, the denoising unit comprises:

[0062] A first denoising subunit is configured to denoise the operation image by a non-local average denoising algorithm;

[0063] A binarization subunit is configured to convert the operation image into an HSV color space, adjust the color area of ​​the opening and closing tools, and obtain a binary mask image, wherein black is the background and white is the opening and closing tools;

[0064] The erosion and dilation subunit is configured to perform erosion operations and dilation operations on the binary mask image in sequence to remove the final noise.

[0065] Preferably, the straight line detection unit comprises:

[0066] A Huffman transform subunit is configured to perform straight line detection by Huffman transform within the bounding box of the obtained opening and closing tool, and set the shortest span distance of the straight line to obtain a plurality of straight lines;

[0067] The binary processing subunit is configured to binary the starting coordinate points and the end coordinate points of the plurality of straight lines by using a hyperplane algorithm, and then take the average of the coordinate points of the two categories respectively to obtain two points, and then obtain a unique Huffman line;

[0068] The radian calculation subunit is configured to obtain a slope k=(y2-y1) / (x2-x1) according to the coordinates (x1, y1) and (x2, y2) of any two points on the unique Huffman line, and obtain a corresponding radian r by the arc tangent of the slope k;

[0069] The angle calculation subunit is configured to Calculate the angle angle of the four quadrants; if the calculated angle angle is less than 0, add 180° to the calculated result as the final angle; otherwise, directly use the calculated angle angle as the final angle;

[0070] The opening and closing state judgment subunit of the opening and closing tool is configured to judge the opening and closing state of the opening and closing tool according to the final angle.

[0071] Preferably, judging the open and closed state of the opening and closing tool according to the final angle includes:

[0072] If the angles in the first quadrant and the second quadrant are respectively 0°<angle<60° or 150°<angle<180°, it is determined that the opening and closing tool is in the open state;

[0073] If the angle between the first quadrant and the second quadrant is 70°<angle<120°, it is determined that the opening and closing tool is in the closed state.

[0074] Preferably, the target size calculation module includes:

[0075] The cache unit is configured to: cache the labels of the background targets and / or abnormal targets; cache the bounding boxes of the background targets and / or abnormal targets; cache the temporary variables of the on and off states of the open and close tools; and cache the sizes of the background targets and / or abnormal targets in the bounding boxes obtained by the target size dynamic calculation unit;

[0076] The target size dynamic calculation unit is configured to obtain the actual size of the open and close tool in the open and close state, and obtain the size of the background target and / or abnormal target in the bounding box accordingly;

[0077] The current target sizing unit is configured as:

[0078] When the opening and closing tool is in a closed state or a horizontally opened state, the cache of the sizes of the background targets and abnormal targets in the closed state is classified according to the label cache of the background targets and / or abnormal targets, and the average width and average height of each classification are calculated to obtain the size of the background targets and / or abnormal targets;

[0079] When the opening and closing tool is in a vertically open state, the cache of the sizes of background targets and / or abnormal targets in the open state is classified according to the label cache of the background targets and / or abnormal targets, and the size of the last element in each classification is used as the size of the background target or abnormal target.

[0080] Preferably, the target size dynamic calculation unit comprises:

[0081] a decision region division subunit, configured to record the starting and ending coordinates of all Hoffman lines of the opening and closing tool, and divide the coordinates into two decision regions through a hyperplane;

[0082] A Huffman line equation obtaining subunit is configured to obtain a final Huffman line equation according to the starting point coordinates of all Huffman lines and the hyperplane properties;

[0083] The opening and closing tool screen pixel width calculation subunit is configured as follows:

[0084] If the opening and closing tool is in the closed state, all coordinates in the Hoffman line starting coordinate point array are traversed to obtain all coordinate points in the area above the Hoffman line equation and record them in the coordinate array; the coordinate array is traversed to record the leftmost coordinate point and the rightmost coordinate point, and the Euclidean distance between the two is calculated to obtain the screen pixel width of the opening and closing tool in the closed state; or, the coordinate array is traversed to record the leftmost coordinate point and the uppermost coordinate point on the left, and the average of the two coordinates is taken to obtain the left coordinate of the opening and closing tool; the rightmost coordinate point and the uppermost coordinate point on the right are recorded, and the average of the two coordinates is taken to obtain the right coordinate of the opening and closing tool; then, the Euclidean distance between the left coordinate of the opening and closing tool and the right coordinate of the opening and closing tool is calculated to obtain the screen pixel width of the opening and closing tool in the closed state;

[0085] If the opening and closing tool is in the open state, all coordinates in the Huffman line starting coordinate point array are traversed, the leftmost coordinate point and the rightmost coordinate point are recorded, and the Euclidean distance between the two is calculated to obtain the screen pixel width of the opening and closing tool in the open state;

[0086] The target size calculation subunit is configured to: obtain the open state width and the closed state width of the opening and closing tool from the configuration file, and perform a division operation on the open state screen pixel width or the closed state screen pixel width of the opening and closing tool respectively; and then multiply it with the width and height in the bounding box coordinates of the background target and / or the abnormal target to obtain the size of the background target and / or the abnormal target in the bounding box.

[0087] The present invention utilizes deep learning and computer vision technology to dynamically identify reference objects and measurement target states, and automatically measures and records the sizes of reference objects and measurement target states. For example, the present invention determines the sizes of reference objects (such as biopsy forceps), background targets (such as colon bands, pyloric orifice, cardia, descending duodenal papilla, ileocecal valve and other normal target tissues in the background) and / or abnormal targets (such as flat polyps, abnormal vascular fractals, atypical hyperplasia, inflammation, bleeding, fecal residue, tumors, advanced cancer and other abnormal target tissues) during endoscopic examination, and outputs accurate and specific values. BRIEF DESCRIPTION OF THE DRAWINGS

[0088] Figure 1 It is a schematic flow chart of a method for measuring the size of a target under endoscopy according to an embodiment of the present invention;

[0089] Figure 2 It shows that in the step of determining the open and closed state of the biopsy forceps in the method for measuring the size of a target under endoscopy provided by an embodiment of the present invention, taking the determination of the open state of the biopsy forceps as an example, the target detection model outputs the bounding box and probability of the biopsy forceps;

[0090] Figure 3 Shows the Figure 2 The image shown is the image obtained by denoising the image using a non-local mean denoising algorithm;

[0091] Figure 4 Shows the Figure 3 The image in is converted to the HSV color space, the color area of ​​the biopsy forceps is adjusted, and a binary mask image is obtained;

[0092] Figure 5 Shows the Figure 4 The image obtained after denoising the image in;

[0093] Figure 6 Shows the Figure 5 The denoised binary mask image shown is subjected to an erosion operation and then an expansion operation to remove the final noise points.

[0094] Figure 7 Shows the Figure 6 The image shown is processed by the edge detection Canny algorithm to obtain the boundary map;

[0095] Figure 8 Shows Figure 1 Within the obtained bounding box, straight line detection is performed through Huffman transform, and the shortest span distance of the straight line is set to obtain the effect diagram of multiple straight lines;

[0096] Fig. 9 It shows that in the step of determining the open and closed state of the biopsy forceps in the method for measuring the size of a target under endoscopy provided by an embodiment of the present invention, taking the determination of the closed state of the biopsy forceps as an example, the target detection model outputs the bounding box and probability of the biopsy forceps;

[0097] Fig.10 Shows the Fig. 9 The image shown is the image obtained by denoising the image using a non-local mean denoising algorithm;

[0098] Fig.11 Shows the Fig.10 The image in is converted to HSV color space, and the color area of ​​the biopsy forceps is adjusted to obtain a binary mask image;

[0099] Fig.12 Shows the Fig.11 The image in is subjected to denoising, corrosion operation, and expansion operation to remove the final noise point.

[0100] Fig.13 Shows the Fig.12 The image shown is a boundary map obtained by edge detection using the Canny algorithm;

[0101] Fig.14 Shown in Fig. 9 Within the obtained bounding box, the image is superimposed after Huffman transformation;

[0102] Fig.15 It is a schematic diagram of a flow chart of calculating the sizes of other objects in the same frame image according to the opening and closing states of the biopsy forceps in a preferred embodiment of the present invention;

[0103] Fig.16 This is a schematic diagram of dividing the coordinates of the starting and ending points of all Hoffman lines of the biopsy forceps into two decision areas by a hyperplane in a preferred embodiment of the present invention. DETAILED DESCRIPTION

[0104] The present invention will be further described below in conjunction with specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not intended to limit the scope of the present invention. In addition, it should be understood that after reading the content taught by the present invention, those skilled in the art can make various changes or modifications to the present invention, and these equivalent forms fall within the scope limited by the appended claims of the application equally.

[0105] See also Figure 1-Figure 16 Taking gastroscopy as an application scenario, the method for measuring the size of a target according to an exemplary embodiment of the present invention comprises the following steps:

[0106] Step 1: Read the live stream of the endoscope device or read the video frame from the recorded endoscope operation video, send it to the auxiliary identification device, and enter Step 2.

[0107] Step 2: The auxiliary discrimination device loads the target detection model YOLO v3 and sends the image to the target detection model YOLO v3 for multi-target detection to obtain the predicted probabilities and bounding boxes of multiple labels. These labels can be divided into three major categories: biopsy forceps classification, background target classification, and abnormal target classification. The processing flow enters Step 3, Step 4, and Step 5 respectively.

[0108] Step 3: The biopsy forceps are classified as a reference for target size determination. After obtaining the bounding box, the open and closed states are determined by the computer vision processing algorithm. For details, see Step 6.

[0109] Step 4: Background target classification includes: tongue, pharynx, gastric angle, colon band, pyloric orifice, cardia orifice, descending duodenal papilla, ileocecal valve and other normal target tissues in the background. The results are sent to Step 7 after judgment.

[0110] Step 5: Abnormal target classification includes: flat polyps, abnormal vascular fractal, atypical hyperplasia, inflammation, bleeding, fecal residue, tumor, advanced cancer, leukoplakia, erythema, ulcer and other abnormal target tissues. The results after judgment are sent to Step 7.

[0111] Step 6: Use computer vision processing methods to determine whether the biopsy forceps is open or closed.

[0112] The open state judgment process is as follows:

[0113] 1) Cut the upper half of the video and the left and right black screen parts. Since the biopsy forceps cannot appear in the upper half of the endoscope detection window, and the left and right parts are black screens, retaining the input detection model is a waste of computing resources. The target detection model outputs the bounding box and probability of the biopsy forceps. The effect is shown in Figure 2 .

[0114] 2) De-noise the image using the non-local average denoising algorithm. See the results. Figure 3 .

[0115] 3) Convert the image to HSV color space, adjust the color area of ​​the biopsy forceps, and obtain a binary mask image, where black is the background and white is the biopsy forceps. The original image effect is shown in Figure 4 Then the image is denoised again using the non-local average denoising algorithm. The denoising effect is shown in Figure 5 .

[0116] 4) Perform an erosion operation on the denoised binary mask image, then perform an expansion operation, and finally use the non-local average denoising algorithm to remove the final noise points from the image. The effect is shown in Figure 6 .

[0117] 5) The dilated binary image is processed by the edge detection Canny algorithm to obtain the boundary map. The effect is shown in Figure 7 .

[0118] 6) Within the biopsy forceps bounding box obtained in step 1), straight line detection is performed through Huffman transform, and the shortest span distance of the straight line is set to obtain multiple Huffman straight lines. The effect is shown in Figure 8 .

[0119] 7) By using a hyperplane algorithm, the starting coordinate points and the end coordinate points of the multiple Huffman lines are divided into two parts, and then the average of the coordinate points of the two categories is taken respectively to obtain two points, and then a unique Huffman line is obtained; according to the coordinates (x1, y1) and (x2, y2) of the two points of the unique Huffman line, the slope k is obtained, k = (y2-y1) / (x2-x1), and the corresponding radian r is obtained by the inverse tangent of the slope k.

[0120] 8) Calculate the angles of the four quadrants using the formula:

[0121]

[0122] 9) If angle is less than 0, add 180° to the result to convert the negative angle (the angles in the third and fourth quadrants) to the angles in the first and second quadrants.

[0123] 10) After observation, the angles of the biopsy forceps in the first and second quadrants are 0°<angle<60° or 150°<angle<180° respectively, and the results are output to Step 7.

[0124] The closing status judgment process is as follows:

[0125] 1) Repeat steps 1) to 9) in the above open state judgment process: AI target detection outputs the bounding box and probability of the biopsy forceps. Fig. 9 ; Image denoising effect see Fig.10 ; Mask after denoising see Fig.11 ; After corrosion expansion, Fig.12 ; Canny algorithm edge detection effect see Fig.13 ; The effect of Huffman transform and the original image are superimposed as shown in 14, and angle is calculated.

[0126] 2) After observation, the angle of the biopsy forceps in the closed state in the first and second quadrants is 70°<angle<120°, and the result is output to Step 8.

[0127] Step 7: If the biopsy forceps and the background target or abnormal target exist at the same time, record the temporary variables of the open and closed states of the biopsy forceps to OpenBBox and CloseBBox respectively, and record the labels of the background target or abnormal target to the cache LabelCache and the bounding box to the cache BBoxCache, such as Fig.15 As shown. Since the bounding boxes of background targets and abnormal targets may not always exist, they may be displayed intermittently. If they are blocked when the pliers are opened, the bounding boxes may not be displayed. Therefore, it is necessary to record the cache of the bounding boxes to facilitate dynamic identification of the state of the reference object.

[0128] Step 8: Get the opening and closing sizes of biopsy forceps of different manufacturers and specifications that are manually set by the user in advance from the configuration file, such as the width of the open state and the width of the closed state of the biopsy forceps. If the biopsy forceps is in the open state, start combining the cache BBoxCache of the background target and the abnormal target with the biopsy forceps OpenBBox, and the biopsy forceps open size (i.e., the biopsy forceps open state width) read from the configuration file to obtain the biopsy forceps bounding box and record it in OpenSizeCache. If the biopsy forceps is in the closed state, start combining the cache BBoxCache of the background target and the abnormal target with the biopsy forceps CloseBBox, and the biopsy forceps closed size (i.e., the biopsy forceps closed state width) read from the configuration file to obtain the biopsy forceps bounding box and record it in CloseSizeCache. See. Fig.15 , the specific process is as follows:

[0129] 1) Record the coordinates of the starting and ending points of all Hoffman lines obtained within the bounding box of the biopsy forceps into an array CoorArr, and use a hyperplane to divide the coordinate points into two decision regions. The formula is as follows:

[0130]

[0131] i represents the i-th partition, m is the total number of partitions, and since the present invention adopts a binary region, m=2; x i is the coordinate point of the i-th partition; w i is the coordinate point x i The above formula can be used to divide the space into two regions, namely class A and class B. If Then the coordinate point x i Belongs to class A; if Then the coordinate point x i Belongs to class B.

[0132] 2) n is the number of coordinate points, which can be assumed to be known, then:

[0133] x(n)=[1,x1(n),x2(n)] T

[0134] Where x(n) represents the input vector composed of three vectors at the nth iteration; x1(n) represents the second vector that constitutes x(n) at the nth iteration; x2(n) represents the third vector that constitutes x(n) at the nth iteration; and T is the transposition symbol.

[0135] unknown:

[0136] w(n)=[b,w1(n),w2(n)] T

[0137] Where w(n) represents the weight input vector composed of three vectors at the nth iteration; w1(n) represents the second vector that constitutes w(n) at the nth iteration; w2(n) represents the third vector that constitutes w(n) at the nth iteration.

[0138] Then the hyperplane formula can be converted into a linear combination of x and w, written as:

[0139] v(n)=w(n) T x(n)

[0140] Where v(n) represents the output of the linear combiner, and the scalar result is obtained by calculating the inner product of two vectors.

[0141] According to the properties of the hyperplane, if w T x>0, w is w(n), then all input vectors x belong to class A, if w T x≤0, then all input vectors x belong to class B.

[0142] 3) Let the learning rate η, and dynamically update w through n rounds (here n is a parameter obtained through experience, usually 2 or 4, and has nothing to do with the number of coordinate points n in step 2) above). If w Tx>0, then w(n+1)=w(n)-x(n)η(n), w(n+1) represents the iterative formula, which means that the next result is equal to the difference or sum of the product of the previous weight and the current input and the learning rate, η(n) represents the learning rate of the nth round, and x(n) represents the input vector of the nth round; if w T x≤0, then w(n+1)=w(n)+x(n)η(n);

[0143] 4) Finally, we get the equation of the straight line w1x1+w2x2+w3=0, which is the equation of the straight line that separates the linearly separable coordinate points through the super single-layer perceptron. w1, w2 and w3 are the weights obtained by the perceptron in multiple rounds of calculation. The equation of the straight line is shown in Fig.16 The center line (the horizontal line close to the bottom).

[0144] 5) If the biopsy forceps is in the closed state, traverse all the coordinates in the Hoffman line starting coordinate point CoorArr array, obtain all the coordinate points in the w1x1+w2x2+w3>0 decision area, and record them in the coordinate array TopCoorArr. Traverse the TopCoorArr coordinate array and record the leftmost coordinate point L=(X L , Y L ) and the rightmost coordinate point R=(X R , Y R ), calculate the Euclidean distance (L2 norm distance) between L and R, and obtain the screen pixel width DClose of the biopsy forceps in the closed state. Alternatively, traverse the TopCoorArr coordinate array, record the leftmost coordinate point and the topmost coordinate point on the left, and take the average of the two coordinates to obtain the left coordinate of the biopsy forceps L = (X L , Y L ); record the rightmost coordinate point and the topmost coordinate point on the right side, and take the average of the two coordinates to obtain the right coordinate of the biopsy forceps R = (X R , Y R ) ; Calculate the L2 norm distance between the two to obtain the screen pixel width DCl of the biopsy forceps closed state ose .

[0145] 6) If the biopsy forceps is in the open state, traverse all the coordinates in the CoorArr array of the starting coordinate point of the Hoffman line, record the leftmost coordinate point and the rightmost coordinate point, calculate the Euclidean distance (L2 norm distance) between the two, and obtain the screen pixel width DOpen of the biopsy forceps in the open state.

[0146] 7) Read the open state width and closed state width of the biopsy forceps manually set in the configuration file, divide DClose and DOpen respectively, and obtain rClose and rOpen respectively; the bounding box coordinates extracted from BBoxCache are [x, y, w, h], multiply w and h by rClose or rOpen respectively, and obtain the size of the background target and abnormal target in the current bounding box, and put them into the target size cache CloseSizeCache or OpenSizeCache respectively. If the coordinates are out of bounds or the number of Hoffman lines is less than 2, the size is recorded as [-1, -1, -1, -1] (due to the characteristics of video playback, it is impossible to get a suitable Hoffman line for each frame, and some cannot meet the judgment requirements, such as: the vision is blurred in the flushing state, and the part where the biopsy forceps / pathology clamp is extended is too small. Such a result has no meaning for calculation, so [-1, -1] is used instead of illegal input for exclusion filtering during calculation), such as Fig.15 As shown, output the result to Step 9.

[0147] Step 9: If the biopsy forceps is currently in the closed state, go to Step 10; if it is in the open state, go to Step 11.

[0148] Step 10: According to the same type of labels in LabelCache, classify the contents in the mapping cache CloseSizeCache according to the LabelCache index group, and calculate the average width and average height corresponding to each classification. The formula is as follows:

[0149]

[0150]

[0151]

[0152]

[0153] Get the size of background objects or abnormal objects and

[0154] Step 11: After identifying that the biopsy forceps is in the open state, the content in the mapping cache OpenSizeCache is classified according to the LabelCache index group according to the same type of label in LabelCache, and the size of the last (i.e., the most recently added) element in each classification is used as the size of the final abnormal target or background target.

[0155] By using deep learning and computer vision technology, the opening and closing state of the opening and closing tool (biopsy forceps) can be dynamically identified, and the screen pixel width of the opening and closing tool (biopsy forceps) can be accurately calculated. Then, by using the proportional relationship, it is finally possible to judge and accurately calculate the size of background targets and / or abnormal targets in the endoscopic examination image.

Claims

1. A method for measuring the size of a target, It is characterized in that The following steps are involved: Acquiring an operational image of an opening and closing tool; Perform multi-target detection on the operation image to obtain the opening and closing tools and the target to be detected in the same frame of the operation image; Determine the open and closed status of the opening and closing tools; Calculate the size of other objects in the same frame operation image according to the open and close status of the open and close tool, including: Cache the labels of background objects and / or abnormal objects; Cache the bounding boxes of background objects and / or abnormal objects; Cache the temporary variables of the open and close states of the opening and closing tool; Acquire the actual size of the open and close tool in the open and close state, and accordingly obtain the size of the background object and / or abnormal object in the bounding box, and cache the size; When the opening and closing tool is in a closed state or a horizontally opened state, the cache of the sizes of background targets and / or abnormal targets in the closed state is classified according to the label cache of the background targets and / or abnormal targets, and the average width and average height of each classification are calculated to obtain the size of the background targets and / or abnormal targets; When the opening and closing tool is in a vertically opened state, the cache of the sizes of background targets and abnormal targets in the opened state is classified according to the label cache of the background targets and / or abnormal targets, and the size of the last element in each classification is used as the size of the background target and / or abnormal target; Obtaining the size of the background object and / or the abnormal object in the bounding box includes the following: Recording the starting point and end point coordinates of all Hoffman lines of the opening and closing tool, and dividing the coordinates into two decision regions by a hyperplane; According to the coordinates of the starting points of all Huffman lines and the properties of the hyperplane, the final Huffman line equation is obtained; If the opening and closing tool is in the closed state, all coordinates in the Hoffman line starting coordinate point array are traversed to obtain all coordinate points in the area above the Hoffman line equation and record them in the coordinate array; the coordinate array is traversed to record the leftmost coordinate point and the rightmost coordinate point, and the Euclidean distance between the two is calculated to obtain the screen pixel width of the opening and closing tool in the closed state; or, the coordinate array is traversed to record the leftmost coordinate point and the uppermost coordinate point on the left, and the average of the two coordinates is taken to obtain the left coordinate of the opening and closing tool; the rightmost coordinate point and the uppermost coordinate point on the right are recorded, and the average of the two coordinates is taken to obtain the right coordinate of the opening and closing tool; then, the Euclidean distance between the left coordinate of the opening and closing tool and the right coordinate of the opening and closing tool is calculated to obtain the screen pixel width of the opening and closing tool in the closed state; If the opening and closing tool is in the open state, traverse all coordinates in the Huffman line starting coordinate point array, record the leftmost coordinate point and the rightmost coordinate point, calculate the Euclidean distance between the two, and obtain the screen pixel width of the opening state of the opening and closing tool; Get the width of the open and closed state of the opening and closing tool, and divide the screen pixel width of the open and closing tool in the open and closing state and the screen pixel width of the closed state respectively; then multiply it with the width and height in the bounding box coordinates of the background target and the abnormal target to obtain the size of the background target and the abnormal target in the bounding box, and store it in the cache.

2. The method for measuring the size of a target according to claim 1, It is characterized in that Performing the multi-target detection on the operation image to obtain the enclosing frames of the opening and closing tool and the target to be detected in the same frame of the operation image respectively; The targets to be detected include background targets and / or abnormal targets.

3. The method for measuring the size of a target according to claim 2, It is characterized in that The open and closed state of the open and close tool is determined by a computer vision processing method.

4. The method for measuring the size of a target according to claim 3, It is characterized in that Determining the open and closed state of the open and close tool includes: Performing edge detection on the operation image to obtain a boundary map of the opening and closing tool; A straight line detection is performed on a boundary image of the openable tool within the enclosing frame of the openable tool, thereby determining the open and closed state of the openable tool.

5. The method for measuring the size of a target according to claim 4, It is characterized in that Before performing edge detection on the operation image, the method for measuring the size of the target further includes: The operation image is subjected to denoising processing.

6. The method for measuring the size of a target according to claim 5, It is characterized in that Before performing denoising processing on the operation image, the method for measuring the size of the target further includes: A portion of the operation image excluding the opening and closing tool is captured.

7. The method for measuring the size of a target according to claim 5 or 6, It is characterized in that The operation image is subjected to denoising processing, comprising the following steps: De-noising the operation image by using a non-local mean denoising algorithm; Convert the denoised operation image to the HSV color space, adjust the color area of ​​the opening and closing tool, and obtain a binary mask image, wherein black is the background and white is the opening and closing tool; The binary mask image is eroded and then expanded to remove the final noise.

8. The method for measuring the size of a target according to claim 4, It is characterized in that Performing straight line detection on the boundary graph of the openable tool within the enclosing frame of the openable tool to determine the open and closed state of the openable tool includes the following steps: Within the obtained enclosing frame of the openable tool, straight line detection is performed by Huffman transformation, and the shortest span distance of the straight line is set to obtain a plurality of straight lines; Through the hyperplane algorithm, the starting and ending coordinate points of multiple straight lines are divided into two parts, and then the average of the coordinate points of the two categories is taken to obtain two points, and then the unique Huffman line is obtained; According to the coordinates of any two points on the unique Huffman line (x 1 ,y 1 ) and (x 2 ,y 2 ), we get the slope k = (y 2 -y 1 ) / (x 2 -x 1 ), the corresponding radian r is obtained by the arc tangent of the slope k; Calculate the angle angle of the four quadrants: If the calculated angle angle is less than 0, then add 180° to the calculated angle angle as the final angle; otherwise, directly use the calculated angle angle as the final angle; Determine the opening and closing state of the opening and closing tool according to the magnitude of the final angle.

9. The method for measuring the size of a target according to claim 8, characterized in that, Determining the opening and closing state of the opening and closing tool according to the magnitude of the final angle includes the following steps: If the angles in the first quadrant and the second quadrant are 0° < angle < 60° or 150° < angle < 180°, respectively, then determine that the opening and closing tool is in the open state; If the angles in the first quadrant and the second quadrant are 70° < angle < 120°, then determine that the opening and closing tool is in the closed state.

10. A device for measuring the size of a target, characterized in that, comprising: An operation image acquisition module configured to acquire an operation image of an opening and closing tool; A multi-target detection module configured to perform multi-target detection on the operation image to respectively obtain an opening and closing tool and a target to be measured in the same frame of operation image; An opening and closing tool state detection module configured to determine the opening and closing state of the opening and closing tool; A target size calculation module configured to calculate the size of other targets in the same frame of operation image according to the opening and closing state of the opening and closing tool, including: A cache unit configured to: cache the labels of background targets and / or abnormal targets; cache the bounding boxes of background targets and / or abnormal targets; cache the temporary variables of the open state and closed state of the opening and closing tool; cache the sizes of background targets and / or abnormal targets within the bounding box obtained by the target size dynamic calculation unit; A target size dynamic calculation unit configured to obtain the actual size of the opening and closing state of the opening and closing tool, and accordingly obtain the sizes of background targets and / or abnormal targets within the bounding box; A current target size determination unit configured to: When the opening and closing tool is in the closed state or the horizontal open state, classify the cached sizes of background targets and abnormal targets in the closed state according to the cached labels of background targets and / or abnormal targets, and calculate the average width and average height of each classification to obtain the sizes of background targets and / or abnormal targets; When the opening and closing tool is in the vertical open state, classify the cached sizes of background targets and / or abnormal targets in the open state according to the cached labels of background targets and / or abnormal targets, and use the size of the last element in each classification as the size of the background target or abnormal target; The target size dynamic calculation unit includes: A decision region division sub-unit configured to record the starting and ending coordinates of all Huffman lines of the opening and closing tool, and divide the coordinates into two decision regions by a hyperplane; A Huffman line equation acquisition sub-unit configured to obtain the final Huffman line equation according to the starting point coordinates of all Huffman lines and the properties of the hyperplane; An opening and closing tool screen pixel width calculation sub-unit configured to: If the opening and closing tool is in the closed state, all coordinates in the Hoffman line starting coordinate point array are traversed to obtain all coordinate points in the area above the Hoffman line equation and record them in the coordinate array; the coordinate array is traversed to record the leftmost coordinate point and the rightmost coordinate point, and the Euclidean distance between the two is calculated to obtain the screen pixel width of the opening and closing tool in the closed state; or, the coordinate array is traversed to record the leftmost coordinate point and the uppermost coordinate point on the left, and the average of the two coordinates is taken to obtain the left coordinate of the opening and closing tool; the rightmost coordinate point and the uppermost coordinate point on the right are recorded, and the average of the two coordinates is taken to obtain the right coordinate of the opening and closing tool; then, the Euclidean distance between the left coordinate of the opening and closing tool and the right coordinate of the opening and closing tool is calculated to obtain the screen pixel width of the opening and closing tool in the closed state; If the opening and closing tool is in the open state, all coordinates in the Huffman line starting coordinate point array are traversed, the leftmost coordinate point and the rightmost coordinate point are recorded, and the Euclidean distance between the two is calculated to obtain the screen pixel width of the opening and closing tool in the open state; The target size calculation subunit is configured to: obtain the open state width and the closed state width of the opening and closing tool from the configuration file, and perform a division operation on the open state screen pixel width or the closed state screen pixel width of the opening and closing tool respectively; and then multiply it with the width and height in the bounding box coordinates of the background target and / or the abnormal target to obtain the size of the background target and / or the abnormal target in the bounding box.

11. The device for measuring the size of a target according to claim 10, It is characterized in that Performing multi-target detection on the operation image to respectively obtain the enclosing frames of the opening and closing tool and the target to be detected in the same frame of the operation image; The targets to be detected include background targets and / or abnormal targets.

12. The device for measuring the size of a target according to claim 11, It is characterized in that The open-and-close tool state detection module determines the open and closed state of the open-and-close tool through a computer vision processing method.

13. The device for measuring the size of a target according to claim 12, It is characterized in that The opening and closing tool state detection module comprises: an edge detection unit, configured to perform edge detection on the operation image to obtain a boundary map of the opening and closing tool; The straight line detection unit is configured to perform straight line detection on the boundary map of the openable tool within the enclosing frame of the openable tool, so as to determine the open or closed state of the openable tool.

14. The device for measuring the size of a target according to claim 13, It is characterized in that The opening and closing tool state detection module further includes: The denoising unit is configured to perform denoising processing on the operation image before performing the edge detection.

15. The device for measuring the size of a target according to claim 14, It is characterized in that The opening and closing tool state detection module further includes: The cutting unit is configured to cut out a portion of the operation image that does not include the opening and closing tool before the denoising process.

16. The device for measuring the size of a target according to claim 15 or 14, It is characterized in that The denoising unit comprises: The first denoising unit is configured to denoise the operation image through a non-local mean denoising algorithm; The binarization subunit is configured to convert the operation image to the HSV color space, adjust the color region of the opening and closing tool, and obtain a binarized mask image, where black is the background and white is the opening and closing tool; The erosion and dilation subunit is configured to perform an erosion operation and a dilation operation on the binarized mask image in sequence to remove the final noise.

17. The device for measuring the size of the target according to claim 13, wherein, The straight line detection unit includes: The Hough transform subunit is configured to perform straight line detection through the Hough transform within the range of the bounding box of the obtained opening and closing tool, and set the shortest spanning distance of the straight line to obtain a plurality of straight lines; The binary processing subunit is configured to perform binary division on the starting coordinate points and ending coordinate points of the plurality of straight lines through a hyperplane algorithm, and then take the mean values of the coordinate points of the two classifications respectively to obtain two points, and further obtain a unique Hough straight line; The radian calculation subunit is configured to calculate the angle of any two points on the unique Huffman line according to their coordinates (x 1 ,y 1 ) and (x 2 ,y 2 ), we get the slope k = (y 2 -y 1 ) / (x 2 -x 1 ), the corresponding radian r is obtained by the arc tangent of the slope k; The angle calculation subunit is configured to Calculate the angle angle of the four quadrants; if the calculated angle angle is less than 0, add 180° to the calculated result as the final angle; otherwise, directly use the calculated angle angle as the final angle; The opening and closing state judgment subunit of the opening and closing tool is configured to judge the opening and closing state of the opening and closing tool according to the final angle.

18. The device for measuring the size of the target according to claim 17, wherein, Judging the opening and closing state of the opening and closing tool according to the final angle includes: If the angles in the first quadrant and the second quadrant are 0° < angle < 60° or 150° < angle < 180° respectively, it is determined that the opening and closing tool is in the open state; If the angles in the first quadrant and the second quadrant are 70° < angle < 120°, it is determined that the opening and closing tool is in the closed state.