Summary of the invention
For solving the problems of the technologies described above, the embodiment of the invention provides a kind of parallel transmission computing method and system of two-dimensional image data, and to realize parallel computation and the transmission of two dimensional image when the line-crossing processing, technical scheme is as follows:
The embodiment of the invention provides a kind of parallel transmission computing method of two-dimensional image data,
If pending picture traverse is img_w, calculation window is wide to be wnd_w, the high wnd_h of being, described calculation window can obtain m*n result of calculation at every turn, then distributing width is that col_w, total volume are that the buffer zone is used for Flame Image Process in the sheet of col_w* (wnd_h+n-1)+img_w, wherein col_w=wnd_w+m*2-1;
Described method comprises:
In T unit constantly, buffer memory transmits the 2 dimensional region reference data of calculating required pending image for the first time in sheet;
In T+1 unit constantly, according to the reference data in the buffer memory in anter, obtain corresponding this result of calculation, simultaneously, required reference data is calculated in the buffer memory transmission next time in sheet.
Preferably, when next result of calculation is in delegation with this result of calculation in described pending image,
Described in sheet buffer memory transmission calculate required reference data next time, distribute according to the two-dimensional position of data in the described pending image, be stored in buffer memory in anter in the adjacent 2 dimensional region of reference data.
Preferably, when next result of calculation is not in delegation with this result of calculation in described pending image,
Described in sheet buffer memory transmission calculate required reference data next time, be stored in buffer memory in anter in the non-conterminous 2 dimensional region of reference data.
Preferably, the non-conterminous 2 dimensional region of reference data in described and the buffer memory in the anter, its start address with respect to the start address side-play amount of described interior buffer zone is:
(address+1 of last data of current line buffer zone in sheet) mod col_w.
The embodiment of the invention also provides a kind of parallel transmission computing system of two-dimensional image data, and described system comprises buffer memory distributor, transmitting device and calculation element in the sheet;
If pending picture traverse is img_w, calculation window is wide to be wnd_w, the high wnd_h of being, described calculation window can obtain m*n result of calculation at every turn,
Described interior buffer memory distributor, distribution width are that col_w, total volume are that the buffer zone is used for Flame Image Process in the sheet of col_w* (wnd_h+n-1)+img_w, wherein col_w=wnd_w+m*2-1;
Described transmitting device, in T unit constantly, the 2 dimensional region reference data of required pending image is calculated in the buffer memory transmission for the first time in sheet;
Described calculation element in T+1 unit constantly, according to the reference data in the buffer memory in anter, obtains corresponding this result of calculation, and simultaneously, required reference data is calculated in the buffer memory transmission in sheet of described transmitting device next time.
Preferably, when next result of calculation is in delegation with this result of calculation in described pending image,
Described transmitting device in sheet buffer memory transmission calculate required reference data next time, distribute according to the two-dimensional position of data in the described pending image, be stored in buffer memory in anter in the adjacent 2 dimensional region of reference data.
Preferably, when next result of calculation is not in delegation with this result of calculation in described pending image,
Described transmitting device in sheet buffer memory transmission calculate required reference data next time, be stored in buffer memory in anter in the non-conterminous 2 dimensional region of reference data.
Preferably, the non-conterminous 2 dimensional region of reference data in described and the buffer memory in the anter, its start address with respect to the start address side-play amount of described interior buffer zone is:
(address+1 of last data of current line buffer zone in sheet) mod col_w.
In the prior art, when two dimensional image is handled, the initial interior buffer memory of sheet that must be placed on of the reference data of transmission is the section start of the internal memory of computation process distribution, otherwise can cross the border when handling end of line portion, and when line-crossing processing, the position that the reference data of downlink data is put into this requirement then can cover and be used to the reference data calculated, and therefore when carrying out line-crossing processing, data computing and transmission can't realize parallel processing.For addressing the above problem, it is that col_w, total volume are the processing that the buffer zone is used for two dimensional image in the sheet of col_w* (wnd_h+n-1)+img_w that the present invention distributes width,, when not crossing the border, also guarantee not overlap at first by the target location being got _ mould calculating start address at every row.Increase to cost with buffer memory in the less sheet, realized parallel computation and the transmission of two dimensional image when line-crossing processing, thereby improved treatment effeciency.
Embodiment
At first the parallel transmission computing method to a kind of two-dimensional image data of the embodiment of the invention describe,
If pending picture traverse is img_w, calculation window is wide to be wnd_w, the high wnd_h of being, described calculation window can obtain m*n result of calculation at every turn, then distributing width is that col_w, total volume are that the buffer zone is used for Flame Image Process in the sheet of col_w* (wnd_h+n-1)+img_w, wherein col_w=wnd_w+m*2-1;
Described method comprises:
In T unit constantly, buffer memory transmits the 2 dimensional region reference data of calculating required pending image for the first time in sheet;
In T+1 unit constantly, according to the reference data in the buffer memory in anter, obtain corresponding this result of calculation, simultaneously, required reference data is calculated in the buffer memory transmission next time in sheet.
Wherein, when next result of calculation is in delegation with this result of calculation in described pending image, buffer memory transmission calculates required reference data next time in sheet, two-dimensional position according to data in the described pending image distributes, and is stored in in the 2 dimensional region that reference data is adjacent in the interior buffer memory of anter.
When next result of calculation is not in delegation with this result of calculation in described pending image, buffer memory transmission calculates required reference data next time in sheet, be stored in in the non-conterminous 2 dimensional region of reference data in the interior buffer memory of anter, the start address of this 2 dimensional region with respect to the start address side-play amount of described interior buffer zone is:
(address+1 of last data of current line buffer zone in sheet) mod col_w.
In order to make those skilled in the art person understand technical scheme among the present invention better, below in conjunction with the accompanying drawing in the embodiment of the invention, technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills should belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
Be calculated as example with typical two dimensional image filtering, suppose to carry out the image of a 11*4 FIR Filtering Processing of 5*3 window, Fig. 1 a represents raw image data, and Fig. 1 b represents the view data after Filtering Processing.
In Fig. 1 b, f2~g8 is conventional 5*3 filtering result calculated, and for example, f2 calculates acquisition by the data of a0~a4, b0~b4, these 3 row, 5 row of c0~c4, by that analogy, g8 calculates acquisition by the data of b6~b10, c6~c10, these 3 row, 5 row of d6~d10; Dash area among Fig. 1 b belongs to the image border data, this part data can't be calculated by conventional 5*3 filtering because the calculation window desired data is complete and obtain, and generally can adopt direct replicating original or adjacent area data or dwindle method acquisition such as calculation window.
For convenience of description, in the embodiment of back, all represent data in the original image with a, b, c, d, and the view data that obtains after representing to calculate with e, f, g, h, wherein, the corresponding relation of data can be referring to shown in Fig. 1 a and Fig. 1 b.
Since in the sheet address space of buffer memory actual is one dimension, and need relate to calculating and transmission to 2-D data to the processing of digital picture, therefore require corresponding calculated device and the transmitting device can be with the mode deal with data of two dimension, below simply describe.
The meaning with the two dimensional form computational data is: the first address Addr, the calculating window width wnd_w that provide a slice continuous data storage space, calculate the high wnd_h of window, and be the deal with data col_w of memory allocation, then can calculate dash area data area as shown in Figure 2, wherein a10 and b0, b10 and c0 are respectively physically adjacent core positions.
The meaning with two dimensional form transmission data is: the source address src_addr, the source data window width src_w that provide a slice continuous data storage space, destination address dst-addr with another sheet continuous data storage space, destination data window width dst_w, and the columns w_cnt and the line number h_cnt of transmission data, then can carry out data transmission as shown in Figure 3, NA represents to be indifferent to wherein content, and the beginning data of the end of the previous row of two figure up and down among Fig. 2 and back delegation all are physically adjacent core positions.
Below in conjunction with concrete example, the parallel transmission computing method of two-dimensional image data of the present invention are described:
Suppose pending picture traverse img_w=11, filtering calculation window wnd_w=5, wnd_h=3, the result of calculation that can obtain 2 row, 1 row is calculated in each filtering, i.e. m=2, n=1.According to above condition, can obtain:
Need be buffer memory width col_w=wnd_w+m*2-1=8 in the sheet of handling this image distribution
The total volume of buffer memory is col_w* (wnd_h+n-1)+img_w=24+11=35 in the sheet
According to above result of calculation, spatial cache as shown in Figure 4 in the sheet that can obtain being distributed.
After spatial cache has assigned, carry out the transmission of data and calculate parallel processing according to following steps:
Step 101, constantly in T unit, data a0~a5, b0~b5, the c0~c5 of buffer memory transmission 6*3 in sheet, as shown in Figure 5, wherein the N prefix designates is vacant or invalid data is regional:
Step 102, referring to shown in Fig. 1 b, f0 as a result, the f1 of the result of calculation e0 of the first line data~e10 and second line data belong to marginal date, can adopt respective edges data computation method to obtain, the embodiment of the invention does not limit this.And for non-marginal date, in T+1 unit constantly, calculate by a filtering, can obtain f2 and f3 as a result.Wherein, f2 obtains according to reference data a0~a4, b0~b4, c0~c4 in the buffer memory in anter, and f3 obtains according to reference data a1~a5, b1~b5, c1~c5.
When carrying out aforementioned calculation, buffer memory transmits the required reference data of the calculating of filtering next time in sheet.It is a2~a7, b2~b7, c2~c7 that required reference data is calculated in filtering next time, and a2~a5, b2~b5, c2~c5 be in current sheet in the buffer memory, so this needs transmission a6, a7, b6, b7, c6, c7.
Distribute according to the two-dimensional position of data in pending image, with the data storage of transmission in buffer memory in anter in the adjacent 2 dimensional region of reference data, i.e. position shown in N0, N1, N2, N3, N4, the N5 among Fig. 5.In addition, because in next filtering is calculated, preceding two column data in the sheet in the buffer memory are that a0, a1, b0, b1, c0, c1 die on, and therefore can replace expression with N17, N18, N19, N20, N21, N22, after this transmission, the store status of buffer memory is shown in Fig. 6 a in the sheet.
Because the storage space of buffer memory is that 1 dimension is continuous in the sheet, therefore for the ease of observing, Fig. 6 a can be expressed as Fig. 6 b form.
Step 103 in T+2 unit constantly, obtains f4, obtains f5 according to a3~a7, b3~b7, c3~c7 according to current reference data a2~a6, b2~b6, c2~c6; Transmit filtering next time simultaneously and calculate the position of required reference data a8, a9, b8, b9, c8, c9 to N19, N20, N21, N22, N6, N7.After this transmission, the store status of buffer memory as shown in Figure 7 in the sheet.
Step 104 in T+3 unit constantly, obtains f6, obtains f7 according to a5~a9, b5~b9, c5~c9 according to current reference data a4~a8, b4~b8, c4~c8; Transmit filtering next time simultaneously and calculate the position of required reference data a10, b10, c10 to N25, N27, N8.After this transmission, the store status of buffer memory as shown in Figure 8 in the sheet.
Step 105, in T+4 unit constantly, at first according to current reference data a6~a10, b6~b10, c6~c10 obtains f8, because f9 and f10 are marginal date, therefore the calculating of filtering next time is exactly the 3rd row at image, required reference data is b0~b5, c0~c5, d0~d5, this can transmit b0 earlier, b1, c0, c1, d0, the data of this two row triplex row of d1, because it doesn't matter for the used reference data of reference data that next line is used and one's own profession, therefore, b0, b1, c0, c1, d0, d1 can be stored in in the non-conterminous 2 dimensional region of reference data in the interior buffer memory of anter, as shown in Figure 9.Wherein, the start address of this 2 dimensional region with respect to the start address side-play amount of described interior buffer zone for obtaining by following formula:
(address+1 of last data of current line buffer zone in sheet) mod col_w.
For present embodiment, address+1 of last data of current line buffer zone in sheet is the residing position of N28 among Fig. 8, divided by remainder behind the col_w, promptly obtains the pairing position of N24 among Fig. 8.
Follow-up can be when obtaining rim value f9 and f10, transmit filtering next time such as b2, c2, d2 and b3, c3, d3 respectively and calculate required reference data, can certainly adopt other transmission policy according to the concrete account form of marginal date, principle is that the data of being transmitted can not cover the reference data that is being used for filtering calculating and will be used for filtering calculating, and will be with required reference data end of transmission before each filtering is calculated.As buffer memory in sheet transmission data b 0~b5, c0~c5, d0~d5, finish after, can repeating step above-mentioned steps 102, begin the third line data of image are calculated.
As seen, use method provided by the present invention, the distribution width is that col_w, total volume are that the buffer zone is used for two dimensional image and handles in the sheet of col_w* (wnd_h+n-1)+img_w,, when not crossing the border, also guarantee not overlap at first by the target location delivery is calculated start address at every row.Increase to cost with buffer memory in the less sheet, realized parallel computation and the transmission of two dimensional image when line-crossing processing, thereby improved treatment effeciency.
Corresponding to top method embodiment, the present invention also provides a kind of parallel transmission computing system of two-dimensional image data, it is characterized in that, referring to shown in Figure 10, this system comprises buffer memory distributor 1001, transmitting device 1002 and calculation element 1003 in the sheet;
If pending picture traverse is img_w, calculation window is wide to be wnd_w, the high wnd_h of being, described calculation window can obtain m*n result of calculation at every turn,
Described interior buffer memory distributor, distribution width are that col_w, total volume are that the buffer zone is used for Flame Image Process in the sheet of col_w* (wnd_h+n-1)+img_w, wherein col_w=wnd_w+m*2-1;
Described transmitting device, in T unit constantly, the 2 dimensional region reference data of required pending image is calculated in the buffer memory transmission for the first time in sheet;
Described calculation element in T+1 unit constantly, according to the reference data in the buffer memory in anter, obtains corresponding this result of calculation, and simultaneously, required reference data is calculated in the buffer memory transmission in sheet of described transmitting device next time.
Wherein, when next result of calculation is in delegation with this result of calculation in described pending image,
Described transmitting device in sheet buffer memory transmission calculate required reference data next time, distribute according to the two-dimensional position of data in the described pending image, be stored in buffer memory in anter in the adjacent 2 dimensional region of reference data.
When next result of calculation is not in delegation with this result of calculation in described pending image,
Described transmitting device in sheet buffer memory transmission calculate required reference data next time, be stored in buffer memory in anter in the non-conterminous 2 dimensional region of reference data.
The non-conterminous 2 dimensional region of reference data in described and the buffer memory in the anter, its start address with respect to the start address side-play amount of described interior buffer zone can for:
(address+1 of last data of current line buffer zone in sheet) mod col_w.
As seen through the above description of the embodiments, those skilled in the art can be well understood to the present invention and can realize by the mode that software adds essential general hardware platform.Based on such understanding, the part that technical scheme of the present invention contributes to prior art in essence in other words can embody with the form of software product, this computer software product can be stored in the storage medium, as ROM/RAM, magnetic disc, CD etc., comprise that some instructions are with so that a computer equipment (can be a personal computer, server, the perhaps network equipment etc.) carry out the described method of some part of each embodiment of the present invention or embodiment.
Each embodiment in this instructions all adopts the mode of going forward one by one to describe, and identical similar part is mutually referring to getting final product between each embodiment, and each embodiment stresses all is difference with other embodiment.Especially, for system embodiment, because it is substantially similar in appearance to method embodiment, so describe fairly simplely, relevant part gets final product referring to the part explanation of method embodiment.System embodiment described above only is schematic, wherein said unit as the separating component explanation can or can not be physically to separate also, the parts that show as the unit can be or can not be physical locations also, promptly can be positioned at a place, perhaps also can be distributed on a plurality of network element.Can select wherein some or all of module to realize the purpose of present embodiment scheme according to the actual needs.Those of ordinary skills promptly can understand and implement under the situation of not paying creative work.
The above only is the specific embodiment of the present invention; should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the principle of the invention; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.