CN116012573A - Method for rapidly extracting region of interest - Google Patents

Method for rapidly extracting region of interest Download PDF

Info

Publication number
CN116012573A
CN116012573A CN202211405396.9A CN202211405396A CN116012573A CN 116012573 A CN116012573 A CN 116012573A CN 202211405396 A CN202211405396 A CN 202211405396A CN 116012573 A CN116012573 A CN 116012573A
Authority
CN
China
Prior art keywords
interest
region
value
stack
boundary
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211405396.9A
Other languages
Chinese (zh)
Inventor
潘威
刘帆
毛善
曹玲
卢盛林
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong OPT Machine Vision Co Ltd
Original Assignee
Guangdong OPT Machine Vision Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong OPT Machine Vision Co Ltd filed Critical Guangdong OPT Machine Vision Co Ltd
Priority to CN202211405396.9A priority Critical patent/CN116012573A/en
Publication of CN116012573A publication Critical patent/CN116012573A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Image Analysis (AREA)

Abstract

The invention discloses a method for quickly extracting an interested region, which is suitable for quickly extracting the interested region of a target picture, and comprises the following steps: s1, performing image analysis on an interested region of a target picture to obtain shape parameters of the interested region; s2, calculating boundary information of the region of interest, wherein the boundary information is upper and lower boundary positions or left and right boundary positions of the region of interest; s3, calculating scanning line run-length codes of the region of interest in image coordinates; s4, performing TBB operation-based parallel image processing on the shape parameters, the boundary information and the scanning line run-length codes of the region of interest, and extracting to obtain image data about the region of interest; the invention utilizes the boundary information of the region of interest and combines the characteristics of the scanning lines, mathematical operation and parallel operation to extract the region of interest in the target image, thereby being fast, stable and reliable.

Description

Method for rapidly extracting region of interest
Technical Field
The invention relates to the technical field of image processing, in particular to a method for rapidly extracting a region of interest.
Background
Machine vision is the measurement and judgment of using a machine instead of a human eye. With the rapid development of the microelectronics industry, a machine vision system with high resolution and high processing speed is continuously produced, which puts new requirements on the speed, precision, stability and the like of an image processing algorithm.
The processing of the region of interest image in machine vision is a common and widely applied image processing mode, and only a part of the region of interest in millions of to tens of millions of pixels is taken for image processing, so that the processing efficiency can be remarkably improved.
In the prior art, only the region of interest is processed in one image, other regions keep source pixels unchanged, and the main stream algorithm steps are as follows:
1. generating a black-and-white mask image capable of distinguishing between the interested region and the non-interested region;
2. generating an image A with unchanged source pixels and black regions of interest according to the mask image 1 (the non-regions of interest are white and the mask image 1 with black regions of interest) by the source image and the mask image 1 and operation;
3. generating an image B with a black non-region of interest as a result by performing AND operation on the source image processing result and the mask image 2 according to the mask image 2 (the non-region of interest is black and the region of interest is white mask image 2);
4. the image A and the image B are subjected to OR operation, so that an image which only processes the region of interest and keeps the source pixels unchanged in other regions can be obtained.
However, in the execution process of the algorithm, the construction and operation of the mask image can enable the non-interested area to participate in the operation, so that the calculation time is long due to the large calculation amount, and the operation efficiency is reduced.
Therefore, a rapid extraction method of the region of interest is needed to solve the above problems.
Disclosure of Invention
The invention aims to provide a rapid extraction method of an interested region, which utilizes boundary information of the interested region and combines scanning line characteristics, mathematical operation and parallel operation to extract the interested region in a target image, thereby being rapid, stable and reliable.
In order to achieve the above object, the present invention discloses a method for rapidly extracting a region of interest, which is suitable for rapidly extracting a region of interest of a target picture, the method for rapidly extracting a region of interest comprising the steps of:
s1, performing image analysis on an interested region of a target picture to obtain shape parameters of the interested region;
s2, calculating boundary information of the region of interest, wherein the boundary information is upper and lower boundary positions or left and right boundary positions of the region of interest;
s3, calculating scanning line run-length codes of the region of interest in image coordinates;
s4, performing parallel image processing based on TBB operation on the shape parameter, boundary information and scanning line run-length coding of the region of interest, and extracting to obtain image data about the region of interest.
Preferably, the shape of the region of interest is a point, a line segment, an arc, a rectangle, an inclined rectangle, a circle, an ellipse, a torus, or a non-self-intersecting polygon;
when the region of interest is a point, the shape parameter includes coordinates of the point;
when the region of interest is a line segment, the shape parameter comprises coordinates of two endpoints of the line segment;
when the region of interest is an arc, the shape parameters include a radius, a starting angle, and a scanning angle of the arc;
when the region of interest is rectangular, the shape parameters include center point coordinates, long axis length and short axis length of the rectangle;
when the region of interest is an oblique rectangle, the shape parameters include center point coordinates, rotation angle, major axis length and minor axis length of the oblique rectangle;
when the region of interest is a circle, the shape parameters include the center coordinates and the radius of the circle;
when the region of interest is elliptical, the shape parameters include center point coordinates, angle, major axis length, and minor axis length of the elliptical;
when the region of interest is a circular ring, the shape parameters comprise the center coordinates of the circular ring, the radius of the inner ring, the radius of the outer ring, the initial 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 coordinates of the respective vertices.
Preferably, in the image coordinates, for the boundary information being the upper and lower boundary positions of the region of interest, the scan line run code of the region of interest in the image coordinates is calculated by a method a, and for the boundary information being the left and right boundary positions of the region of interest, the scan line run code of the region of interest in the image coordinates is calculated by a method B, wherein the method a specifically includes:
starting from the Y value with the minimum Y axis corresponding to the upper boundary, sequentially increasing to the Y value with the maximum Y axis corresponding to the lower boundary by a preset step length, and respectively calculating the leftmost value XLeft and the rightmost value XRight corresponding to each Y value to obtain the scanning line run code of the region of interest in the image coordinates;
the method B specifically comprises the following steps:
starting from the X value with the minimum X axis corresponding to the left boundary, sequentially increasing to the X value with the maximum X axis corresponding to the right boundary by a preset step length, and respectively calculating the minimum value YTop and the maximum value YDOWm corresponding to each X value to obtain the scanning line run code of the region of interest in the image coordinates.
Preferably, when the region of interest is a diagonal rectangle, the boundary information is the upper and lower boundary positions of the region of interest, and the scan line run code of the region of interest in the image coordinates is calculated by the method a, which comprises the following specific steps:
quick sorting is carried out on the vertexes, and the vertexes are marked as topLeft, topRight, bottomLeft, bottomRight;
starting from the Y value with the minimum upper boundary, calculating the leftmost value XLeft and the rightmost value XRight of the boundary of the region of interest when the Y value is increased by taking 1 as a unit, and as shown in FIG. 2, the calculation method is as follows:
substituting the Y value into the linear equation for the left and right boundaries of the known distribution: y=kx+b, and the leftmost value XLeft and the rightmost value XRight of the left-right intersection point are obtained.
Preferably, when the region of interest is circular, the boundary information is the upper and lower boundary positions of the region of interest, and the scan line run code of the region of interest in the image coordinates is calculated by the method a, which comprises the following specific steps:
when the region of interest is circular, starting from the Y value with the smallest upper boundary, calculating the leftmost value XLeft and the rightmost value XRight of the region of interest boundary when the Y value increases in units of 1, as shown in fig. 3, the calculation method is as follows:
calculating a difference value dy of a current Y value and a center Y coordinate, knowing dy, and calculating a radius according to a circle equation: x 2+y2=r2, and dx is obtained;
then subtracting dx from the X coordinate of the center coordinate to obtain XLeft of the current Y value;
and adding dx to the X coordinate of the center coordinate to obtain the XRight of the current Y value.
Preferably, when the region of interest is elliptical, the boundary information is the upper and lower boundary positions of the region of interest, and the scan line run code of the region of interest in the image coordinates is calculated by the method a, which comprises the following specific steps:
when the region of interest is elliptical, starting from the Y value with the minimum upper boundary, calculating the leftmost value XLeft and the rightmost value XRight of the boundary of the region of interest when the Y value increases by 1, wherein the calculation method comprises the following steps:
substituting Y into Y, solving two x of elliptic equations:
Figure BDA0003936859240000041
then subtracting dx from the X coordinate of the center coordinate to obtain XLeft of the current Y value;
and adding dx to the X coordinate of the center coordinate to obtain the XRight of the current Y value.
Preferably, when the region of interest is a polygon that is not self-intersecting, starting from the Y value with the smallest upper boundary, calculating the intersection point of the scan line and any side of the polygon when the Y value increases in 1 unit, and storing the number of intersection points of the scan line under the condition that the intersection point is internal intersection, where the number of calculated intersection points is also divided into an odd number and an even number, where the even number of intersection points can be sequentially stored by two-by-two combination XLeft and XRight, and the odd number needs to judge the condition of the intersection point to combine XLeft and XRight.
Preferably, the target picture includes k regions of interest, and a shielding region is disposed between adjacent regions of interest, and the parallel image processing based on TBB operation is performed on the shape parameter, the boundary information and the scan line run-length code of the regions of interest, so as to extract image data about the regions of interest, which specifically includes:
combining the scan line run codes of the k regions of interest by Boolean operation to obtain total scan line run codes of the k regions of interest;
and performing parallel image processing based on TBB operation on the shape parameters, boundary information and total scanning line run-length codes of the k regions of interest, and extracting to obtain image data of the k regions of interest.
Preferably, the combining operation is performed on the scan line run codes of the k regions of interest by boolean operation to obtain a total scan line run code of the k regions of interest, which specifically includes:
respectively carrying out quick sequencing on the k run codes based on the row, the starting point column and/or the end point column, so that the arrangement sequence of each run code based on the row, the starting point column and/or the end point column is from small to large;
respectively carrying out single-row merging Boolean operation on each sequenced run code by a TBB tool, so as to obtain a Boolean operation result of each row of each run code;
and merging the Boolean operation results of the same row of all the run codes to obtain the total scan line run codes of k regions of interest.
Preferably, the TBB tool respectively performs a single-row merging boolean operation on each sequenced run code, so as to obtain a single-row run code merging algorithm, an intersection algorithm, a subtraction algorithm and an exclusive-or algorithm in the boolean operation result of each row of each run code, where the single-row run code merging algorithm, the intersection algorithm, the subtraction algorithm and the exclusive-or algorithm are respectively as follows:
and the algorithm:
building a stack in and a stack out;
when the stack in has only one element, judging whether the element entering the stack out is paired with the element of the stack in, if so, storing the result as a Boolean operation result, and if not, pairing the element entering the stack out with the element of the stack in and discarding the paired element;
clearing paired elements from the top of the stack in and the top of the stack out respectively;
and (3) an intersection algorithm:
building a stack in and a stack out;
for the addition of k scanning lines, when the stack in has k elements, judging whether the element entering the stack out is paired with the element of the stack in, if so, storing the result as a Boolean operation result, and if not, pairing the element entering the stack out with the element of the stack in and discarding the paired element;
subtraction algorithm:
building a stack in and a stack out;
when the stack in of A is paired with the latter element and the stack out of A is paired with the former element, the elements in the middle of the stack in of B and the stack out of B are stopped to be paired and cleared;
a exclusive or B algorithm:
building a stack in and a stack out;
and pairing the elements of the stack in and the stack out in pairs in sequence.
Compared with the prior art, the method and the device have the advantages that the shape parameters, the boundary information and the scanning line run code of the region of interest in the image coordinates are obtained, the shape parameters, the boundary information and the scanning line run code of the region of interest are subjected to TBB operation-based parallel image processing, the image data about the region of interest are extracted, the boundary information of the region of interest is utilized, and the region of interest in the target image is extracted by combining the characteristics of the scanning line, mathematical operation and parallel operation, so that the method and the device are rapid, stable and reliable.
Drawings
FIG. 1 is a flow chart of a region of interest rapid extraction method of the present invention;
FIG. 2 is a graphical illustration of the leftmost value XLeft and the rightmost value XRight at any Y value in a skewed rectangle calculated by method A;
FIG. 3 is a graphical illustration of the calculation of the leftmost value XLeft and the rightmost value XRight for any Y value in a circle by method A;
FIG. 4 is a graphical illustration of the leftmost value XLeft and rightmost value XRight at any Y value in an oval calculated by method A;
FIG. 5 is a graphical illustration of the leftmost value XLeft and rightmost value XRight at any Y value in a line segment calculated by method A;
FIG. 6 is a graphical illustration of the calculation of the minimum value YTOP and the maximum value YDOWNN at any X value in a sloped rectangle by method B;
FIG. 7 is a graphical illustration of the calculation of the minimum value YTOP and the maximum value YDOWNN at any X value in a circle by method B;
FIG. 8 is a graphical illustration of the calculation of the minimum value YTOP and the maximum value YDOWNN for any X value in an ellipse by method B;
fig. 9 is a schematic diagram of a scan thread encoding array for 3200 x 10000 gray scale image extraction according to the present invention;
FIG. 10 shows a run of 3 15000 lines for the run information according to the present invention
FIG. 11 is a schematic illustration of the extraction of irregular shapes for a region of interest in accordance with the present invention;
FIG. 12 is a schematic diagram of the operational graph of the union algorithm;
FIG. 13 is a schematic diagram of the operational graph of the algorithm;
FIG. 14 is a schematic diagram of the subtraction algorithm;
fig. 15 is a schematic diagram of an operation pattern of the exclusive or algorithm.
Detailed Description
In order to describe the technical content, the constructional features, the achieved objects and effects of the present invention in detail, the following description is made in connection with the embodiments and the accompanying drawings.
Referring to fig. 1 to 15, the method for quickly extracting an area of interest in the present embodiment is suitable for quickly extracting an area of interest in a target picture, and includes the following steps:
s1, performing image analysis on an interested region of a target picture to obtain shape parameters of the interested region;
s2, calculating boundary information of the region of interest, wherein the boundary information is upper and lower boundary positions or left and right boundary positions of the region of interest;
s3, calculating scanning line run-length codes of the region of interest in image coordinates;
s4, performing parallel image processing based on TBB operation on the shape parameter, boundary information and scanning line run-length coding of the region of interest, and extracting to obtain image data about the region of interest.
Preferably, the shape of the region of interest is a point, a line segment, an arc, a rectangle, an inclined rectangle, a circle, an ellipse, a torus, or a non-self-intersecting polygon;
when the region of interest is a point, the shape parameter includes coordinates of the point;
when the region of interest is a line segment, the shape parameter comprises coordinates of two endpoints of the line segment;
when the region of interest is an arc, the shape parameters include a radius, a starting angle, and a scanning angle of the arc;
when the region of interest is rectangular, the shape parameters include center point coordinates, long axis length and short axis length of the rectangle;
when the region of interest is an oblique rectangle, the shape parameters include center point coordinates, rotation angle, major axis length and minor axis length of the oblique rectangle;
when the region of interest is a circle, the shape parameters include the center coordinates and the radius of the circle;
when the region of interest is elliptical, the shape parameters include center point coordinates, angle, major axis length, and minor axis length of the elliptical;
when the region of interest is a circular ring, the shape parameters comprise the center coordinates of the circular ring, the radius of the inner ring, the radius of the outer ring, the initial 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 coordinates of the respective vertices.
Preferably, in the image coordinates, for the boundary information being the upper and lower boundary positions of the region of interest, the scan line run code of the region of interest in the image coordinates is calculated by a method a, and for the boundary information being the left and right boundary positions of the region of interest, the scan line run code of the region of interest in the image coordinates is calculated by a method B, wherein the method a specifically includes:
starting from the Y value with the minimum Y axis corresponding to the upper boundary, sequentially increasing to the Y value with the maximum Y axis corresponding to the lower boundary by a preset step length, and respectively calculating the leftmost value XLeft and the rightmost value XRight corresponding to each Y value to obtain the scanning line run code of the region of interest in the image coordinates;
the method B specifically comprises the following steps:
starting from the X value with the minimum X axis corresponding to the left boundary, sequentially increasing to the X value with the maximum X axis corresponding to the right boundary by a preset step length, and respectively calculating the minimum value YTop and the maximum value YDOWm corresponding to each X value to obtain the scanning line run code of the region of interest in the image coordinates.
Preferably, when the region of interest is a diagonal rectangle, the boundary information is the upper and lower boundary positions of the region of interest, and the scan line run code of the region of interest in the image coordinates is calculated by the method a, which comprises the following specific steps:
quick sorting is carried out on the vertexes, and the vertexes are marked as topLeft, topRight, bottomLeft, bottomRight;
then, starting from the Y value with the minimum upper boundary, calculating the leftmost value XLeft and the rightmost value XRight of the boundary of the region of interest when the Y value is increased by taking 1 as a unit, wherein the calculation method comprises the following steps:
substituting the Y value into the linear equation for the left and right boundaries of the known distribution: y=kx+b, and the leftmost value XLeft and the rightmost value XRight of the left-right intersection point are obtained.
Preferably, when the region of interest is circular, the boundary information is the upper and lower boundary positions of the region of interest, and the scan line run code of the region of interest in the image coordinates is calculated by the method a, which comprises the following specific steps:
when the region of interest is circular, starting from the Y value with the minimum upper boundary, calculating the leftmost value XLeft and the rightmost value XRight of the boundary of the region of interest when the Y value increases by 1, wherein the calculation method comprises the following steps:
calculating a difference value dy of a current Y value and a center Y coordinate, knowing dy, and calculating a radius according to a circle equation: x 2+y2=r2, and dx is obtained;
then subtracting dx from the X coordinate of the center coordinate to obtain XLeft of the current Y value;
and adding dx to the X coordinate of the center coordinate to obtain the XRight of the current Y value.
Preferably, when the region of interest is elliptical, the boundary information is the upper and lower boundary positions of the region of interest, and the scan line run code of the region of interest in the image coordinates is calculated by the method a, which comprises the following specific steps:
when the region of interest is elliptical, starting from the Y value with the minimum upper boundary, calculating the leftmost value XLeft and the rightmost value XRight of the boundary of the region of interest when the Y value increases by 1, wherein the calculation method comprises the following steps:
substituting Y into Y, solving two x of elliptic equations:
Figure BDA0003936859240000101
then subtracting dx from the X coordinate of the center coordinate to obtain XLeft of the current Y value;
and adding dx to the X coordinate of the center coordinate to obtain the XRight of the current Y value.
Preferably, when the region of interest is a polygon that is not self-intersecting, starting from the Y value with the smallest upper boundary, calculating the intersection point of the scan line and any side of the polygon when the Y value increases in 1 unit, and storing the number of intersection points of the scan line under the condition that the intersection point is internal intersection, where the number of calculated intersection points is also divided into an odd number and an even number, where the even number of intersection points can be sequentially stored by two-by-two combination XLeft and XRight, and the odd number needs to judge the condition of the intersection point to combine XLeft and XRight.
In addition, fig. 5 shows a graphical illustration of the calculation of the minimum value YTOP and the maximum value YDown at any X value in the diagonal rectangle by method B.
Fig. 6 presents a graphical illustration of the calculation of the minimum value YTOP and the maximum value YDown at any X value in the circle by method B.
Fig. 7 shows a graphical illustration of the calculation of the minimum value YTOP and the maximum value YDown at any X value in the ellipse by method B.
For the case that the region of interest is a point, a line segment, an arc, a rectangle, an inclined rectangle, a circle, an ellipse, a torus or a non-self-intersecting polygon, the region of interest can be classified into a regular shape, and the method for extracting the shape of the region of interest into the regular shape is summarized below:
step one, carrying out geometric analysis on an interested region to obtain a geometric shape characterization parameter of the interested region;
step two, calculating the upper and lower boundaries of the region of interest under different shapes;
step three, starting from the Y value with the minimum upper boundary, calculating the leftmost value XLeft and the rightmost value XRight of the boundary of the special shape when the Y value is increased by taking 1 as a unit, ending and storing the run when the Y value is increased to the Y value with the maximum lower boundary;
and fourthly, performing parallel operation access run by utilizing TBB operation and combining the calculation results of the first step to the third step to acquire the image pixel value of the source image, wherein the image data which is originally only processed in a single way is changed into the image data which is processed in multiple lines simultaneously by utilizing the advantage of CPU multiple cores, so that the method is stable and reliable.
The second step can be a region of interest with any shape, the third step has two methods of A/B, and the fourth step needs to select whether to use TBB technology according to the size of the image.
For a 3200 x 10000 gray scale image, the region of interest is a circle, the center (1600, 5000) of the circle, the inner radius of the circle is 800, the outer radius is 5000, the starting angle is 0, and the scan angle is 360. The traditional method is to complete the storage of the region of interest by creating a black-and-white graph, the traditional method takes 23.65ms, the algorithm takes 5.2ms to complete the storage of the region of interest, the traditional method has memory consumption of 3200 x 10000 x 1 byte, the traditional method has memory consumption of 11160 x 3 x 4 bytes, and the middle memory consumption is reduced by about 238 times.
For a gray image of 3200×10000, the region of interest is a polygon, and vertex information of the polygon is (0, 0), (3100, 100), (3200, 10000), (100, 9900). The traditional method is to complete the storage of the region of interest by creating a black-and-white graph, the traditional method takes 22.84ms, the algorithm takes 5.38ms to complete the storage of the region of interest, the traditional method consumes 3200 x 10000 x 1 byte, the method is 10000 x 3 x 4 bytes, the intermediate memory is reduced by about 267 times, and the extracted scanning thread coding array is shown in fig. 9.
Because the irregular shape can be practically split into a plurality of regular shapes, the method utilizes a Boolean algorithm to rapidly extract the region of interest according to the irregular shape of the region of interest, as shown in fig. 11, specifically as follows:
the target picture comprises k regions of interest, shielding regions are arranged between adjacent regions of interest, the parallel image processing based on TBB operation is carried out on the shape parameters, boundary information and scanning line run-length coding of the regions of interest, and image data about the regions of interest is extracted, and the method specifically comprises the following steps:
combining the scan line run codes of the k regions of interest by Boolean operation to obtain total scan line run codes of the k regions of interest;
and performing parallel image processing based on TBB operation on the shape parameters, boundary information and total scanning line run-length codes of the k regions of interest, and extracting to obtain image data of the k regions of interest.
Preferably, the combining operation is performed on the scan line run codes of the k regions of interest by boolean operation to obtain a total scan line run code of the k regions of interest, which specifically includes:
respectively carrying out quick sequencing on the k run codes based on the row, the starting point column and/or the end point column, so that the arrangement sequence of each run code based on the row, the starting point column and/or the end point column is from small to large;
respectively carrying out single-row merging Boolean operation on each sequenced run code by a TBB tool, so as to obtain a Boolean operation result of each row of each run code;
and merging the Boolean operation results of the same row of all the run codes to obtain the total scan line run codes of k regions of interest.
Preferably, the TBB tool respectively performs a single-row merging boolean operation on each sequenced run code, so as to obtain a single-row run code merging algorithm, an intersection algorithm, a subtraction algorithm and an exclusive-or algorithm in the boolean operation result of each row of each run code, where the single-row run code merging algorithm, the intersection algorithm, the subtraction algorithm and the exclusive-or algorithm are respectively as follows:
and algorithm (as shown in fig. 12):
building a stack in and a stack out;
when the stack in has only one element, judging whether the element entering the stack out is paired with the element of the stack in, if so, storing the result as a Boolean operation result, and if not, pairing the element entering the stack out with the element of the stack in and discarding the paired element;
clearing paired elements from the top of the stack in and the top of the stack out respectively;
intersection algorithm (as shown in fig. 13):
building a stack in and a stack out;
for the addition of k scanning lines, when the stack in has k elements, judging whether the element entering the stack out is paired with the element of the stack in, if so, storing the result as a Boolean operation result, and if not, pairing the element entering the stack out with the element of the stack in and discarding the paired element;
subtraction algorithm (as shown in fig. 14):
building a stack in and a stack out;
when the stack in of A is paired with the latter element and the stack out of A is paired with the former element, the elements in the middle of the stack in of B and the stack out of B are stopped to be paired and cleared;
exclusive-or B algorithm (as shown in fig. 15):
building a stack in and a stack out;
and pairing the elements of the stack in and the stack out in pairs in sequence.
For two 15000 runs of information, the time taken for the merging operation is 0.508ms; the time taken for the traffic calculation is 0.525ms; the time taken to find the exclusive OR is 0.566ms; the subtraction takes 0.52ms.
For the combination of a plurality of runlengths, the runlength information is 3 runlengths of 15000 rows, the runlengths to be combined are ordered in the conventional mode, the time consumption of the conventional method is 11.21ms, and the time consumption of the new method for combining by the method of the runlength Cheng Youbiao is 1.15ms.
With reference to fig. 1-15, the method and the device acquire the shape parameter, the boundary information and the scanning line run code of the region of interest in the image coordinates, then perform parallel image processing based on TBB operation on the shape parameter, the boundary information and the scanning line run code of the region of interest, extract image data about the region of interest, and extract the region of interest in the target image by utilizing the boundary information of the region of interest and combining the characteristics of the scanning line, mathematical operation and parallel operation, thereby being fast, stable and reliable.
The foregoing description of the preferred embodiments of the present invention is not intended to limit the scope of the claims, which follow, as defined in the claims.

Claims (10)

1. The rapid extraction method of the region of interest is suitable for rapidly extracting the region of interest of the target picture and is characterized by comprising the following steps:
image analysis is carried out on an interested region of a target picture, and shape parameters of the interested region are obtained;
calculating boundary information of the region of interest, wherein the boundary information is upper and lower boundary positions or left and right boundary positions of the region of interest;
calculating the scanning line run-length coding of the region of interest in the image coordinates;
and performing parallel image processing based on TBB operation on the shape parameter, boundary information and scanning line run-length coding of the region of interest, and extracting to obtain image data about the region of interest.
2. The method of claim 1, wherein the shape of the region of interest is a point, a line segment, an arc, a rectangle, an inclined rectangle, a circle, an ellipse, a torus, or a non-self intersecting polygon;
when the region of interest is a point, the shape parameter includes coordinates of the point;
when the region of interest is a line segment, the shape parameter comprises coordinates of two endpoints of the line segment;
when the region of interest is an arc, the shape parameters include a radius, a starting angle, and a scanning angle of the arc;
when the region of interest is rectangular, the shape parameters include center point coordinates, long axis length and short axis length of the rectangle;
when the region of interest is an oblique rectangle, the shape parameters include center point coordinates, rotation angle, major axis length and minor axis length of the oblique rectangle;
when the region of interest is a circle, the shape parameters include the center coordinates and the radius of the circle;
when the region of interest is elliptical, the shape parameters include center point coordinates, angle, major axis length, and minor axis length of the elliptical;
when the region of interest is a circular ring, the shape parameters comprise the center coordinates of the circular ring, the radius of the inner ring, the radius of the outer ring, the initial 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 coordinates of the respective vertices.
3. The method for rapidly extracting a region of interest according to claim 2, wherein in image coordinates, for the boundary information being upper and lower boundary positions of the region of interest, a scan line run code of the region of interest in image coordinates is calculated by a method a, and for the boundary information being left and right boundary positions of the region of interest, a scan line run code of the region of interest in image coordinates is calculated by a method B, wherein the method a specifically comprises:
starting from the Y value with the minimum Y axis corresponding to the upper boundary, sequentially increasing to the Y value with the maximum Y axis corresponding to the lower boundary by a preset step length, and respectively calculating the leftmost value XLeft and the rightmost value XRight corresponding to each Y value to obtain the scanning line run code of the region of interest in the image coordinates;
the method B specifically comprises the following steps:
starting from the X value with the minimum X axis corresponding to the left boundary, sequentially increasing to the X value with the maximum X axis corresponding to the right boundary by a preset step length, and respectively calculating the minimum value YTop and the maximum value YDOWm corresponding to each X value to obtain the scanning line run code of the region of interest in the image coordinates.
4. A method for rapidly extracting a region of interest according to claim 3, wherein when the region of interest is a diagonal rectangle, the boundary information is the upper and lower boundary positions of the region of interest, and the scan line run code of the region of interest in the image coordinates is calculated by method a, which comprises the following steps:
quick sorting is carried out on the vertexes, and the vertexes are marked as topLeft, topRight, bottomLeft, bottomRight;
then, starting from the Y value with the minimum upper boundary, calculating the leftmost value XLeft and the rightmost value XRight of the boundary of the region of interest when the Y value is increased by taking 1 as a unit, wherein the calculation method comprises the following steps:
substituting the Y value into the linear equation for the left and right boundaries of the known distribution: y=kx+b, and the leftmost value XLeft and the rightmost value XRight of the left-right intersection point are obtained.
5. A method for rapidly extracting a region of interest according to claim 3, wherein when the region of interest is circular, the boundary information is the upper and lower boundary positions of the region of interest, and the scan line run code of the region of interest in the image coordinates is calculated by method a, which comprises the following steps:
when the region of interest is circular, starting from the Y value with the minimum upper boundary, calculating the leftmost value XLeft and the rightmost value XRight of the boundary of the region of interest when the Y value increases by 1, wherein the calculation method comprises the following steps:
calculating a difference value dy of a current Y value and a center Y coordinate, knowing dy, and calculating a radius according to a circle equation: x 2+y2=r2, and dx is obtained;
then subtracting dx from the X coordinate of the center coordinate to obtain XLeft of the current Y value;
and adding dx to the X coordinate of the center coordinate to obtain the XRight of the current Y value.
6. A method for rapidly extracting a region of interest according to claim 3, wherein when the region of interest is elliptical, the boundary information is the upper and lower boundary positions of the region of interest, and the scan line run code of the region of interest in the image coordinates is calculated by method a, which comprises the following steps:
when the region of interest is elliptical, starting from the Y value with the minimum upper boundary, calculating the leftmost value XLeft and the rightmost value XRight of the boundary of the region of interest when the Y value increases by 1, wherein the calculation method comprises the following steps:
substituting Y into Y, solving two x of elliptic equations:
Figure FDA0003936859230000031
then subtracting dx from the X coordinate of the center coordinate to obtain XLeft of the current Y value;
and adding dx to the X coordinate of the center coordinate to obtain the XRight of the current Y value.
7. The method for rapidly extracting a region of interest according to claim 3, wherein when the region of interest is a polygon which is not self-intersecting, starting from a Y value with the smallest upper boundary, calculating an intersection point of a scan line and any side of the polygon when the Y value is incremented by 1, and storing the number of intersection points of the scan line under the condition that the intersection point is an internal intersection, and equally dividing the number of the calculated intersection points into an odd number and an even number, for the case of the even number, the same can be sequentially stored by combining XLeft and XRight in pairs, and the odd number needs to judge the condition of the intersection point to combine XLeft and XRight.
8. The method for rapidly extracting a region of interest according to claim 1, wherein the target picture includes k regions of interest, and a mask region is provided between adjacent regions of interest, and the performing a TBB operation-based parallel image processing on the shape parameter, the boundary information, and the scan line run-length code of the regions of interest, and extracting image data about the regions of interest specifically includes:
combining the scan line run codes of the k regions of interest by Boolean operation to obtain total scan line run codes of the k regions of interest;
and performing parallel image processing based on TBB operation on the shape parameters, boundary information and total scanning line run-length codes of the k regions of interest, and extracting to obtain image data of the k regions of interest.
9. The method of claim 8, wherein the merging operation is performed on scan line run codes of k regions of interest by boolean operation to obtain a total scan line run code of k regions of interest, and the method specifically comprises:
respectively carrying out quick sequencing on the k run codes based on the row, the starting point column and/or the end point column, so that the arrangement sequence of each run code based on the row, the starting point column and/or the end point column is from small to large;
respectively carrying out single-row merging Boolean operation on each sequenced run code by a TBB tool, so as to obtain a Boolean operation result of each row of each run code;
and merging the Boolean operation results of the same row of all the run codes to obtain the total scan line run codes of k regions of interest.
10. The method as set forth in claim 9, wherein the TBB tool respectively encodes each ordered run, and performs a single-row merging boolean operation on a row-by-row basis to obtain a boolean operation result of each row of each run, where a single-row run-encoded merging algorithm, an intersection algorithm, a subtraction algorithm, and an exclusive-or algorithm are respectively as follows:
and the algorithm:
building a stack in and a stack out;
when the stack in has only one element, judging whether the element entering the stack out is paired with the element of the stack in, if so, storing the result as a Boolean operation result, and if not, pairing the element entering the stack out with the element of the stack in and discarding the paired element;
clearing paired elements from the top of the stack in and the top of the stack out respectively;
and (3) an intersection algorithm:
building a stack in and a stack out;
for the addition of k scanning lines, when the stack in has k elements, judging whether the element entering the stack out is paired with the element of the stack in, if so, storing the result as a Boolean operation result, and if not, pairing the element entering the stack out with the element of the stack in and discarding the paired element;
subtraction algorithm:
building a stack in and a stack out;
when the stack in of A is paired with the latter element and the stack out of A is paired with the former element, the elements in the middle of the stack in of B and the stack out of B are stopped to be paired and cleared;
a exclusive or B algorithm:
building a stack in and a stack out;
and pairing the elements of the stack in and the stack out in pairs in sequence.
CN202211405396.9A 2022-11-10 2022-11-10 Method for rapidly extracting region of interest Pending CN116012573A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211405396.9A CN116012573A (en) 2022-11-10 2022-11-10 Method for rapidly extracting region of interest

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211405396.9A CN116012573A (en) 2022-11-10 2022-11-10 Method for rapidly extracting region of interest

Publications (1)

Publication Number Publication Date
CN116012573A true CN116012573A (en) 2023-04-25

Family

ID=86034210

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211405396.9A Pending CN116012573A (en) 2022-11-10 2022-11-10 Method for rapidly extracting region of interest

Country Status (1)

Country Link
CN (1) CN116012573A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116934774A (en) * 2023-06-30 2023-10-24 安徽大学 Quick and high-precision panoramic image clipping method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116934774A (en) * 2023-06-30 2023-10-24 安徽大学 Quick and high-precision panoramic image clipping method
CN116934774B (en) * 2023-06-30 2024-03-22 安徽大学 Quick and high-precision panoramic image clipping method

Similar Documents

Publication Publication Date Title
US4908872A (en) Method and apparatus for extracting pattern contours in image processing
CN101727580B (en) Image processing apparatus, image processing unit, and image processing method
JP3706385B2 (en) Information input / output method using dot pattern
JP6493163B2 (en) Density search method and image processing apparatus
US4630308A (en) Character reader
CN108573511B (en) Point-distributed cooperative coding mark and identification and positioning method thereof
WO2017041600A1 (en) Chinese-sensitive code feature pattern detection method and system
CN106446894A (en) Method for recognizing position of spherical object based on contour
CN116012573A (en) Method for rapidly extracting region of interest
WO2021190155A1 (en) Method and apparatus for identifying spaces in text lines, electronic device and storage medium
CN114863492B (en) Method and device for repairing low-quality fingerprint image
CN110264397B (en) Method and device for extracting effective region of fisheye image
CN108073964B (en) Perspective two-dimensional code generation method and device
CN113223047A (en) FPGA-based template matching target tracking method and tracking system
US20240013417A1 (en) Method for recognizing various lines in pdf by function fitting based on desktop software
CN112733826B (en) Image processing method and device
CN110728345B (en) Identification code resisting background character interference and generation method thereof
CN114596245A (en) Image reconstruction model generation method and computer equipment
CN110598694B (en) Method for rapidly processing region-of-interest image
TWI494900B (en) Method of real time image tracking
JP2004334461A (en) Character recognition device and character recognition program
JP2789622B2 (en) Character / graphic area determination device
CN107194328B (en) Feature extraction method for circular image
Wang et al. Calligraphy image processing with stroke extraction and representation
CN118095313A (en) Dot matrix code quick decoding method based on centroid

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination