Fast extraction method of region of interest

By acquiring the shape parameters and boundary information of the region of interest, combining scan line characteristics and parallel computing, and using the TBB tool for image processing, the problem of high computational load in existing technologies is solved, and fast, stable and reliable extraction of the region of interest is achieved.

CN116012573BActive Publication Date: 2026-02-10GUANGDONG AOPUTE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211405396.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-10
Publication Date
2026-02-10
Estimated Expiration
2042-11-10

AI Technical Summary

Technical Problem

Existing technologies, when processing regions of interest, result in a large computational load and reduced computational efficiency due to the computation of non-regions of interest.

Method used

By acquiring the shape parameters and boundary information of the region of interest, and combining scan line characteristics and parallel computing, the TBB tool is used for image processing to extract the image data of the region of interest.

Benefits of technology

It achieves fast, stable, and reliable extraction of regions of interest, reducing computation time and memory consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116012573B_ABST
    Figure CN116012573B_ABST
Patent Text Reader

Abstract

The application discloses a kind of region of interest fast extraction method, suitable for the region of interest of target picture is extracted fast, the region of interest fast extraction method includes the following steps: S1, the region of interest of target picture is carried out image analysis, obtains the shape parameter of the region of interest;S2, the boundary information of the region of interest is calculated, the boundary information is the upper and lower boundary position or left and right boundary position of the region of interest;S3, the scan line run-length encoding of the region of interest in image coordinate is calculated;S4, the shape parameter, boundary information and scan line run-length encoding of the region of interest are carried out parallel image processing based on TBB operation, and the image data about the region of interest is extracted;The application extracts the region of interest in target image using the boundary information of region of interest, and combines scan line characteristics, mathematical operation and parallel operation, fast and stable and reliable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a method for rapid extraction of regions of interest. Background Technology

[0002] Machine vision is the use of machines to replace human eyes for measurement and judgment. With the rapid development of the microelectronics industry, high-resolution, high-speed machine vision systems are constantly emerging, which puts forward new requirements for the speed, accuracy, and stability of image processing algorithms.

[0003] Processing regions of interest (ROIs) in machine vision is a common and widely used image processing method. By processing only a portion of the ROI from an image with millions or even tens of millions of pixels, processing efficiency can be significantly improved.

[0004] In existing technologies, only the region of interest is processed in an image, while other regions retain their original pixel values. The mainstream algorithm steps are as follows:

[0005] 1. Generate a black and white mask image that can distinguish between regions of interest and non-interest.

[0006] 2. Based on mask image 1 (the non-interest area is white and the interest area is black), perform a bitwise AND operation between the source image and mask image 1 to generate an image A whose non-interest area is the same as the source pixel and whose interest area is black;

[0007] 3. Based on mask image 2 (the non-interest area is black and the interest area is white), the source image processing result is ANDed with mask image 2 to generate an image B in which the non-interest area is black and the interest area is the result;

[0008] 4. By performing an OR operation between image A and image B, you can obtain an image that only processes the region of interest while keeping the source pixels unchanged in other regions.

[0009] However, during the execution of the above algorithm, the construction and operation of the mask image will cause regions of non-interest to participate in the operation, which greatly increases the amount of computation, resulting in long operation time and reduced computational efficiency.

[0010] Therefore, there is an urgent need for a fast method for extracting regions of interest to solve the above problems. Summary of the Invention

[0011] The purpose of this invention is to provide a fast method for extracting regions of interest (ROIs). This method utilizes the boundary information of the ROIs and combines scan line characteristics, mathematical operations, and parallel operations to extract the ROIs from the target image, which is fast, stable, and reliable.

[0012] To achieve the above objectives, this invention discloses a method for rapid extraction of regions of interest (ROIs), suitable for quickly extracting ROIs from target images. The method for rapid ROI extraction includes the following steps:

[0013] S1. Perform image analysis on the region of interest of the target image to obtain the shape parameters of the region of interest;

[0014] S2. Calculate the boundary information of the region of interest, wherein the boundary information is the upper and lower boundary positions or the left and right boundary positions of the region of interest;

[0015] S3. Calculate the scan line run-length encoding of the region of interest in the image coordinates;

[0016] S4. Perform parallel image processing based on TBB operation on the shape parameters, boundary information and scan line run-length encoding of the region of interest to extract image data about the region of interest.

[0017] Preferably, the shape of the region of interest is a point, line segment, arc, rectangle, oblique rectangle, circle, ellipse, annulus or non-self-intersecting polygon;

[0018] When the region of interest is a point, the shape parameters include the coordinates of the point;

[0019] When the region of interest is a line segment, the shape parameters include the coordinates of the two endpoints of the line segment;

[0020] When the region of interest is an arc, the shape parameters include the radius of the arc, the starting angle, and the scanning angle;

[0021] When the region of interest is a rectangle, the shape parameters include the coordinates of the center point of the rectangle, the length of the major axis, and the length of the minor axis;

[0022] When the region of interest is a slanted rectangle, the shape parameters include the coordinates of the center point of the slanted rectangle, the rotation angle, the length of the major axis, and the length of the minor axis.

[0023] When the region of interest is circular, the shape parameters include the coordinates of the circle's center and its radius;

[0024] When the region of interest is elliptical, the shape parameters include the coordinates of the center point of the ellipse, the angle, the length of the major axis, and the length of the minor axis.

[0025] When the region of interest is an annular ring, the shape parameters include the coordinates of the center of the annular ring, the inner radius, the outer radius, the starting angle, and the scanning angle.

[0026] When the region of interest is a non-self-intersecting polygon, the shape parameters include the number of vertices of the polygon and the coordinates of each vertex.

[0027] Preferably, in image coordinates, for the boundary information being the upper and lower boundary positions of the region of interest, the scan line run-length encoding of the region of interest in image coordinates is calculated using method A; for the boundary information being the left and right boundary positions of the region of interest, the scan line run-length encoding of the region of interest in image coordinates is calculated using method B, wherein method A specifically includes:

[0028] Starting from the smallest Y value corresponding to the upper boundary Y-axis, the Y value is increased sequentially with a preset step size to the largest Y value corresponding to the lower boundary Y-axis. The leftmost value XLeft and the rightmost value XRight corresponding to each Y value are calculated to obtain the scan line run-length encoding of the region of interest in the image coordinates.

[0029] Method B specifically includes:

[0030] Starting from the minimum X value corresponding to the left boundary on the X-axis, the X value is incremented sequentially with a preset step size to the maximum X value corresponding to the right boundary on the X-axis. The minimum value YTop and the maximum value YDowm corresponding to each X value are calculated to obtain the scan line run-length encoding of the region of interest in the image coordinates.

[0031] Preferably, when the region of interest is a slanted rectangle, the boundary information is the upper and lower boundary positions of the region of interest. The scan line run-length encoding of the region of interest in image coordinates is calculated using method A, and the specific steps are as follows:

[0032] First, perform quicksort on the vertices and label them as topLeft, topRight, bottomLeft, and bottomRight;

[0033] Starting from the smallest Y value at the upper boundary, calculate the leftmost XLeft and rightmost XRight of the region of interest boundary as the Y value increases in units of 1, such as... Figure 2 As shown, the calculation method is as follows:

[0034] Substitute the Y value into the equation of the straight line on the left and right boundaries of the known distribution: Y = kX + b, and find the leftmost value XLeft and the rightmost value XRight at the intersection of the left and right points.

[0035] Preferably, when the region of interest is circular, the boundary information is the upper and lower boundary positions of the region of interest. The scan line run-length encoding of the region of interest in image coordinates is calculated using method A, and the specific steps are as follows:

[0036] When the region of interest is circular, starting from the smallest Y value at the upper boundary, calculate the leftmost XLeft and rightmost XRight values ​​of the region of interest boundary as the Y values ​​increase in units of 1. Figure 3 As shown, the calculation method is as follows:

[0037] First, calculate the difference dy between the current Y value and the Y coordinate of the circle center. Given dy, the radius can be calculated using the circle equation: x^2 + y^2 = r^2.

[0038] Then subtract dx from the X coordinate of the center to obtain the current Y value XLeft;

[0039] Then add dx to the X coordinate of the center of the circle to get the current Y value XRight.

[0040] Preferably, when the region of interest is elliptical, the boundary information is the upper and lower boundary positions of the region of interest. The scan line run-length encoding of the region of interest in image coordinates is calculated using method A, and the specific steps are as follows:

[0041] When the region of interest is elliptical, starting from the smallest Y value at the upper boundary, calculate the leftmost XLeft and rightmost XRight of the region of interest boundary as the Y value increases in units of 1. The calculation method is as follows:

[0042] First, substitute Y into y to solve for the two x's in the equation of the ellipse:

[0043] ;

[0044] Then, subtracting dx from the X coordinate of the center of the circle gives the current Y value, XLeft.

[0045] Adding dx to the X coordinate of the center of the circle gives the current Y value, XRight.

[0046] Preferably, when the region of interest is a non-self-intersecting polygon, starting from the smallest Y value at the upper boundary, the intersection of the scan line with any edge of the polygon is calculated as the Y value increases by 1. The number of intersections of the scan line is stored while ensuring that the intersections are internal. Similarly, the number of intersections is divided into odd and even. For an even number of intersections, they can be stored in pairs using XLEFT and XRight. For an odd number of intersections, the intersection situation needs to be judged to combine XLEFT and XRight.

[0047] Preferably, the target image includes k regions of interest, and there are masking regions between adjacent regions of interest. The parallel image processing based on TBB operation is performed on the shape parameters, boundary information, and scan line run-length encoding of the regions of interest to extract image data about the regions of interest, specifically including:

[0048] The scanline run-length codes of k regions of interest are combined using Boolean operations to obtain the total scanline run-length codes of the k regions of interest.

[0049] Parallel image processing based on TBB operation is performed on the shape parameters, boundary information, and total scan line run-length encoding of k regions of interest to extract image data about the k regions of interest.

[0050] Preferably, the step of performing a union operation on the scan line run-length encodings of the k regions of interest using Boolean operations to obtain the total scan line run-length encodings of the k regions of interest specifically includes:

[0051] Perform quick sorting on the k run-length encodings based on the row, start column, and / or end column, so that the order of each run-length encoding based on the row, start column, and / or end column is from smallest to largest;

[0052] The TBB tool is used to perform a single-row merge Boolean operation on each sorted run-length code to obtain the Boolean operation result for each row of each run-length code.

[0053] The Boolean operation results of the same rows of all run-length codes are merged to obtain the total scan-line run-length code for k regions of interest.

[0054] Preferably, the step of performing single-row merge Boolean operations on each sorted run-length encoding using the TBB tool to obtain the Boolean operation results for each row of each run-length encoding is as follows:

[0055] Union Algorithm:

[0056] Create stack in and stack out;

[0057] When stack in has only one element, check if the element entered from stack out is paired with the element in stack in. If they are paired, save it as a Boolean operation result. If not, pair the element entered from stack out with the element in stack in and discard it.

[0058] Remove the paired elements from the top of the stack in and the top of the stack out, respectively;

[0059] Intersection algorithm:

[0060] Create stack in and stack out;

[0061] For the sum of k scan lines, when stack in has k elements, determine whether the element entering stack out is paired with the element in stack in. If so, save it as the Boolean operation result. If not, pair the element entering stack out with the element in stack in and discard it.

[0062] Subtraction algorithm:

[0063] Create stack in and stack out;

[0064] When stack in of A is paired with the next element and stack out of A is paired with the previous element, then the element between stack in of B and stack out of B stops pairing and is cleared.

[0065] A XOR B algorithm:

[0066] Create stack in and stack out;

[0067] Pair the elements in the stack with the elements out of the stack in order.

[0068] Compared with existing technologies, this invention obtains the shape parameters, boundary information, and scan line run length encoding of the region of interest in the image coordinates, and then performs parallel image processing based on TBB operation on the shape parameters, boundary information, and scan line run length encoding of the region of interest to extract image data about the region of interest. It utilizes the boundary information of the region of interest and combines scan line characteristics, mathematical operations, and parallel operations to extract the region of interest in the target image, which is fast, stable, and reliable. Attached Figure Description

[0069] Figure 1 This is a flowchart of the method for rapid extraction of the region of interest according to the present invention;

[0070] Figure 2 This is a graphical illustration of calculating the leftmost value XLeft and the rightmost value XRight of a diagonal rectangle for any Y value using method A;

[0071] Figure 3 This is a graphical illustration of calculating the leftmost value XLeft and the rightmost value XRight of a circle for any Y value using method A;

[0072] Figure 4 This is a graphical illustration of calculating the leftmost value XLeft and the rightmost value XRight of an ellipse for any Y value using method A;

[0073] Figure 5 This is a graphical illustration of calculating the leftmost value XLeft and the rightmost value XRight of a line segment for any Y value using method A;

[0074] Figure 6 This is a graphical illustration of calculating the minimum value YTOP and maximum value YDown of any X value in the oblique rectangle using method B;

[0075] Figure 7 This is a graphical illustration of the minimum value YTOP and maximum value YDown of any X value in a circle calculated using method B;

[0076] Figure 8 This is a graphical illustration of the minimum value YTOP and maximum value YDown of an ellipse calculated using method B for any X value.

[0077] Figure 9 This is a schematic diagram of the scanning thread encoding array for extracting data from a 3200*10000 grayscale image according to the present invention;

[0078] Figure 10 This invention is for runs with run information consisting of three 15,000-row sequences.

[0079] Figure 11 This is a schematic diagram illustrating the extraction of the region of interest (ROI) in this invention when the ROI is irregular in shape.

[0080] Figure 12 This is a graphical representation of the operation of the union algorithm;

[0081] Figure 13 This is a graphical diagram illustrating the operation of the intersection algorithm;

[0082] Figure 14 This is a graphical diagram illustrating the subtraction algorithm.

[0083] Figure 15 This is a graphical diagram illustrating the XOR algorithm. Detailed Implementation

[0084] To illustrate the technical content, structural features, objectives, and effects of the present invention in detail, the following description is provided in conjunction with the embodiments and accompanying drawings.

[0085] Please see Figures 1-15 As shown, the region of interest (ROI) extraction method of this embodiment is suitable for quickly extracting the ROI of a target image. The ROI extraction method includes the following steps:

[0086] S1. Perform image analysis on the region of interest of the target image to obtain the shape parameters of the region of interest;

[0087] S2. Calculate the boundary information of the region of interest, wherein the boundary information is the upper and lower boundary positions or the left and right boundary positions of the region of interest;

[0088] S3. Calculate the scan line run-length encoding of the region of interest in the image coordinates;

[0089] S4. Perform parallel image processing based on TBB operation on the shape parameters, boundary information and scan line run-length encoding of the region of interest to extract image data about the region of interest.

[0090] Preferably, the shape of the region of interest is a point, line segment, arc, rectangle, oblique rectangle, circle, ellipse, annulus or non-self-intersecting polygon;

[0091] When the region of interest is a point, the shape parameters include the coordinates of the point;

[0092] When the region of interest is a line segment, the shape parameters include the coordinates of the two endpoints of the line segment;

[0093] When the region of interest is an arc, the shape parameters include the radius of the arc, the starting angle, and the scanning angle;

[0094] When the region of interest is a rectangle, the shape parameters include the coordinates of the center point of the rectangle, the length of the major axis, and the length of the minor axis;

[0095] When the region of interest is a slanted rectangle, the shape parameters include the coordinates of the center point of the slanted rectangle, the rotation angle, the length of the major axis, and the length of the minor axis.

[0096] When the region of interest is circular, the shape parameters include the coordinates of the circle's center and its radius;

[0097] When the region of interest is elliptical, the shape parameters include the coordinates of the center point of the ellipse, the angle, the length of the major axis, and the length of the minor axis.

[0098] When the region of interest is an annular ring, the shape parameters include the coordinates of the center of the annular ring, the inner radius, the outer radius, the starting angle, and the scanning angle.

[0099] When the region of interest is a non-self-intersecting polygon, the shape parameters include the number of vertices of the polygon and the coordinates of each vertex.

[0100] Preferably, in image coordinates, for the boundary information being the upper and lower boundary positions of the region of interest, the scan line run-length encoding of the region of interest in image coordinates is calculated using method A; for the boundary information being the left and right boundary positions of the region of interest, the scan line run-length encoding of the region of interest in image coordinates is calculated using method B, wherein method A specifically includes:

[0101] Starting from the smallest Y value corresponding to the upper boundary Y-axis, the Y value is increased sequentially with a preset step size to the largest Y value corresponding to the lower boundary Y-axis. The leftmost value XLeft and the rightmost value XRight corresponding to each Y value are calculated to obtain the scan line run-length encoding of the region of interest in the image coordinates.

[0102] Method B specifically includes:

[0103] Starting from the minimum X value corresponding to the left boundary on the X-axis, the X value is incremented sequentially with a preset step size to the maximum X value corresponding to the right boundary on the X-axis. The minimum value YTop and the maximum value YDowm corresponding to each X value are calculated to obtain the scan line run-length encoding of the region of interest in the image coordinates.

[0104] Preferably, when the region of interest is a slanted rectangle, the boundary information is the upper and lower boundary positions of the region of interest. The scan line run-length encoding of the region of interest in image coordinates is calculated using method A, and the specific steps are as follows:

[0105] First, perform quicksort on the vertices and label them as topLeft, topRight, bottomLeft, and bottomRight;

[0106] Starting from the smallest Y value at the upper boundary, calculate the leftmost XLeft and rightmost XRight of the region of interest boundary as the Y value increases in units of 1. The calculation method is as follows:

[0107] Substitute the Y value into the equation of the straight line on the left and right boundaries of the known distribution: Y = kX + b, and find the leftmost value XLeft and the rightmost value XRight of the left and right intersection points.

[0108] Preferably, when the region of interest is circular, the boundary information is the upper and lower boundary positions of the region of interest. The scan line run-length encoding of the region of interest in image coordinates is calculated using method A, and the specific steps are as follows:

[0109] When the region of interest is circular, starting from the smallest Y value at the upper boundary, calculate the leftmost XLeft and rightmost XRight of the region of interest boundary as the Y value increases in units of 1. The calculation method is as follows:

[0110] First, calculate the difference dy between the current Y value and the Y coordinate of the circle center. Given dy, the radius can be calculated using the circle equation: x^2 + y^2 = r^2.

[0111] Then subtract dx from the X coordinate of the center to obtain the current Y value XLeft;

[0112] Then add dx to the X coordinate of the center of the circle to get the current Y value XRight.

[0113] Preferably, when the region of interest is elliptical, the boundary information is the upper and lower boundary positions of the region of interest. The scan line run-length encoding of the region of interest in image coordinates is calculated using method A, and the specific steps are as follows:

[0114] When the region of interest is elliptical, starting from the smallest Y value at the upper boundary, calculate the leftmost XLeft and rightmost XRight of the region of interest boundary as the Y value increases in units of 1. The calculation method is as follows:

[0115] First, substitute Y into y to solve for the two x's in the equation of the ellipse:

[0116] ;

[0117] Then, subtracting dx from the X coordinate of the center of the circle gives the current Y value, XLeft.

[0118] Adding dx to the X coordinate of the center of the circle gives the current Y value, XRight.

[0119] Preferably, when the region of interest is a non-self-intersecting polygon, starting from the smallest Y value at the upper boundary, the intersection of the scan line with any edge of the polygon is calculated as the Y value increases by 1. The number of intersections of the scan line is stored while ensuring that the intersections are internal. Similarly, the number of intersections is divided into odd and even. For an even number of intersections, they can be stored in pairs using XLEFT and XRight. For an odd number of intersections, the intersection situation needs to be judged to combine XLEFT and XRight.

[0120] in addition, Figure 6 A graphical illustration is provided to calculate the minimum value YTOP and maximum value YDown of any X value in the oblique rectangle using method B.

[0121] Figure 7 A graphical illustration is provided to calculate the minimum value YTOP and maximum value YDown of any X value in a circle using method B.

[0122] Figure 8 A graphical illustration is provided to calculate the minimum value YTOP and maximum value YDown of an ellipse for any X value using method B.

[0123] For the cases where the region of interest is a point, line segment, arc, rectangle, oblique rectangle, circle, ellipse, annulus, or non-self-intersecting polygon, these regions of interest can all be classified as regular shapes. The following is a summary of the extraction method for regions of interest with regular shapes according to this invention:

[0124] Step 1: Perform geometric analysis on the region of interest to obtain its geometric shape representation parameters;

[0125] Step 2: Calculate the upper and lower boundaries of the region of interest under different shapes;

[0126] Step 3: Starting from the smallest Y value at the upper boundary, calculate the leftmost value XLeft and the rightmost value XRight of the special shape boundary as the Y value increases in units of 1. The run ends when the Y value increases to the largest Y value at the lower boundary and is stored.

[0127] Step 4: Using TBB operations, combined with the calculation results from Steps 1 to 3, parallel operations are performed to access the run length to obtain the image pixel values ​​of the source image. This takes advantage of the multi-core CPU, which originally could only process image data in a single line, but now processes multiple lines simultaneously, making it stable and reliable.

[0128] Step two can be any shape of region of interest, step three has two methods, A and B, and step four requires choosing whether to use TBB technology based on the size of the image.

[0129] For a 3200*10000 grayscale image, the region of interest (ROI) is a ring with its center at (1600, 5000). The inner radius of the ring is 800, the outer radius is 5000, the starting angle is 0, and the scanning angle is 360. Traditionally, the ROI is stored by creating a black-and-white image, which takes 23.65ms. This algorithm stores the ROI in 5.2ms. The traditional method consumes 3200*10000*1 byte of memory, while this method consumes only 11160*3*4 bytes, reducing intermediate memory consumption by approximately 238 times.

[0130] For a 3200*10000 grayscale image, the region of interest (ROI) is a polygon with vertex information of (0, 0), (3100, 100), (3200, 10000), and (100, 9900). Traditionally, the ROI is stored by creating a black-and-white image, which takes 22.84ms. This algorithm stores the ROI in 5.38ms. The traditional method consumes 3200*10000*1 byte of memory, while this method consumes 10000*3*4 bytes, reducing intermediate memory usage by approximately 267 times. The extracted scan thread encoding array is attached. Figure 9 As shown.

[0131] Since irregular shapes can actually be broken down into several regular shapes, this invention utilizes Boolean operations to quickly extract regions of interest (ROIs) when the region of interest is irregular in shape. Figure 11 As shown, the details are as follows:

[0132] The target image includes k regions of interest (ROIs), with masking regions between adjacent ROIs. The parallel image processing based on TBB operations is performed on the shape parameters, boundary information, and scan line run-length encoding of the ROIs to extract image data about the ROIs. Specifically, this includes:

[0133] The scanline run-length codes of k regions of interest are combined using Boolean operations to obtain the total scanline run-length codes of the k regions of interest.

[0134] Parallel image processing based on TBB operation is performed on the shape parameters, boundary information, and total scan line run-length encoding of k regions of interest to extract image data about the k regions of interest.

[0135] Preferably, the step of performing a union operation on the scan line run-length encodings of the k regions of interest using Boolean operations to obtain the total scan line run-length encodings of the k regions of interest specifically includes:

[0136] Perform quick sorting on the k run-length encodings based on the row, start column, and / or end column, so that the order of each run-length encoding based on the row, start column, and / or end column is from smallest to largest;

[0137] The TBB tool is used to perform a single-row merge Boolean operation on each sorted run-length code to obtain the Boolean operation result for each row of each run-length code.

[0138] The Boolean operation results of the same rows of all run-length codes are merged to obtain the total scan-line run-length code for k regions of interest.

[0139] Preferably, the step of performing single-row merge Boolean operations on each sorted run-length encoding using the TBB tool to obtain the Boolean operation results for each row of each run-length encoding is as follows:

[0140] And algorithms (such as) Figure 12 (as shown)

[0141] Create stack in and stack out;

[0142] When stack in has only one element, check if the element entered from stack out is paired with the element in stack in. If they are paired, save it as a Boolean operation result. If not, pair the element entered from stack out with the element in stack in and discard it.

[0143] Remove the paired elements from the top of the stack in and the top of the stack out, respectively;

[0144] Intersection algorithm (e.g.) Figure 13 (as shown)

[0145] Create stack in and stack out;

[0146] For the sum of k scan lines, when stack in has k elements, determine whether the element entering stack out is paired with the element in stack in. If so, save it as the Boolean operation result. If not, pair the element entering stack out with the element in stack in and discard it.

[0147] Subtraction algorithms (such as) Figure 14 (as shown)

[0148] Create stack in and stack out;

[0149] When stack in of A is paired with the next element and stack out of A is paired with the previous element, then the element between stack in of B and stack out of B stops pairing and is cleared.

[0150] A XOR B algorithm (e.g.) Figure 15 (as shown)

[0151] Create stack in and stack out;

[0152] Pair the elements in the stack with the elements out of the stack in order.

[0153] For two runs of 15,000 rows each, the time taken for the union operation is 0.508ms; the time taken for the intersection operation is 0.525ms; the time taken for the XOR operation is 0.566ms; and the time taken for the subtraction operation is 0.52ms.

[0154] For merging multiple runs, the run information consists of three runs of 15,000 rows each. The previous method involved sorting the runs to be merged, which took 11.21ms. The new method uses a run cursor to merge the runs, which takes 1.15ms.

[0155] Combination Figures 1-15 This invention obtains the shape parameters, boundary information, and scan line run length encoding of the region of interest in the image coordinates, and then performs parallel image processing based on TBB operation on the shape parameters, boundary information, and scan line run length encoding of the region of interest to extract image data about the region of interest. It utilizes the boundary information of the region of interest and combines scan line characteristics, mathematical operations, and parallel operations to extract the region of interest in the target image, which is fast, stable, and reliable.

[0156] The above-disclosed embodiments are merely preferred embodiments of the present invention and should not be construed as limiting the scope of the present invention. Therefore, any equivalent variations made in accordance with the claims of the present invention are still within the scope of the present invention.

Claims

1. A method for rapid extraction of regions of interest, suitable for rapidly extracting regions of interest from target images, characterized in that, The method for rapid extraction of the region of interest includes the following steps: Image analysis is performed on the region of interest (ROI) of the target image to obtain the shape parameters of the ROI; Calculate the boundary information of the region of interest, where the boundary information is the upper and lower boundary positions or the left and right boundary positions of the region of interest; Calculate the scanline run-length encoding of the region of interest in image coordinates; Parallel image processing based on TBB operation is performed on the shape parameters, boundary information, and scan line run-length encoding of the region of interest to extract image data about the region of interest; The target image includes k regions of interest (ROIs), with masking regions between adjacent ROIs. The parallel image processing based on TBB operations is performed on the shape parameters, boundary information, and scan line run-length encoding of the ROIs to extract image data about the ROIs. Specifically, this includes: The scanline run-length codes of k regions of interest are combined using Boolean operations to obtain the total scanline run-length codes of the k regions of interest. Parallel image processing based on TBB operation is performed on the shape parameters, boundary information, and total scan line run-length encoding of k regions of interest to extract image data about the k regions of interest.

2. The method for rapid extraction of regions of interest as described in claim 1, characterized in that, The shape of the region of interest can be a point, line segment, arc, rectangle, oblique rectangle, circle, ellipse, annulus, or non-self-intersecting polygon. When the region of interest is a point, the shape parameters include the coordinates of the point; When the region of interest is a line segment, the shape parameters include the coordinates of the two endpoints of the line segment; When the region of interest is an arc, the shape parameters include the radius of the arc, the starting angle, and the scanning angle; When the region of interest is a rectangle, the shape parameters include the coordinates of the center point of the rectangle, the length of the major axis, and the length of the minor axis; When the region of interest is a slanted rectangle, the shape parameters include the coordinates of the center point of the slanted rectangle, the rotation angle, the length of the major axis, and the length of the minor axis. When the region of interest is circular, the shape parameters include the coordinates of the circle's center and its radius; When the region of interest is elliptical, the shape parameters include the coordinates of the center point of the ellipse, the angle, the length of the major axis, and the length of the minor axis. When the region of interest is an annular ring, the shape parameters include the coordinates of the center of the annular ring, the inner radius, the outer radius, the starting angle, and the scanning angle. When the region of interest is a non-self-intersecting polygon, the shape parameters include the number of vertices of the polygon and the coordinates of each vertex.

3. The method for rapid extraction of regions of interest as described in claim 2, characterized in that, In image coordinates, for the boundary information representing the upper and lower boundary positions of the region of interest, the scan line run-length encoding of the region of interest in image coordinates is calculated using method A; for the boundary information representing the left and right boundary positions of the region of interest, the scan line run-length encoding of the region of interest in image coordinates is calculated using method B. Specifically, method A includes: Starting from the smallest Y value corresponding to the upper boundary Y-axis, the Y value is increased sequentially with a preset step size to the largest Y value corresponding to the lower boundary Y-axis. The leftmost value XLeft and the rightmost value XRight corresponding to each Y value are calculated to obtain the scan line run-length encoding of the region of interest in the image coordinates. Method B specifically includes: Starting from the minimum X value corresponding to the left boundary on the X-axis, the X value is incremented sequentially with a preset step size to the maximum X value corresponding to the right boundary on the X-axis. The minimum value YTop and the maximum value YDowm corresponding to each X value are calculated to obtain the scan line run-length encoding of the region of interest in the image coordinates.

4. The method for rapid extraction of regions of interest as described in claim 3, characterized in that, When the region of interest is a slanted rectangle, the boundary information refers to the upper and lower boundary positions of the region of interest. The scan line run-length encoding of the region of interest in image coordinates is calculated using method A, and the specific steps are as follows: First, perform quicksort on the vertices and label them as topLeft, topRight, bottomLeft, and bottomRight; Starting from the smallest Y value at the upper boundary, calculate the leftmost XLeft and rightmost XRight of the region of interest boundary as the Y value increases in units of 1. The calculation method is as follows: Substitute the Y value into the equation of the straight line on the left and right boundaries of the known distribution: Y = kX + b, and find the leftmost value XLeft and the rightmost value XRight of the left and right intersection points.

5. The method for rapid extraction of regions of interest as described in claim 3, characterized in that, When the region of interest is circular, the boundary information refers to the upper and lower boundary positions of the region of interest. The scan line run-length encoding of the region of interest in image coordinates is calculated using method A, and the specific steps are as follows: When the region of interest is circular, starting from the smallest Y value at the upper boundary, calculate the leftmost XLeft and rightmost XRight of the region of interest boundary as the Y value increases in units of 1. The calculation method is as follows: First, calculate the difference dy between the current Y value and the Y coordinate of the circle center. Given dy, the radius can be calculated using the circle equation: x^2 + y^2 = r^2. Then subtract dx from the X coordinate of the center to obtain the current Y value XLeft; Then add dx to the X coordinate of the center of the circle to get the current Y value XRight.

6. The method for rapid extraction of regions of interest as described in claim 3, characterized in that, When the region of interest is elliptical, the boundary information refers to the upper and lower boundary positions of the region of interest. The scan line run-length encoding of the region of interest in image coordinates is calculated using method A, and the specific steps are as follows: When the region of interest is elliptical, starting from the smallest Y value at the upper boundary, calculate the leftmost XLeft and rightmost XRight of the region of interest boundary as the Y value increases in units of 1. The calculation method is as follows: First, substitute Y into y to solve for the two x's in the equation of the ellipse: ; Then, subtracting dx from the X coordinate of the center of the circle gives the current Y value, XLeft. Adding dx to the X coordinate of the center of the circle gives the current Y value, XRight.

7. The method for rapid extraction of regions of interest as described in claim 3, characterized in that, When the region of interest is a non-self-intersecting polygon, starting from the smallest Y value on the upper boundary, calculate the intersection points of the scan line with any edge of the polygon as the Y value increases by 1. Store the number of intersection points of the scan line while ensuring that the intersection points are internal intersections. Similarly, the calculated number of intersection points is divided into odd and even numbers. For the case of an even number, use pairwise combinations of XLEFT and XRight to store them sequentially. For the case of an odd number, it is necessary to judge the intersection point situation to combine XLEFT and XRight.

8. The method for rapid extraction of regions of interest as described in claim 1, characterized in that, The step of performing a union operation on the scan line run-length encodings of k regions of interest using Boolean operations to obtain the total scan line run-length encodings of the k regions of interest specifically includes: Perform quick sorting on the k run-length encodings based on the row, start column, and / or end column, so that the order of each run-length encoding based on the row, start column, and / or end column is from smallest to largest; The TBB tool is used to perform a single-row merge Boolean operation on each sorted run-length code to obtain the Boolean operation result for each row of each run-length code. The Boolean operation results of the same rows of all run-length codes are merged to obtain the total scan-line run-length code for k regions of interest.

9. The method for rapid extraction of regions of interest as described in claim 8, characterized in that, The TBB tool is used to perform single-row merge Boolean operations on each sorted run-length encoding row by row to obtain the Boolean operation results for each row of each run-length encoding. The union, intersection, subtraction, and XOR algorithms for single-row run-length encoding are as follows: Union Algorithm: Create stack in and stack out; When stack in has only one element, check if the element entered from stack out is paired with the element in stack in. If they are paired, save it as a Boolean operation result. If not, pair the element entered from stack out with the element in stack in and discard it. Remove the paired elements from the top of the stack in and the top of the stack out, respectively; Intersection algorithm: Create stack in and stack out; For the sum of k scan lines, when stack in has k elements, determine whether the element entering stack out is paired with the element in stack in. If so, save it as the Boolean operation result. If not, pair the element entering stack out with the element in stack in and discard it. Subtraction algorithm: Create stack in and stack out; When stack in of A is paired with the next element and stack out of A is paired with the previous element, then the element between stack in of B and stack out of B stops pairing and is cleared. A XOR B algorithm: Create stack in and stack out; Pair the elements in the stack with the elements out of the stack in order.

Citation Information

Patent Citations

  • Multidimensional characteristic extraction method and device based on connected domain analysis

    CN106529550A

  • Algorithm for quickly processing region-of-interest image

    CN110598694A