Method for stochastic computing image processing using correlation controlled contingency tables
Disclosed herein a method for agile simulation of a stochastic computing image processing where the input operands are processed with the aid of a correlation-controlled contingency table (CT) construct without using actual stochastic bit-streams. The disclosed method utilizes contingency tables to perform (i) template matching, (ii) image compositing, and (iii) pattern detection. Results show that the proposed approach achieves similar computation accuracy to the traditional stochastic computing simulation while performing runtime- and memory-efficient computations.
1 . A method for processing an input image in a stochastic computing system utilizing at least one multi-level cascaded stochastic computing circuit comprising:
a. establishing one or more contingency tables comprising a 2×2 matrix comprising four primitives, a, b, c, and d;
b. storing the contingency table in a memory in the stochastic computing circuit; and
c. processing the input image, comprising the following:
i. combining the input image with an additional image through an image composition process, wherein the image composition process comprises:
aa. providing the input image, comprising a background image (B);
bb. providing an input foreground image (F);
cc. providing a foreground image opacity of the input foreground image (a);
dd. providing a two-input multiplexer;
ee. identifying a probability value of the background image P B ;
ff. identifying a probability value of the foreground image P F ;
gg. identifying a probability value of the foreground image opacity P a ; and
hh. generating a composite image by performing the following operations: P B ×(1−P a )+(P F ×P a ),
ii. identifying a degree of similarity between the input image and an additional image through a template matching process; and
iii. comparing the input image with a comparison image through a pattern comparison process.
2 . The method of claim 1 , wherein the template matching process comprises:
a. determining a size of the input image, comprising a total amount of pixels, r×c;
b. providing a template, K, wherein said template comprises a kernel that is a subset of the input image;
c. comparing each pixel of the input image with the template;
d. identifying each pixel where the input image pixel and template intersect;
e. generating a temporary matching image; and
f. normalizing the temporary matching image.
3 . The method of claim 2 , wherein generating the temporary matching image comprises by applying Σ f(I, K), wherein/represents the input image; and
wherein f(I, K) comprises any one of the following:
a. |I-K|;
b. (I-K) 2 ; and
c. I×K.
4 . The method of claim 2 , further comprising:
a. generating a contingency table for the input image;
b. generating a contingency table for the template;
c. generating the temporary matching image by performing an AND operation on the input image and template, wherein the input image and the template each comprise zero correlated bit streams;
d. decoding the temporary matching image by identifying a population count of 1s, comprising a result ΣI×K;
e. subtracting K 2 from the decoding result; and
f. identifying an exact template match wherein a result of the foregoing steps generates a zero result.
5 . The method of claim 2 , further comprising:
a. generating a contingency table for the input image;
b. generating a contingency table for the template;
c. generating the temporary matching image by performing a stochastic computing multiplication operation on the input image and template, wherein the input image and the template each comprise zero correlated bit streams;
d. decoding the temporary matching image by identifying a population count of 1s; and
e. identifying a template match wherein a result of the foregoing steps generates a zero result.
6 . The method of claim 2 , further comprising:
a. generating a contingency table for the input image;
b. generating a contingency table for the template;
c. generating the temporary matching image by performing an XOR operation on the input image and template, wherein the input image and the template each comprise maximally correlated bit streams;
d. decoding the temporary matching image by identifying a population count of 1s; and
e. identifying a template match wherein a result of the foregoing steps generates a zero result.
7 . The method of claim 1 , wherein the pattern comparison process comprises:
a. calculating a maximum a value by applying min (M, P), wherein M represents the input image and P represents the comparison image;
b. setting the maximum a value as an expected a value;
c. calculating b, comprising subtracting a from the input image;
d. calculating c, comprising subtracting a from the comparison image;
e. applying an XOR operation to b and c; and
f. determining any differences between the input image and comparison image;
wherein a zero value is obtained when an exact pattern match is present.
8 . The method of claim 1 , wherein the pattern comparison process comprises:
a. generating the contingency table comprising:
i. providing a plurality of inputs to the contingency table comprising a bit stream length (N), at least two input scalars X1 and X2, and a target correlation;
ii. establishing a range of correlation points for a, wherein said range comprises a minimum a value, a maximum a value, and a zero a value;
iii. calculating the maximum a value by applying min (M, P), wherein M represents the input image and P represents the comparison image;
b. setting the maximum a value as an expected a value;
c. calculating b, comprising subtracting a from the input image;
d. calculating c, comprising subtracting a from the comparison image;
e. applying an XOR operation to b and c; and
f. determining any differences between the input image and comparison image;
wherein a zero value is obtained when an exact pattern match is present.