|
Algorithm 2 Pseudocode for depth-wise cross-correlation accelerator. |
-
1:
Procedure ReadFromMem
-
2:
Ensure stride, height, and width of image are valid
-
3:
Read filter coefficients from memory into coeff_stream
-
4:
Read pixel data from memory into pixel_stream
-
5:
End Procedure
-
6:
Procedure WriteToMem
-
7:
Ensure stride, height, and width of image are valid
-
8:
Read pixel data from output_stream and write it back to memory
-
9:
End Procedure
-
10:
Procedure Window2D
-
11:
Initialize LineBuffer and Window structures
-
12:
Read pixels from pixel_stream
-
13:
Shift Window and LineBuffer structures to accommodate new pixel
-
14:
After enough pixels have been read, write Window structure to window_stream
-
15:
End Procedure
-
16:
Procedure Xcorr
-
17:
Load filter coefficients into a 2D array
-
18:
for each pixel window in window_stream do
-
19:
Apply filter to pixel window to compute output pixel
-
20:
Write output pixel to output_stream
-
21:
end for
-
22:
End Procedure
-
23:
Procedure DWXCorr
-
24:
Initialize input and output streams
-
25:
for each channel in the image do
-
26:
Call ReadFromMem to read filter coefficients and pixel data from input stream into
coeff_stream and pixel_stream
-
27:
Call Window2D to form pixel windows
-
28:
Call Xcorr to filter pixel windows and generate output pixels
-
29:
Write output pixels to output stream
-
30:
end for
-
31:
End Procedure
|