Efficient Parallel Computing Method For Box Filter

LIU; Xinzhe ;   et al.

Patent Application Summary

U.S. patent application number 17/054169 was filed with the patent office on 2021-08-12 for efficient parallel computing method for box filter. This patent application is currently assigned to SHANGHAITECH UNIVERSITY. The applicant listed for this patent is SHANGHAITECH UNIVERSITY. Invention is credited to Fupeng CHEN, Yajun HA, Xinzhe LIU.

Application Number20210248764 17/054169
Document ID /
Family ID1000005580236
Filed Date2021-08-12

United States Patent Application 20210248764
Kind Code A1
LIU; Xinzhe ;   et al. August 12, 2021

EFFICIENT PARALLEL COMPUTING METHOD FOR BOX FILTER

Abstract

An efficient parallel computing method for a box filter, includes: step 1, with respect to a given degree of parallelism N and a radius r of the filter kernel, establishing a first architecture provided without an extra register and a second architecture provided with the extra register; step 2, building a first adder tree for the first architecture and a second adder tree for the second architecture, respectively; step 3, searching the first adder tree and the second adder tree from top to bottom, calculating the pixel average corresponding to each filter kernel by using the first adder tree and the second adder tree, respectively, and counting resources required to be consumed by the first architecture and the second architecture, respectively; and, step 4, selecting one architecture consuming a relatively small resources from the first architecture and the second architecture for computing the box filter.


Inventors: LIU; Xinzhe; (Shanghai, CN) ; CHEN; Fupeng; (Shanghai, CN) ; HA; Yajun; (Shanghai, CN)
Applicant:
Name City State Country Type

SHANGHAITECH UNIVERSITY

Shanghai

CN
Assignee: SHANGHAITECH UNIVERSITY
Shanghai
CN

Family ID: 1000005580236
Appl. No.: 17/054169
Filed: June 17, 2020
PCT Filed: June 17, 2020
PCT NO: PCT/CN2020/096461
371 Date: November 10, 2020

Current U.S. Class: 1/1
Current CPC Class: G06T 7/44 20170101; G06F 9/30109 20130101; G06F 1/10 20130101; G06F 9/3838 20130101; G06F 9/545 20130101
International Class: G06T 7/44 20060101 G06T007/44; G06F 9/38 20060101 G06F009/38; G06F 9/54 20060101 G06F009/54; G06F 9/30 20060101 G06F009/30; G06F 1/10 20060101 G06F001/10

Foreign Application Data

Date Code Application Number
Aug 26, 2019 CN 201910788715.0

Claims



1. A parallel computing method for a box filter, wherein, a filter kernel is initially located on an upper left corner of the box filter, and moves from left to right and from top to bottom; assuming that a radius of the filter kernel is r, the filter kernel consists of (2r+1) columns of pixels, and each column of pixels of the (2r+1) columns of pixels consist of (2r+1) rows of pixels; the filter kernel moves by one column each time when moving from left to right, and moves by one row each time when moving from top to bottom; an average of all pixels within the filter kernel is defined as a pixel average; the pixel average corresponding to the filter kernel after each movement is calculated, and the pixel averages corresponding to all filter kernels are taken as a computing result of the box filter; the averages corresponding to all the filter kernels are calculated by the parallel computing method comprising the following steps: step 1: establishing two parallel architectures with respect to a given degree of parallelism N and the radius r of the filter kernel, a first architecture of the two parallel architectures is provided without an extra register, and a second architecture of the two parallel architectures is provided with the extra register; wherein in the first architecture, N first pixel averages in all pixel averages formed during a left-to-right movement process of the filter kernels are calculated in parallel within each clock cycle, each pixel average of the N first pixel averages is obtained by adding up all partial sums, and a partial sum is a sum of pixel values of one column of pixels; in the second architecture, N second pixel averages in all pixel averages formed during the left-to-right movement process of the filter kernels are calculated in parallel within each clock cycle; with respect to a current clock cycle T, pixel averages of N filter kernels in a previous clock cycle (T-1) are stored in the extra register, then a position F.sub.T(x, y) of the filter kernel of the N filter kernels in the current clock cycle T is obtained by moving a position F.sub.T-1(x, y) of the filter kernel in the previous clock cycle from left to right for N times, that is, F.sub.T-1(x, y)=F.sub.T(x-N, y); assuming that a pixel average of the position F.sub.T(x, y) of the filter kernel in the current clock cycle T is F.sub.T(x, y), and a pixel average of the position F.sub.T-1(x, y) of the filter kernel in the previous clock cycle stored in the extra register is F.sub.T-1(x, y), then: F.sub.T(x, y)=F.sub.T-1 (x, y)-SS.sup.-+SS.sup.+, wherein, SS.sup.- represents a sum of pixel values of N first columns of pixels, wherein a left edge of the position F.sub.T-1(x, y) of the filter kernel passes through the N first columns of pixels when the position F.sub.T-1(x, y) of the filter kernel moves from left to right for N times, and a sum of pixel values of each column of pixels of the N first columns of pixels is defined as a first partial sum; SS.sup.+ represents a sum of pixel values of N second columns of pixels, wherein a right edge of the position F.sub.T-1(x, y) of the filter kernel passes through the N second columns of pixels when the position F.sub.T-1(x, y) of the filter kernel moves from left to right for N times, and a sum of pixel values of each column of pixels of the N second columns of pixels is defined as a second partial sum; step 2: building a first adder tree for the first architecture and a second adder tree for the second architecture, respectively, wherein two second adder trees are built for calculating each SS.sup.- and each SS.sup.+, respectively; step 3: searching the first adder tree and the second adder tree from top to bottom; calculating the pixel average corresponding to each filter kernel by using the first adder tree and the second adder tree, respectively, wherein identical partial sums used for computing a previous filter kernel are reused during computing of a current filter kernel; and counting resources required to be consumed by the first architecture and the second architecture, respectively; and step 4: selecting one architecture consuming a relatively small resources from the first architecture and the second architecture for computing the box filter.

2. The parallel computing method according to claim 1, wherein constraint conditions of building the first adder tree comprise: 1) first inputs of the first adder tree are (2r+N) partial sums; 2) the first adder tree calculates N outputs simultaneously, and each output of the N outputs of the first adder tree is the pixel average of the filter kernel; 3) the each output of the N outputs of the first adder tree is a sum of (2r+1) adjacent first inputs; a building manner of the first adder tree comprises: 1) the first adder tree is built by combining a first plurality of binary trees together and the first adder tree comprises [log.sub.2(2r+1)]+1 layers in total, from a 0.sup.th layer to a ([log.sub.2(2r+1)]).sup.th layer; 2) each node of the 0.sup.th layer of the first adder tree is one of the (2r+N) partial sums; indexes of initial elements of adjacent nodes in each layer from a 1.sup.st layer to the ([log.sub.2(2r+1)]).sup.th layer of the first adder tree have a difference of 2 in the first inputs; a quantity of elements in each node of each layer from the 0.sup.th layer to the ([log.sub.2(2r+1)]).sup.th layer of the first adder tree is 2 to a power of a layer number; and nodes in the [log.sub.2(2r+1)]+1 layers of the first adder tree are combined in the following manner to obtain the N outputs: 2r+1 is expressed by an M-digit binary number; a 1.sup.st digit to an M.sup.th digit of the M-digit binary number from right to left correspond to the 0.sup.th layer to a (M-1).sup.th layer of the first adder tree successively; in layers corresponding to digits with a value of 1 in the M-digit binary number, required nodes are searched from top to bottom and from left to right, and are combined to form the N outputs.

3. The parallel computing method according to claim 2, wherein constraint conditions of building the second adder tree for calculating each SS.sup.- or each SS.sup.+ comprises: 1) second inputs of the second adder tree are (2N-1) partial sums; 2) each output of N outputs of the second adder tree is a sum of N adjacent second inputs; 3) the second adder tree calculates the N outputs simultaneously, and the each output of the N outputs of the second adder tree is one SS.sup.- or one SS.sup.+, a building manner of the second adder tree comprises: 1) the second adder tree is built by combining a second plurality of binary trees together and the second adder tree comprises log.sub.2 N+1 layers in total from a 0.sup.th layer to a (log.sub.2 N).sup.th layer; 2) each node of the 0.sup.th layer of the second adder tree is one of the (2N-1) partial sums; indexes of initial elements of adjacent nodes in each layer from a 1.sup.st layer to the (log.sub.2 N).sup.th layer of the second adder tree have the difference of 2 in the second inputs; 3) an N.sup.th node in the 0.sup.th layer of the second adder tree is combined with a (N/2-1).sup.th node and a (N/2).sup.th node in the 1.sup.st layer of the second adder tree, respectively, to generate a new node; the new node comprises all elements of two parent nodes; the new node is still located in the 1.sup.st layer of the second adder tree and occupies a position identical to a position of a father node of the new node in the 1.sup.st layer of the second adder tree; 4) during computing of a 2.sup.nd layer of the second adder tree, nodes comprising three elements in the 1.sup.st layer of the second adder tree are adopted preferentially, unless the condition 2) are not satisfied; and 5) a building manner of layers from a 3.sup.rd layer to the (log.sub.2 N).sup.th layer of the second adder tree are identical to the building manner of the first adder tree; and nodes in the log.sub.2 N+1 layers of the second adder tree are combined in the following manner to obtain the N outputs: nodes in a current layer are searched from top to bottom and from left to right, and are combined, and a next layer is searched if no suitable element is adopted for combination in the current layer.
Description



CROSS REFERENCE TO THE RELATED APPLICATIONS

[0001] This application is the national phase entry of International Application No. PCT/CN2020/096461, filed on Jun. 17, 2020, which is based upon and claims priority to Chinese Patent Application No. 201910788715.0, filed on Aug. 26, 2019, the entire contents of which are incorporated herein by reference.

TECHNICAL FIELD

[0002] The present invention relates to a fast and efficient computing method for a box filter. Box filters are generally used in various image and video processing applications, they are also widely applied to implement other algorithms.

BACKGROUND

[0003] In the field of computer vision, there may be a need for many box filters in algorithms. The box filter, as a smooth filter, may be used for calculating an average of all pixels in a kernel. Therefore, the speed of implementation of each box filter should be sufficiently high so that not too much time is consumed even when a large quantity of box filters is used. Additionally, the implementation of the box filter should be more economical, so that it does not consume excessive resources.

[0004] In the past research projects, an attempt is made to accelerate box filters in different computing platforms, such as, a graphics processing unit (GPU) and a field programmable gate array (FPGA). In some researches, e.g., Christoph Rhemann, Asmaa Hosni, Michael Bleyer, Carsten Rother, and Margrit Gelautz, Fast cost-volume filtering for visual correspondence and beyond, CVPR 2011, pages 3017-3024, 2011; Ziyang Ma, Kaiming He, Yichen Wei, Jian Sun, and Enhua Wu, Constant time weighted median filtering for stereo matching and beyond, 2013 IEEE International Conference on Computer Vision, pages 49-56, 2013.; H. Gupta, D. S. Antony, and R. G. N., Implementation of gaussian and box kernel-based approximation of bilateral filter using OpenCL, and In 2015 International Conference on Digital Image Computing: Techniques and Applications (DICTA), pages 1-5, November 2015; a series of box filters are accelerated by using a GPU, and these box filters benefit from the better accessibility which is provided by CUDA/OpenCL. However, for a power-limited system, the FPGA has been becoming an increasingly competitive alternative solution. Some other researches disclosed an original method for implementing a box filter by using an FPGA is disclosed, see, Hadi Parandeh-Afshar, Arkosnato Neogy, Philip Brisk, and Paolo Ienne, Compressor tree synthesis on commercial high-performance fpgas. TRETS, 4:39:1-39:19, 2011. Unfortunately, although the existing researches increase the speed of the box filter, a parallelization capability of the FPGA is not fully considered. Different from a common algorithm, such a zigzag scanning method, which the prior art discloses, requires the assistance of an additional row buffer to collaborate with other algorithms and would waste resources and places restrictions on the generality.

[0005] Typical methods for computing a box filter are as follow:

[0006] General method: the numbers in the kernel are simply added up one by one. In each round, such computing is performed as: F(x, y)=.SIGMA..sub.dy=-r.sup.r.SIGMA..sub.dx=-r.sup.rI(x+dx, y+dy). In the method, operations are independent of each other, so any degree of parallelism can be implemented to achieve a high speed. However, the computations in method are excessively complex, such as the (2r+1).sup.2 computing operations need to be averagely performed for each pixel. As a result, the implementation of this method consumes a large quantity of resources.

[0007] Integral image method: an integral image is defined as a sum of all pixels from the origin of coordinates to a current position. When this method is used, an integral image is calculated first using Box(x, y)=.SIGMA..sub.x'=0.sup.x.SIGMA..sub.y'=0.sup.yI(x', y'). Then, a final result is calculated by using the integral image: F(x, y)=Box(x+r, y+r)-Box(x-r-1, y+r)-Box(x+r, y-r-1)+Box(x-r-1, y-r-1). This computing method requires the integral image to be buffered for subsequent computing. At least the intermediate results from formular (2r+1).times.W+(2r+1) need to be buffered, and each result needs to consume .left brkt-top.log.sub.2 (W.times.H)+n.right brkt-bot. bits. This is excessively expensive and unacceptable for hardware implementation.

[0008] Partial sum method: partial sums are calculated first, and then a final result is calculated by using the partial sums. Such a computing method can save resources but has a high dependency and cannot be accelerated through parallelization.

SUMMARY

[0009] An objective of the present invention is to provide a fast and efficient computing method for a box filter.

[0010] To achieve the foregoing objective, the technical solution of the present invention is to provide an efficient parallel computing method for a box filter, the method includes: starting from an upper left corner of the box filter, a filter kernel moves from left to right and from top to bottom; assuming that a radius of the filter kernel is r, the filter kernel consists of (2r+1) columns of pixels, and each column of pixels consist of (2r+1) rows of pixels; the filter kernel moves by one column each time when moving from left to right, and moves by one row each time when moving from top to bottom; an average of all pixels within the filter kernel is defined as a pixel average; a pixel average corresponding to the filter kernel after each movement is then calculated, and pixel averages corresponding to all filter kernels are taken as a computing result of the box filter; calculation of the averages corresponding to all the filter kernels includes the following steps:

[0011] step 1: establishing two parallel architectures with respect to a given degree of parallelism N and the radius r of the filter kernel, one architecture is an architecture without an extra register, and the other architecture is an architecture with the extra register;

[0012] wherein in the architecture without the extra register, N pixel averages in all pixel averages formed during a left-to-right movement process of the filter kernels are calculated in parallel within each clock cycle, each pixel average is obtained by adding up all partial sums, and the partial sum is a sum of pixel values of one column of pixels;

[0013] in the architecture with the extra register, N pixel averages in all pixel averages that are formed during a left-to-right movement process of the filter kernels are calculated in parallel within each clock cycle; with respect to a current clock cycle T, the pixel averages of the positions of the N filter kernels in a previous clock cycle (T-1) are stored in the register, then a position F.sub.T(x, y) of any filter kernel in the current clock cycle T is obtained by moving a position F.sub.T-1(x, y) of the filter kernel in the previous clock cycle from left to right for N times, that is, F.sub.T-1(x, y)=F.sub.T(x-N, y); assuming that a pixel average of the position F.sub.T(x, y) of the filter kernel in the current clock cycle T is F.sub.T(x, y), and a pixel average of the position F.sub.T-1(x, y) of the filter kernel in the previous clock cycle stored in the register is F.sub.T-1(x, y), then:

[0014] F.sub.T(x, y)=F.sub.T-1 (x, y)-SS.sup.-+SS.sup.+, wherein, SS.sup.- represents a sum of pixel values of the N first columns of pixels, wherein a left edge of the position F.sub.T-1(x, y) of the filter kernel passes through the N first columns of pixels when the position F.sub.T-1(x, y) of the filter kernel moves from left to right for N times, and a sum of pixel values of each column of pixels of the N first columns of pixels is defined as a partial sum; SS.sup.+ represents a sum of pixel values of the N second columns of pixels, wherein a right edge of the position F.sub.T-1(x, y) of the filter kernel passes through the N second columns of pixels when the position F.sub.T-1(x, y) of the filter kernel moves from left to right for N times, and a sum of pixel values of each column of pixels of the N second columns of pixels is defined as a partial sum;

[0015] step 2: building adder trees for the two architectures established in step 1, wherein adder trees that are built for the two architectures are defined as a first adder tree and a second adder tree, respectively, wherein two second adder trees are built for calculating each SS.sup.- and each SS.sup.+, respectively;

[0016] step 3: searching the first adder tree and the second adder tree from top to bottom; calculating the pixel average corresponding to each filter kernel by using the first adder tree and the second adder tree, respectively, wherein identical partial sums that are used for computing a previous filter kernel are reused during computing of a current filter kernel; and counting resources required to be consumed by the two architectures established in step 1, respectively; and

[0017] step 4: selecting an architecture, which is established in step 1, that consumes a relatively small resources for computing the box filter.

[0018] Preferably, constraint conditions of building the first adder tree are as follows: 1) inputs of the first adder tree are (2r+N) partial sums; 2) the first adder tree calculates N outputs simultaneously, and each output is a pixel average of the filter kernel; 3) each output is a sum of (2r+1) adjacent inputs;

[0019] a building manner of the first adder tree is as follows: 1) the first adder tree is built by combining a plurality of binary trees together and includes [log.sub.2(2r+1)]+1 layers in total, which are layer 0 to layer [log.sub.2(2r+1)], respectively; 2) each node of layer 0 is one of the partial sums; indexes of initial elements of adjacent nodes in each layer from layer 1 to layer [log.sub.2(2r+1)] have a difference of 2 in the inputs; the quantity of elements in each node of each layer is 2 to the power of a layer number; and

[0020] the nodes in the layers of the first adder tree are combined in the following manner to obtain the outputs: 2r+1 is expressed by an M-digit binary number; a 1.sup.st digit to an M.sup.th digit of the binary number from right to left correspond to layer 0 to layer M-1 of the first adder tree successively; in layers corresponding to digits with a value of 1 in the M-digit binary number, required nodes are searched from top to bottom and from left to right, and are combined to form the outputs.

[0021] Preferably, constraint conditions of building the second adder tree for calculating each SS- or each SS+ are as follows: 1) inputs of the second adder tree are (2N-1) partial sums; 2) each output of the second adder tree is a sum of N adjacent inputs; 3) the second adder tree calculates N outputs simultaneously, and each output is one SS- or one SS+;

[0022] a building manner of the second adder tree is as follows: 1) the second adder tree is built by combining a plurality of binary trees together and includes log.sub.2 N+1 layers in total, which are layer 0 to layer log.sub.2 N, respectively; 2) each node of layer 0 is one of the partial sums; the indexes of initial elements of the adjacent nodes in each layer from layer 1 have a difference of 2 in the inputs; 3) an N.sup.th node in layer 0 is combined with a (N/2-1).sup.th node and a (N/2).sup.th node in layer 1, respectively; a generated new node includes all elements of two parent nodes; the generated new node is still located in layer 1 and occupies a position identical to a position of a father node of the generated new node in layer 1; 4) during computing of layer 2, nodes including three elements in layer 1 are adopted preferentially, unless the condition 2) cannot be satisfied; and 5) a building manner of other layers are identical to the building manner of the first adder tree; and

[0023] the nodes in the layers of the second adder tree are combined in the following manner to obtain the outputs: nodes are searched from top to bottom and from left to right, and are combined, and a next layer is searched if no suitable element is adopted for combination in a current layer.

[0024] The present invention proposes two architectures for implementing a box filter in parallel, and an adder tree is built to reduce required resources. The present invention has the following features.

[0025] (1) Based on the "partial sum" algorithm, the present invention proposes two architectures suitable for different parameter combinations, the two architectures eliminate intrinsic data dependency of an algorithm and therefore can achieve any degree of parallelism.

[0026] (2) The present invention reuses all intermediate results by using the adder trees, and greatly reduces computing resources required for algorithm parallelism.

[0027] (3) The present invention develops a program that automatically generates a box filter code according to an input parameter combination, and the code is accepted by a high-level synthesis tool.

BRIEF DESCRIPTION OF THE DRAWINGS

[0028] FIG. 1 is a schematic diagram of a design of a box filter according to the present invention;

[0029] FIG. 2 is a schematic diagram of calculation of S.sub.y(x+r, y) according to the present invention;

[0030] FIG. 3 is a schematic diagram of calculation of F(x, y) according to the present invention;

[0031] FIG. 4 is a schematic diagram of calculation of pixel averages of filter kernels used in an architecture without an extra register according to the present invention;

[0032] FIG. 5 is a schematic diagram of calculation of pixel averages of filter kernels used in an architecture with an extra register according to the present invention;

[0033] FIG. 6 is a schematic diagram of building the first adder tree according to the present invention; and

[0034] FIG. 7 is a schematic diagram of building the second adder tree according to the present invention.

DETAILED DESCRIPTION OF THE EMBODIMENTS

[0035] The present invention will be described in detail below in conjunction with specific embodiments. It should be understood that these embodiments are only used to describe the present invention and are not intended to limit the scope of the present invention. In addition, it should be understood that various changes and modifications may be made to the present invention by those skilled in the art after reading the content of the present invention, and these equivalent forms shall fall within the scope defined by the claims of the present invention.

[0036] As shown in FIG. 1, the external frame in FIG. 1 depicts a box filter, and the small frame in the center of the external frame depicts a filter kernel, wherein r is the radius of the filter kernel, which is an external input value when computing the box filter. A current position F(x, y) of the filter kernel consists of (2r+1) columns of pixels, and each column of pixels consist of (2r+1) rows of pixels. An average of all pixels within the filter kernel is defined as a pixel average. X coordinate axis and Y coordinate axis are established by using a central pixel of the box filter as an origin. Then, a pixel average of the current position F(x, y) of the filter kernel is F(x, y), which is expressed as:

F .function. ( x , y ) = 1 ( 2 .times. r + 1 ) 2 .times. d .times. y = - r r .times. d .times. x = - r r .times. I .function. ( X + d .times. x , Y + dy ) , ##EQU00001##

[0037] wherein, I(x, y) is a pixel value of a pixel in x.sup.th column and y.sup.th row in the current position F(x, y) of the filter kernel, that is, a pixel value of a pixel at the coordinates (x, y); (X, Y) are coordinates of the central pixel of the current position F(x, y) of the filter kernel; dx is a deviation with respect to X, and dy is a deviation with respect to Y.

[0038] When computing the box filter, starting from an upper left corner of the box filter, the filter kernel moves from left to right and from top to bottom. The filter kernel moves by one column each time when moving from left to right, and moves by one row each time when moving from top to bottom. Each time the filter kernel moves, a different pixel average is obtained. One objective of computing the box filter is to calculate all pixel averages.

[0039] Based on an existing "partial sum" algorithm, the present invention proposes two architectures that are suitable for different parameter combinations. The architectures eliminate intrinsic data dependency of an algorithm, and therefore can achieve any degree of parallelism. The "partial sum" algorithm is briefly introduced below.

[0040] With regard to a filter kernel with a radius of r, this method begins with calculating a sum of pixel values of (2r+1) rows of pixels in each column of pixels. For example, for the (x+r).sup.th column of pixels, a sum of pixel values of (2r+1) rows of pixels in the x+r.sup.th column is defined as S.sub.y(x+r, y), as shown in FIG. 2. A previous calculation result S.sub.y(x+r, y-1) is adopted during the calculation of S.sub.y(x+r, y), and the previous calculation result S.sub.y(x+r, y-1) is a sum of pixel values of a corresponding column of pixels obtained by moving the current (x+r).sup.th column of pixels upward by one row. Then, letting S.sub.y(x+r, y)=S.sub.y(x+r, y-1)+I(x+r, y+r)I(x+r, y-r-1), that is, the current (x+r).sup.th column of pixels is regarded as being obtained by moving a column of pixels at the same position downward by one row. When the column of pixels is moved downward, an upper edge of the column of pixels passes through a first pixel when being moved downward, and a pixel value of the first pixel is I(x+r, y-r-1); meanwhile, when the column of pixels is moved downward, a lower edge of the column of pixels passes through a second pixel when being moved downward, and a pixel value of the second pixel is I(x+r, y+r). Subsequently, the sum of each column of pixels is used for calculating a pixel average of the filter kernel.

[0041] As shown in FIG. 3, a pixel average F(x, y) in the current position F(x, y) of the filter kernel is expressed as: F(x, y)=F(x-1, y)+S.sub.y(x+r, y)S.sub.y(x-r-1, y), wherein F(x-1, y) is an average of all pixels in a previous position F(x-1, y) of the filter kernel before the current position F(x, y) of the filter kernel is moved from left to right; (X, Y) is the coordinates of a central pixel of the current position F(x, y) of the filter kernel; S.sub.y(X+r, y) represents a sum of pixel values of the (X+r).sup.th column of pixels, and S.sub.y(X-r-1, y) represents a sum of pixel values of the (X-r-1).sup.h' column of pixels. That is, the previous position F(x-1, y) of the filter kernel is moved from left to right by one column to form the current position F(x, y) of the filter kernel. In this case, S.sub.y(X+r, y) corresponds to a sum of pixel values of a first column of pixels, wherein a right edge of the previous position F(x-1, y) of the filter kernel passes through the first column of pixels during movement, and S.sub.y(X-r-1, y) corresponds to a sum of pixel values of a second column of pixels, wherein a left edge of the previous position F(x-1, y) of the filter kernel passes through the second column of pixels during movement.

[0042] It is expected to calculate a plurality of pixel averages in parallel to increase a computing speed. Assuming that a specified degree of parallelism is N, N pixel averages are expected to be obtained simultaneously: F(x, y), F(x+1, y), F(x+2, y), . . . , F(x+N-1, y). This requires the processes of calculating these final results to be independent of each other, as the original partial sum calculation formula is F(x, y)=F(x-1, y)+S.sub.y(X+r, y)S.sub.y(X-r-1, y), it can be seen that the calculation of F(x, y) depends on the computing result of F (x-1, y).

[0043] The present invention designs two parallel architectures for a given degree of parallelism N and the radius r of the filter kernel, one architecture is an architecture without an extra register, and the other architecture is an architecture with the extra register.

[0044] In the architecture without an extra register, during the calculation of a final result, all the partial sums are directly added up without using the previous calculation result, where each partial sum is a sum of pixel values of one column of pixels. For example, if the degree of parallelism N=2, a pixel average F.sub.0 and a pixel average F.sub.1 need to be calculated simultaneously. The calculation manner is as shown in FIG. 4. In FIG. 4, S.sub.a to S.sub.h are the sums of the pixel values of different columns of pixels; then, the pixel average F.sub.0 is an accumulation of S.sub.a to S.sub.g, and the pixel average F.sub.1 is an accumulation of S.sub.b to S.sub.h. In the architecture without an extra register, a formula for calculating a pixel average may be summarized as follows:

F .function. ( x , y ) = x = X - r x = X + r .times. S y .function. ( x , y ) ##EQU00002##

[0045] wherein, S.sub.y(x, y) represents a sum of pixel values of the x.sup.th column of pixels, and (X, Y) is a central pixel of the current position of the filter kernel.

[0046] In the architecture with an extra register, the pixel averages of N filter kernels in an identical row are calculated at a time within each clock cycle; with respect to a current clock cycle T, the pixel averages of N filter kernels in a previous clock cycle (T-1) are stored in the register; then, a position F.sub.T(x, y) of any filter kernel in the current clock cycle T is obtained by moving a position F.sub.T-1(x, y) of the filter kernel in the previous clock cycle from left to right for N times, that is, F.sub.T-1(x, y)=F.sub.T(x-N, y); assuming that the pixel average of the position F.sub.T(x, y) of the filter kernel in the current clock cycle T is F.sub.T(x, y), and the pixel average of the position F.sub.T-1(x, y) of the filter kernel in the previous clock cycle stored in the register is F.sub.T-1(x, y), then:

[0047] F.sub.T(x, y)=F.sub.T-1 (x, y)SS.sup.-+SS.sup.+, wherein SS.sup.- represents a sum of pixel values of the N first columns of pixels, wherein a left edge of the position F.sub.T-1(x, y) of the filter kernel passes through the N first columns of pixels when the position F.sub.T-1(x, y) of the filter kernel moves from left to right for N times, and a sum of pixel values of each column of pixels is defined as a partial sum, SS.sup.-=.SIGMA..sub.x=X-r.sup.x=X-r+NS.sub.y(x, y); SS.sup.+ represents a sum of pixel values of the N second columns of pixels, wherein a right edge of the position F.sub.T-1(x, y) of the filter kernel passes through the N second columns of pixels when the position F.sub.T-1(x, y) of the filter kernel moves from left to right for N times, and a sum of pixel values of each column of pixels is defined as a partial sum, SS.sup.+=.SIGMA..sub.x=X+r-N.sup.x=X+rS.sub.y(x, y); For example, if the degree of parallelism N=2, a pixel average F.sub.0 and a pixel average F.sub.1 need to be calculated simultaneously. A calculation manner is as shown in FIG. 5. In FIG. 5, S.sub.a to S.sub.j are sums of pixel values of different columns of pixels, and F.sub.0' and F.sub.1' are pixel averages in a previous clock cycle that are stored in the register; then F.sub.0=F.sub.0'-S.sub.a-S.sub.b+S.sub.h+S.sub.i, F.sub.1=F.sub.1'-S.sub.b-S.sub.c+S.sub.i+S.sub.j.

[0048] It is assumed that the degree of parallelism N=6, and the radius r of the filter kernel is 4, in the process of calculating the final result F(x, y) by using partial sums of S.sub.y(x, y), the following operations are performed:

[0049] A) With respect to the architecture without an extra register, according to the formula in FIG. 4, the operations in the following six formulas need to be performed simultaneously, and a total of 2Nr=48 adders are required:

F.sub.0=S.sub.a+S.sub.b+S.sub.c+S.sub.d+S.sub.e+S.sub.f+S.sub.g+S.sub.h+- S.sub.i vii.

F.sub.1=S.sub.h+S.sub.c+S.sub.d+S.sub.e+S.sub.f+S.sub.g+S.sub.h+S.sub.i+- S.sub.j viii.

F.sub.2=S.sub.c+S.sub.d+S.sub.e+S.sub.f+S.sub.g+S.sub.h+S.sub.i+S.sub.j+- S.sub.k ix.

F.sub.3=S.sub.d+S.sub.e+S.sub.f+S.sub.g+S.sub.h+S.sub.i+S.sub.j+S.sub.k+- S.sub.i x.

F.sub.4=S.sub.e+S.sub.f+S.sub.g+S.sub.h+S.sub.i+S.sub.j+S.sub.k+S.sub.i+- S.sub.m xi.

F.sub.5=S.sub.f+S.sub.g+S.sub.h+S.sub.i+S.sub.j+S.sub.k+S.sub.i+S.sub.m+- S.sub.p xii.

[0050] B) With respect to the architecture with an extra register, according to the formula in FIG. 5, the operations in the following twelve formulas need to be performed simultaneously, and a total of 2N(N-1)=60 adders are required:

SS.sub.0.sup.-=S.sub.a+S.sub.b+S.sub.c+S.sub.d+S.sub.e+S.sub.f xiii.

SS.sub.1.sup.-=S.sub.h+S.sub.c+S.sub.d+S.sub.e+S.sub.f+S.sub.g xiv.

SS.sub.2.sup.-=S.sub.c+S.sub.d+S.sub.e+S.sub.f+S.sub.g+S.sub.h xv.

SS.sub.3.sup.-=S.sub.d+S.sub.e+S.sub.f+S.sub.g+S.sub.h+S.sub.i xvi.

SS.sub.4.sup.-=S.sub.e+S.sub.f+S.sub.g+S.sub.h+S.sub.i+S.sub.j xvii.

SS.sub.5.sup.-=S.sub.i+S.sub.g+S.sub.h+S.sub.i+S.sub.j+S.sub.k xviii.

SS.sub.0.sup.+=S.sub.i+S.sub.k++S.sub.m+S.sub.p+S.sub.o xix.

SS.sub.1.sup.+=S.sub.k++S.sub.m+S.sub.p+S.sub.o+S.sub.p xx.

SS.sub.2.sup.+=S.sub.i+S.sub.m+S.sub.p+S.sub.o+S.sub.p+S.sub.o xxi.

SS.sub.3.sup.+=S.sub.m+S.sub.n+S.sub.a+S.sub.p+S.sub.q+S.sub.r xxii.

SS.sub.4.sup.+=S.sub.p+S.sub.o+S.sub.p+S.sub.o++S.sub.s xxiii.

SS.sub.5.sup.+=S.sub.o+S.sub.p+S.sub.q+S.sub.r+S.sub.s+S.sub.t xxiv.

[0051] The present invention reuses all intermediate results in the foregoing architectures by using the adder trees, which greatly reduces computing resources required for algorithm parallelism.

[0052] The first adder tree is applicable to the architecture without an extra register, and it is used to perform the operation process in the foregoing step A). The quantity of required adders is decreased to 20 after using the first adder tree.

[0053] The first adder tree is built through the following aspects:

[0054] I) Requirements

[0055] 1) 2r+N inputs are needed. For example, in the foregoing step A), N=6 and r=4, then, there are a total of fourteen inputs, namely S.sub.a to S.sub.n.

[0056] 2) Each output is a sum of 2r+1 adjacent inputs. For example, in the foregoing step A), r=4, then, the output F is a sum of nine S.

[0057] 3) N outputs are calculated simultaneously. For example, in the foregoing step A), N=6, then, six outputs, namely F.sub.0 to F.sub.5, are calculated simultaneously.

[0058] II) Tree Building Method

[0059] 1) The first adder tree is built by combining a plurality of binary trees together, and it includes [log.sub.2 (2r+1)]+1 layers, which are layer 0 to layer [log.sub.2 (2r+1)], respectively.

[0060] 2) Indexes of initial elements of adjacent nodes in each layer have a difference of 2 in the inputs.

[0061] 3) The quantity of elements contained in each node of each layer is 2 to the power of a layer number.

[0062] As shown in FIG. 6, from a to n are sums of pixel values of different columns of pixels, namely, the inputs, which are nodes in layer 0; elements of nodes contained in layer 1 are bc, de, and the like. Elements of nodes contained in other layers are obtained in the same manner.

[0063] III) Combination Manner

[0064] 2r+1 is expressed in a binary manner. In layers corresponding to digits with a value of 1, required nodes are searched from top to bottom and from left to right, and are combined.

[0065] For example, assume 2r+1=19=10011. Then, nodes need to be searched in layer 4, layer 1, and layer 0 and combined, and an output is obtained after the combination.

[0066] The second adder trees are applicable to the architecture with an extra register, and are used for calculating each SS.sup.- and each SS.sup.+, respectively, for example, to perform the operation process of SS.sub.0.sup.- to SS.sub.5.sup.- in step B) or the operation process of SS.sub.0.sup.+ to SS.sub.5.sup.+ in step B). The quantity of the required adders is decreased to 32 after using the second adder trees.

[0067] The second adder tree for calculating SS.sup.- is built through the following aspects, (note, the second adder tree for calculating SS.sup.+ is built in the same manner).

[0068] I) Requirements

[0069] 1) 2N-1 inputs are needed. For example, in the foregoing step B), N=6 and r=4, then, there are a total of eleven inputs, namely S.sub.a to S.sub.k.

[0070] 2) Each output is a sum of N adjacent inputs. For example, in the foregoing step B), N=6, then, the output SS is a sum of six S.

[0071] 3) N outputs are calculated simultaneously. For example, in the foregoing step B), N=6, then, six outputs, namely SS.sub.0.sup.- to SS.sub.5.sup.-, are calculated simultaneously.

[0072] II) Tree Building Method

[0073] 1) The second adder tree is built by combining a plurality of binary trees together, including log.sub.2 N+1 layers, which are layer 0 to layer log.sub.2 N, respectively.

[0074] 2) Indexes of initial elements of adjacent nodes in each layer have a difference of 2 in the inputs.

[0075] 3) The N.sup.th input element (in layer 0) is combined with the (N/2-1).sup.th node and the (N/2).sup.th node in layer 1, respectively, and the generated new node includes all elements of two parent nodes. The generated new node is still located in layer 1 and occupies the position identical to the position of the father node thereof in layer 1.

[0076] 4) During computing of layer 2, nodes including three elements in layer 1 are adopted preferentially, unless the condition 2) cannot be satisfied.

[0077] 5) Building manners of other layers are the same as that of the first adder tree in the architecture without an extra register.

[0078] As shown in FIG. 7, a to k are sums of pixel values of different columns of pixels, namely, the inputs, which are nodes in layer 0.

[0079] III) Combination Manner

[0080] Nodes are searched from top to bottom and from left to right, and are combined, and the next layer is searched if no suitable element is used for combination in the current layer.

[0081] After using the second adder tree, operations in step A) and step B) are converted as follows.

[0082] With respect to the architecture without an extra register, the following operations are performed, and a total of twenty adders are required:

tmp_bc=S.sub.b+S.sub.c; tmp_de=S.sub.d+S.sub.e; tmp_fg=S.sub.f+S.sub.g; xii.

tmp_hi=S.sub.h+S.sub.i; tmp_jk=S.sub.j+S.sub.k; tmp_lm=S.sub.l+S.sub.m; xiii.

tmp_bcde=tmp_bc+tmp_de; tmp_defg=tmp_de+tmp_fg; xiv.

tmp_fghi=tmp_fg+tmp_hi; tmp_hijk=tmp_hi+tmp_jk; xv.

tmp_jklm=tmp_jk+tmp_lm; xvi.

tmp_bcdefghi=tmp_bcde+tmp_fghi; xvii.

tmp_defghijk=tmp_defg+tmp_hijk; xviii.

tmp_fghihklm=tmp_fghi+tmp_jklm; xix.

F.sub.0=S.sub.a+tmp_bcdefghi; F.sub.1=tmp_bcdefghi+S.sub.j; xx.

F.sub.2=S.sub.c+tmp_defghijk; F.sub.3=tmp_defghijk+S.sub.l; xxi.

F.sub.4=S.sub.e+tmp_fghihklm; F.sub.5=tmp_fghihklm+S.sub.n; xxii.

[0083] The present invention further develops a program that can automatically generate a box filter code according to an input parameter combination, and the code can be accepted by a high-level synthesis tool:

[0084] a) the program includes two sets of manned-programmed code templates, which adopts the two parallel architectures described above, respectively;

[0085] b) the program reads input parameters (the degree of parallelism N and the radius r of the filter kernel), and then generates the adder trees corresponding to the two architectures according to the foregoing rules;

[0086] c) the program searches the adder trees from top to bottom to generate the code, and counts resources required to be consumed by the two architectures; and

[0087] d) a solution that consumes a relatively small resources is selected after comparison, the code template is filled, and C++ code acceptable to a high-level synthesis tool is output.

* * * * *


uspto.report is an independent third-party trademark research tool that is not affiliated, endorsed, or sponsored by the United States Patent and Trademark Office (USPTO) or any other governmental organization. The information provided by uspto.report is based on publicly available data at the time of writing and is intended for informational purposes only.

While we strive to provide accurate and up-to-date information, we do not guarantee the accuracy, completeness, reliability, or suitability of the information displayed on this site. The use of this site is at your own risk. Any reliance you place on such information is therefore strictly at your own risk.

All official trademark data, including owner information, should be verified by visiting the official USPTO website at www.uspto.gov. This site is not intended to replace professional legal advice and should not be used as a substitute for consulting with a legal professional who is knowledgeable about trademark law.

© 2024 USPTO.report | Privacy Policy | Resources | RSS Feed of Trademarks | Trademark Filings Twitter Feed