An improved RoIAlign regional feature aggregation method

By using center point alignment and bilinear interpolation calculations in the RoIAlign regional feature aggregation method, and converting floating point operations into integer operations, the problems of uneven pixel distribution and long calculation time in the existing technology are solved, and the calculation efficiency is improved. and hardware requirements.

CN109685064BInactive Publication Date: 2024-10-18HEILONGJIANG UNIVERSITY OF SCIENCE AND TECHNOLOGY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201811270899.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-10-29
Publication Date
2024-10-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing RoIAlign regional feature aggregation method leads to uneven distribution of pixels when mapping the target image and the source image, takes a long time to calculate and requires high equipment, especially in floating point operations, resulting in loss of regional information and low computational efficiency.

Method used

The center point alignment method is used to align the source image and the target image with geometric centers, and through bilinear interpolation calculations, floating point operations are converted into integer operations, and shift operations are used to reduce the amount of calculation and improve efficiency.

Benefits of technology

It achieves more uniform pixel utilization, avoids the loss of regional information, significantly reduces the amount of calculation, improves calculation efficiency, and reduces hardware requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN109685064B_ABST
    Figure CN109685064B_ABST
Patent Text Reader

Abstract

The present invention discloses an improved RoIAlign regional feature aggregation algorithm, which comprises the following steps: firstly aligning the geometric centers of a source image and a target image, and adopting an improved center point alignment as the alignment method; then performing bilinear interpolation calculation, and converting floating point operations into integer operations to improve calculation efficiency and calculation accuracy; the present invention optimizes the RoIAlign regional feature aggregation method, and overlaps the center point coordinates of the source image and the target image, so that the mapping process fully and evenly utilizes all pixels of the source image, avoids the loss of regional information caused by feature map pooling, and makes the target image interpolation effect better, and greatly reduces the amount of calculation by converting floating point operations into integer operations, and since the calculation efficiency of shift operations is much higher than that of ordinary multiplication and division operations, the calculation efficiency is improved and the hardware requirements are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of algorithms based on regional feature aggregation, and in particular relates to an improved RoIAlign regional feature aggregation method. Background Art

[0002] ROI Align is a regional feature aggregation method proposed in the Mask-RCNN paper, which effectively solves the problem of regional misalignment caused by double quantization in the ROIPooling operation. Experiments show that replacing ROIPooling with ROI Align in detection tasks can improve the accuracy of the detection model.

[0003] However, in the prior art, when the entire target image is mapped to the source image, the pixels used are concentrated in the upper left corner of the image, and the pixels in the lower right corner are not used. Moreover, as the interpolation ratio increases, the unevenness becomes more obvious. In addition, due to the use of floating-point operations, the calculation takes a long time and has high requirements on the equipment. Therefore, a new technology is urgently needed to optimize the RoIAlign regional feature aggregation algorithm. Summary of the invention

[0004] The purpose of the present invention is to propose an improved RoIAlign regional feature aggregation method to reduce the amount of interpolation calculation as much as possible and realize the rapid segmentation of image ship targets under the ocean background. The steps of the present invention are as follows:

[0005] S1 uses the center point alignment method to align the geometric centers of the source image and the target image. Assuming that the source image size is m×n and the target image size is a×b, the width and height ratios of the two images are m / a and n / b respectively. Then a pixel point (dstX, dstY) in the target image can be mapped back to the corresponding pixel position (srcX, srcY) in the source image through the interpolation ratio, improving the alignment of the source image and the target image, and improving the upper left corner alignment to center point alignment. At this time, the calculation formula is as follows:

[0006]

[0007] The formula can be further transformed into:

[0008]

[0009] The second half of the formula can be regarded as the control factor of the entire interpolation operation, and its value can be positive or negative. At this time, the coordinate center of the source image and the target image is the origin of the coordinate system, and the coordinates of the center points of the source image and the target image are made to coincide. Due to the existence of this control factor, the mapping process fully and evenly utilizes all the pixels of the source image.

[0010] S2 performs bilinear interpolation calculations. To improve calculation efficiency and accuracy, floating-point operations are converted into integer operations. The calculation method is to first round the coordinate points of the target image, enlarge the decimal part according to the magnification and then round it, and then shift it to the right to achieve the purpose of dividing by the magnification, thereby obtaining the final interpolation result.

[0011] Preferably, in step S2, the method of rounding the target image coordinate point and magnifying the decimal part according to the magnification and then rounding it is as follows:

[0012] To obtain the pixel value f(x, y) at a certain pixel point (x, y) of the target image, assuming that the coordinates of the point are floating point numbers (26.15, 25.66), first round the coordinates of the target image point, magnify the decimal part according to the magnification, and then round it, as shown in the following formula:

[0013]

[0014] Among them, New_x and New_y are the integer parts of the floating point coordinates of the target point, Δx and Δy are the rounded values ​​after the decimal part of the floating point number is magnified, inv_x and inv_y represent (1-x) and (1-y), and the above data are all rounded down using the floor() function. Substitute these parameters into the following formula:

[0015]

[0016] The parameters in the formula are all integers, and the pixel values ​​f(0,0), f(0,1), f(1,0) and f(1,1) of the source image at (0,0), (0,1), (1,0) and (1,1) are all integers, so the integer Integer is obtained, and then it is shifted right by 22 bits to achieve the purpose of dividing by the magnification 4194304 to obtain the final interpolation result.

[0017] The beneficial effects of the present invention are as follows: the present invention optimizes the RoIAlign regional feature aggregation method, overlaps the center point coordinates of the source image and the target image, so that the mapping process fully and evenly utilizes all pixels of the source image, avoids the loss of regional information caused by feature map pooling, and makes the target image interpolation effect better. By converting floating-point operations into integer operations, the amount of calculation is greatly reduced. Since the calculation efficiency of shift operations is much higher than that of ordinary multiplication and division operations, the calculation efficiency is improved and the hardware requirements are reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 is a flow chart of the steps of the present invention;

[0019] Figure 2 A mapping relationship diagram between pixels of a target image and a source image in the prior art;

[0020] Figure 3 is a mapping relationship diagram between a source image and a target image in the present invention;

[0021] Figure 4 Graph showing the optimized acceleration solution for bilinear interpolation calculation. DETAILED DESCRIPTION

[0022] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments, which are intended to explain the present invention rather than to limit it.

[0023] The present invention discloses an improved RoIAlign regional feature aggregation method, the method is as follows:

[0024] When RoIAlign performs bilinear interpolation, the geometric centers of the source image and the target image are first aligned. The specific implementation process is as follows:

[0025] When performing the RoIAlign step on the region of interest in the feature map, in order to speed up the processing speed of the bilinear interpolation algorithm, the amount of interpolation calculation should be reduced as much as possible. The number of pixels to be interpolated can be reduced by center alignment.

[0026] In the original bilinear interpolation algorithm, assuming that the source image size is m×n and the target image size is a×b, the width and height ratios of the two images are m / a and n / b respectively. Then a pixel point (dstX, dstY) in the target image can be mapped back to the corresponding pixel position (srcX, srcY) in the source image through the interpolation ratio. The calculation formula is:

[0027]

[0028] Assume that the source image size is 7×7, the target image size is 3×3, and the upper left corner is selected as the coordinate origin. The coordinates of the center points of the source image and the target image are (3,3) and (1,1) respectively. When performing interpolation mapping, the pixel information of the source image should be used as evenly as possible. For example, the lower right corner pixel point (2,2) in the target image uses the original interpolation algorithm to calculate the corresponding source image coordinates as srcX=2·(7 / 3)=4.67. The four closest pixel points (4,4), (4,5), (5,4) and (5,5) are selected for bilinear interpolation. At this time, the pixel (7,7) in the source image is not used. When the entire target image is mapped to the source image, the pixels used are concentrated in the upper left corner of the image, and the pixels in the lower right part are not used. Moreover, as the interpolation ratio increases, the unevenness becomes more obvious. The mapping between the target image and the source image pixels is as follows: Figure 2 , the pixel blocks without color in the source image are the non-uniform distribution of unused pixels.

[0029] Improve the alignment of the source image and the target image, and change the upper left corner alignment to the center point alignment. The calculation formula is as follows:

[0030]

[0031] The formula can be further transformed into:

[0032]

[0033] The second half of the formula can be regarded as the control factor of the entire interpolation operation, and its value can be positive or negative. At this time, the coordinate center of the source image and the target image is the origin of the coordinate system, and the coordinates of the center points of the source image and the target image are made to coincide. It is precisely because of the existence of this control factor that the mapping process fully and evenly utilizes all the pixels of the source image. The mapping relationship is as follows: Figure 3 .

[0034] At this time, the interpolation mapping uses the pixels of the source image more evenly, avoiding the loss of regional information caused by feature map pooling, and making the target image interpolation effect better.

[0035] Then convert the floating-point operation into integer operation. The specific implementation process is as follows:

[0036] The bilinear interpolation process will cause a lot of floating-point operations due to the selection of different target image sizes. There are many feature map areas in the Mask R-CNN network that need to be RoIAligned, which requires a lot of bilinear interpolation operations. This is one of the reasons why the bilinear interpolation process is time-consuming when performing floating-point operations. Considering that the amount of integer operations is much smaller than floating-point operations, and the efficiency of shift operations is much higher than that of ordinary multiplication and division operations, a RoIAlign optimization acceleration solution is proposed based on this. The steps are as follows: Figure 4 .

[0037] The pixel value f(x,y) at a certain point (x,y) of the target image obtained by bilinear interpolation is usually a floating point number. The floating point number is first rounded, and the decimal part is magnified and then rounded. The key step is the selection of the magnification, which requires comprehensive consideration of three factors. First, a certain accuracy must be guaranteed. If the magnification value is small, the decimal of the pixel value is not effectively magnified, and the final rounding will discard more values, which may cause a large error in the interpolation result; secondly, the magnification value should not be too large. If the magnification is too large, it may cause the value of the calculation process to overflow, that is, exceed the maximum value that the data type can express; finally, in order to use shift operations for acceleration, the magnification must be an integer power of 2. If the magnification is 16, the final link must be divided by 16×16=256, and 256 can be quickly implemented by right shifting the bit. Considering all factors, the magnification is selected as 2048.

[0038] To obtain the pixel value f(x, y) at a certain pixel point (x, y) of the target image, assuming that the coordinates of the point are floating point numbers (26.15, 25.66), first round the coordinates of the target image point, magnify the decimal part according to the magnification, and then round it, as shown in the following formula:

[0039]

[0040] Among them, New_x and New_y are the integer parts of the floating point coordinates of the target point, Δx and Δy are the rounded values ​​after the decimal part of the floating point number is magnified, inv_x and inv_y represent (1-x) and (1-y), and the above data are all rounded down using the floor() function. Substitute these parameters into the following formula:

[0041]

[0042] The parameters in the formula are all integers, and the pixel values ​​f(0,0), f(0,1), f(1,0) and f(1,1) of the source image at (0,0), (0,1), (1,0) and (1,1) are all integers, so the integer Integer is obtained, and then it is shifted to the right by 22 bits to achieve the purpose of dividing by the magnification 4194304 to obtain the final interpolation result. Shift operations are more efficient than multiplication and division operations. Shift operation instructions take up 2 machine cycles, while multiplication and division instructions take 4 machine cycles. The computing efficiency is increased while the hardware requirements are reduced.

[0043] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.

Claims

1. An improved RoIAlign regional feature aggregation method, characterized in that: Here are the steps: S1 uses the center point alignment method to align the geometric centers of the source image and the target image. Assuming that the size of the source image is m×n and the size of the target image is a×b, the width and height ratios of the two images are m / a and n / b respectively. Then, a pixel point (dstX, dstY) in the target image is mapped back to the corresponding pixel position (srcX, srcY) in the source image through the interpolation ratio, and the alignment of the source image and the target image is improved, and the upper left corner alignment is improved to the center point alignment. At this time, the calculation formula is as follows: The formula can be further transformed into: The second half of the formula can be regarded as the control factor of the entire interpolation operation, and its value can be positive or negative. At this time, the coordinate center of the source image and the target image is the origin of the coordinate system, and the coordinates of the center points of the source image and the target image are made to coincide. Due to the existence of this control factor, the mapping process fully and evenly utilizes all pixels of the source image. S2 performs bilinear interpolation calculation. To improve calculation efficiency and accuracy, floating point calculation is converted into integer calculation. The calculation method is to first round the coordinate point of the target image, enlarge the decimal part according to the magnification and then round it, and then shift it to the right to achieve the purpose of dividing by the magnification, so as to obtain the final interpolation result. In step S2, the coordinate point of the target image is rounded, and the decimal part is magnified according to the magnification and then rounded as follows: To obtain the pixel value f(x, y) at a certain pixel point (x, y) of the target image, assuming that the coordinates of the point are floating point numbers (26.15, 25.66), first round the coordinates of the target image point, magnify the decimal part according to the magnification, and then round it, as shown in the following formula: Among them, New_x and New_y are the integer parts of the floating-point coordinates of the target point, Δx and Δy are the rounded values ​​after the decimal part of the floating-point number is magnified, inv_x and inv_y represent (1-x) and (1-y), and the above data are all rounded down using the floor() function; substitute these parameters into the following formula: The parameters in the formula are all integers, and it is known that the pixel values ​​f(0,0), f(0,1), f(1,0) and f(1,1) of the source image at (0,0), (0,1), (1,0) and (1,1) are all integers, so the integer Integer is obtained, and then it is shifted right by 22 bits to achieve the purpose of dividing by the magnification 4194304 to obtain the final interpolation result.

Citation Information

Patent Citations

  • Image splicing method by means of blocking operation

    CN106815808A

  • Quick double linear interpolating method in image amplification process

    CN1901602A