APPARATUS AND METHOD FOR SIGNAL PROCESSING

Abstract: Associative signal processing apparatus for processing an incoming signal including a plurality of samples, the apparatus including a two-dimensional array of processors, each processor (20) including a multiplicity of content addressable memory cells (122), each sample of an incoming signal being processed by at least one of the processors, and a register array including at least one register operative to store responders arriving from the processors and to provide communication, within a single cycle, between non-adjacent processors.

Description: APPARATUS AND METHOD FOR SIGNAL PROCESSING FIELD OF THE INVENTION The present invention relates to methods and apparatus for signal processing. BACKGROUND OF THE INVENTION State of the art computer vision systems and methods and state of the art associative processing methods are described in the following publications, the disclosure of which is hereby incorporated by reference: C. C. Foster . "Content addressable parallel processors", Van Nostrand Reinhold Co., 1976, chs. 2 and S. Ruhman, I. Scherson, "Associative processor for tomographic image reconstruction", Proc. Medcomp 82 (1982 IEEE Comp. Soc. Int. Conf. on Medical Comp. Sc./ Computational Medicine), pp. 353 - 358, C. eems, E. Riseman, A. Hanson, A. Rosenfeld, "IU parallel processing benchmark", Proc. Comp. Vision & Pattern Recogn., pp. 673 - 688, 1988, I. Scherson, "Multioperand associative processing and application to tomography and computer graphics", Ph.D. Thesis, Computer Sciences, Weizman Institute of Science, 1983, Canny, J. "Computational approach to edge detection", IEEE Trans. on pattern analysis and machine Int., Nov. 1986, pp. 679 - 698, and Sha'ashua, A. and S. Ullman, "Structural saliency: the detection of global salient structures using a local connected network", Proc. ICCV Conf., pp, 321 - 327, Florida, 1988, and Akerib, A. J. and Ξhmil Ruhman, "Associative contour processing", MVP 1990 IAPR Workshop on Machine Vision Applications, Nov. 28 - 30, 1990, Tokyo. Image processing techniques and other subject matter useful for associative signal pro¬ cessing are described in the following references: References [1] W.D. Hillis, "The Connection Machine", MIT Press, 1985. [2] C. C. Weems, Jr., "Image Processing on a Content Addressable Array Parallel Proces¬ sor", Ph.D. Thesis, Computer and Information Sciences, University of Massachusetts at Amherst, 1984. [3] C. C. Foster, "Content Addressable Parallel Processors", Van Nostrand Reinhold Co., 1976, chs. 2 & 5. [4] S. Ruhman, I. Scherson, "Associative Processor for Tomographic Image Reconstruc¬ tion", Proc. Medcomp 82 (1982 IEEE Comp. Soc. Int. Conf. on Medical Comp. Sc./Computational Medicine), pp 353-358. [5] S. Ruhman, I. Scherson, "Feasibility Study of Associative Radar Signal Processing", Internal Report, Weizmann Institute of Science, October 1984. [6] S. Ruhman, I. Scherson, "Associative Processor Particularly Useful for Tomographic Image Reconstruction", U.S. Patent 4,491,932, filed Oct. 1, 1981, issued Jan. 1, 1985. [7] C. Weems, E. Riseman, A. Hanson, A. Rosenfeld, "IU Parallel Processing Benchmark", Proc. Comp. Vision & Pattern Recogn. pp 673-688, 1988. [8] D.C. Marr, E. Hildreth, "Theory of Edge Detection", Proc. R. Soc. London, Vol. B 207, pp 187-217, 1980. [9] W.E.L. Grimson, "A Computer Implementation of a Theory of Human Stereo Vision", Phil. Trans. Royal Soc. of London, Vol. B 292, pp 217-253, 1981. [10] B.K.P. Horn, B.G. Schunck, "Determining Optical Flow", Artificial Intelligence Vol. 17, pp 1S5-203, 1981. [11] V. Cantoni, C. Guerra and S. Levialdi, "Towards an Evaluation of an Image Processing System " . In: Computing Structures for Image Processing, Academic Press, 1983. ch. 4. [12] M.J. Flynn, "Very high-speed computer systems", Proc. IEEE, Vol. 54, pp 1901-1909, 1966. [13] B. Lindskog "PICAP, An SIMD architecture for multi-dimensional signal processing", Dissertation No. 176, Dept. of El. Eng., Linkoping University, Sweden, 1988. [14] S.S. Wilson, "One dimensional SIMD architectures - the AIS-5000", Multicomputer Vision, Academic Press, pp. 131-149. [15] D. Juvini, J.L. Basille, H. Essafi, J.Y. Latil, "Sympati 2, a 1.5D processor array for image application", EUSIPCO IV, Theories and applications, North-Holland, pp. 311- 314, 1988. [16] I.N. Robinson and W.R. Moore, "A parallel processor array architecture and its imple¬ mentation in silicon", Proc. IEEE Custom Integrated Circuit Conf. pp 41-45, 1982. [17] M.J.B. Duff, "CLIP4: A large scale integrated circuit array parallel processor", Proc. IJCPR, pp. 728-733, 1976. [18] K.E. Batcher, "Design of a massively parallel processor", IEEE Trans. Comp., Vol. C-29, pp. 836-840, 1980. [19] S.F. Reddaway, "DAP - A flexible number cruncher", Proc. LASL Workshop on Vector and Parallel Processors, pp. 233-234, 1978. [20] D.E. Shaw, "The NON- VON supercomputer", Computer Science Dept., Columbia Uni¬ versity, New York, NY, 1982. [21] V. Cantoni and S. Levialdi, "PAPIA: A case history, ", Parallel Computer Vision, L. Uhr, Ed. New York, NY: Academic Press, 1987, pp. 3-13. [22] L.I. Hungwen and M. Maresca. "Polymorphic-Torus Architecture for Computer Vision", IEEE Trans. PAMI, Vol. 11, No. 3, 1989. [23] S.R. Sternberg, "Biomedical image processing" , Computer, Vol. 16, pp. 22-35, 1983. [24] E.VV. Kent. M.O. Shneier, and R. Lumia, " PIPE: Pipeline image processing engine ", Parallel and Distributed Computing, Vol. 2, pp. 50-78, 1985. [25] Max Video product literature, Datacube Corp., Peabody, MA, 1987. [26] T. Gross, H.T. Kung, M.S. Lam, and J.A. Webb, " Warp as a machine for low-level vision", Proc. of the 1985 Int. Conf. on Robotics and Automation, 1985. [27] W.W. Wilcke, R.C. Booth, D.A. Brown, D.G. Shea, and F.T. Tong, "Design and appli¬ cation of an experimental multiprocessor", IBM RC 12604, 1987. [28] C. Withby-Strevens, "The Transputer", Proc. 12th ACM Int. Symp. on Computer Ar¬ chitectures, pp. 292-300, 1985. [29] L. Erman, "The Hearsay-II Speech- Understanding System: integrating knowledge to re¬ solve uncertainty", Computing Surveys Vol. 12, pp. 213-253, 1980. [30] H.P. Nii, "The blackboard model of problem solving and the evaluation of blackboard architectures", Al Magazine, Vol. 7, No. 2, pp. 38-53, 1986. [31] B.A. Draper, R.T. Collins, J. Brolio, J. Griffith, A.R. Hanson, and E.M. Riseman, "Tools and experiments in the knowledge-directed interpretation of road scenes", Proc. Image Understanding Workshop, Morgan Kaufmann: Los Altos, CA, 1987. [32] NCube Corp, Promotional literature, Beaverton, OR, 1985. [33] C. Fernstrom, I.Kruzela, B.Svensson, "LUCAS Associative Array Processor", Springer- Verlag, 1985, ch. 2. [34] S. Ruhman, I. Scherson, "Associative Memory Cell and Memory Unit Including Same", U.S. Patent 4,404,653, filed Oct. 1, 1981, issued Sep. 13, 1983. [35] I. Scherson, "Multioperand Associative Processing and Application to Tomography and Computer Graphics", Ph.D. thesis, Computer Sciences, Weizmann Institute of Science, 1983. [36] J. Worlton, "Some Patterns Technology Change in High- Performance Computers", Proc. Supercomputing, pp 312-320, Nov. 1988. [37] I. Scherson. S. Ruhman, ''Multi-Operand Associative Arithmetic ' , Proc. 6th Symp. on Computer Arithmetic, Aarhus 19S3, pp 124-128. [38] I. Scherson, S. Ruhman, "Multi- Operand Arithmetic in a Partitioned Associative Archi¬ tecture", J. of Parallel & Distr. Comp., Vol. 5., pp 655-668, 1988. [39] D.C. Marr, E. Hildreth, "Theory of Edge Detection", Proc. R. Soc. London, Vol. B 207, pp 187-217, 1980. [40] John Canny, "Computational Approach to Edge Detection", IEEE Trans, on Pattern Analysis k Machine Int., Nov. 1986, pp. 679-698. [41] E.R. Davis and A.P.N. Plummer, Thinning Algorithms: A Critique and New Methodol¬ ogy, Pattern Recognition 14: 53-63, 1981. [42] R.T. Chin, H.K. War, D.L. Stover, and R.D. Iverson, A One-Pass Thinning Algorithm and its Parallel Implementation, Comp. Vision, Graph. <k Image Proc. 40: 30-40, 1987. [43] W.E.L. Grimson, "A Computer Implementation of a Theory of Human Stereo Vision", Phil. Trans. Royal Soc. of London, Vol. B 292, pp 217-253, 1981. [44] D. Marr, T. Poggio, " A Computational Theory of Human Stereo Vision", Proc. Royal Soc. London B 204, pp 301-324, 1979. ■ [45] B.K.P. Horn, B.G. Schunck, Determining Optical Flow, Artificial Intelligence, Vol. 17, pp 185-203, 1981. [46] Amnon Sha'ashua and Shimon Ullman, "Structural Saliency: The Detection of Global Salient Structures Using a Local Connected Network", Proc. ICCV Conf., pp. 321-327, Florida, 1988. [47] Amnon Sha'ashua, "Structural Saliency: The detection of globally salient structures using a locally connected network", M.Sc thesis, Dept. of Applied Math., Weizmann Inst. of Science, 1988. [48] Amnon Sha'ashua, Al Lab., MIT, Private Communication, May 1991. [49] Duda R.O. and Hart P.E., "Use of the Hough transformation to detect lines and curves in pictures " , Comm. ACM Vol. 15, Num. 1, pp. 11-15, Jan. 1972. [50] O'Gorman, F. and M.B. Clowes "Finding picture edge through collinearity of feature points", Proc. Int. Joint Conf. on Artif. Intel., pp. 543-55, 1973. [51] A. Rosenfeld, A.C. Kak, "Digital Picture Processing", Academic Press, 1982. [52] Robert Sedgewick, "Algorithms", Addison-Wesley, 1988. [53] Preston, K., "The Abingdon Cross benchmark survey", IEEE Computer 22(7) , pp 9-18, 1989. [54] S. Siegel and S. Waitings, "MaxVideo 's Performance of the Abingdon Cross Bench- Mark, ", Proc. Vision '87, Society of Manufacturing Engineers, Dearborn, Mich., pp 2-17, 1987. [55] W.B. Teeuw and R.P.W. Duin, "An algorithm for benchmarking an SIMD pyramid with the Abingdon Cross", Pattern Recognition Letters 11, pp 501-506, 1990. [56] K. Preston Jr., "Benchmark Results - The Abingdon Cross", Evaluation of Multicom¬ puter for Image Processing, L. Uhr et al., eds., Academic Press, Cambridge, Mass., 1986. [57] A.J. Akerib, S. Ruhman, S. Ullman, "Real Time Associative Vision Machine", Proc. 7th Israel Conf. on Artif. Intel., Vision & Pattern Recog. Elsevier, Dec. 1990. [58] Avidan J. Akerib and Smil Ruhman, "Associative Contour Processing", MVP'90 IAPR Workshop on Machine Vision Applications, Nov. 28-30,1990, Tokyo. [59] Avidan J. Akerib and Smil Ruhman "Associative Array and Tree Algorithms in Stereo Vision", Proc. 8th Israel Conf. on Artif. Intel. Vision & Pattern Recog., Elsevier, Dec. 1991. All of the above references and publications cited therein are hereby incorporated by reference. Numbers in square brackets in the foregoing text are references to the above documents. SUMMARY OF THE INVENTION The present invention seeks to provide improved methods and apparatus for signal processing. The Associative Signal Processing (ASP) approach is now compared to a conventional serial computer's structure which includes a memory and a CPU. The CPU is responsible for computation, while the memory is a simple device which only stores data. The ASP architecture is totally different. The computation is carried out on an "intelligent memory" while the CPU is replaced by a simple controller that manages this "intelligent" memory. In addition to its capability to read and write, each cell or word in this memory can identify its contents and change it according to instructions received from the controller. For example, assume an array of a million numbers between 1 and 5. The requirement is to add 3 to the array. In conventional serial computers, a number is transferred from the addressable memory to the CPU, 3 is then added, and the result is returned to the memory. The process takes 1 - 3 machine cycles for each specific number, for a total of 1 - 3 million machine cycles for the whole array. In the associative approach the one million numbers are stored in the "intelligent memory". The controller has to ask five questions and generate five answers as follows: "Who is 5?" Please identify yourself." This takes one machine cycle. The controller instructs all those who identified themselves, to become "8". The controller continues to ask "Who is 4" and instruct "You are 7!" and so on, until it covers all the combinations. This operation takes only 10 machine cycles in comparison to 1 - 3 million machine cycles with conventional serial computers. Using this basic instruction set of read, identify and write, all the arithmetical and logical operations can be performed. There is thus provided, in accordance with a preferred embodiment of the present invention, associative signal processing apparatus for processing an incoming signal, the apparatus including an array of processors, each processor including a multiplicity of associative memory cells, each sample of an incoming signal being processed by at least one of the processors, a register array including at least one register operative to store responders arriving from the processors and to provide communication between processors, and an I/O buffer register for inputting and outputting a signal, wherein the processor array, the register array and the I/O buffer register are arranged on a single module. There is also provided, in accordance with a preferred embodiment of the present invention, associative signal processing apparatus including an array of processors, each processor including a multiplicity of associative memory cells, at least one of the processors being operative to process a plurality of samples of an incoming signal, a register array including at least one register operative to store responders arriving from the processors and to provide communication between processors, and an I/O buffer register for inputting and outputting a signal. Further in accordance with a preferred embodiment of the present invention, the processor array, the register array and the I/O buffer register are arranged on a single chip. Still further in accordance with a preferred embodiment of the present invention, the register array is operative to perform at least one multicell shift operation. There is also provided, in accordance with a preferred embodiment of the present invention, signal processing apparatus including an array of associative memory words, each word including a processor, each sample of an incoming signal being processed by at least one of the processors, a register array including at least one register operative to provide communication between words and to perform at least one multicell shift operation, and an I/O buffer register for inputting and outputting a signal. Further in accordance with a preferred embodiment of the present invention, the register array is also operative to perform single cell shift operations. Still further in accordance with a preferred embodiment of the present invention, the I/O buffer register and the processors are operative in parallel. Additionally in accordance with a preferred embodiment of the present invention, the word length of the I/O buffer register is increasable by decreasing the wordlength of the associative memory cells. Further in accordance with a preferred embodiment of the present invention, the apparatus is operative in video real time. Still further in accordance with a preferred embodiment of the present invention, the signal includes an image. Further in accordance with a preferred embodiment of the present invention, at least one word in the array of words includes at least one nonassociative memory cell. Still further in accordance with a preferred embodiment of the present invention, at least one word in the array of words includes at least one column of nonassociative memory cells. Further in accordance with a preferred embodiment of the present invention, the array, the register array and the I/O buffer register are arranged on a single module. Still further in accordance with a preferred embodiment of the present invention, the module has a bus which receives instructions and also performs at least one multicell shift operation. Additionally in accordance with a preferred embodiment of the present invention, the module has a first bus which performs at least one multicell shift operation and a second bus which performs at least one single cell shift operation. There is also provided, in accordance with a preferred embodiment of the present invention, an array of processors which communicate by multicell and single cell shift operations, the array including a plurality of processors, a first bus connecting at least a pair of the processors which is operative to perform at least one multicell shift operation, and a second bus connecting at least a pair of the processors which is operative to perform single cell shift operations. There is additionally provided, in accordance with a preferred embodiment of the present invention, a signal processing method including: for each consecutive pair of first and second signal characteristics within a sequence of signal characteristics, counting the number of samples having the first signal characteristic, and subsequently, counting the number of samples having the second signal characteristic. Further in accordance with a preferred embodiment of the present invention, counting includes generating a histogram. Still further in accordance with a preferred embodiment of the present invention, the signal includes a color imag e . Still further in accordance with a preferred embodiment of the present invention, at least one characteristic includes at least one of the following group of characteristics: intensity, noise, and color density. Further in accordance with a preferred embodiment of the present invention, the method also includes scanning a medium bearing the color image. Still further in accordance with a preferred embodiment of the present invention, the image includes a color image. There is also provided, in accordance with a preferred embodiment of the present invention, an edge detection method including identifying a first plurality of edge pixels and a second plurality of candidate edge pixels, identifying, in parallel, all candidate edge pixels which are connected to at least one edge pixel as edge pixels, and repeating the second identifying step at least once. There is additionally provided, in accordance with a preferred embodiment of the present invention, a signal processing method including storing an indication that a first plurality of first samples has a first characteristic, storing, in parallel for all individual samples which are connected to at least one sample having the first characteristic, an indication that the connected samples have the first characteristic, and repeating the second step at least once. Further in accordance with a preferred embodiment of the present invention, the signal includes an image and the first characteristic of the first samples is that the first samples are edge pixels. There is also provided, in accordance with a preferred embodiment of the present invention, a feature labeling method in which a signal is inspected, the signal including at least one feature, the feature including a set of connected samples, the method including storing a plurality of indices for a corresponding plurality of samples, replacing, in parallel for each individual sample from among the plurality of samples, the stored index of the individual sample by an index of a sample connected thereto, if the index of the connected sample is ordered above the index of the individual sample, and repeating the replacing step at least once. Further in accordance with a preferred embodiment of the present invention, replacing is repeated until only a small number of indices are replaced in each iteration. Still further in accordance with a preferred embodiment of the present invention, the signal includes an image. Additionally in accordance with a preferred embodiment of the present invention, the signal includes a color image. Still further in accordance with a preferred embodiment of the present invention, the samples include pixels, the first characteristic includes at least one color component and adjacency of pixels at least partly determines connectivity of samples. Additionally in accordance with a preferred embodiment of the present invention, the pixels form an image in which a boundary is defined and repeating is performed until the boundary is reached. Further in accordance with a preferred embodiment of the present invention, repeating is performed a predetermined number of times. There is also provided, in accordance with a preferred embodiment of the present invention, a method for image correction including computing a transformation for an output image imaged by a distorting lens, such as an HDTV lens, which compensates for the lens distortion, and applying the transformation in parallel to each of a plurality of pixels in the output image. There is also provided associative signal processing apparatus including a plurality of comparing memory elements each of which is operative to compare the contents of memory elements other than itself to respective references in accordance with a user-selected logical criterion, thereby to generate a responder if the comparing memory element complies with the criterion, and a register operative to store the responders. Further in accordance with a preferred embodiment of the present invention, the criterion includes at least one logical operand. Still further in accordance with a preferred embodiment of the present invention, at least one logical operand includes a reference for at least one memory element other than the comparing memory element itself. For example, a plurality of memory elements may be respectively responsible for a corresponding plurality of pixels forming a color image. The references may include three specific pixel values A, B and C and the user- selected logical criterion may be that an individual pixel have a value of A, OR that its upper right neighbor has a value of B and its lower left neighbor has a value of C. Further in accordance with a preferred embodiment of the present invention, each memory element includes at least one memory cell. Still further in accordance with a preferred embodiment of the present invention, the plurality of comparing memory elements are operative in parallel to compare the contents of a memory element other than themselves to an individual reference. There is also provided, in accordance with a preferred embodiment of the present invention, an associative memory including an array of PEs (processor elements) including a plurality of PE's, wherein each PE includes a processor of variable size, and a word of variable size including an associative memory cell, wherein all of the associative memory cells from among the plurality of associative memory cells included in the plurality of PE's are arranged in the same location within the word and wherein the plurality of words included in the plurality of PE's together form a FIFO. Further in accordance with a preferred embodiment of the present invention, the word of variable size includes more than one associative memory cell. There is also provided, in accordance with a preferred embodiment of the present invention, a method for modifying contents of a multiplicity of memory cells and including performing, once, an arithmetic computation on an individual value stored in a plurality of memory cells and storing the result of the arithmetic computation in a plurality of memory cells which contain the individual value. Further in accordance with a preferred embodiment of the present invention, storing is carried out in all memory cells in parallel. Also described herein is a chip for multimedia and image processing applications. It is suitable for low-cost, low power consumption, small size and high- performance real-time image processing for consumer applications and high-end powerful image processing for multimedia and communication applications. The chip is a general purpose, massively parallel processing chip, in which typically 1024 associative processors are crowded onto one chip, enabling the processing of 1024 digital words in one machine cycle of the computer clock. The chip was designed to allow the performance of a wide range of image processing and multimedia applications in real-time video rate. In comparison, existing general purpose, serial computing chips and digital signal processing chips (DSPs) enable the processing of only 1 - 16 words in one machine cycle. The chip's major instruction set is based on four basic commands that enable the performance' of all arithmetic and logic instructions. This is another design advantage that allows more than a thousand processors to be crowded onto a single chip. A single chip typically performs the equivalent of 500 - 2000 million instructions per second (MIPS) . A system based on the chip's architecture can reach multimedia performance of high-end computers at only a small fraction of the price of typical high-end computers. The chip is based on a modular architecture, and enables easy connection of more than one chip in order to gain high performance (in a linear ratio) . Thus, a large number of the chips can be connected in parallel in order to linearly increase overall performance to the level of the most sophisticated supercomputers . Existing CPU chips and DSPs require a dedicated operating system when more than one chip is connected in parallel. The performance increases in ratio to the square root of the number of chips connected together. Connecting more than two chips requires the architecture of a supercomputer. The chip's architecture allows massively parallel processing in concurrence with data input and output transactions. As an associative processor, each of the 1024 chips has its own internal memory and data path. The chip's data path architecture provides parallel loading of data into the internal processors, thereby eliminating the bottleneck between memory and CPU that can cause severe performance degradation in serial computers. The chip uses an average of 1 watt to perform the equivalent of 500 MIPS which is 10 - 25 times better than existing general purpose and DSP chips. BRIEF DESCRIPTION OF THE DRAWINGS The present invention will be understood and appreciated from the following detailed description, taken in conjunction with the drawings in which: Fig. 1 is a simplified functional block diagram of associative signal processing apparatus constructed and operative in accordance with a preferred embodiment of the present invention; Fig. 2 is a simplified flowchart of a preferred method for employing the apparatus of Fig. 1; Fig. 3 is a simplified block diagram of associative signal processing apparatus for processing an incoming signal which is constructed and operative in accordance with a preferred embodiment of the present invention; Fig. 4 is simplified block diagram of a preferred implementation of the apparatus of Fig. 1; Fig. 5 is a simplified block diagram of an alternative preferred implementation of the apparatus of Fig. 1; Fig. 6 is a simplified block diagram of a portion of the apparatus of Fig. 5; Fig. 7 is a simplified block diagram of a portion of the apparatus of Fig. 6; Fig. 8 is a simplified block diagram of another portion of the apparatus of Fig. 6; Fig. 9 is a simplified flowchart illustrating the operation of the apparatus of Fig. 5; Fig. 10 is a simplified pictorial diagram illustrating the operation of a portion of the apparatus of Fig. 5; Fig. 11 is a simplified block diagram of associative real-time vision apparatus constructed and operative in accordance with an alternative preferred embodiment of the present invention; Fig. 12 is a simplified pictorial illustration of the operation of the apparatus of Fig. 11 during compare and write commands; Fig. 13 is a simplified pictorial illustration of interprocessor communication within a portion of the apparatus of Fig. 11; Fig. 14 is a simplified block diagram illustrating chip interface and interconnections within a portion of the apparatus of Fig. 11; Fig. 15 is a simplified pictorial illustration of an automaton used to evaluate the complexity of the apparatus of Fig. 11; Fig. 16 is a simplified block diagram illustrating word format of associative memory within a portion of the apparatus of Fig. 11; Fig. 17 is a simplified block diagram illustrating another word format of associative memory within a portion of the apparatus of Fig. 11; Fig. 18 is a simplified block diagram illustrating an additional word format of associative memory within a portion of the apparatus of Fig. 11; Fig. 19 is a simplified block diagram illustrating an implementation of a method of thresholding utilizing the apparatus of Fig. 11; Figs. 20A - 20F are simplified pictorial illustrations of test templates illustrating an implementation of a method of thinning utilizing the apparatus of Fig. 11; Fig. 21 is a simplified block diagram illustrating an implementation of a method of matching utilizing the apparatus of Fig. 11; Fig. 22 is a simplified block diagram illustrating still another word format of associative memory within a portion of the apparatus of Fig. 11; Fig. 23 is a simplified block diagram illustrating an additional word format of associative memory within a portion of the apparatus of Fig. 11; Fig. 24 is a simplified block diagram illustrating another word format of associative memory within a portion of the apparatus of Fig. 11; Fig. 25 is a graphical illustration of comparative execution time for alternative implementations of a stereo method utilizing the apparatus of Fig. 11; Fig. 26 is graphical illustration of comparative complexity for alternative implementations of a stereo method utilizing the apparatus of Fig. 11; Fig. 27 is a simplified block diagram illustrating another word format of associative memory within a portion of the apparatus of Fig. 11; Fig. 28 is a simplified block diagram illustrating a portion of a method for edge detection utilizing the apparatus of Fig. 11; Fig. 29 is a simplified block diagram illustrating another word format of associative memory within a portion of the apparatus of Fig. 11; Fig. 30 is a simplified pictorial illustration of pixels used within a method for processing an associative saliency network utilizing the apparatus of Fig. 11; Fig. 31 is a simplified block diagram illustrating another word format of associative memory within a portion of the apparatus of Fig. 11; Fig. 32 is a graphical illustration of normal parameterization of a line used within a method for computing a Hough transform utilizing the apparatus of Fig. 11; Fig. 33 is a graphical illustration of a portion of a method for Convex Hull generation utilizing the apparatus of Fig. 11; Fig. 34 is a simplified block diagram illustrating a method for processing an associative Voronoi diagram utilizing the apparatus of Fig. 11; Attached herewith are the following appendices which aid in the understanding and appreciation of one preferred embodiment of the invention shown and described herein: Appendix A is a listing of a subroutine called "sub.rtn" which is called in each of the listings of Appendices B - 0; Appendix B is a listing of a preferred associative signal processing method for generating a histogram; Appendix C is a listing of a preferred associative signal processing method for ID convolution; Appendix D is a listing of a preferred associative signal processing method for a low pass filter application of 2D convolution; Appendix E is a listing of a preferred associative signal processing method for a Laplacian filter application of 2D convolution; Appendix F is a listing of a preferred associative signal processing method for a Sobel filter application of 2D convolution; Appendix G is a listing of a preferred associative signal processing method for curve propagation; Appendix H is a listing of a preferred associative signal processing method for optical flow; Appendix I is a listing of a preferred associative signal processing method for performing an RGB to YUV transformation; Appendix J is a listing of a preferred associative signal processing method for corner and line detection; Appendix K is a listing of a preferred associative signal processing method for contour label ing ; Appendix L is a listing of a preferred associative signal processing method for saliency networking; Appendix M is a listing of a preferred associative signal processing method for performing a Hough transform on a signal which is configured as a line; Appendix N is a listing of a preferred associative signal processing method for performing a Hough transform on a signal which is configured as a circle; and Appendix 0 is a listing of a preferred associative signal processing method for generating a Voronoi diagram signal. DETAILED DESCRIPTION OF PREFERRED EMBODIMENTS Reference is now made to Fig. 1 which is a simplified functional block diagram of associative signal processing apparatus constructed and operative in accordance with a preferred embodiment of the present invention. The apparatus of Fig. 1 includes a simultaneously accessible FIFO 10, or, more generally, any simultaneously accessible memory, which stores at least a portion of an incoming signal which arrives over a bus termed herein the DBUS. The simultaneously accessible FIFO 10 feeds onto a PE (processor element) array 16 including a plurality of PE's 20 which feed onto a datalink 30 which preferably also serves as a responder memory. Alternatively, a separate responder memory may be provided. Each PE includes at least one associative memory cell, more typically a plurality of associative memory cells such as, for example, 72 associative memory cells. Each PE 20 stores and processes a subportion of the image, such that the subportions stored and processed by all of the PE's 20 forms the portion of the incoming signal stored at a single time in the simultaneously accessible FIFO 10. For example, there may be 1024 PE's 20. If the processing task is simple enough to allow each PE to process 2 pixels at a time, then the FIFO may, at a single time, store a block of 2048 pixels within the color image. If the processing task is so complex that two PEs are required to process each pixel, then the FIFO may, at a single time, store a smaller block of only 512 pixels within the color image. The PE's 20 are controlled by a controller 40 which is typically connected in parallel to all the PE's. Reference is also made to Fig. 2 which is a simplified flowchart of a preferred method for employing the apparatus of Fig. 1. The first step of the method of Fig. 2 is step 54. In step 54, the system receives a user selected command sequence which is to be processed for each pixel of a current block of the color image. The command sequence is stored in command sequence memory 50. Typically, a command sequence comprises commands of some or all of the following types: a. Compare — Each of one or more PE's compares its contents to a comparand and generates an output indicating whether or not its contents is equivalent to the comparand. b. Write — Each of one or more PE's if its own contents and/or the contents of other PE's in its vicinity comply with a logical criterion preceding the write command, changes its contents in accordance with a provided writing operand. c. Single cell shift — The contents of each of one or more PE's shifts, via the datalink 30, into respectively adjacent one or more PE's. d. Multicell shift — The contents of each of one or more PE's shifts, via the datalink 30, directly into respectively non-adjacent one or more PE's, Also in step 54, the first block of the incoming signal is received by simultaneously accessible FIFO 10. The command sequence is then processed, command by command, as shown in Fig. 2. Reference is now made to Fig. 3 which is a simplified block diagram of associative signal processing apparatus for processing an incoming signal which is constructed and operative in accordance with a preferred embodiment of the present invention. The signal processing apparatus of Fig. 3 includes the following elements, all of which are arranged on a single module 104 such as a single chip: a. An array 110 of processors or PE's 114, of which, for simplicity, three are shown. Each processor 114 includes a multiplicity of memory cells 120, of which, for simplicity, four are shown. From among each multiplicity of memory cells 120, at least one memory cell (exactly one, in the illustrated embodiment) is an associative memory cell 122. The associative memory cell or cells 122 of each processor are all arranged in the same location or locations within their respective processors, as shown. As an example, there may be IK processors 114 each including 72 memory cells 120, all of which are associative. Preferably, at least one of the processors is operative to process more than one sample of an incoming signal . b. A responder memory 130 including one or more registers which are operative to store responders arriving from the processors 120 and, preferably, to serve as a datalink therebetween. Alternatively, a separate datalink between the processors may be provided. Preferably, the datalink function of memory 130 allows at least one multicell shift operation, such as a 16-cell per cycle shift operation, to be performed. The datalink function of memory 130 also preferably performs single cell shift operations in which a shift from one cell to a neighboring cell or from one PE to a neighboring PE is performed in each cycle. c. A simultaneously accessible FIFO 140, or, more generally a simultaneously accessible memory, which inputs and outputs a signal. d. A responder counting unit 150 which is operative to count the number of "YES" responders in responder memory 130. e. Comparand, mask and write operand registers 180, as described above with reference to Fig. 1. A command sequence memory 160, which may be similar to the command sequence memory 50 of Fig. 1, and a controller 170 are typically external to the module 104. The controller 170 is operative to control the command sequence memory 160. Preferred methods for associative signal processing are now described, including: a. Low level associative signal processing methods — histogram generation, ID and 2D convolution, curve propagation, optical flow, and transformations between color spaces such as RGB to YUV transformations; and b. Mid-level associative signal processing methods — corner and line detection; contour labeling, saliency networking, Hough transform, and geometric tasks such as convex hull generation and Voronoi diagram generation. Each of the above associative signal processing methods are now described. Histogram generation: A preferred histogram generation method is now described with reference to Appendix B which is a listing of one software implementation of a histogram generation method. The method of Appendix B includes a very short loop repeated for each gray level. A COMPARE instruction tags all the pixels of that level and a COUNTAG tallies them up. The count is automatically available at the controller, which accumulates the histogram in an external buffer. Convolution: Low level vision, particularly edge-detection, involves the application of various filters to the image, which are most conveniently executed by convolution. The image may be considered as a simple vector of length N X M or as a concatenation of N row vectors, each of length M. Convolution of an N-element data vector by a P-element filter results in a vector of length N+P-l, but only the central N-P+l elements, representing the area of full overlap between the two vectors, are typically of interest. The convolution filter vector [f], of length P and precision 8, is applied as an operand by the controller, one element at a time. The result may, for example, be accumulated in a field [fd] of length 8+8+log2(P) . A "temp" bit is used for temporary storage of the carry that propagates through field [fd]. A "mark" bit serves to identify the area of complete overlap by the filter vector. An example of a row convolution method is provided in Appendix C. An example of a 2D convolution method which implements a low pass filter is provided in Appendix D. An example of a 2D convolution method which implements a Laplacian filter is given in Appendix E. An example of a 2D convolution method which implements the Sobel method of edge detection is given in Appendix F. Curve Propagation: Curve propagation is useful in that it eliminates weak edges due to noise, but continues to trace strong edges as they weaken. On the basis of signal statistics and an estimate of noise in the image, two thresholds on gradient magnitude may be computed - "low" and "high". Edge candidates with gradient magnitude under "low" are eliminated, while those above "high" are considered edges. Candidates with values between "low" and "high" are considered edges if they can be connected to a pixel above "high" through a chain of pixels above "low". All other candidates in this interval are eliminated. The process involves propagation along curves. Associative implementation, a method for which is set forth in detail in Appendix G, uses three flags: l. "E", which initially marks candidates above "high" threshold (unambiguous edge points), and eventually designates all selected edge points; li. "OE" (Old Edges) — to keep track of confirmed edges at the last iteration; and iii. "L" to designate candidates above "low". At every iteration, each "L" candidate is examined to see if at least one of its 8-neighbors is an edge, in which case it is also declared an edge by setting "E". Before moving "E" into "OE", the two flags are compared to see if steady state has been reached, in which case the process terminates. Optical Flow: Optical flow assigns to every point in the image a velocity vector which describes its motion across the visual field. The potential applications of optical flow include the areas of target tracking, target identification, moving image compression, autonomous robots and related areas. The theory of computing optical flow is typically based on two constraints: the brightness of a particular point m the image remains constant, and the flow of brightness patterns varies smoothly almost everywhere. Horn & Schunck derived an iterative process to solve the constrained minimization problem. The flow velocity has two components (u,v) . At each iteration, a new set of velocities [u (n+1) , v (n+1) ] can be estimated from the average of the previous velocity estimates. A method for implementing the Horn and Schunk method associatively is given in Appendix H. Color Space Transformation: One of the major task in color image processing is to transform the 24 bit space of the conventional Red (R) , Green (G) and Blue (B) color components, to another space such as a (Y,U,V) space which is more suited for color image compression. A preferred associative method for color space transformation is set forth in Appendix I. Detection of Corners and Line Direction: An important feature for middle and higher level processing is the ability to distinguish corners and line direction. In Canny edge detection, line orientation is generated during the process. On the other hand, the M&H algorithm is not directional, and the edge bit-map it produces must be further processed to detect line orientation. According to a preferred embodiment of the present invention, an edge bit-map of a 9 X 9 neighborhood around each pixel is used to distinguish segment direction. The resulting method can typically discriminate 120 different lines and corners. A program listing of this method is set forth as Appendix J. Contour Tracing and Labeling: A preparation step labels each contour point with its x,y coordinates. The process is generally iterative and operates on a 3 X 3 neighborhood of all contour points in parallel. Every contour point looks at each one of its 8 neighbors in turn and adopts the neighbor's label if smaller than its own. The circular sequence in which neighbors are handled appreciably enhances label propagation. Iteration stops when all labels remain unchanged, leaving each contour identified by its lowest coordinates. The point of lowest coordinates in each contour is the only one to retain its original label. The lowest coordinate points have been kept track of and are now counted to obtain the number of contours in the image. A preferred associative method for performing this method is set forth in Appendix K. Associative Saliency Networkin : Salient structures in an image can be perceived at a glance without the need for an organized search or prior knowledge about their shape. Such a structure may stand out even when embedded in a cluttered background or when its elements are fragmented. Sha'ashua & Ullman have proposed a global saliency measure for curves based on their length, continuity and smoothness. The image is considered as a network of N X N grid points, with d orientation elements segments or gaps coming into each point from its neighbors, and as many going out to its neighbors. A curve of length L in this image is a connected sequence of orientation elements p(i),p(i+l), ... ,p(i+L), each element representing a line-segment or a gap in the image. An associative implementation of this method is set forth in Appendix L. Hough Transform: The Hough transform detects a curve whose shape is described by a parametric equation, such as a straight line or a conic section, even if there are gaps in the curve. Each point of the figure in image space is transformed to a locus in parameter space. After splitting the parameters into suitable ranges, a histogram is generated giving the distribution of locus points in parameter space. Occurrence of the object curve is marked by a distinct peak in the histogram (intersection of many loci) . In the case of a straight line the normal parameterization may be used and given by: Xcos (A) + Ysin(A) = R which specifies the line by R and the angle A, and the histogram includes a straight line in every direction of A. But if the candidate points are the result of edge detection by a method that yields direction, then the angle A is known. An associative implementation of this method is set forth in Appendix M. Example: The major steps required to perform a Hough transform operation for a sample image of 256 X 256 pixels are now described: The 256 X 256 image with the origin at its center is arranged linearly pixel after pixel and row after row in multiple chips, each in one processor. For example, if the chip includes IK processors, 64 chips may be used to hold the 256 X 256 = 64K. The x-y coordinates are given by 8 bits in absolute value and sign. Angle A from 0 to pi (3.1415...) is given to a matching precision of 10 bits (excluding sign of gradient) . The sine and cosine are evaluated by table look-up. Preferably, the table size is recued four-fold to take into account the symmetry of these functions. After comparing A, the histogram is evaluated and read¬ out element by element using a "countag" command. Example: A circle with given radius R and center x0,y0 is to be detected. The direction of the gradient is employed to simplify the process, dy/dx = (x-xO) / (y-yO) = tan(T- pi/2), by differentiation, where T is the gradient direction. Solving for xO and yO: xO = x +/- R sin (T - pi/2); and yO = y +/- R cos (T - pi/2) . A histogram is generated for x0,y0. An associative implementation of a preferred Hough transform is set forth in Appendix N. Vorono Diagram: This type of diagram is useful for proximity analysis. Starting with a given set of L points in the plane, P(ι), ι=l,2, ...,L, the Voronoi diagram surrounds each point P(ι) by a region, R(ι), such that every point in R(ι) is closer to P(ι) than to any other point in the set, P(] ) , ]=1, 2, ...L and 1 not equal to ]. The boundaries of all these regions, R( ), constitute the Voronoi diagram. An associative method based on the "brush fire" technique is presented in Appendix 0. Each of the given points acts as a source of "fire" that spreads uniformly in all directions. The boundaries consist of those points at which fires from two (or three) sources meet. Every point in the given set is initially marked with a different color, such as its own xy-coordinates. Each point n the image looks at its 8-neιghbors. A blank (uncolored) point that sees a colored neighbor will copy its color. If both are colored, the point will compare colors, marking itself as a Voronoi (boundary) point if the colors are different. This process s iterated until all points are colored. The following are basic associative signal processing steps which are frequently used in the methods of Appendices B to 0. Any of the steps categorized as Group 1 may be carried out in parallel with any of the steps from Group 3. Also, any of the steps from Group 1, any of the steps from Group 2 and any of the steps from Group 4 may be carried out in parallel. Group i Number Step .abbreviation. Step (full description. Load mask register Load comparand register Load mask and comparand Load mask clear comparand Load mask clear comparand Load comparand set mask Load mask exclusive Load comparand exclusive Load mask set comparand Set mask exclusive Set comparand exclusive Group 2 12 SETAG Set all responders to (yes) Group 3 13 SHUP Single cell shift up 14 SHDN Single cell shift down 15 LGUP Multiple cell shift up 16 SHUP Multiple cell shift down Group 4 17 COMPARE Search for a specific value 18 WRITE Write a value to one or more processors simultaneously Read data from one processor Count all responders Mark the first responder FIFO Select I/O bit/s for FIFO 23 NOP No operation To employ any of the methods described in any of Appendices B to 0, the listings of Appendices B to 0 may be run on any "C" language compiler such as the Borland "C++" compiler, using the CLASS function. As already described, each of the methods of Appendices B to 0 includes the following steps: a. a basic memory size defining step; b. a basic associative word length defining step; c. a step in which the subroutine of Appendix A is called; and d. steps which are specific to the individual application. It is appreciated that the particular embodi¬ ment described in the Appendices is intended only to provide an extremely detailed disclosure of the present invention and is not intended to be limiting. One implementation of an associative signal processing chip is now described. The implementation is termed herein ASP 100. 1. Introduction The ASP100 is an associative processing chip. It is intended to serve as part of the Vision Associative Computer, most likely in an array of multiple AΞP100 chips . The ASP100 consists of an associative memory array of lKx72 bits, peripheral circuitry, image FIFO I/O buffer, and control logic. 2. Modes of Operation The ASP100 can be operated as a single chip (Single Chip Mode) or as part of an array of ASP100 chips (Array Mode) . 2.1 Single Chip Mode The Single Chip Mode is shown in Figure 4. In this mode a single ASPlOO is operated in conjunction with a controller. 2.2 Array Mode The Array mode is shown in Figure 5. An array of ASPlOO chips are interconnected in parallel, constituting a linear array. A single controller chip, or a suitable circuit, controls the array. 3. Pinout 3.1 Basic Pinout The ASPlOO may be packaged in a 160 pin PQFP package. All output and I/O pins are 3-state, and can be disabled by CS. Following is the complete list of pins: PRSP Precharse RSP line I FIRCNTEN Connec t s tag to first-se! and count-tag circ us FENB Enable FIFO I/O 150. t otal # of pins 3.2 Test Pinout The following is a list of the pins which serve as test points. They can be ignored while packing the production version: 4. Architecture and Operation 4.1 Top-Level View The top-level view is shown in Figure 6. ARRAY is the main associative array. FIFO is the image input/output fifo buffer. SIDE is the side-array, consisting of the tag, the tag logic, the tag count, the select-first, the row drivers (of riteLine and MatchLine) and sense amplifiers, and the shift units. TOP consists of the mask and comparand registers, and the column drivers (of BitLine, InverseBitLine, and MaskLine) . BOTTOM contains the output register and sense amplifiers. CONTROL is the control logic for the chip. Microcontrol is external in this version. 4.2 ARRAY Architecture The Array consists of 1024x72 associative processing elements (APEs), organized in three columns of 24 APEs wide each, and physically split into three blocks of 342x72 APEs. This six-way split achieves square aspect ratio of the layout and also helps contain the load of the vertical bus wires. As is explained in Section 4.3 below, one 24 bit sector of the array is reconfigurable as follows (by means of the "CONFIFO" Configure Fifo instruction) : 1. All 24 bits serve as FIFO (total ARRAY width is 48) . 2. 16 bits FIFO, 8 bits ARRAY (total ARRAY width is 56) . 3. 8 bits FIFO, 16 bits ARRAY (total ARRAY width is 64) . The Associative Processing Element (APE) is a Content Addressable Memory (CAM) cell. It consists of three components : Storage element; Write device; Match device. There are three vertical incident buses and four horizontal incident buses in the APE: Vertical: Bit Line (BL) Inverse Bit Line (IL) Mask Line (MASK) Horizontal: Write Line (WL) Match Line (ML) VDD VSS (GND) The Storage element consists of two cross coupled CMOS inverters. The Write device implements the logical AND of MASK and WL, so that it can support the MASKED WRITE operation. The Match device implements a dynamic EXCLUSIVE OR (XOR) logic. This technique allows area efficient and reliable implementation of the COMPARE operation. 4.3 FIFO Architecture Reference is now made to Fig. 7. The FIFO is designed to input and output image data in parallel with computations carried out on the ARRAY. It consists of a reconfigurable MATRIX of 1024 x [24 or 16 or 8] APEs 190, three columns 192 each of 1024 bi-directional Switches, and Address Generator 194. The corresponding section of the Comparand register, in TOP, serves as the FIFO input register, and the corresponding section of the Output Register, in BOTTOM, serves as the FIFO Output Register. The FIFO Controller FC resides in TOP. The FIFO is configured by the CONFIFO instruction, where the three LSBs of the operand are: 6 for 8 bit FIFO, 5 for 16 bit FIFO, 3 for 24 bit FIFO, and 7 for no FIFO. When FIFO is 8 bits w de, inputs VIN[0:7] and outputs VOUT[0:7] are routed to bits [0:7] of the FIFO, where bit 0 is the "leftmost" bit. When FIFO is 16 bits wide, inputs VIN[0:15] and outputs VOUT[0:15] are routed to FIFO bits [0:15], such that the least significant byte (0:7) is the same routing as in the previous case. Similarly, when the FIFO is 24 bits wide, the least significant 2 bytes are routed in the same way as in the case of a FIFO 16 bits wide. The Address Generator 194 consists of a shift register and implements a sequential addressing mode. It selects a currently active FIFO word line. The FIFO has two modes of operation, IMAGE I/O Mode and IMAGE EXCHANGE Modes. The bi-directional Switches (one column of the three) disconnect the MATRIX from the ARRAY in IMAGE I/O Mode (see below) and connects the MATRIX to the ARRAY in IMAGE EXCHANGE Mode, creating a combined array of APEs. The Input and Output Registers serve as buffer registers for the image I/O. IMAGE I/O Mode In IMAGE I/O Mode, a new image is read into the FIFO, while the processed (preceding) image is written out. The FIFO Controller (FC) controls the FIFO as follows: Pixel I/O is synchronous with the CLK. External control input RSTFIFO resets (clears) the Address Generator 194. FENB (asserted for at least 2 CLK cycles) enables the input (and output) of the next pixel (on the positive edge of CLK) . Once all pixels entered (and output), FFUL is asserted for 2 CLK cycles. This I/O activity is performed asynchronously of the computation in the rest of the chip. The basic operation of IMAGE I/O mode is carried out as follows. The pixel at the VIN pins is entered into the FIFO Input Register (the FIFO section of the comparand register) . The Address Generator 194 enables exactly one word line. The corresponding word is written into the FIFO Output Register (the FIFO section of the Output Register) , and through it directly to the VOUT pins, in an operation similar to Read execution. Subsequently, the word in the FIFO Input Register is written into the same word, similar to a Write execution. Note that VOUT pins are 3-state. They are enabled and disabled internally as needed. This sequence of operations is carried out in a loop 1024 times in order to fill the 1024 processors with data. Multiple ASPlOO chips can be chained together with a FENB/FFUL chain, where the first ASPlOO receives the FENB from an external controller (true for 2 cycles), the FFUL of each ASPlOO (true for 2 cycles) is connected directly to the FENB input of the next chip, and the last FFUL goes back to the controller. IMAGE EXCHANGE Mode In IMAGE EXCHANGE Mode, the image previously loaded into the FIFO is transferred into the ARRAY for subsequent processing, and the previously processed image from the ARRAY is transferred to the FIFO for subsequent output. These transfers are carried out via the TAG register of the SIDE block by a sequence of COMPARE and WRITE operations, as follows: IMAGE IN A destination bit slice of the ARRAY is masked by MASK register and is then reset by a chain of SETAG; ClearComparand,WRITE operations (which can all be executed in one cycle) . A source bit slice of the FIFO MATRIX is masked by the MASK register. The contents of the bit slice are passed to the TAG register as a result of the COMPARE operation. The destination bit slice is masked again and then the contents of the TAG register are passed to the destination bit slice by a SetComparand, WRITE operation. In summary, the following five cycles are employed: FOR (all bit slices of FIFO) : LMCC (sector 0/1/2, destination ARRAY bit); SETAG; WRITE /* reset destination bit slice in the proper array sector */ LETMC(sector 2, source FIFO MATRIX bit); COMPARE /* copy source slice (FIFO sector) to TAG */ LETMC(sector 0/1/2, destination ARRAY bit); WRITE /* copy TAG to destination in the proper sector */ IMAGE OUT This operation is carried out in exactly the same way as IMAGE IN, except that a destination bit slice is allocated m the FIFO MATRIX while a source bit slice is allocated in the ARRAY. Note that IMAGE EXCHANGE operation requires two different fields in the ARRAY (a first field for allocation of a new image, and a second one for temporary storage of the processed image) . The two operations (IMAGE IN & OUT) can be combined in one loop. 4.4 SIDE Architecture Reference is now made to Fig. 8 which illustrates a preferred implementation of the SIDE block of Fig. 6. The SIDE block is shown to include the TAG register, the NEAR neighbor connections, the FAR neighbor connections, the COUNT_TAG counter, the FIRST_RESPONDER circuit, the RSP circuit, and the required horizontal bus drivers and sense amplifiers. The TAG register consists of a column of 1024 TAG_CELLs. The TAG register is implemented by D flip flop with a set input and non-inverse output. The input is selected by means of a 8-ιnput multiplexer, with the following inputs: FarNorth, NearNorth, FarSouth, NearSouth, MatchLme (via sense amp) , TAG (feedback loop) , GND (for tag reset) , and FirstResponder output. The mux is controlled by MUX[0 : 2 ] . The NEAR neighbor connections interconnect the TAG_CELLs in an up/down shift register manner to nearest neighbors. They are typically employed for neighborhood operations along an image line, since pixels are stored consecutively by lines. The FAR connections interconnect TAG_CELLs 16 apart, for faster shifts of many steps. They are typically used for neighborhood operations between image lines. The following instructions affect TAG: SETAG, SHUP, SHDN, LGUP, LGDN, video load up and video load down microcode signals termed herein VLUP and VLDN respectively, COMPARE, FIRSEL. The COUNT_TAG counter counts the number of TAG_CELLs containing '1' . It consists of three iterative logic arrays of 1x342 cells each. The side inputs of the counter are fed from the TAG register outputs. The counter operates in a bit-serial mode, starting with the least significant bits. In each cycle, the carry bits are retained in the FF (memory cell flip-flop) for the next cycle, and the sum is propagated down to the next stage. The counter is partitioned into pipeline stages. The output of all six columns are added by a summation stage, which generates the final result in a bit-serial manner. The serial output appears on the CTAG outputs and signal CTAGVAL (CTAG valid) is generated by the controller. COUNT_TAG counter is activated by the COUNTAG instruction. The FIRST_RESPONDER circuit finds the first TAG CELL containing '1', and resets all other TAG_CELLs to '0' . It is activated by the FIRSEL instruction. The beginning of the chain is fed from a FIRSTIN input, wherein FIRSTIN is a microcode command according to which the first arriving datum is the first datum to enter the chip memory. If FIRSTIN is '0', then all TAG_CELLs are reset to '0' . This is intended to chain the FIRST_SELECT operation over all ASPlOOs interconnected together, and the OR of the RSP outputs of the lower-numbered ASPlOO should be input into FIRSTIN. The TAG outputs can be disconnected from the FIRST_RESPONDER and COUNT_TAG circuits, in order to save power, by pulling the FIRCNTEN control input to '0' . The RSP circuit generates ' 1' on the RSP output pin after COMPARE instruction, if there is at least one '1' TAG value. This output is registered. 4.5 TOP Architecture The TOP block consists of the COMPARAND and MASK registers and their respective logic, and the vertical bus drivers. The COMPARAND register contains the word which is compared against the ARRAY. It -is 72 bits long, and is partitioned according to FIFO configuration (see Section 4.3) It is affected by the following instructions: LETC, LETMC, LMCC, LMSC, LCSM. All these instructions affect only one of the three sectors at a time, according to the sector bits. The FIFO section of the COMPARAND operates differently, as described in Section 4.3. The MASK registers masks (by '0') the bits of the COMPARAND which are to be ignored during comparison and write. The BitLines and InverseBitLines of the masked bits are kept at '0' to conserve power. It is affected by the following instructions: LETM, LETMC, LMCC, LMSC, LCSM, LMX, SMX. The former five instructions affect only one sector at a time, whereas LMX and SMX also clear the mask bits of the non-addressed sectors. The FIFO section of the MASK operates differently, as described in Section 4.3. The 24 bit data input from DBUS (the operand) are pipelined by three stages, so as to synchronize the operand and the corresponding control signals. 4.6 BOTTOM Architecture BOTTOM contains the BitLine and InverseBitLine sense amplifiers, the Output Register and its multiplexor, the DBUS multiplexors, and the DBUS I/O buffers. Since the ARRAY is physically organized in three columns, the output of the three sense amplifiers must be resolved. A logic unit selects which column actually generated the output, as follows: READ: Select the column whose RSP is true. FIFO OUT: Select the column in which the address token is in. The Output Register is 72 bits long. 8 or 16 or 24 bits serve the FIFO and are connected to the VOUT pins. On READ operation, one of the three sectors (according to the sector bits) is connected to 24 bits of DBUS via a multiplexor. DBUS multiplexors allow two configurations: 1. SHIFT: Connects the south long shift (from rows 1008:1023) to DBUS [31: 16] and the north long shift lines (from rows 0:15) to DBUS[15:0]. 2. READ: Connects bits [15:0] (bit 0 is LSB) of the Output Register to DBUS [15:0], and bits [23:16] of the OR to DBUS[23: 16] . The DBUS I/O buffers control whether the DBUS is connected as input or output, and are controlled by the HIN and LIN control signals: Instruction LIN HIN SHUP, LGUP, VLUP 1 0 SHDN, LGDN, VLDN 0 1 READ 0 0 other 1 1 Since, in SHIFT mode, lines DBUS [31: 16] of one ASPlOO chip must be connected to lines DBUS [15:0] of the next ASPlOO chip, the external connections are not simply bused but should be switched as necessary. 4.7 CONTROL Architecture The ASPlOO is controlled by means of an external microcoded state machine, and it receives the decoded control lines. The external microcontroller allows horizontal microprogramming with parallel activities . The combined operation of APS100, its microcontroller, and the external controller is organized in a five-stage instruction pipeline, consisting of the following stages: Fetch, Decode, microFetch, Comparand, and Execute. In the Fetch stage, the instruction is fetched from the external program memory, and is transferred over the system bus to the IR (instruction register) . In the Decode stage, the instruction (from the IR) is decoded by the microcontroller and stored in the μlR. In the μFetch stage, the control codes are transferred from the external μlR, through the input pads, into the internal μlR. In the Comparand stage, parts of the execution which affect the Comparand register are carried out, and the control codes move from the internal μlR to the internal μIR2. In the Execute stage, execution in the ARRAY and other parts takes place. See Figure 9. Note that more pipeline stages separate the ASPlOO from the External Program Memory, necessary for instruction transfer from the memory via the bus to the IR inside the microcontroller. Pipeline breaks occur during SHIFT and READ, when DBUS is used for data transfer rather than instructions, and as a result of branches. Branches are handled by the external controller, and are interpreted as NOP by the APS100 microcontroller. Similarly, operations belonging to the controller are treated as NOPs. 4.8 Initialization On Reset (active low) , all ASPlOO internal registers are set to zero, except for TAG and the memory array. 4.9 Operation Notes 1. Write is designed so that while WRITE;COMPARE,-WRITE: ... can be done, two consecutive WRITES and two consecutive COMPARES cannot. 2. In all instructions which include SETs, such as SETAG, the corresponding control signal LETM and/or LETC must be set high. This is required since the set and reset of the comparand and mask registers is synchronous. 4.10 Clock Generator Preferably, a single 50 MHz CLKIN clock is input into the ASPlOO. In addition, a clock synchronization control DCKIN signal is also input. The CLKIN signal serves as the clock of the generator circuit. DCLKIN is an input signal (abiding by the required setup and hold timing) . The circuit creates two clocks of, for example, 25 MHz, CLK and DCLK, delayed by 1/4 cycle relative to each others. CLK is fed back into a clock-generating pad, to provide the required drive capability. CLK, DCLK and their complements provide for four-phase clocking, as shown in Figure 10. 5. Programming Model 5.1 Instruction Set An example of an instruction set is now described. Two instruction formats are employed. Instruction format A is used for Group 1 and READ instructions, and instruction format B is used for all other groups. It contains one bit for NOP, five OpCode bits, two sector bits, and 24 operand bits. Instruction format B contains one bit for NOP, seven OpCode bits, and 24 operand bits. As presented here, these formats do not allow parallel execution of multiple instructions. It is appreciated that, in an alternative implementation of the instruction set format, parallel execution of multiple instructions could be included. In the following table, d(n) is a n-bit argument, n<24, and s(2) is a 2-bit sector number. Parallel ("Horizontal") Execution 1. Groups 1,3 instructions can be carried out in parallel. 2. Groups 1,2,4 instructions can be carried out in parallel. It is appreciated that various features of the invention which are, for clarity, described in the contexts of separate embodiments may also be provided in combination in a single embodiment. Conversely, various features of the invention which are, for brevity, described in the context of a single embodiment may also be provided separately or in any suitable subcombination. Associative real time vision research vision research findings of Dr. Avidan Akerib, which were submitted to the Weizman Institute of Science, Rehovot, Israel, in the framework of a doctoral thesis, are now described with reference to Figs. 11 - 34. The ARTVM Architecture The Associative Real Time Vision Machine (ARTVM) was endowed with a number of char¬ acteristics which enable it to meet the vision requirements. In describing the structure of the machine and its primitive operations these attributes will be emphasized. Referring to Fig. 11, the core of the machine is a basic, classical, associative processor that is parallel by bit as well as by word. The main associative primitive is COMPARE. The comparand register is matched against all words of memory simultaneously and agreement is indicated by setting the corresponding tag bit. The comparison is only carried out in the bits indicated by the mask register and the words indicated by the tag register. Status bit rsp signals that there was at least one match (Fig. 12). The WRITE primitive operates in a similar manner. The contents of the comparand are simultaneously written into all words indicated by the tag and all bits indicated by the mask (Fig. 12). The READ command is normally used to bring out a single word, the one pointed to by the tag. Since the combination COMPARE- WRITE is of the type u if condition then action" , all logical and arithmetic functions can be executed [3]. Hence the associative machine may be regarded as an array of simple processors, one for each word in memory. ARTVM provides N x N words, one for each pixel in the image to be processed, and the pixels are arranged linearly, row after row. The full machine instruction set is given in the following table. Neighborhood operations which play an important role in vision algorithms, require bring¬ ing data from "neighboring" pixels. Data communication is carried out a bit slice at a time via the tag register, by means of the SHIFTAG primitives, as shown in Fig. 13. The number of shifts applied determines the distance or relation between source and destination. When this relation is uniform, communication between all processors is simultaneous. Fortunately, neighborhood algorithms only require a uniform communication pattern. Since the image is two-dimensional while the tag register is only one-dimensional, communication between neighbors in adjacent rows requires N shifts. To facilitate these long shifts a multiple shift primitive, SHIFTAG(±&), was implemented in hardware, where 6 is a sub-multiple of N. The time complexity in cycles for shifting an N x N image k places is given by [5 + k — [£(& — 1)], where M is the precision and b is the extent of the multiple-shift primitive. Loading data images into associative memory and outputting computed results could take up much valuable processor time. This can be avoided by distributing a frame buffer within associative memory and giving it access to the tag register [33]. That is the function of the I/O Buffer Array which consists of a 16-bit shift register attached to each word. A stereo image frame can be shifted into the buffer array as it is received and digitized, without interfering with associative processing. During vertical blanking, the stereo image frame is transferred into associative memory, a bit slice at a time, using Vj = 0, 1,2,-- • , J-\ V/c = 0,1,2,---,Λ ' -1 and V. = 1, 2,3, • ■ ■ , L - 1 Tag Operations SETAG: T n <- 1 SHIFTAG(±l): T„±_ <- T„ (One-Place Shift) SHIFTAG(±b): r„± 6 <-T„ (Long Shift) TAGXCH: T } *-B,o, B. ( ,_i ) <- Bji, B. (L _. ) <- T } COUNTAG: 5 <- ~ " ~ n T,. FIRSEL- T ■<- ^ " " ^ ~ "n is """e ~~ rst " " " of ~ ^ 0 otherwiselll Comparand and Mask Initialization Let X denote any one of the following: M (Mask), C (Comparand), MC (Mask & Comparand) SETX: X k «- 1 LETX opti o tS opΛ? Where: optl=d{r_),d{r 2 ),---,d(r_) opt2 = c._!e5(uι , u_) opt5 = tfror(vι, ϋ 2 , ) and options can be intermingled in any order. Then: 1 Vλ = ri • • • r. if optl defined 1 Vfc = tii • • • LI_ if opt2 defined Xk*- { Pk-v_ Vfe € [ i , V] if optS defined 0 otherwise Compare Operation COMPARE: Read Write Operations READ: Λ <- |+|. _4„*T„ WRITE: _4„ fc <-r„Λ„*ωT„(M*C fc ωM*_4„*) The symbols tt),φ and (+) stand for or, exclusive-or and or-expansion, respectively. the TAGXCH (TAG eXCHange) primitive. Under this command, the buffer array is rotated right circularly via the tag register. If results of computation on the previous frame are available for output, they can be entered into the tag by a compare instruction before executing the tagxch. which will now put out a bit-slice at the same time that it brings one i - hence the name tag exchange for this primitive. For a full stereo image this operation mus be repeated 16 times. During the next frame time, both input and output proceed in paralle with processing without interference. The following routine will exchange the contents of th buffer array with those of a 16-bit field in associative memory starting at bit position iO, or(i=iO;i<iO+16;i++) { letmc d(i); setag; compare; /* load tag with memory bit slice */ letc; write; /* clear bit slice in memory */ tagxch; /* exchange bit slice with buffer array */ letmc d(i) ; write; /* load memory with bit slice from buffer »/ } Execution time is 64 machine cycles (under 2 μs), which is negligible compared to th vertical blanking period (1.8 τns). While the sample routine exchanges data between th buffer array and a continuous field in memory, it should be noted that the tagxch primitiv is quite flexible, can fetch data from one field and put to another, and both fields can b distributed. Up to four operations may be done concurrently during a given memory cycle: SETAG or SHIFTAG; loading M (SETX, LETX); loading C (SETX, LETX); and COMPARE, REA .X or WRITE. FIRSEL resolves multiple responses in 6 cycles. COUNTAG is used to compil \ statistics and executes in 12 cycles. Control functions are given in the C language, and are carried out in parallel with the associative operations, hence do not contribute to th execution time. To illustrate parallel processing capability, suppose that associative memory contains tw data vectors, A and B, each having J elements and A_ ~ -bit precision. We wish to replace vecto field B by the sum A + B. The associative operation is carried out sequentially, a bit slic at a time, starting with the least significant bit. In each step, the three slices A{, B_ and (i = 0, 1, • • • , M — 1, and C is the carry slice) are compared in parallel to an input combinatio of the applicable truth table by means of the statement βetm d(.); letc d(.); setag; compare] followed by a parallel replacement of B and C with the appropriate output combination b means of the statement [letc d(.) write]. A full description of the routine is given in Th Machine Simulator. The execution time of addition in machine cycles is 8.5M which is see to be independent of vector size J. It follows that for a 512 x 512 image (J = 2 18 ) and machine cycle of 30 nanoseconds (see VLSI Chip Implementation and Interconnection) , th machine executes 125 billion 8-bit additions per second. Associative subtraction operates on the same principle and also takes S.δiW cycles. It is easy to extend addition to multiplication (8.5iV/ 2 cycles) , and subtraction to division (15.5 2 cycles). Multiplication techniques will be discussed in detail in Vision Algorithms. ARTVM was seen to be microprogrammed, hence it can operate at just the precision needed in each phase and produce just the significant bits required in the result. In many vision algorithms precision is quite low, and this gives the ARTVM an additional speed advantage over conventional machines. As mentioned earlier, each word in memory acts as a simple processor so that memory and processor are indistinguishable. Input, output and processing go on simultaneously in different fields of the same word. The field to be accessed or processed, is completely flexible, depending on application. Hence, processing capabilities (families of vision algorithms) may be expanded by increasing word length K. It will be shown in Vision Algorithms that for K = 152 all the vision algorithms we considered will run in real time, while K = 32 is sufficient for many simple image processing applications (such as histogram evaluation, convolution, morphological operations etc.). VLSI Chip Implementation and Interconnection Ruhman and Scherson [34, 35] devised a static associative cell and used it to lay out an associative memory chip. After evaluating its performance by circuit level simulation, they conservatively estimated the area ratio between associative memory and static RAM at 4. Considering that 4 megabits of static RAM is now commercially available on a chip area less than 100mm 2 , associative memory chip capacity becomes 1 M bits. The proposed chip for ARTVM stores 4K words x 152 bits, which is only 59 percent of capacity. Conservative extrapolation of cycle time to a 0.5 micron technology yields 30 nanoseconds. This value was used in computing execution time of associative vision algorithms. Loading an entire comparand or mask word would require a bus 152 bits wide. Fortunately, associative algorithms only operate on one or two short fields and on a number of flag bits at a time. Hence the word was partitioned into four 32-bit sectors and an 8-bit flag field. Buses are provided for simultaneous access to the flag field and one sector. Fig. 14 describes the chip interface, and shows how 64 such chips can be interconnected to make up the associative memory of ARTVM. Considering the exponential growth of chip capacity by a factor of 10 every five years [36], the ARTVM &y be reduced to 8 chips around 1995. Since the bulk of the machine is associative memory, upgrading is simple and inexpensive. As indicated in Fig. 11, a control unit is required to generate a sequence of microin¬ structions and constants (mask and comparand) for associative memory as well as to receive and test its outputs (count and rsp). This unit may be realized using high speed bit-slice components, or may be optimized by the design of one or more VLSI chips. The functions of the control unit will become apparent from the associative algorithms that follow. See fig. 14, for the notation employed. The Machine Simulator A simulator for the ARTVM was created, which enables the user to check out associative implementations of vision algorithms and to evaluate their performance. It was written in the "C" language and is referred to as "asslib.h". The vision machine simulator consists of an associative instruction modeler and an execution time evaluator. Associative Instruction Modeler The main features are: • The dimensions of associative memory have been defined as variables memsize and word-length, hence must be initialized in the application program by # define com¬ mands. • The contents of associative memory and its registers are defined as external parameters called: A[MEM_SIZE] [WORD-LENGTH] mask [WORD-LENGTH] comparand [WORD-LENGTH] tag[MEM_SIZE] All are members of a structure called parameters. • The associative instructions defined in The ARTVM Architechure were implemented as "C" functions which get their inputs from, and write their results to the external structure parameters. • Three instructions were added: load, save and print-cycles. The load command initial¬ izes the array A[.][.] with data from the file ass.inp, while the save command writes into file ass. out the contents of memory array A[.][.] at the end of the application program. The print-cycles command displays the number of machine cycles required to execute the simulated program. • Program control functions are written directly in "C" . • The general format of an application program is as follows: # define MEM.SIZE mmm # define WORD-LENGTH www # include " asslib.h" mainø { load; BODY save; print-cycles; Execution Time Evaluator Speed evaluation was achieved by modeling the machine as a simplified Finite Automaton (F.A.) in which a cost, in machine cycles, was assigned to each state transition. The machine has only two states: So and Si . The input alphabet was selected by grouping the instructions into 5 categories called /,-, i = 1, • • • , 5, where: letm d(.) letc d(.) I = one of < letmc d(.) letm c.(.) letc letm _.(.) setc setag 7 2 = one of < shiftag(±l) shiftag(±b) compare _ ~ 3 = one of < write read 7 = countag I 5 = firsel Fig. 15 presents the transition table and diagram. At initialization we reset a cycle counter (called cycles) to zero, then increment it at each state transition by the assigned cost in cycles (appears as output in the diagram). In Out This speed model reflects the fact that any instruction from group 7ι can execute simul¬ taneously with one from group 7 , and they can both be overlapped by an instruction from group 7 3 . The cost of countag (7 ) is conservatively estimated at 12 cycles on the basis o implementing it on-chip by a pyramid of adders, and summing the partial counts off-chip in a two-dimensional array. The cost of firsel (1 $ ) is conservatively estimated at 6 cycles on th basis of implementing it by a pyramid of OR gates whose depth is log 2 N — 1, part of which is on-chip and the rest off-chip. In the worst case, the pyramid must be traversed twice and then a tag flip-flop must be reset. The simplicity of the model for speed evaluation imposes a mild restriction on the programmer. Instructions that are permitted to proceed concurrently must be written in the order Iχ, 7 2 , 7 3 . To illustrate the instruction set and assembly language used by the simulator, we present below a listing of the vector addition program discussed earlier (The ARTVM Architecture) . /*****«**•*•••******** ASSOCIATIVE ADDITION PROGRAM *****»»»»»»»*:**»******/ /* The process adds two 8-bit vectors A and B according to the truth table »/ /* given belou, and replaces field B with the sum (A+B) . */ /*******•«****»****•**«* yonD FORMAT and TRUTH TABLE **++**•+****+**+**** + **/ /* I 1—I 1 */ /, i A i-c-i B 1 » / /* < A+ B > */ /* */ /* order of »/ /* execution */ /* */ /* */ /* •/ /* */ /* */ /* */ /* */ /* */ I* •/ /* */ •define MEM_SIZE 16 #define WORD_LENGTH 17 ♦include "asslib.h" main.) { int cnt; int c_bit = 8; load; for(cnt=0; cnt<8; cnt++) letm d(cnt) d( c.bit) d( cnt+c-bit+l) ; letc d(c_bit) ; setag; compare; letc d(cnt) ; write; letc d(cnt) d( c.bit) ; setag; compare; letc d(c-bit); write; letc d(cnt) d( cnt+c.bit+l) ; setag; compar letc d(c_bit) d( cnt+c_bit+l) ; write; letc d(cnt+c_bit+l) ; setag; compare; letc d(cnt) d( cnt+c_bit+l) ; write; } save print_cycles; Vision Al ι g»o v rithms To test the flexibility and speed of the proposed associative architecture ARTVM, a broad range of vision functions were implemented. They included low level algorithms such as histogram generation, convolution, edge detection, thinning, stereo matching and optical flow. Mid-level functions were also implemented, including contour tracing and labeling, Hough transforms, saliency mapping, and such geometric tasks as the convex hull and Voronoi diagram. Our simulator was used to test the associative algorithms and to verify their complexity. Before describing the associative algorithms it might be helpful to recall briefly the con¬ figuration of the machine, the value of some parameters and the data structure employed. The image resolution is taken to be 512 x 512 (N=512), hence associative memory capacity is 256K words (one word per pixel) . The data is arranged linearly in memory, in the order of the video scan, row after row of pixels, starting at the top left hand corner of the im¬ age. Incoming data is given to 8-bit precision (M = 8), and although the processing is all fixed-point, the algorithms are designed to retain the full inherent accuracy. The long shift instruction was provided for communication between rows, and its extent was denoted by b, where b is a submultiple of the row length, N. In our model of the machine, the extent of long shift is taken to be 32 places (b = 32). Algorithm complexity will be expressed in cycle times; the machine cycle was conservatively estimated in VLSI Chip Implementation and Interconnection at 30 ns., and this value will be used to compute execution time. Low Level Vision Histogram The associative nature of ARTVM and its relatively fast countag instruction facilitate his¬ togram evaluation. The program is given in Listing 1. It consists of a very short loop repeated for each gray level: a compare instruction tags all the pixels of that level, and a countag tal¬ lies them up. The count is automatically available at the controller, which accumulates the histogram in an external buffer. Accordingly, the time complexity in machine cycles is given by, T hιs _ = 0.5 + (1Z)2 M (1) where M is the gray level precision and is taken to be 8 bits in our model. Hence the histogram is executed in under 3330 machine cycles or nearly lOOμs. LISTING 1: Associative Computation of Image Histogram main .) { int gray-level; long int his ogram_array [256] ; letm dseq(0 ,7) ; /* sets the first 8 bits in the mask */ f or(gray_level=0; gray_level<256; gray_level++) { letc dvar (0 ,7 ,gray_level) ; setag; compare ; histogram_array [gray.level] = countag; } Convolution Low level vision, particularly edge-detection, involves the application of various filters to the image, which are most conveniently executed by convolution. The image may be considered as a simple vector of length N 2 or as a concatenation of N row vectors, each of length N. Convolution of an N-element data vector by a P-element filter results in a vector of length N + P — 1, but only the central N - P + 1 elements, representing the area of full overlap between the two vectors, are of interest here. We developed several techniques to implement convolution associatively, depending on filter characteristics such as dimensional separability, and symmetry. We start with the multiply-and-shift approach given by Ruhman & Scherson [6, 37, 38]. The word format in associative memory is depicted in Fig. 16. The convolution filter vector [f] of length P and precision 8 is applied as operand from the machine controller, one element at a time. The result is accumulated in field [fd] of length 8 + 8 + log 2 (P). Bit temp is used for temporary storage of the carry that propagates through field [fd]. The mark bit serves to identify the area of complete overlap by the filter vector. The program for row convolution is given in Listing 2. Field /if/ is multiplied by successive elements of vector /// and the results accumulated in field [fd]. Between multiplications, data field [d]ιs shifted down one word position for row convolution; down N word positions for col¬ umn convolution. The /-element acts as multiplier, each of its bits is tested by the controller, and if set will cause field [d] to be added into field [fd] starting at bit position add.offset. After each addition the carry is propagated to the highest bit of [fd]. For column convolution, only the last program line must be changed, replacing "shiftag(l)" by "for(i=0;i<N/b;i-H-) shiftag(b)". LISTING 2: 1-d Image Convolution /**•**•******•*•******* ASSOCIATIVE CONVOLUTION PROGRAM mm*****************/ main.) { /* ... declarations */ for(f_index=0; f_index<f_size; f_index++) { /************************* Summed Multiplication *»itiι*****i*i.*4it»t**4**4_4it»»it*/ /* add [d] to [fd] if the bit at position bit .count of f [f_index] is ONE */ for(add_offset=0; add.off set<n; add.offset++) if ( BIT (add_ off set) OF.WORD f [f .index]) /*test if bit is ONE */ { /************ add ********»»*****/ for(bit_count=0; bit_count<n; bit_count++ ) fd_bitcnt = add-Off set + bit .count; letm d(fd_bitcnt) d(temp) d(d_offset+bit_count) d(mark) ; letc d(temp) d(mark) ; setag; compare; letc d(fd.bitcnt) d(mark) ; write; letc d(fd.bitcnt) d(temp) d(mark) setag; compare; letc d(temp) d(mark) ; write; letc d(fd_bitcnt) dCd.off set+b it .count) d(mark) ; setag; compare; letc d(temp) d.d.of set+b it.count) d(mark) ; write; letc d.d.of set+bit.count) d.mark) ; setag; compare; letc d(fd.bitcnt) d(d_off set+bit_count) d(mark) ; write; } /****** propagate carry *******/ letc d(mark) d(temp) ; while (fd-bitcnt < 2*n +3 ) letm d(fd.bitcnt) d(mark) d(temp) ; setag; compare; letc d(fd.bitcnt) d(mark) ; write; letc d(fd.bitcnt) d(mark) d(temp) ; setag; compare; letc d(mark) d(temp) ; write; bit_count++; } } /********* shift [d] field down ***»*****/ f or(bit_count=mark+l; bit_count<=mark+n; bit_count++) { letmc d(bit_count) ; setag; compare; letc; write; letc d (bit-count ) ; shiftag ( l ) ; write ; } } The time complexity for 1-d convolution in machine cycles is given by, T = PM[ {Mt a + T p 1 ") + t s ] (2) where t a , t 3 are the per-bit addition and shift complexity, and T d is the complexity of carry propagation over field [fd]. Since addition and carry propagation are only executed for a ONE digit in the multiplier (filter element), time complexity is a function of , the ratio of ONE digits in the filter vector elements, whose range is - < a < 1. From the program listing, addition time t a is 8.5 cycles. Carry propagation takes 4 cycles per bit, and the average propagation distance is [log 2 P] + ^ 1 , hence T p ld = 4(| " log 2 P] + M ^ 1 ). The program time to shift a field, excluding shiftagQ, is 3 cycles per bit. Therefore, to move a pixel field over to the next column takes i ~ = 3 cycles per bit, and to the next row i ~ -= 3 -r- 0.5(y — 1) per bit. Extending the above algorithm to 2-d gives, T 2d _= P 2 M(t a + T p 2 -) + M(P - 1) (f s + Pt c 3 ) (3) where T d = 4( [log 2 P 2 ] + ^~f^) is the average carry propagation for 2-d convolution. By substitution of . α , _T 2d and t s into 11, we get: T 2d = αP 2 M(10.5M + 4 [log 2 P 2 ] + 2) + M{P - 1) (3P + ^ + 2.5) (4) This simple algorithm is quite efficient for 1-d convolution, particularly if the filters used are inherently of low precision ( << 1) . But for a wide 2-d filter, say 31 x 31, execution time may still exceed half a video frame (20 ms) . Several approaches will be considered for reducing the time complexity. Some 2-d filters are separable into two 1-d convolutions. Thus the 2-d Gaussian can be effected by successive application of a 1-d filter in the two coordinate directions. Reduction to 1-d convolution leads to a drastic improvement in execution time. Equation 11 can be written as: 2Tu = PM[ (Mt a + T p xd ) + t r „] + PM[ (Mt a + T xd ) + t e a ], (5) and by substitution of t α , T xd and t s it reduces to, 2T ld = P [α(21 + 8 [log 2 P] + 4) + ^ + 5.5]. (6) The filters we deal with all have symmetry about the origin. The Gaussian has even symmetry, while the derivative of the Gaussian has odd symmetry. This brings up the interesting question of how far one can exploit symmetry to improve execution time. Consider first convolution in one dimension with a filter of even symmetry and length P = 2L + 1 applied at point d m , L y n - ~ f d + ∑ fi(d m +i + d m .i) _=ι where the filter elements fi, on either side of the center element / 0 , are equal. Using the following word format, the algorithm for 1-d convolution with an even function is given in Fig. 17. For convolution in the x-direction, all shifts are one-place, "shiftag(±l)" ; in the y-direction each one is N/b long shifts, "for(i=0;i< N/b;i++) shiftag(±δ);". Applying this algorithm to a separable 2-d filter with even symmetry, such as the Gaussian, the time complexity becomes, 2Tt d ven = M[(17α - 4) + LM{21M + 30 + 8 flog 2 P}) + L ( + 11). (7) For odd symmetry, o = 0, and /,- is the absolute value of the filter elements on either side of it. Hence the convolution formula reduces to, and two modifications are required in the algorithm: to remove step 1 of the program (eval ¬ uation of d ■ /o); and change step 1 of the loop from ΝEXT+d to ΝEXT-d. Time complexity of the odd symmetry filter, applied in both directions, becomes, 2T - = cxLM(2lM + 30 + 8 flog 2 P] ) + LM( + 11) - AM. (8) The methods for reducing convolution time that were considered so far, all take advantage of particular properties of the filter: symmetry, element bit statistics, and separability of 2-d filter. We now a consider an enhancement that applies to the most general filter, treats the pixel data as multiplier, and speeds up multiplication by applying 4 bits of the multiplier at a time. Referring to the following algorithm and word format as illustrated in Fig. 18, the 8-bit data field is partitioned into a high (d__) and low ' d_ι) nibble. A 12-bit field, md, is provided for the partial product of the current filter element by the current data nibble. To fill in all the partial products by table look-up requires 15 compare-write cycles (no action required for all-ZERO nibble). Using the enhanced multiplication algorithm, the time complexity of general 2-d image convolution becomes, T% h = P- (T m + 3 t α + T v d + T v 2d ) + M(P - l)(t r s + Pt ' ), (9) and that of 1-d convolution in both directions, 2TξS" = P[ ' (T m + 3M. α + T# + T p ld ) + M{f s + t c 3 )}. (10) T m is the time (2 x 15 x 2.5 cycles) to generate the two partial products by table look-up, and T p i, T P2 are their carry propagation times following addition into field fd. Substituting for T m , - α and t s , and evaluating T p ι, T p , the time complexities reduce to, Ti = 295P 2 + 8P 2 [log 2 P 2 ] + 8(P - 1) (3P + ^ + 2.5) (11) and T h = 634P + 16P [log 2 P] + 4P . (12) The following table compares all the convolution methods discussed for filters of size o 7 x 7, 15 x 15 and 31 x 31. Enhanced multiplication T ~nh is seen to be the fastest method to compute general convolution, achieves this at a 12-bit increase in word-length. For particular filter characteristics, other methods offer a modest advantage, but those exploiting symmetry require an even larger increment in word length (17 bits) . Marr H Hildreth Edge Detection This algorithm [39] detects the Zero Crossings, ZC, of the Laplacian of the Gaussian filtered image, and can be written as: ZC{ ~ 7 G σ * /) (13) where I is the original image, G σ is the 2-d Gaussian filter of scale σ and V 2 is the Laplacian operator. The M&H algorithm consists of two steps: 1. Approximate ~ 7 ' G * I by the Difference Of two Gaussians DOG(I). 2. Detect the ZC in the DOG{I) output. The DOG filter has the following form: «~ +v~ DOG{x, y) e ~"p (14) 2πσj 2τrσ 2 where σ p and σ n are the space constants of the positive and negative Gaussian respectively, and their ratio j " a 1.6 for closest agreement with the Laplacian of the Gaussian (V 2 G) operator . Implementation of the DOG filter requires four 1-d convolutions, a row and a column convolution for each space constant. The complexity of associative DOG execution is, T dog = 2r ld (P p ) + 2T ld (P n ) + T di g (15) where P p and P n are the appropriate filter sizes for space constants σ p and σ n respectively, and T d iβ is the complexity of M-bit subtraction and borrow propagation into the sign bit. The speed of associative subtraction is the same as that of addition, hence, Tdiff = 8.5M + 2. (16) Assuming the fastest general convolution method T^ ~h , we substitute eqs. 20 and 16 with M = 8 in eq. 15 to obtain, T dog = {P P + P n ) (634 + 4 ) + 16(P p [log 2 P p ] + P n [log 2 P n ]) + 70. (17) P p , P n and DOG complexity (in cycles and milliseconds) are tabulated below for the three filters corresponding to σ = 0.5, 1 and 2 respectively, where P p and P n are the filter vector lengths. The second step of the M&.H algorithm, zero cross detection, operates on a 3 X 3 neigh¬ borhood. The center pixel is considered to be an edge point if one of the four directions (horizontal, vertical and the two diagonals) yields a change in sign. Specifically, we test if one item of a pair (about the center) exceeds a positive threshold T while the other is less than -T. The associative implementation of ZC for each space filter is outlined below. 1. Compare all pixels ( resulting from the DOG function) concurrently against the thresh ¬ olds T and -T, and assign two bits in memory to indicate the results. 2. Shift and write all pairs of indicator bits concurrently from the 8 neighbors of each pixel into a 16-bit field of its word in memory. 3. Use the 16-bit indicator field to test all 4 directions for a ZC and mark the edge-points. The associative algorithm to detect zero crossings shows a time complexity of 165 cycles or 4.95 microseconds. It should be noted that the M&H algorithm generates edge points without gradient direction. This parameter can be computed by operating on a larger neighborhood (9 x 9) around each edge point. An associative algorithm to detect 16 segment directions (and corners) was developed and is described below. Its time complexity is 1010 cycles or 30.3 microseconds. Canny Edge Detection Canny 's algorithm [40] has three stages: 1. Directional derivatives of Gaussian filter ( ~ 7G * I ). 2. Non-maximum suppression. 3. Threshold with hysteresis. The general form of the Gaussian derivative of scale σ in direction n is: The x and y derivatives of the Gaussian filter can be obtained by convolving the image with ■ Q XJ 0 and ~ ^G σ respectively. Applying the enhanced multiplication method, the execution time 2T 1 e~ ' Λ for a typical set of filter sizes becomes: Non-maximum suppression selects as edge candidates pixels for which the gradient magnitude is maximal. For optimum sensitivity, the test is carried out in the direction of the gradient. Since a 3 x 3 neighborhood provides only 8 directions, interpolation is used to double this number to 16. To determine if maximal, the gradient value at each pixel is compared with those on either side of it. Associative implementation requires somewhat fewer operations than that of zero-cross detection discussed earlier. Thresholding with hysteresis eliminates weak edges that may be due to noise, but continues to trace strong edges as they become weaken. On the basis of signal statistics and an estimate of noise in the image, two thresholds on gradient magnitude are computed - low and high. Edge candidates with gradient magnitude under low are eliminated, while those above high are considered edges. Candidates with values between low and high are considered edges if they can be connected to a pixel above high through a chain of pixels above low. All other candidates in this interval are eliminated. The process involves propagation along curves. Associative implementation ( Listing 3 ) uses three flags as shown in Fig. 19: E, which initially marks candidates above high threshold (unambiguous edge points), and at the end designates all selected edge points; OE (Old Edges) to keep track of confirmed edges at the last iteration; and L to designate candidates above low. At every iteration, each L candidate is examined to see if at least one of its 8-neighbors is an edge, in which case it is also declared an edge by setting E. Before moving E into OE, the two flags are compared to see if steady state has been reached, in which case the process terminates. LISTING 3: Curve Propagation mai O { /* — declarations */ letm d(DE) ; letc; setag; write; /* clear OE */ letmc d(E) ; setag; compare; letmc d(0E) ; write; /* copy E into OE */ while ( rsp ) i letmc d(E) ; setag; compare; /* load Tag with E */ /* OR the three northern unambiguous edges into E */ shiftag(-b); shiftag(-l); write; shiftag(l); write; shiftag(l); write; save_new_edges() ; /* OR the left and right unambiguous edges into E */ shiftag(l); write; shiftag(-l) ; shiftag(-l); write; save_new_edges() ; /* OR the three southern unambiguous edges into E */ shiftag(b) ; shiftag(l); write; shiftag(-l); write; shiftag(-l); write; save_new_edges() ; letm d(0E) ; letc; compare; setc; write; } } /* Find new edges by ANDing L into E */ save_new_edges() i setag; compare; letc; write; letmc d(L) ; compare; letmc d(E) ; write; } Program time complexity is given by, T pro = 7(23.5 + ) (19) where I is the number of iterations, 23.5 is the time to examine the state of 8 neighbors, and N/b accounts for long shifts to bring in edge points from neighboring rows. The upper bound of I, given by the longest propagation chain, is nearly N 2 /2, but for a representative value of 100 iterations the complexity of curve propagation becomes 3950 cycles or 119 microseconds. Thinning The propagation algorithm presented above produces a curve that may not be thin. A multi¬ pass thinning algorithm is proposed, consisting of a pre-thinning phase and an iterative thinning phase. Referring to Fig. 20A-20E, the pre-thinning phase fills a single gap by applying template (a) , and removes some border noise by clearing point P if one of templates b,c or d holds. Multi-pass implies that the templates are applied first in the north direction, then in the south, east and west directions, in succession - except for template (a) which is fully symmetrical and need only be applied once. All templates are shown in the north direction and use an X to denote a "don't care" (ONE or ZERO). Similarly, the thinning phase tests templates e,f and g in each of the 4 directions successively, and clears point P when agreement is found. This 4-pass sequence is iterated until there is no further change. Particularly worthy of note is the quality of the skeleton produced by this simple local process. The most precise definition of a skeleton is based on the medial axis. Davies and Plummer [41 proposed a very elaborate algorithm to produce such a skeleton, and chose 8 images for testin it. Our thinning algorithm was applied to these images and produced interesting results: th skeletons agree virtually exactly with those of Davies and Plummer; any discrepancy, not a an end-point, occurs at a point of ambiguity and constitutes an equally valid result. Th removal of border noise in the prethinning phase prevents the formation of extraneous spur in the skeleton. Time complexity of the algorithm is given by, 5N 4N T t = 70 + ≤i- + /(150 + -^-), where the first two terms account for the prethinning phase. Execution times are 150 cycles (4.5 μs) for prethinning and 214 cycles (6.4μs) per thinning iteration. For edge thinning 3 iterations will suffice, giving a completion time of 24 microseconds. Single-pass thinning was considered and found to be rather critical. The algorithm pro¬ posed by Chin et alia [42] appears to be optimal, yet it does not yield an ideal skeleton, and application of their own preliminary phase of noise-trimming leads to amputation of some main branches during thinning. Stereo Vision Stereo vision must solve the correspondence problem: for each feature point in the left image, find its corresponding point in the right image, and compute their disparity. Since stereo has been a major research topic in computer vision over the past decade, a large number o approaches have been proposed, too many to attempt to implement them all associatively. Instead, we concentrate on the Grimson [43] algorithm. This also has some similarity with the hierarchical structure of human vision, and it can use its input edges producted by th M&H or Canny edge detection schemes discussed above. Assume edge detection was carried out on both the left and the right image, and the result are sitting side by side in memory. The edge points are marked and their orientation given to a 4-bit precision over 2π radians or a resolution of 22.5 degrees. The stereo process use the left image as reference, and matches edge points with gradient of equal sign and roughl the same orientation. Edge lines near the horizontal (within ±33.75 degrees) are excluded in order to minimize disparity error. The Grimson algorithm consists of the following steps: • Locate an edge-point (of acceptable orientation) in the left image. • Divide the region about the corresponding point in the right image into three pools. • Assign a match to the edge-point based on the potential matches within the pools. • Disambiguate any ambiguous matches. • Assign disparity values. The associative memory word format for the matching process is given below. Input fields DL, DR label edge points of the left and right images, respectively, while DIR_L, DIR.R give their orientations. The resulting value of disparity will be recorded in output field DISP. The associative algorithm is outlined in Fig. 21. • Search the neighborhood of ±W pixels divided into three pools, A, B and C, where pools A and C are equal in size and represent the divergent and convergent regions, respectively. The smaller pool B, is the region about zero disparity. • Shift fields DIR l and DR (of the right image) W word positions down (corresponding to a shift in the right image of W pixels to the right) . • For edge points (DR,DL = 1), compare field DIR.R against DIR_L within a tolerance of ±1. After each comparison, shift the right image fields up one word position, until position + W is reached. The results of the comparison are registered in fields PX and TX (X= A,B or C). A PX value of 00 indicates no match, 01 indicates one match, and 11 more than one match in pool X. The TX fields temporarily store disparity in each pool for use in case of ambiguity. Note that disparity is the net shift of the right image at the time the match was found. • Edge points with unambiguous disparity (01 in some PX, 00 in all PY where Y φ X) are selected and their disparity assigned in field DISP (DISP := TX). • An attempt is made to disambiguate matches in more than one pool by use of the dominant disparity in the neighborhood. If there is a dominant pool in the neighbor¬ hood, and the ambiguous point has a potential match in the same pool, then that is chosen as the match. Otherwise, the match at that point remains ambiguous. To test a neighborhood for dominant disparity we start by counting all its edge points (field DL) into the COUNT field. Then, for each pool in turn, we count into field COUNT-P just its unambiguous matches over the same neighborhood. If COUNT JP > COUNT/2 the pool is dominant and a match in the same pool will have its disparity copied from TX into DISP. If no pool is dominant or there is no match in the dominant pool, DISP will not be updated and the point in question will stay marked as ambiguous in bit MR. • The last step tests whether disparity is within range. Marr & Poggio show that for a region within range, more than 70 percent of its edge points will be matched. Un¬ matched edge points are labeled in MR and counted over the neighborhood into field COUNT-P. If COUNT-P > COUNT/4, all edge points in the neighborhood are labeled as unmatched and their disparity cleared. The time complexity of the associative stereo algorithm is given by, T a tereo = T a h + T mα t + Tdi, + T or (20) where T 3h accounts for shifting the right image, T mαt is the time to evaluate matches within the pools, T i a the disambiguation time, and T or the time to find and remove out-of-range disparity. The shift time in cycles is given by, W — 1 T, A = 2 x 5(3 + --2-^) + 5 x 3 x 2-y + (2 + 8-y) (21) The first term accounts for the initial and final W-place shift-up of fields DR, DIR-R (5 bits). The second term covers the one-place shift-down between successive matching operations. And the last term is due to the generation and update of a border flag for handling row end effects. Consider now the matching complexity T mαt . It requires an 8-cycle comparison for every disparity (2W + 1) and every orientation (10) with a tolerance of ±1. Hence T mαt = 8 x 3 x 10 (2W + 1) + 13.5 (22) where the second term accounts for final processing of the comparison results. The disambiguation process consists of the following steps: • Count the edge points over every L x L neighborhood. • For each of three pools: - Count the unambiguous matches over the same neighborhoods. - Compare this result to half the edge count. - Copy disparity from match in dominant pool. Hence we may write, dis = ent + 3 {Tc_t + T gt + Tcpy + 3.5) (23) where Tent is the time to count labeled pixels over a neighborhood, T gt to compare for greater than, and T cpy to copy disparity, respectively. T c -_ t is the subject of the next section, while the other two are given by, r^ = l + 4.5(riog 2 L-l - l) (24) T cpy = + 2(\\og 2 L 2 ] - l) (25) The disambiguation algorithm is listed below. LISTING 4: Attempt to Resolve Ambiguous Matches count_flag_to_field(DL,COUNT) ; /* count edge points in L X neighborhood */ for(pool=PA; pool<= PA+4; pool+=2) { /* Flag unambiguous points in TEMP */ letm d(TEHP); letc; setag; write; /* clear TEMP »/ letm dseq(PA,PA+5) ; letc d(pool) ; setag; compare; letmc d(TEMP); write; count- lag_to_ ield(TEMP,COUNT-P) ; /*********** Test if COUNT-P > COUNT/2 ****************/ letm d(TEMP); letc; setag; write; /* clear TEMP */ /* Starting with C0UNT_P+2k-2, compare bit i of COUNT.P to bit i+1 of COUNT. C0UNT_P+2 -l used as GTF */ for(bit_count=2*k-2; bit_count>=0; bit.count—) { next-bit = COUNT + bit.count + 1; next_bit_p = COUNT.P + bit_count; letm d(MARK) d(TEMP) d(GTF) d(next_bit) d(next_bit_p) ; letc d(MARK) d(next_bit) ; setag; compare; letc d(MARK) d(TEMP) d(next.bit) ; write; letc d(MARK) d(next_bit_p) ; setag; compare; letc d(MARK) d(GTF) d(next_bit_p) ; write; } /********** Copy disparity of dominant pool to DISP **************/ letmc d(GTF); setag; compare; letm dseq(DISP,DISP+k-l) ; letc; write; /* clear DISP ield marked by GTF */ letmc d (GTF) d (MARK) d (pool ) ; setag ; compare ; letc d (GTF) d (pool) ; write ; /* clear MARK of disa biguated points */ f or(bit_count=0 ; bit_count<k ; bit_count++) { letmc d (GTF) d (2* (pool-PA)+TA+bit_count) ; setag ; compare ; letmc d .DISP+bit. count) ; write ; } } Lastly, the time to test and register out-of-range disparity is given by, T or = 4.5 + T mt + r /t + T rm (26) where the constant term accounts for grouping unmatched edge points and labelling them in MR; T ent is the time to count the unmatched edge points over the neighborhood; Tu covers comparison of this count to 1/4 the number of edge points in the neighborhood; and _T rm is the time to label and clear disparity of edge points in out-of-range neighborhoods. T. 4 = 3 + 4.5([log 2 £ 2 ] - 2) (27) T rm = 2L 2 + ^^ - 1) + 0.5 (28) Stereo matching is performed for each of the spatial frequency channels. From the Marr and Poggio [44] model of stereo vision, W = P and L = 2W + 1 where P is the filter size (vector length) of the channel. If we choose P of the form 2 ' — 1, then L has the same form, L = 2 i+1 - 1 = 2 k - 1 with k = \og 2 (L + 1) Substituting 21 - 28 into equation 20, using the relations between P, W and L, and applying the above definition of k, we obtain, T stert0 = 5T mt + + (1025 + ) (^) + <-Sk + ψ. (29) The algorithm complexity excluding neighborhood counts, is tabulated below in cycles and milliseconds for three channels of spatial frequency. We now consider the problem of counting labeled pixels over a sizable neighborhood, a function that is executed five times during stereo evaluation, hence could come to dominate its time complexity. Linear Summation The straightforward approach to count labeled pixels over a neighborhood about each pixel would be to provide a count field in each word and let the neighboring labels increment it as they are entered in some convenient sequence. For an L x L neighborhood the maximum count is L ' , and for L odd, the count field length is 21og 2 L. The program listing follows, where "flag" labels the pixels to be counted, and "field" points to the beginning (LSB) of the count field. The word format is in Fig. 22. LISTING 5: Linear Summation Over L x L with L Odd count-flag_to- ield.flag, ield) int flag, field; { /* ... declarations */ letm d(TEMP) d(CY) dseq(field,field-l+ceiling(Log2(L*L) )) ; letc; setag; write; /*clear count field, TEMP * Carry*/ /* Shift flag ( -D/2 lines and columns down and enter in TEMP */ letmc d(flag) ; setag; compare; for(index=0; index<(L-D/2; index++) {shiftag(l); shiftag(b);} letmc d(TEMP) d(CY) ; write; /* move flag to TEMP k Carry*/ for(line_count=0; line_count<L; line_count++) { for(pιxel_count=0; pixel_count<L; pixel.count++) { for(bit= ield; bit<field+ceiling(Log2(L*D) ; bit++) { letm d(bit) d(CY) ; /* increment COUNT */ letc d(CY); setag; compare; letc d(bit) ; write; letc d(bit) d(CY) ; setag; compare; letc d(CY); write; if(pixel-count < L-l) { letmc d(TEMP); setag; compare; letc; write; if(BIT(0) 0F_W0RD line.count) shιftag(l); else shiftag(-l) letmc d(TEMP) d(CY) ; write; } if(line_count<L-l) { letmc d(TEMP); setag; compare; letc; write; shiftag(-b); letmc d(TEMP) d(CY) ; write; } } Execution time in machine cycles is given by, Tenti = ^- - 1) + (3 + 9k)L 2 (30) where k = \og 2 (L + 1), hence it grows as Z 2 log . Incorporation of this program in the stereo algorithm completely swamps its execution time, which, for the coarsest channel, now exceeds video frame time. This is illustrated in the following table, which gives all times in milliseconds. For the sake of comparison, stereo execution time excluding neighborhood counts is repeated here under T 3t - cn ts- 2-d Summation In the linear summation program, every row of I- labels was actually counted L times, once in each of the vertically overlapping neighborhoods. By taking advantage of the two-dimensional structure of the neighborhood, the count may be carried out in two stages: first the neighbor¬ ing labels within each row are tallied up, and then the vertically neighboring row sums are accumulated as they are entered in some convenient sequence. That requires an additional "rows" field of length log L, and yields the following program, where the word format is as in Fig. 23 and k r = [log 2 L ~ and k c _= log 2 L 2 LISTING 6: 2-d Summation Over L x L with L Odd coun .flag.to.field(flag-field) int flag, field; { /* . . . declarations */ letm d(cy ) dseq(rows,flag-D ; letc; setag; write; /* clear cy, rows k count fields */ /* Shift flag (L-D/2 lines k columns down into "field" */ letmc d(flag); setag; compare; for(index=0; index<(L-D/2; index++) {shiftag(l); shiftag(b);} tmp_cnt=field+kc-1; /* pointer */ /* Move flag to "tmp-cnt", "rows" and "field" to avoid the first row summation */ letmc d(tmp_cnt) d( ield) d(rows) ; write; /******************** Rows Summation *****************/ for(shift_count=0; shift_count<L-l; shift.coun ++) { /* Shift "tmp-cnt" up and enter into "tmp_cnt" and "cy" */ letmc d(tmp-cnt); setag; compare; letc; write; letmc d(tmp_cnt) d(cy) ; shiftag(-D; write; for(bit_count=0; bit_count<kr; bit_count++) { /* Increment rows and count fields */ rows_next=rows+bit.count; field_next=field+bit-count; letm d(rows_next) d(field_next) d(cy) ; letc d(cy) ; setag; compare; letc d(rows_next) d(field_next) ; write; letc d(rows_next) d(field_next); d(cy) ; setag; compare; letc d(cy) ; write; } } /******************** Columns Summation *****************/ letm d(tmp-cnt) ; letc; setag; write; /* clear "tmp_cnt" */ for(shift_count=0; shift_count<L-l; shift_count++) for(bit_count=rows; bit_count<rows+kr; bit_count++) ' letmc d(bit-count) ; setag; compare; letc write; letc d(bit.count) ; shiftag(-b); write; } /* count field <— count ield + rows field */ for(bit_count=0; bit_count<kr; bit.count++) { rows_next=rows+bi .count; field_next=field+bit-count; letm d(field_next) d(cy) d(rows.next) ; letc d(cy) ; setag; compare; letc d(field_next) ; write; letc d(field.next) d(cy) ; setag; compare; letc d(cy) ; write; letc d(field.next) d(rows_next) ; setag; compare; letc d(cy) d(rows_next) ; write; letc d(rows_next) ; setag; compare; letc d(field.next) d(rows_next) ; write; } /****** propagate carry *******/ letc d(cy) ; while(++field.next < field+kc ) { letm d(field.next) d(cy) ; setag; compare; letc d(field.next); write; letc d(field.next) d(cy); setag; compare; letc d(cy) ; write; } Execution time in machine cycles is given by, N + 156 N + 236 - cnt2 + 4/;- + k r ) (L - l). 46 26 For our case, in which the filter vector lengths were chosen to be of the form 2' ' — 1, it was shown earlier that L is also of the form 2^ - 1. Hence we may write, k r = k = log 2 (X + 1) and k c = 2k and T cr _ t becomes, _ ^ N + 156 , N + 396 >- r (31) 46 26 Execution time now grows as L log L. This count algorithm brings stereo complexity well within real-time video limits, as indicated by the following table, listing execution times in milliseconds. 2-d Tree Summation Although 2-d summation reduces stereo time complexity sufficiently to meet real-time re¬ quirements, the question arises whether this result is optimal or can be improved signifi¬ cantly. While retaining the two-dimensional summation approach (first by rows and then by columns), consider handling each dimension in binary tree fashion, summing elements in pairs, then pairing results and adding again until the dimension is covered. Since L is of the form 2* — 1, an extra row and column are added to complete the tree. The extra element denoted by "tail" , is remembered and subtracted from the sum, hence a fc-bit "tail" field is provided for temporary storage of the extra row sum. The program listing is given below. The word format is in Fig. 24. LISTING 7: 2-d Summation Over L x L with L Odd count.flag.to.field(flag,field) int flag, field; { /* ... declarations */ letm dseq(tail.flag-l) ; letc; setag; write; /* clear count k tail fields */ /* Shift flag (L+D/2 rows k columns down into "tail" and "field" */ letmc d(flag) ; setag; compare; for(index=0; index<(L+D/2; index++) {shiftag(l); shiftag(b) ;} letmc d(tail) d(field) ; write; /* enter flag in "tail" and "field" */ /*****************»**** Rows Summation *******************/ tree.step=0; for(shift_count=l; shift_count<=(L+D/2; shift_count*=2) { cy = field+tree.step+1; for(bit_count=field; bit.count<cy; bit_count++) { letm d(tmp) ; letc; setag; write; /* clear tmp */ letmc d(bit.count) ; setag; compare; for(index=0; index<shift.count; index++) shiftag(-D ; letmc d(tmp) ; write; /* move flag to tmp */ add.bits(tmp.bit.count,cy) ; } tree_step++; } /*** Subtract "tail" from row sum, write results into tail field ***/ letm d(tmp) ; letc; setag; write; /* clear tmp (use it as borrow) */ letm d(temp) d(tail) ; letc d(temp) ; write; for(bit_count=0; bit.count<k+1; bit_couπt++) { letmc d(tmp) d(field+bit.count); setag; compare; letc; write; letc d(tmp) ; setag; compare; letc d(tmp) d(field+bit.count); write; letmc d( ield+bit.count) ; setag; compare; letmc d(tail+bit count); write; } /******************** Columns Summation *****************/ tree_step=0; for(shift_count=l; shift_count<=(L+D/2; shift_count*=2) ' cy = ield+k+tree_step; for(bit_count= ield; bit_count<cy; bit_count++) { letm d(tmp) ; letc; setag; write; /* clear tmp */ letmc d(bit.count) ; setag; compare; for(index=0; index<shif .count; index++) shiftag(-b) ; letmc d(tmp) ; write; /* move flag to tmp */ add.bits(tmp,bit.count,cy) ; } tree_step++; } /*** Subtract tail field from summation «•*/ letm d(tmp) ; letc; setag; write; /*clear temp*/ for(bit_count=0; bit_count<k; bit_count++) { letm d(tail+bit_count) d(field+bit.count) d(tmp) ; letc d(tail+bit_count) ; setag; compare; letc d(tail+bit_count) d( ield+bit.count) d(tmp) ; write; letc d(field+bit.count) d(tmp) ; setag; compare; letc; write; letc d(field+bit.count) d(tail+bit_count) ; setag; compare; letc d(tail+bit_count) ; write; letc d(tmp) ; setag; compare; letc d(field+bit.count) d(tmp) ; write; } /** propagate borrow **/ for(; bit_count<2*k; bit_count++) { letmc d( ield+bit.count) d(tmp) ; setag; compare; letc ; write; letc d(tmp) ; setag; compare; letc d(f ield+bit.count) d(tmp) ; write; } } /******* ADD BITS FUNCTION *******/ add.bits (tmp .bit.count , cy) int tmp, bit.count, cy; { letm d(bit.count) d(tmp) d(cy) ; letc d(cy) ; setag; compare; letc d(bit.count) ; write; letc d(cy) d(bit.count) setag; compare; letc d(cy) ; write; letc d(tmp) d(bit.count) ; setag; compare; letc d(cy) d(tmp) ; write; letc d(tmp) ; setag; compare; letc d(tmp) d(bit.count) ; write; Execution time is given by, r„,_, and since - 2 ' = 2(k2 k~1 - 2 k + 1), Tmm - 1 + £ + ( + £)* + f k- -V (2- - 1)2'- + ^( * - 3). (32) The results are tabulated below for the three channels defined earlier. Count complexity is still seen to grow as Llog in equation 32, but the table indicates an improvement of 40 percent over 2-d summation (for the largest neighborhood), and a resulting improvement in stereo complexity of 27.5 percent. The improvement stems mostly from the fact that at each level of the tree, arithmetic is carried out just to the precision required, which is known in advance. Discussion of Stereo Results Real time stereo vision by associative processing was considered and the problematic function was identified as the counting of labeled pixels over a large neighborhood. This function occurs four times in the resolution of ambiguous matches, and once in the handling of out-of-range disparity. Implementation of the count function in a straightforward (linear) manner pushes stereo execution time beyond real-time (video) limits. It was shown how associative array and tree techniques can be applied to great advantage; indeed, they bring stereo complexity well within real-time limits. To illustrate the results graphically, we present two comparative plots. Fig. 25 gives execution time as a function of neighborhood dimension for the three implementations described: the linear, the two-dimensional, and the two-dimensional tree. Fig. 26 presents stereo complexity without neighborhood counts, and with neighborhood counts by each of the three methods, all as a function of neighborhood dimension. Optical Flow Optical flow assigns to every point in the image a velocity vector which describes its motion across the visual field. The potential applications of optical flow include the areas of target tracking, target identification, moving image compression, autonomous robots and related areas. The theory of computing optical flow is based on two constraints: the brightness of a particular point in the image remains constant, and the flow of brightness patterns varies smoothly almost everywhere. Horn & Schunck [45] derived an iterative process to solve the constrained minimization problem. The flow velocity has two components (u, v). At each iteration, a new set of velocities (u ~+1 , v ~+1 ) can be estimated from the average of the previous velocity estimates ( " f , "" "-) by, u n+1 = u n - E x [E x u n + E y - ~ + E t ]/( 2 + E x 2 + E y 2 ), υ n+1 -= v n - E y [E x u n + E y ϋ n + E t ]/(a 2 + E X + E y 2 ) (33) where is a weighting factor dependent on noise in the measurement. The partial derivatives E x , E y and E t in ( 33) are estimated as an average of four first differences taken over adjacent measurements in a cube, Ex « ■ 7[E-,ι+ι,k ~ E ~,j,k + -EΗ-ij+i.fc - E,+ι,j,k +E,,. + ι t jfc+ι - _5t,j,fc+ι + ■Et+i. j .+i.jj.+i ~~ Eι+ι, ], ' +'] Ey ~ - E XιJ _k + E l+ ι ι]+ ι t k - E.j+u ( 34 ) +£ , .+ι,. . ,A:+ι - E l k+ι + -^t+i +i^+i - _E. I J+ ι > fc + ι] Et « -[E,,j,i+1 - £.,;,*: + E. + l . j .jfc+ l - E.+ l j. jfc + .j+l,fc+l - E-.j+l,-. + Et+l.j+l.jk+l - E.+ lj+l.jfc]. E, ι k is the pixel value at the intersection of row i and column j in frame k. Indices i, j increase from top to bottom and left to right, respectively. Local averages u and v in ( 33) are defined as follows: -*i,j,k = + t-,-ι j+ι,fc + u, + ι,j + ι,jb + u.'+i ,j-ι,k] (35) l r , V i,j,k - g L u « ' -l, J ,fc + V i,j+l,k + J -Λ+l t + υ.j-i.jfcj 1 r _ + Ϊ2 - υ ' "lj'~1,fc + υ,' - 1 ' "+1 ' fc + vi + ' ιi+ ~ , ' + u« +ι> ' -ι,* : J There is the practical matter of how to interlace the iterations with the time steps. A good initial guess for the optical flow velocities is usually available from the previous time step (video frame time) . In the case of high speed motion, one iteration per time step may not be enough to get a stabilized value of optical flow, and there is a necessity to iterate several times before advancing to the next frame. To implement the above equations associatively, the memory word was partitioned into multiple fields, each holding input data, output data, or intermediate results. The format is given in Fig. 27. The flow is computed from two successive video frames: E n and E n\ . Each frame contains 512 x 512 pixels whose grey level is given to 8-bit precision. During vertical blanking (time interval between frames) , the current image is moved to E n ι, and a new image from the I/O buffer array (Fig. 15) is written into field E n . During the frame time, one or more iterations of the algorithm are executed, enough to obtain a reasonable approximation of the optical flow for use with the next frame. Equation 33 can be rewritten as, ,n+l u n - D x (E x u n + E y v n + E t ) ,"+1 = V - D y (E x ύ n + E y ϋ n + Et) , (36) where D x = E x /P, D y = E y /P and P = a 2 + E 2 + E 2 . It will be noted that the partial derivatives E x , E y and E t , as well as D x and D y , remain fixed during a given frame and are not involved in the iterative process between frames. Hence computation of these parameters is referred to as the "fixed part" of the algorithm. Fixed Part The first stage computes the partial derivatives E x , E y and E t . • Clear fields E x , E y and E t . • Shift E n _ E n\ one row up and one column to the left (N + 1 words up) to furnish .+ι,j+ι,n and Et+ij+i.n+i - • Enter E n + \ into E x , E y , E t ; add or subtract E n into the derivative fields as indicated in the following table, step 2. • Shift E n , E n ι one column to the right (one word down), to furnish E_ + ι ιJ<n and E t +ι ι3<n +ι. • Accumulate E n , E n ι as shown in the following table, steps 3,4: Shift E n , E n ι one row (_V words) down, and accumulate as shown in the above table, steps 5,6. Shift E n , E n\ one column to the left (one word up) and accumulate as shown in the above table, steps 7,8. • Shift E n , E n\ to their original position (one word down) . The next stage in is to evaluate D x and D y : • Use a look up table to compute α 2 + E ' , enter it in field S c . • Use another look up table to compute E y , enter it in field A c . - Add field A c into field S c to obtain P. • Divide field E x by field S c placing the quotient in field U. • Divide field E y by field S c placing the quotient in field V . • Copy D x from field U to the right side ( 9 least significant bits) of field S c . • Copy D y from field V to the left side of field S c . Before executing another division, the dividend E x or E y is ZERO extended to the left for proper scaling with respect to divisor P. It then follows from a > 0 that D x , D y < 1, hence the quotient will not overflow. The complexity of the "fixed part" was evaluated as, 2/V T/,* = 1829 + (337 + —) M + 64 2 . (37) Iterative Part • Compute local average of u component (field U) as prescribed in equation 44, and place the result ( ~ T) in field U aυ . The neighboring values of u are accessed by shifting the U- field up and down in an optimal sequence and summing into field A c . The 4-~eighbors are given double weight by adding them in one place to the left. The value accumulated in A c is divided by 3 and the result placed in field U av . • Similarly, compute local average of υ component (field V) as prescribed in equation 44 and place the result (v) in field V av . • Copy E t into field A c with sign extension. • Multiply E x by U aυ placing the product in field U. • Add field U into field A c • Multiply E y by V av placing the product in field A c . • Add field U into field A c to obtain the term E x u + E y v + E t . • Multiply field A c by the right side of field S c to obtain D x [E x u + E y v + E t ]. Place the result in field U. • Multiply field A c by the left side of field S c to obtain D y [E x u + E y v + E t ]. Place the result in field V. • Compute the u component of optical flow by evaluating U av — U into field U. • Compute the υ component of optical flow by evaluating V av — V into field V. The complexity of this part in machine cycles per iteration is given by, 4N Tur = 809 + 372 + 34 2 + — (M + 1) (38) Hence the overall complexity of optical flow can now be evaluated as, TOF = T fix +ITi tr = 1829+(337+-^) +64M 2 +/[809+372M+34 2 + ^(M+l)] (39) where I denotes the number of iterations required for the flow to converge. Evaluating the above expression, the fixed part takes 266 μs., and each iteration requires an additional 196 μs. The execution time for different values of I is given in the following table: Mid-Level Vision Detection of Corners and Line Direction An important feature for middle and higher level processing is the ability to distinguish corners and line direction. In the case of Canny Edge Detection, line orientation was generated during the process. On the other hand, the M&H algorithm is not directional, and the edge bit-map it produces must be further processed to detect line orientation. We proposed to use the edge bit-map of a 9 x 9 neighborhood around each pixel to distinguish segment direction. The resulting algorithm can discriminate 120 different lines and corners. The approach is outlined below. 1. Since a 9 x 9 neighborhood involves too many patterns to handle directly, it was par¬ titioned into 24 sectors as shown in Fig. 27. To maintain angular accuracy, sector size increases with distance from the center. The sector evaluation function is here defined as the logical OR of its edge point indicators, and a 24- bit field was assigned to the sector values. Evaluation is carried out by shifting in neighboring edge point indicators and OR'ing them directly into the corresponding sector values. 2. Sector partitioning was based on 7r/8 angular resolution, and defines 16 equally spaced segments or rays around the circle. Each segment (direction) is characterized by a required code in a prescribed subset of the segment values, and a maximum Hamming distance of 1 is permitted. The sector value field is now compared against each of the 16 codes and the results registered in a 16-bit field to mark the presence of each segment direction. 3. Simplification of segment characterization and testing introduces a measure of ambigu¬ ity in each triplet about one of the 8 main compass directions. Additional sector values are now used to resolve this uncertainty and the few cases of inherent ambiguity are settled arbitrarily. 4. The 16-bit segment field can now be tested for any pair of segments representing a given line or corner. The sample program selects all pairs without distinction. From simulation, the complexity of this algorithm was found to be 1010 cycles or 30.3 μs. It should be noted that the concept of this algorithm can be extended to a broad range o functions depending on the choice of sector boundaries, of the evaluation function, and of pattern characterization. Contour Tracing and Labeling A preparation step labels each contour point with its x-y coordinates. The main process is iterative and operates on a 3 x 3 neighborhood of all contour points in parallel. Every contour point looks at each one of its 8 neighbors in turn and adopts the neighbor's label if smaller than its own. The circular sequence in which neighbors are handled appreciably enhances label propagation. Iteration stops when all labels remain unchanged, leaving each contour identified by its lowest coordinates. The point of lowest coordinates in each contour is the only one to retain its original label. These points were kept track of and are now counted to obtain the number of contours in the image. Listing 8 presents the program in associative memory. The input fields are [xy.coord] to specify pixel position and [edge] to identify contour points. The output fields are contour flabel] and contour starting point [mr]. The word format is in Fig. 29. LISTING 8: Contour Tracing and Labeling main() { ... declarations I** Clear working fields **/ letm dseqdabel,mark) ; letc; setag; write; /*** Mark and label all edge points ***/ letmc d(edge) ; setag; compare; letmc d(mark) ; write; for(bit_count=0; bit_count<label_size; bit_count++) { letmc d(xy_coord+bit_count) d(edge) ; setag; compare; letmc ddabel+bit.count); write; } while( new.condition > growth.threshold) { letm d(sf) letc; setag; write; /*clear switch flag */ /****** CONNECTIVITY TESTING ******/ for(window.index=0; window_index<8; window.index++) { /* Shift "edge" and "label" into "temp" and "operand" */ letm dseq(temp,operand+label_size-l) ; letc; setag; write; for(bit_count=0; bit.count<label_size+l; bit_count++) { letmc d(edge+bit_count) ; setag; compare; letmc d(temp+bit_count) ; general.shift(window.index) ; write; } /** Test if "operand" < "label" **/ letm d(gt) d(lt) ; letc; setag; write; /* clear greater k less than flags */ for(bit_count=label_size-l; bit_count>=0; bit.count—) { letm d(edge) d(temp) d(gt) d(lt) d(operand+bit_count) ddabel+bit.count) ; letc d(edge) d(temp) d(operand+bit_count) ; setag; compare; letc d(edge) d(temp) d(gt) d(operand+bit_count) ; write; letc d(edge) d(temp) ddabel+bit.count); setag;compare; letc d(edge) d(temp) d(lt) ddabel+bit.count); write; } letmc d(lt); setag; compare; /* clear "label" and "mark", set switch flag */ letm dseqdabel,label+label_size-D d(mark) d(sf) ; letc d(s ) ; write; /* copy "operand" into "label" */ for(bit_count=0; bit_count<label_size; bit_count++) letmc d(operand+bit_count) d(lt) ; setag; compare; letmc ddabel+bit.count); write; } } /** Test for termination **/ letmc d(sf) ; setag; compare; new.condition = countag; } /** Find number of contours **/ letmc d(mark) ; setag; compare; countag; } general.shi t(index) int index; < if (index<=2) shiftag(b) ; if (index>=4 kk index<=6) shiftag (-b) ; if (index=0 I I index=6 I I index==7) shiftag(-l) ; if (index>=2 kk index<=4) shiftag(l) ; } The time complexity of the algorithm (in machine cycles) is given by, ~. /V ~ . Λ ~ Tι = 16 + 4 log 2 N + 7[65 + X- + 2 log 2 N(67 + -^-)]. o o The upper bound of I is nearly N 2 /2, but for a representative value of 100 iterations, execution time becomes 218 kilocycles or 6.6 milliseconds. A good approximation to the time complexity is, ' N r. = J(67 + )(l + 21og 2 N). A list of contours, giving label and length (in pixels) , may be generated in relatively short order (24 cycles per contour). Associative Saliency Network Salient structures in an image can be perceived at a glance without the need for an organized search or prior knowledge about their shape. Such a structure may stand out even when embedded in a cluttered background or when its elements are fragmented. Sha'ashua & Ull¬ man [46] have proposed a global saliency measure for curves based on their length, continuity and smoothness. Consider the image as a network of N X N grid points, with d orientation elements (segments or gaps) coming into each point from its neighbors, and as many going out to its neighbors. A curve of length L in this image is a connected sequence of orientation elements pi, pi + ι , - • • , ?.+_ . , each element representing a line-segment or a gap in the image, and the saliency measure of the curve is defined as, -+ ∑ XιP^ σ ι (40) ]= ~ where the local saliency σ is assigned the value unity for an active element (real segment), and zero for a virtual element (gap) . The attenuation function p l<: provides a penalty for gaps, p x - where the attenuation factor p approaches unity for an active element and is appreciably less than unity (here taken to be 0.7) for a virtual element. The first factor, c J , is a discrete approximation to a bounded measure of the inverse of total curvature, ■ _ 2α |j . t*π(α fe /2) ' ■<- = 11 f ' . fk,k+- = ' ' S ( 42 ) where α^ denotes the difference in orientation from the / -th element to its successor, and ΔS, the length of an orientation element. It will be noted that this measure is global in nature, being evaluated over a curve of L orientation elements, any number of which may be gaps. Hence, to find the maximum value at a given segment, one must evaluate all d possible curves starting with this segment, where d is the (discrete) number of directions considered at each point. This exponential complexity cannot be reduced by pyramid techniques, since parts of a salient curve are not necessarily salient. Nevertheless, Sha'ashua and Ullman reduced complexity to order dL by maximizing repeatedly over shorter curves. Let E x be a state variable associated with element p_, then the iterative process is defined by, where E 2 is the state variable of p. , one of the d possible neighbors of p_; the superscript of E is the iteration number; and /,.. is the inverse curvature factor from p_ to p r After L iterations the state variable becomes equivalent to the saliency measure defined earlier, i+L E (L) = max ∑ Ci j Pi j t (44) ]=~ The proof is sketched in [46] and detailed in [47]. The final state variables of all the orientation elements (segments or gaps) in the N x N grid constitute a saliency map of the image. In our associative architecture, the pixels constitute the grid points, and d = 8 orientation elements connect each pixel to its neighbors (Fig. 30). In Fig. 30, the following notation is employed: • solid line: Ei element for which saliency is computed • broken line: Successors used in computation • dotted line: Successors ignored in computation For d discrete directions, angle is given in increments of 360 /d = 45 degrees, and , takes on the following values: It can be seen that only three values of are significant, -45, 0, and 45, hence only successors with these values of α will be considered in the computation. Since the initial image is given as edge points, a preprocessing step is required to identify active elements as any pair of edge points that are 8-neighbors. The program outline is given in Listing 9. The memory word format is in Fig. 31. LISTING 9: Associative Saliency Network mainO . . . declarations for(i=0 ; i<8 ; i++) { /* updates Ei with first iteration */ letmc d(Sig+i) ; setag; compare ; letmc d(E[i]+3) ; write ; } f or (iteration=l ; iteration<HaxIteration; iteration++) { for ( i=0 ; i<8 ; i++) { letm dseq ( Tl ,T2+8) ; letc ; setag ; write ; /* clear "Tl " and "T2 */ shift_and_do ( i , 0 ,T2) ; /*perform Ej *Fij — >T2 for j=0*/ for (j=l ; j <3 ; j++) { shift_and_do ( i , j ,T2) ; /* Ej *Fij --> T2 */ max.f ield(T2 ,TD ; /* maximum(T2 ,TD — > Tl */ } Sum.Acc (i) ; /* SIGi + ROi*HAX (Ej*Fij ) — > Ei */ } It may be worth noting that as active p approaches unity, it becomes possible to distinguish between different degrees of high saliency, but a larger number of iterations is required. The algorithm requires a word length of 90 bits and its time complexity in cycles is given by, Tsai = 42 + ^ + 7(12354 + 66^) (45) 0 0 where I denotes the number of iterations. Evaluating the expression in parentheses, execution time becomes 0.4 ms. per iteration. An execution time of 500 ms. per iteration was reported for the Connection Machine [48]. Hough Transform The Hough transform can detect a curve whose shape is described by a parametric equation, such as the straight line or conic section, even if there are gaps in the curve. Each point of the figure in image space is transformed to a locus in parameter space. After splitting the parameters into suitable ranges, a histogram is generated giving the distribution of locus points in parameter space. Occurrence of the object curve is marked by a distinct peak in the histogram (intersection of many loci). In the case of a straight line (Fig. 32), we use the normal parameterization suggested by Duda & Hart [49]: x cos θ + y sin θ = p which specifies the line by p and θ, and the histogram includes a straight line in every direction of θ. But if the candidate points are the result of edge detection by a method that yields direction, then θ is known. Following O 'Gorman & Clowes [50], this information was applied to effect a major reduction of both hardware (word-length) and time complexity. For a 511 x 511 image with the origin at its center, the x-y coordinates are given by 9 bits in absolute value and sign. Angle θ from 0 to π is given to a matching precision of 10 bits (excluding sign of gradient). The sine and cosine are evaluated by table look-up. Advantage is taken of the symmetry of these functions to reduce the table size four-fold. After comparing p, the histogram is evaluated and read-out element by element using the COUNTAG primitive. This algorithm requires a 52-bit word length and has a time complexity of, T. = 1870 + 13i(r - l) machine cycles, where t, r are the resolutions of ), θ respectively in the histogram. The second term accounts for histogram evaluation and dominates T \ at t, r > 32. At a resolution of 16 in both θ and p (t, r = 16), the execution time is only 150 μs per frame, and grows to just 6.4 ms at a resolution of 128. Consider now detection of a circle with given radius R. Its equation may be written as: (x - x 0 ) 2 + (y - yo) 2 = R 2 , where a. υ . 2 o are the coordinates of the center. As in the case of the straight line, we wish to use the direction of the gradient to simplify the process. Differentiating the circle equation we obtain, dy X - XQ . lo π dx y — yo -■ where θ is the gradient direction. Solving for xo, yo, xo = x ± Rs.n(θ - —) yo -= y ± R ~ os(θ - —). These equations are implemented and a histogram generated for x 0 , yo- The algorithm uses gradient polarity to distinguish between bright circles on a dark background and dark circles on a light background, generating a separate histogram for each case. Assuming R less than 32 pixels, the word length required is 62 bits and the time complexity in cycles is given by, T c = 1550 + 26.V.. , (46) where r x , r y are the range resolutions of xo. J o in the histogram. For a resolution of 128 in both x 0 and y 0 . the execution time is 10.8 ms per frame. Mixed circles that are partly black on white, partly white on black, may be detected by summing the two histograms (in the host) before thresholding. If the search is restricted to bright circles on a dark background (or vice-versa) , the complexity reduces to T c = 1280 + 13r x r y , (47) and the execution time drops to 6.4 ms. Geometric Problems Convex Hull It is sometimes interesting or useful to find the boundary of a set of points in the image. When looking at such a point set, one has little trouble distinguishing the inside points from those on the boundary. These natural boundary points are the vertices of the convex hull, which is defined mathematically as the smallest convex polygon containing the point set. Equivalently, the convex hull is the (unique) convex polygon containing the point set, whose vertices belong to the point set. Hence it is also the shortest path surrounding the point set. The approach chosen for associative implementation is known as the package-wrapping method [51]. Starting with a point guaranteed to be on the convex hull, say the lowest one in the set (smallest y coordinate), take a horizontal ray in the positive direction and swing it upward (counter-clockwise) until it hits another point in the set; this point must also be on the hull. Then anchor the ray at this point and continue swinging to the next points, until the starting point is reached, when the package is fully wrapped. For convenience we choose the coordinate system so that the entire image (and point set) is in the first quadrant. The lowest point P j is located by searching for the minimum y-coordinate in the set; it is on the hull and is labeled as such. We take as reference the extension of segment PiP j , such that x,- = 0 and y,- = y-, and consider the angle θ it forms with every P j P k , where P k is anyone of the other points in the set. The next point on the convex hull is the one for which θ is a minimum (Fig. 33). Denoting vector P,-Pj by V " . and vector P j P k by V * , their scalar product becomes, VιV 2 = |V 1 ||V r 2 | cos fl. (48) Hence, Where a\ = x. - x_; a = X k — x ; To avoid taking square roots, we use cos 2 θ, cos 2 θ = , { ? ιa2 + b l b2) * (50) (α + 6 ) ( 2 + δ 2 ) Since θ ranges from 0 to π, before squaring the numerator αια 2 + b \ b 2 , we test for any positive values. If there are, we mark them and look for the maximum cos 2 θ value among them. Otherwise, if all numerators of cos θ are negative, we look for the minimum value of cos 2 θ. The P k corresponding to the selected θ is on the hull and is labeled as such. To continue the process, P, becomes the new P., and the chosen P k becomes the new P. (Fig. 33). The process terminates when it returns to the initial (lowest) point. Two special cases may arise. In the first step, when looking for the lowest point, we may find two or more points having the same minimum y-coordinate. We choose among them the point with highest x-coordinate as P., the one with lowest x-coordinate as P_ , and P,P j becomes the first reference segment. During the iterative part, when looking for the point that makes θ a minimum, we may find two or more points, P ι, P k2 • • - Pksi yielding the same minimum value. Clearly, lines P.P k i, P P k , - • ■ , P ] P k s are collinear, and the point to be chosen is the most distant from P., the one having maximum - ~: \- Should all Xk - x equal zero, the choice is made on the basis of maximum \y k - y } \. Analysis of the algorithm implementation shows on ARTVM gives execution time in machine cycles, TcHuii = 60 + 105V (51 where V is the number of vertices of the complex hull. Hence time complexity is independen of the number of points in the set. For 1000 vertices in the hull, execution time becomes 3.1 ms. Voronoi Diagram This is a classical mathematical object that has become an important tool in computationa geometry for dealing with proximity problems. Starting with a given set of L points in th plane, P_ , i — 1, 2, • • -L, the Voronoi diagram surrounds each point P. by a region, P,, such that every point in P, is closer to Pj than to any other point in the set, P j , j = 1, 2, • • - L and i φ j. The boundaries of all these regions, P,, constitute the Voronoi diagram. An associative algorithm based on the brush fire technique is presented in Listing 10 Each of the given points acts as a source of fire that spreads uniformly in all directions. Th boundaries consist of those points at which fires from two (or three) sources meet. Ever point in the given set is initially marked with a different color - actually its xy-coordinates. Each point in the image looks at its 8-neighbors. A blank (uncolored) point that sees a colore neighbor will copy its color. If both are colored, the point will compare colors, marking itsel as a Voronoi (boundary) point if the colors are different. This process is iterated until all points are colored. One more cycle of color comparison with the neighbors is necessary to complete demar cation of the boundaries. The order of processing the 8-neighbors was chosen to optimiz boundary precision. Not unexpectedly, it alternates between opposite compass directions: N,S,E,W,NE,SW,NW,SE. Analysis of the algorithm yields the time complexity in cycles as, T vor = 2 + 7(1533 + -^), (52 or an execution time of 75μs per iteration. The regions grow diagonally at a rate of 2 pixel per iteration, hence up to 103 iterations may be required. But for a representative value o I = 20, execution time is 1.5ms. The algorithm yields boundaries that are almost thin. One round of thinning in all 4 directions (south, north, west, east) with the following template will suffice. X I X I P O X 0 0 Note that the template is shown in its initial southern orientation and that the order within each pair of opposite directions has been reversed. This reversal appears essential for main¬ taining boundary precision. A pixel removed from the boundary is recolored by examining its 4- n ^9hbors in turn and copying the first one that is not a boundary point. Since thinning and recoloring are not iterative processes, they do not affect execution time significantly. Fig. 34 is useful in understanding Listing 10. LISTING 10: Associative Voronoi Diagram mainO /* ... declarations */ /** Mark the seed points as colored **/ letm d(CL) d(VL) ; letc; setag; write; letmc d(S) ; setag; compare; letmc d(CL) ; write; /****** BRUSH FIRE *•****/ while(rsp) { for(window.index=0; window_index<8; window_index++) /** Bring in CN and VN **/ letm d(CN) d(VN) ; letc; setag; write; letmc d(CL) ; setag; compare; letmc d(CN) ; general.shift(window.index) ; write; letmc d(V ) ; setag; compare; letmc d(VN) ; general.shift(window.index) ; write; process() ; } letm d(C ) letc; setag; compare; > process() ; process 0 { for(i=0 ; i<colour_size; i++) { letm d(TM) ; letc; setag; write; letmc d(color+i) ; setag; compare; letmc d(TM); general.shift (window.index) ; write; letm dseq(CL.TH) d(color+i) ; letc d(CL) d(CN) d.TM) ; setag; compare; letmc d(VL) ; write; letm dseq(CL.TM) d(color+i); letc d(CL) d(CN) d(color+i); setag; compare; letmc d(VL) ; write; letm dseq(CL,TM) d(color+i) ; letc d(CL) d(TH) ; setag; compare; letmc d(color+i); write; general.shift (index) /* 6 0 4 */ int index; /* 3 P 2 */ ' /* 5 1 7 */ if (index ■= 4 I I index == 0 I I index ==6) shiftag(b) ; if (index == 5 I I index == 1 I I index =7) shiftag(-b) ; if (index == 6 I I index »= 3 I I index ==5) shiftag(l) ; if (index *== 4 I I index == 2 I I index ==7) shiftag(-l) ; } The associative Voronoi algorithm was designed for quick access of statistical data. Thus it would take only 13 machine cycles to read out the length (in pixels) of the Voronoi Diagram or the area (in pixels) of any Voronoi region identified by its seed coordinates. Word Length This section estimates the associative memory word length (K), required to compute vision algorithms. Consider the machine model described, for monochrome computer stereo vision in three channels. Its input is M bits for each of the incoming images, left and right. The machine generates parameters in three channels for use in higher level processes. The parameters are: disparity of bit length [log 2 (2W,- + 1)] ; slope orientation and edge designation (of length 4 and 1 respectively) for the left and right images; and a one bit match label. Assuming input data is retained for further processing, the final word size is given by, 3 K Iina ι = 2M + ∑ \og 2 (2Wi + 1) + 3(2(4 + 1) + 1) = 64 (53) t ' =l for M=8 and W=P=7,15,31. Additional word space is required for temporary storage o intermediate results, and this fluctuates dynamically during execution of the various algo rithms. The maximum word length depends on the order of execution. The best order in our case is to compute each channel in turn, starting with the coarsest. Examination of the var¬ ious processing phases indicates that maximum word length is reached during computation of disparity for the last channel. Accordingly, the maximum word length is expressed by, K max = 2M + K chl 2 + K sp (54) where the first term is for the input data, and A ' c/ _. 2 accounts for the results of the first two channels. K chι = 2(2(4 + 1) + 1) + log 2 (2W 3 + 1) + log 2 (2W 2 + 1) = 33 (55) K sv is the working space to compute the last channel disparity and is given by (see Stereo Vision) , K 3p = 3 x 2 + 2[log 2 (2 1 + l) 2 ] + 5[log 2 (2 ~ 1 + 1)] = 42 (56) where K 3p does not include flag bits. Hence K max becomes 91 bits. Let us expand our model to include most of the visual algorithms implemented above. As before, the minimum word length required depends on the order of execution. The rec¬ ommended order is: • Optical Flow. • Edge detection and contour processing. • Hough transform, saliency mapping. • Stereo matching. The critical process appears to be optical flow with 132 bits (including an additional byte of pixel data for stereo). By sharing or reusing fields Enl, Uav and Vav, the word length required drops to 106. Providing some spare capacity for new algorithms, the _4PTVMword length was fixed at 128 (four 32-bit sectors), plus an 8-bit flag bit, or 136 bits. This only considers associative storage - if the 16-bit image buffer is included, the total word length becomes 152. Results and Conclusions of the Akerib Thesis A low cost, general purpose vision architecture was proposed here which could carry out any vision algorithm at video rate. The proposed machine is a classical associative structure adapted to computer vision and VLSI implementation. It is designated Associative Real Time Vision Machine (ARTVM), and uses an up-down shift mechanism in the tag register to enhance operations on a local neighborhood. An internal frame buffer virtually eliminates computer I/O time, and permits simultaneous input, output and computation. To reduce chip interface without materially affecting speed, the word is partitioned into four sectors, only one of which can be accessed at a time, and a flag field that is always accessible. The major hardware complement to handle a 512 x 512 image is shown to consist of 256 K words l52 bits of associative memory. Extrapolation of earlier experiments to 0.5 micron technology yields a capacity of \M bits of associative memory on a chip area of 100mm 2 and a cycle time of 30 nanoseconds. The proposed chip stores AK words x l52 bits, which is 59 percent of capacity, and 64 of these chips make up the associative memory. A simulator of ART VM was generated in the C language for use in developing associative micro-software and evaluating its time complexity. Convolution in the x and y directions with a 15-element filter takes 0.34 ms, hence Canny edge detection executes in 0.5 ms, and the Marr & Hildreth method runs nearly twice as long. Likewise computation of stereo disparity by the Grimson method over a range of ±15 pixels, including disambiguation and out-of-range test, completes in under one ms. This stereo performance was only attained by virtue of an array algorithm for counting labeled pixels over a neighborhood. Optical flow by the Horn & Schunck method executes in less than 0.5 ms. Curve propagation, thinning and contour tracing take 1.5, 6.4 and 66 μs per iteration, respectively. The linear Hough transform takes 150 μs for a resolution of 16 in direction and distance from the origin. An interesting result was obtained for the global saliency mapping of Sha 'ashua & Ullman. It takes 0.4 ms per iteration, which is three orders of magnitude faster than the Connection Machine. Geometric problems were also implemented: the convex hull takes 3.15 μs per vertex, and the Voronoi diagram executes in 0.15 ms per iteration by the brush-fire technique. Two methods were selected for comparative evaluation of ARTVM performance. In the first we compared our architecture to an SIMD array of up to 256 high performance processors (Inmos T800/Intel S60), and found it to have a speed advantage of 2-3 orders of magnitude. The speed advantage was lowest for neighborhood arithmetic operations of higher precision, such as convolution (factor of 97) , and reached a peak for neighborhood logic operations such as curve propagation (factor of 2500). The second method was the Abingdon cross benchmark for which test results were available on several of the better known vision architectures. The ARTVM was found to lead by 2-6 orders of magnitude in price-performance. The ARTVM configuration used throughout this investigation assumed a long shift of 32 places (b = 32) . This added 64 pins to the associative chip, for a total interface of 160 pins. Reducing b to 16 would save 32 pins at the expense of a 17% loss in average speed. It was indicated earlier that the architecture is flexible with respect to advances in technology and can take full advantage of higher chip density. There is equal flexibility in image resolution if memory chip count is varied linearly with this parameter. Thus for a 1024 x 1024 image, the chip count will grow by a factor of 4, with a small loss in speed and, perhaps, a minor increase in word length. In the vision algorithms described above, which the data base is inherently pixel oriented or such orientation offers a decided advantage. Exceptions are the Hough transforms and convex hull. For higher level vision functions, dealing with more complex image elements, an associative architecture is expected to offer even greater advantages. This work has important commercial implications. The apparatus and methods shown and described above are useful in a variety of applications, such as but not limited to: video telephony implementing the H.261 standard; video teleconferencing for CIF resolution and QCIF resolution; compression and decompression of video games; color image enhancement and manipulation for desk top publishing; optical character recognition (OCR); virtual reality; image animation such as computer generated cartoons; 2 or 3 dimensional B/ or color image inspection and processing; video detecting for traffic control; medical imaging such as 3D reconstructions and back projection filtering; real time normalized gray scale correlation; TV tracking of more than one object such as tracking of vehicles for traffic control purposes; other traffic applications such as identification of license numbers; inspection of manufactured objects such as agricultural produce; wood and metal products and microelectronic products; acceleration of computer arithmetics; neural network applications; fuzzy logic applications; post processing the quality of compressed images; photography with video, digital or analog cameras, with or without image compression, with or without special effects such as autofocus, gamma correction, photomontages, bluescreen, aperture correction, exposure correction, real time morphing, and correction of geometrical distortions; television applications such as HDTV (high definition television) , satellite TV, cable TV; infotainment; speech recognition; kiosks for banking, travel, shopping and other purposes; special effects and enhancement of automated office equipment such as facsimile machines, printers, scanners, and photocopiers; compression applications such as compression of faces, fingerprints or other information onto smart cards for driver licenses, ID cards and membership cards; communication applications such as digital filtering, Viterbi decoding and dynamic programming; and training, educational, and entertainment applications. Video and picture editing applications include acceleration of desk top publishing functions such as blurring, sharpening, rotations and other geometrical transformations, and median filtering. CD ROM (compact disc read-only-memory) uses include compression such as MPEG-I, MPEG-II, JPEG, fractal compression, and wavelet compression, with or without enhancement such as video sharpening, for a wide variety of applications such as archiving images for medical, real estate, travel, research, and journalistic purposes . Examples of facsimile applications include canceling out a colored background so as to sharpen the appearance of a text superimposed on the colored background, filling in gaps in letters such as Kanji characters, OCR, facsimile data compression. An example of a photocopier application is automatically superimposing a template stored in memory, such as a logo, onto a photocopy. Security applications for home, workplace, banks, and receptacles for valuables and proprietary information, include the following: recognition of personnel, as by face recognition, fingerprint recognition, iris recognition, voice recognition, and handwriting recognition such as signature recognition; Camera features which may be accelerated by use of the embodiments shown and described herein include the following: 1. Gamma correction: A LUT (look up table) is employed which includes 256 cells, respectively including a value i (i = 0, ..., 255) raised to the power of gamma. Gamma may, for example, be 0.36 or 0.45. The same LUT may be employed for all three color components (R, G and B) and gamma correction may be performed in parallel for all three components. 2. Rapid color-base conversions such as color transformation in which luminance and chrominance are separated before further processing. For example, it is often desirable to transform RGB values or CMYK values into YCrCb values which can be compressed by reducing the number of bits devoted to the Cr and Cb components. Eventually, the compressed YCrCb values are transformed back into RGB or CMYK. 3. Low pass filtering of luminance chrominance signals with 5 - 15 tap filters. 4. Aperture correction. For example, the following stages may be performed: a. Extract a high frequency component of the original signal representing the photographed scene; b. Apply two separable filters, each of which may, for example, be: [-0.25 0.5 -0.25] to the columns and rows respectively. c. Generate a correction signal by shifting the horizontal point signal by K=0, 1, 2 or 4 pixels. d. Generate corrected output by adding the correction signal to the original signal. 5. Autofocus and autoexposure computations: For example, the focus of the camera may be adjusted by a predetermined amount m a first direction. Then, the proportion of high frequency components may be computed using the embodiments shown and described above to determine whether this proportion has increased or decreased as a result of the adjustment. If there is an increase, the focus is again adjusted by a predetermined amount in the first direction. If there is a decrease, the focus is adjusted by a predetermined amount in the second direction. 6. Auto color correction computations, such as auto gain control and auto white balance. For example, the following stages may be performed: a. Adjust black levels until the darkest parts of each R, G or B signal reaches a predetermined level. b. Adjust differential gains so as to equalize the means of the three signals. c. Adjust overall gain such that the most positive of the peaks of the three waveforms just reaches white level. This may be done by computing the maximum, minimum and mean levels of each color. 7. Chroma-keying: a. Key generator: X = Cb cos(z) + Cr sin(z) ; Z = Cr cos(z)s + Cb sin(z) K = X - a|Z| , K=0 if Z<a|Z|, a = 1/2 , 1, 2, 4 b. Foreground suppression: Cb' = Cb - K cos(z) Cr' = Cr - K sin(z) Y' = Y - YsK, Y' = 0 if YsK>Y. Ys - adjustable constant c. Key processing: Kbg = 0 for wanted foreground, Kbg = 1 for wanted background picture. Kbg = (K-Kl)Kg for the transition band, c. Mixer 8. Noise Reduction Weighted averaging of two successive images with weights 1/K, 1-1/K, K=2,4,8 9. Movement Protection (Avoid smearing of moving objects) . 10. Creation of composite and S-video signals: Chrominance modulation and alternating lines: Usin(wt)+Vsin(wt) Usin(wt)-Vsin(wt) done for frequencies of 13.5 MHz. Ill APPENDIX A /*************** ASSOCIATIVE PROCESSOR SIMULATOR ^include <stdio.h> #define setag set_tag() ^define firsel fir_sel() #define countag coun_tag ( ) ^define letm let_m(); ^define letc let_c(); #define letmc let_mc(); ^define clearc let_c(); ^define setc set_c(); ^define c_to_m mov_cm() #define m_to_c mov_mc ( ) #define d(x) del (x) ; ^define dseq(xl,x2) ( (x2>xl) ?dseql (xl,x2) :dseql (x2,xl) ) ; ^define dvar(xl, x2,dat) (cons (xl, x2,dat) ) ; ^define load r_disk() #define save w_disk() ^define compare comp() ^define write wr( ) ^define read rd() #define BΙT(k) ((l«k)) ^define OF_WORD & ^define TRUE 1 ^define FALSE 0 #define EVEN_WORD(x) ( ((x&l)?0:l) ) #define SIGN(x) ( (x<0)?-l:l) ^define print_cycles printf(" %3.1f CYCLES = %4.3f usec\n", CYCLES, CYCLES*.05) ; #define extern float CYCLES = 0; int PULSE = FALSE; int FLAG_CYCLES = FALSE; int space arr[WORD LENGTH]; struct { int COUNTS, RSP; unsigned A[WORD_LENGTH] [MEM_SIZE]; unsigned OUT_DAT[WORD_LENGTH] ; struct { unsigned BOOLEAN: 1; } M_OR_C_FLAG, M_AND_C_FLAG, COMP[WORD_LENGTH; MASK[WORD_LENGTH; TAG[MEM_SIZE] ; } PAR; setag extern struct PAR; int i; CYCLES+=0.5; PULSE = FALSE; FLAG_CYCLES = TRUE; for(i=0; i<MEM_SIZE; i++) PAR.TAG[i] .BOOLEAN = 1; shiftag (b) int b ; extern struct PAR; int i; if (abs(b)>l) CYCLES+=8; else CYCLES+=0.5 ; PULSE = FALSE; FLAG_CYCLES = TRUE; if (b < 0) { for(i=0;i<MEM_SIZE+b; i++) PAR.TAG[i] .BOOLEAN = PAR.TAG[i-b] .BOOLEAN; for (i=MEM_SIZE+b;i<MEM_SIZE;i++) PAR.TAG[i] .BOOLEAN = 0; } else { for(i=MEM_SIZE-l;i>=b;i—) PAR.TAG[i].BOOLEAN = PAR.TAG[i-b] .BOOLEAN; for(i=0;i<b;i++) PAR.TAG[ i ] .BOOLEAN = 0; coun_tag ( ) { extern struct PAR; int i; PULSE = FALSE; CYCLES += 10; PAR.COUNTS = 0; for(i=0; i<MEM_SIZE; i++) PAR.COUNTS = PAR.COUNTS + PAR.TAG [i ]. BOOLEAN; return(PAR.COUNTS) ; } fir_sel() { extern struct PAR; int i; int j = 0; PULSE = FALSE; CYCLES += 6; while (!PAR.TAG[j++] .BOOLEAN) ; for(i=j ; i<MEM_SIZE; i++) PAR.TAG[i ].BOOLEAN = FALSE; } let_c() { extern struct PAR; int i; FLAG_CYCLES = FALSE; PAR.M_OR_C_FLAG.BOOLEAN = TRUE; PAR.M_AND_C_FLAG.BOOLEAN = FALSE; for(i=0; i<WORD_LENGTH; i++) PAR.COMP[i] .BOOLEAN = 0; } let_m() { extern struct PAR; int i; FLAG_CYCLES = FALSE; PAR.M_OR_C_FLAG.BOOLEAN = FALSE; PAR.M AND C FLAG.BOOLEAN = FALSE; for(i=0; i<WORD_LENGTH; i++) PAR.MASK[i] .BOOLEAN = 0; } let_mc ( ) { extern struct PAR; int i; FLAG_CYCLES = FALSE; PAR.M_AND_C_FLAG.BOOLEAN = TRUE; for(i=0; i<WORD_LENGTH; i++) { PAR.MASK[i] .BOOLEAN = 0; PAR.COMP[i] .BOOLEAN = 0; } } set_c () { int i; for(i=0; i<WORD_LENGTH; i++) PAR.COMP[i] .BOOLEAN = 1; } mov_cm( ) { extern struct PAR; int i; for(i=0; i<WORD_LENGTH; i++) PAR.MASK[i] .BOOLEAN = PAR.COMP[i ].BOOLEAN; } mov_mc( ) { extern struct PAR; i nt i ; for(i=0; i<WORD_LENGTH; i++) PAR.COMP[i] .BOOLEAN = PAR.MASK[ i ].BOOLEAN; } del (n) int n; { extern struct PAR; int i; if (!FLAG_CYCLES && PULSE) CYCLES+=0.5; PULSE = FLAG_CYCLES = TRUE; if (PAR.M_OR_C_FLAG.BOOLEAN | | PAR.M_AND_C_FLAG.BOOLEAN) PAR.COMP[n] .BOOLEAN = TRUE; if ( !PAR.M_OR_C_FLAG.BOOLEAN | | PAR.M_AND_C_FLAG.BOOLEA ) PAR.MASK[n] .BOOLEAN = TRUE; } cons (start, stop, var) int start, stop; unsigned var; { extern struct PAR; unsigned i; if (!FLAG_CYCLES δcδc PULSE) CYCLES+=0.5; PULSE = FLAG_CYCLES = TRUE; for(i=start; i<=stop; i++) { if (PAR.M_OR_C_FLAG.BOOLEAN | | PAR.M_AND_C_FLAG.BOOLEA ) if (BΙT(i-start) OF_WORD var) PAR.COMP[i] .BOOLEAN = TRUE; if ( !PAR.M_OR_C_FLAG.BOOLEAN | | PAR.M AND C FLAG.BOOLEAN) if (BΙT(i-start) OF_WORD var) PAR.MASK[i] .BOOLEAN = TRUE; } } dseql (nl, n2) int nl,n2; { extern struct PAR; int i; if(!FLAG_CYCLES && PULSE) CYCLES+=0.5; PULSE = FLAG_CYCLES = TRUE; if (PAR.M_OR__C_FLAG.BOOLEAN | | PAR.M_AND_C_FLAG.BOOLEAN) for( i=n2; i>=nl; i—) PAR.COMP[i] .BOOLEAN = TRUE; if ( !PAR.M_OR_C_FLAG. BOOLEAN | | PAR.M_AND_C_FLAG.BOOLEAN) for( i=n2; i>=nl; i—) PAR.MASK[i] .BOOLEAN = TRUE; } r_disk ( ) { extern struct PAR; int k, j; char cl; FILE *input_file; input_file = fopen("ass. inp" , "r") ; for(k=0; k<WORD_LENGTH-l; k++) space_arr[k] = 0; for(j=0;j < MEM_SIZE; j++) for(k=WORD LENGTH-l;k >= 0; k—) { while ( (cl = getc (input_file) ) != '0' && cl != '1' ) space_arr[k] = 1; if (cl «= '0' ) PAR.A[k] [ ] = 0; if (Cl==* 1' ) PAR.A[k] [j] = 1; } w_disk() { extern struct PAR; int k, j ; FILE *output_file; output_file = fopen( "ass .out" , "w" ) ; for(k=WORD_LENGTH-l;k >=0;k—) { if (space_arr[k] ) fprintf (output_file, " " ) ; fprintf (output_file, "%d" , PAR.COMP[k] .BOOLEAN) ; } fprintf (output_file, "\n") ; for(k=WORD_LENGTH-l;k >=0;k—) { if (space_arr[k] ) fprintf (output_file, " " ) ; fprintf (output_file, "%d",PAR.MASK[k] .BOOLEAN) ; } fprintf (output_file, "\n\n" ) ; for(j=0;j < MEM_SIZE; j++) { for (k=WORD_LENGTH-l;k >=0;k—) ( if (space_arr[ ] ) fprintf (output_file, " "); fprintf (output_file, "%d", PAR.A[k] [ j ] ) ; } fprintf (output_file, "%3d" , PAR.TAG[ j ] .BOOLEAN) ; fprintf (output_file, "%5d\n", j) ; } fprintf (output_file, "\n\n %3.1f CYCLES\n", CYCLES); } comp() { extern struct PAR; int k, j ; unsigned or exp; if (PULSE I ) !FLAG_CYCLES) CYCLES+=1; else CYCLES+=0.5; PULSE = FALSE; for(j=0; j<MEM_SIZE; j++) { or_exp = FALSE; for(k=0;k<WORD_LENGTH;k++) or_exp =(PAR.MASK[k] .BOOLEAN) & (PAR.A[k] [j] ~ PAR.COMP[k] .BOOLEAN) | or_exp; PAR.TAG[j] .BOOLEAN = PAR.TAG[ j ].BOOLEAN δc ( !or_exp) ; } PAR.RSP = FALSE; for(j=0; j<MEM_SIZE; j++) if (PAR.TAG[j ] .BOOLEAN) PAR. RSP = TRUE; wr() { extern struct PAR; int k, j; if (PULSE | | !FLAG_CYCLES) CYCLES+=1; else CYCLES+=0.5; PULSE = FALSE; for(j=0; j<MEM__SIZE; j++) for(k=0;k<WORD_LENGTH;k++) { PAR.A[k] [j ] = ( (!PAR.TAG[j ] .BOOLEAN) & (PAR.A[k] [ j ] ) ) | (PAR.TAG[j ] .BOOLEAN & ( (PAR.MASK[k] .BOOLEAN & PAR.COMP[k] .BOOLEAN) | (( !PAR.MASK[k] .BOOLEAN) & PAR.A[k] [j ] ) ) ) ; } } rd() { extern struct PAR; int k, j; if (PULSE 1 | !FLAG_CYCLES) CYCLES+=1; else CYCLES+=0.5; PULSE = FALSE ; for(k=0; k<WORD_LENGTH; k++) { PAR.OUT_DAT[k] = FALSE; for(j=0; j<MEM_SIZE; j++) { PAR.OUT_DAT[k] = PAR.OUT_DAT[k] | (PAR. AG[j ] .BOOLEAN & PAR.A[k] [j ] ) ; } } APPENDIX B /**** ASSOCIASTIVE COMPUTATION OF IMAGE HISTOGRAM ** * */ /*** MEMORY FORMAT ' ***/ /* 7 6 5 4 3 2 1 0 */ / * i I * / /* i I */ # include "stdlib.h" main() { int p; int hist[256] ; letm dseq(0, 7) ; for (p=0; p<256; p++) { letc dvar(0,7,p); setag; compare; hist[p] = countag; } } APPENDIX C /** ASSOCIATIVE CONVOLUTION PROGRAM **/ /a**************************************/ /* THE MEMORY FORMAT */ * ***************** */ /* i d 1 — I — i fd 1 * / /* I i__i__, , */ /* mark temp */ ^define MEM_SIZE 32 ^define WORD_LENGTH 29 ^include "asslib.h" int f[7] = { 1,2,4,16,4,2,1 } ; /* define the filter*/ main( ) int f_size = 7; /* filter size is 7 words */ int n = 8; /* data word length */ int temp = 19; /* temp is in bit position 19 */ int mark = 20; /* mark is in bit posion 20 */ int d_offset = 21; /* [d] field first bit posion */ int add offset, bit count, f index; load ; /****** summed multiplication *******/ /* */ /* add [d] to [fd] if the bit at */ /* position bit_count of f[f_index] */ /* is 1 */ /************************************ for(f_index=0; f_index<f_size; f__index++) { for(add_offset=0; add_offset<n; add_offset++) if( BIT(add_offset) OF_WORD f[f_index]) /*test if bit is 1 */ { ************ add ****** * ******** for(bit_count=0; bit_count<n; bit_count++) { letm d (add_offset+bit_count) d(temp) d (d_offset+bit_count) d(mark); letc d(temp) d(mark); setag; compare; letc d(add_offset+bit_count) d(mark); write; letc d(add_offset+bit_count) d(temp) d(mark) setag; compare; letc d(temp) d(mark); write; letc d (add_offset+bit_count) d(d_offset+bit_count) d(mark); setag; compare; letc d(temp) d (d_offset+bit_count) d(mark) ; write; letc d(d_offset+bit_count) d(mark); setag; compare; letc d (add_offset+bit__count) d(d_offset+bit_count) d (mark) ; write; } /****** propagate carry *******/ for(bit_count=0; add_offset+bit_count< n+3; bit_count++) { letm d(add offset+n+bit count) d(mark) d(temp) ; letc d(mark) d(temp); setag; compare; letc d(add_offset+n+bit_count) d(mark); write; letc d(add_offset+n+bit_count) d(mark) d(temp) ; setag; compare; letc d(mark) d(temp); write; /********* shift [d] field and marker down ********* for(bit_count=mark; bit_count<=mark+n; bit_count++) { letm d(bit count); letc d (bit_count) ; setag; compare; letc; write; letc d (bit_count) ; shiftag(l); write; } } save; print cycles; APPENDIX D Lpf.C This Program demonstrate a low pass filter opertting on a 24 bit bitmap. The calculation is done for the Red Green and Blue color seperatliy . X ^define Pixel 0 #define PIXELSIZE 8 ^define PixelSign Pixel + PIXELSIZE ^define Array_Res 17 ^define TempNig 39 shift_2 ( int pos , int len , int res , int shift_factor) ; sign (int pos , int len , int res , int temp ); void neighbour(int SrcPos . int DstPos,int len , int NbrName) ; void fifoxchng (int SrcPos,int DstPos,int len , int NbrName) ; add(int src ,int src_len,int dst , int dst_len,int c_bit) ; enum color {RED, GREEN, BLUE }; int lpf_filter[ ] = {4,2,2,2,2,1,1,1,1}; main(int , char *argv[]) { int j ; int i; int cl ; conf i fo ( 0 ) ; letm dseq(0,23) ;letc ; setag;write; letm dseq(24,47) ;letc ; setag;write; letm dseq(48,71) ;letc ; setag;write; printf ( "Runnig Asp Simulator : %s \n\n", argv[0] ) ; load(24,48) ; for (Cl = RED ; Cl <= BLUE ; cl++ ) { fifoxchng (48+8*cl, Pixel, PIXELSIZE, 0) ; shift_2 ( Pixel , PIXELSIZE , Array_Res 2 ) ; /* multply the array * 4 and put result in */ shift_2 ( Pixel , PIXELSIZE , PixelSign 1 ) ; /* multply the array * 4 and put result in */ for ( j = 1 ; j <= 8; j++) { /* copy the neigbour */ if ( j <=4) { neighbour(PixelSign, TempNig , ' , j) add(TempNig, PIXELSIZE+1,Array_Res, PIXELSIZE+1+j, Array Res+PIXELSIZE+1+j ) ; } else neighbour(Pixel,TempNig, 8, j ) ; add(TempNig, PIXELSIZE,Array_Res, PIXELSIZE+1+j, Array Res+PIXELSIZE+1+j ) ; } fifoxchng (Array_Res+4 ,48+8*cl, PIXELSIZE, 0) ; } // confifo(24); save (24,48) ; return 0; } add(int src , int src_len,int dst ,int dst_len,int c_bit) { int cnt ; /* clear carray bit */ letm d(c_bit) ; setag ; letc; write; for(cnt=0; cnt<src_len; cnt++) { letm d(dst+cnt) d( c_bit) d( cnt+src); letc d(c_bit); setag; compare; letc d(dst+cnt) ; write; letc d(dst+cnt) d( c_bit) ; setag; compare; letc d(c_bit) ; write; letc d(dst+cnt) d( cnt+src); setag; compare; letc d(c_bit) d( cnt+src) ; write; letc d(cnt+src); setag; compare; letc d(dst+cnt) d( cnt+src) ; write; /* carry propogation */ for (; cnt < dst_len ; cnt++) { letm d(dst+cnt) d( c_bit) ; letc d(c_bit); setag; compare; letc d(dst+cnt) ; write; letmc d(dst+cnt) d( c_bit) ; setag; compare; letc d(c_bit) ; write; } return 0; } void neighbour(int SrcPos,int DstPos,int len ,int NbrName) { int i; /* clear destintaion */ letm dseq(DstPos ,DstPos+ len - 1) ; setag ; letc ; write ; for ( i = 0 ; i < len letmc d(SrcPos + i) ; setag; compare; letmc d(DstPos + i) ; switch ( brName) { case 0: break; case 1 : shiftag(l) ; break; case 2: shiftag(-l) ; break; case 3: shiftag(128) ; break; case : shiftag(-128) ; break; case 5: shiftag(127) ; break; case 6: shiftag(-127) ; break; case 7 : shiftag(129) ; break; case 8: shiftag(-129) ; break; } write ; } return; } void fifoxchng (int SrcPos,int DstPos,int len , int NbrName) { int i; /* clear destintaion */ letm dseq(DstPos ,DstPos+ len - 1) ; setag ; letc ; write ; for (i = 0; i < len ; i++) letmc d(SrcPos + i) ; setag; compare; letmc d(DstPos+len-l - i) ; switch(NbrName) { case 0: break; case 1 : shiftag(l) ; break; case 2: shiftag(-l) ; break; case 3: shiftag(128) ; break; case 4: shiftag (-128) ; break; case 5: shiftag (127) ; break; case 6: shiftag(-127) ; break; case 7: shiftag(129) ; break; case 8: shiftag (-129) ; break; } write ; } return; } shift_2 ( int pos , int len , int res , int shift_factor) { int i ; /* clean the result operand */ letm dseq(res, res+ len + shift_factor-1) ; setag; letc ; write ; /* copy the operand from pos to res ÷shift factor using the tag register */ for ( i = 0; i < len ; i++ ) { letmc d( pos + i) ; setag ; compare ; letmc d( res + shift_factor + i); write ; } return 0 ; } sign (int pos , int len , int res , int temp ) { int i ; /* clean the result operand */ letm dseq(res, res+ len-1) d(temp); setag; letc ; write ; /* copy the operand from pos to res +shift_factor using the tag register */ for ( i = 0; i < len ; i++ ) { letm d(pos + i) d(temp); setag ; letc d(pos + i) ; compare ; letmc d( res + i) d(temp) ; write ; letm d( pos +i) d(temp); setag; letc d(temp) ; compare ; letmc (res+i) ; write ; } return 0 APPENDIX E Laplacian.C This Program demonstrate a laplacian filter opertting on a 24 bit bitmap. The calculation is done for the Red Green and Blue color seperatliy . ^define Pixel 0 #define PIXELSIZE 8 ^define PixelSign Pixel + PIXELSIZE #define Array_Res 24 #define TempNig 40 shift_2 ( int pos , int len , int res ,int shift_factor) ; sign (int pos , int len , int res , int temp ); void neighbour(int SrcPos,int DstPos,int NbrName); void fifoxchng (int SrcPos,int DstPos,int NbrName); add(int src , int src_len,int dst ,int dst_len,int c_bit) ; enum color {RED, GREEN, BLUE }; main(int , char *argv[]) { int j ; color cl; printf ( "Runnig Asp Simulator : %s \n\n", argv[0] ) ; /* insert data to fifo */ confifo (0) ; letm dseq (0, 23) ; letc; setag;write; letm dseq(24, 47) ;write; letm dseq(48, 71) ; letc; setag;write; // load (24,48); confifo(24) ; for (cl = RED ; cl <= BLUE ; cl++ ) { fifoxchng(48+8*cl, 0, 0) ; shift_2 ( Pixel , PIXELSIZE , Array_Res , 2 ) ; /* multply the array * 4 and put result in */ sign ( Pixel , PIXELSIZE , PixelSign , PixelSign + PIXELSIZE ) ; for ( j = 1 ; j <= 4 ; j++) { /* copy the neigbour */ neighbour(PixelSign, TempNig , j ) ; add (TempNig, PIXELSIZE,Array_Res, PIXELSIZE+1+j, Array_Res+PIXELSIZE+l+j) ; } fifoxchng (Array_Res+2 , 48+8*cl, 0) ; } save (24,48); return 0; add(int src ,int src_len,int dst ,int dst_len,int c_bit) { int cnt ; /* clear carray bit */ letm d(c_bit) ; setag ; letc; write; for(cnt=0; cnt<src_len; cnt++) { letm d(dst+cnt) d( c_bit) d( cnt+src); letc d(c_bit); setag; compare; letc d(dst+cnt) ; write; letc d(dst+cnt) d( c_bit) ; setag; compare; letc d(c_bit) ; write; letc d(dst+cnt) d( cnt+src); setag; compare; letc d(c_bit) d( cnt+src) ; write; letc d(cnt+src); setag; compare; letc d(dst+cnt) d( cnt+src); write; /* carry propogation */ for (; cnt < dst_len ; cnt++) { letm d(dst+cnt) d( c bit) ; letc d(c_bit); setag; compare; letc d(dst+cnt) ; write; letmc d(dst+cnt) d( c_bit) ; setag; compare; letc d(c_bit) ; write; return 0; } void neighbour(int SrcPos,int DstPos,int NbrName) { int i; /* clear destintaion */ letm dseq(DstPos ,DstPos+ PIXELSIZE-1) ; setag letc ; write ; for (i = 0; i < PIXELSIZE ; i++) { letmc d(SrcPos + i) ; setag; compare; switch(NbrName) { case 0: break; case 1 : shiftag(l) ; break; case 2: shiftag (-1) ; break; case 3: shiftag(128) ; break; case 4: shiftag (-128) ; break; } letmc d(DstPos + i) ; write ; } return; } void fifoxchng (int SrcPos,int DstPos,int NbrName) { int i; /* clear destintaion */ letm dseq(DstPos ,DstPos+ PIXELSIZE-1) ; setag letc ; write ; for (i = 0; i < PIXELSIZE ; i++) { letmc d(SrcPos+ i) ; setag; compare; switch (NbrName) { case 0: break; case 1 : shiftag(l) ; break; case 2: shiftag (-1) ; break; case 3: shiftag(128) ; break; case 4: shiftag(-128) ; break; } letmc d(DstPos + PIXELSIZE-1-i) ; write ; } return; } shift_2 ( int pos , int len , int res , int shift_factor) { int i ; /* clean the result operand */ letm dseq (res, res+ len + shift_factor-1) ; setag; letc ; write ; /* copy the operand from pos to res +shift factor using the tag register */ for ( i = 0; i < len ; i++ ) { letmc d( pos + i) ; setag • compare ; letmc d( res + shift_factor + i); write ; } return 0 ; } sign (int pos , int len , int res , int temp ) { int i ; /* clean the result operand */ letm dseq(res, res+ len-1) d(temp); setag; letc ; write ; /* copy the operand from pos to res +shift_factor using the tag register */ for ( i = 0; i < len ; i++ ) { letm d(pos + i) d(temp); setag ; letc d(pos + i) ; compare ; letmc d( res + i) d(temp) ; write ; letm d( pos +i) d(temp); setag; letc d(temp) ; compare ; letmc d (res+i) ; write ; } return 0 APPENDIX F /* Sobel filter demonstration */ ^define Sx 0 ^define Sy 12 ^define Pixel 24 ^define PIXELSIZE 8 ^define Temp 32 ^define TempNig 40 ^define TRESHOLD 44 ^define GT 56 shift_2 ( int pos , int len , int res , int shift_factor) ; sign (int pos , int len , int res , int temp ) ; add(int src , int src_len, int dst , int dst_len,int c_bit) ; void neighbour(int SrcPos,int DstPos,int len ,int NbrName) ; int sqr(int src, int len, int dst, int cont) ; sub (int dst , int src, int len , int c_bit) ; abs (int src, int len, int temp, int flag); int cut_at_treshold (int treshold) ; int histogram(int src); cal angel (int x, int y,int result); main (int , char *argv[]) { int j=0 ; int i ; printf("Runnig Asp Simulator : %s \n\n", argv [ 0 ] ) ; /* reset the array */ letm dseq (0,23) ; letc ; setag; write; letm dseq (24,47); letc ; setag; write; letm dseq (48,71); letc ; setag; write; load (8L,64L); for (1 = 0 ; l < PIXELSIZE ; ι++) { letmc d(71-ι) ; setag; compare; letmc d(Pιxel+ι); write; } neighbour(Pixel, Sx+1, PIXELSIZE, 1) ; /* Sx = 2* A[l] */ neighbour(Pixel, Temp, PIXELSIZE, 2) ; /* Temp = A[2] */ add (Temp, PIXELSIZE, Sx+1, PIXELSIZE, Sx+1+PIXELSIZE ); /* Sx 2*A[1]+2*A[2] */ neighbour(Pixel, Sy+1, PIXELSIZE, 3) ; /* Sy = 2* A[3] */ neighbour (Pixel, Temp, PIXELSIZE, 4) ; /* Temp = A[4] */ add (Temp, PIXELSIZE, Sy+1, PIXELSIZE, Sy+1+PIXELSIZE ) ; /* Sx = 2*A[3]+2*A[4] */ /* Calculate the fixed part of the filter */ /* 1 0 1 / * temp = 0 0 0 */ / * 1 0 1 7 neighbour(Pixel, TempNig, PIXELSIZE, 5) ; /* Temp = A[5] */ for ( j = 6 ; j <= 8 ; j++) { /* copy the neigbour */ neighbour(Pixel, Temp, PIXELSIZE , j) ; add(Temp, PIXELSIZE, empNig,PIXELSIZE+2, TempNig+PIXELSIZE+2) ; } sub (Sx, TempNig, 11, Sx+11) ; sub (Sy,TempNig, 11, Sy+11) ; cal_angel (Sx+11, Sy+11, Pixel) ; histogram(Pixel) ; abs (Sx, 12, Temp, Temp+1) ; abs (Sy, 12, Temp, Temp+1) ; //histogram(Sx) ; add(Sy,ll,Sx, ll,Sx+12) ; cut_at_treshold (60) ; letmc d(Pixel) ;d (Pixel+1) ; setag;compare; letmc d(5);write; letm d(Pixel) d (Pixel+1) ; letc d(Pixel) ; setag;compare; letmc d(3);write; letm d(Pixel) d (Pixel+1) ;letc d(Pixel+1) ; setag; compare; letmc d(4);write; letm d(Pixel) d (Pixel+1) ; letc; setag; compare; letmc d(2);write; histogram(O) ; letm dseq (64, 71) ; letc; setag; write; for (i = 0 ; i< 8 ; i++) { letmc d(Sx+i); setag; compare; letmc d(71-i); write; } save (8L, 64L) ; return 0; } cal_angel (int x,int y,int result) { letm dseq(result, result+1) ; letc ; setag ; write; /* Sx and Sy are negative */ letmc d(x) d(y) ; setag;compare; letmc dvar(result, result+1, 2) ;write; /* Sx is negative and Sy positive second qouter / letm d(x) d(y) ; letc d(x) ; setag ; compare; letm dseq (result, result+1) ; letc dvar(result, result+1, 3) ; write; /* Sy is negative and Sx positive second qouter letm d(x) d(y) ; letc d(y) ; setag ; compare; letm dseq (result, result+1) ; letc dvar(result, result+1, 1) ; write; return 0 ; } abs (int src, int len, int temp, int flag) { int i ; int sign; sign = src+len-1; /* clean the result operand */ letm d(temp) d(flag); letc d(temp); setag ; write ; /* copy the operand from pos to res +shift_factor using the tag register */ for ( i = 0; i < len-1 ; i++ ) { /* if flag is high than invert the bits */ letmc d(src + i) d(flag) d(sign) d(temp); setag ;compare; letc d(flag) d(sign) ; write; letm d(sign) d(flag) d(temp) d(src+i) letc d(sign) d(flag) d(temp) ; setag ; compare; letmc d(src+i) ;write; letmc d (temp) ; setag;write, • /* find the first bit that is high */ letmc d(src+i) d(sign) ; setag; compare; letmc d(flag) ;write; } letm d(sign) ;letc; setag ;write; return 0 ; } add(int src , int src_len,int dst , int dst_len,int c_bit) { int cnt ; /* clear carray bit */ letm d(c_bit) ; setag ; letc;write; for(cnt=0; cnt<src_len; cnt++) { letm d(dst+cnt) d( c_bit) d( cnt+src); letc d(c_bit); setag; compare; letc d(dst+cnt); write; letc d(dst+cnt) d( c_bit) ; setag; compare; letc d(c_bit); write; letc d(dst+cnt) d( cnt+src); setag; compare; letc d(c_bit) d( cnt+src) ; write; letc d(cnt+src); setag; compare; letc d(dst+cnt) d( cnt+src); write; /* carry propogation */ for (; cnt < dst_len ; cnt++; { letm d(dst+cnt) d( c_bit) ; letc d(c_bit); setag; compare; letc d (dst+cnt); write; letmc d(dst+cnt) d( c_bit) ; setag; compare; letc d(c_bit); write; } return 0; } /* dst = dst - src */ sub (int dst ,int src , int len, int c_bit) { int cnt ; /* clear carray bit */ letm d(c_bit) ; setag ;letc;write; for(cnt=0; cnt<len; cnt++) { letm d(dst+cnt) d( c_bit) d( cnt+src); letc d(src+cnt) ; setag; compare; letc d(c_bit) d(dst+cnt)d (src+cnt) ; write; letc d(dst+cnt) d( c_bit) ; setag; compare; letc ; write; letc d(c_bit); setag; compare; letc d(dst+cnt) d( c bit); write; letc d(src+cnt) d(dst+cnt); setag; compare; letc d(src+cnt); write; return 0 ; void neighbour(int SrcPos,int DstPos,int len , int NbrName) { int i; /* clear destintaion */ letm dseq(DstPos ,DstPos+ len - 1) ; setag ; letc ; write ; for (i = 0; i < len ι++: letmc d(SrcPos + i) ; setag; compare; letmc d(DstPos + i) ; switch(NbrName) { case 0: break; case 1 : ■ shiftag (1) ; break; case 2: shiftag (-1) ; break; case 3: shiftag(128) ; break; case 4: shi f tag ( -128 ) ; break ; case 5 : shiftag(127) ; break; case 6: shiftag (-127) ; break; case 7: shiftag(129) ; break; case 8: shiftag(-129) ; break; } write ; } return; } shift_2 ( int pos , int len , int res , int shift_factor) { int i ; /* clean the result operand */ letm dseq(res, res+ len + shift_factor-1) ; setag; letc ; write ; /* copy the operand from pos to res +shift factor using the tag register */ for ( i = 0; i < len ; i++ letmc d( pos + ι) ; setag ; compare ; letmc d( res + shift_factor + i); write ; } return 0 ; } sign (int pos , int len , int res , int temp ) { int i ; /* clean the result operand */ letm dseq(res, res+ len-1) d(temp); setag; letc ; write ; /* copy the operand from pos to res +shift_factor using the tag register */ for ( i = 0; i < len ; i++ ) { letm d(pos + i) d(temp); setag ; letc d(pos + i) ;compare ; letmc d( res + i) d(temp) ;write ; letm d( pos +i) d(temp); setag; letc d(temp) ;compare ; letmc d (res+i) ;write ; } return 0 ; } int sqr(int src, int len, int dst, int cont) { int i , cnt ; /* clear the result area */ letm dseq (dst, dst+2*len) ; letc ; setag; write; for ( i = 0 ; i < len ; ι++) { /* clear the control bit*/ letm d(cont) ; letc ; setag; write; /* set the cont bit if the currunt bit is on V letmc d(src+ι); setag; compare; letmc d (cont) ; write; /* clear carray bit */ letm d(dst+len+i) ; setag ; letc; write; for ( cnt = 0 ; cnt < len ; cnt++ ) { letm d(dst+cnt+i) d( dst+len+i) d( cnt+src) d(cont) letc d(dst+len+ι) d(cont); setag; compare; letc d (dst+cnt-ri) d(cont); write; letc d(dst+cnt+i) d( dst+len+i) d(cont); setag; compare; letc d(dst+len+ι) d(cont); write; letc d(dst+cnt+i) d( cnt+src) d(cont) ; setag; compare; letc d(dst+len+i) d( cnt+src) d(cont); write; letc d(cnt+src+i) d(cont); setag; compare; letc d(dst+cnt+i) d( cnt+src) d(cont); write; } } return 0; } int cut_at_treshold (int treshold) { int cmpr(int F,int S,int size, int gt,int le,int cont); int i; letm dseq (TRESHOLD, TRESHOLD+11) ; letc dvar (TRESHOLD,TRESHOLD+11, treshold) ; setag;write; letmc d (GT+2) ; setag;write; cmpr(Sx, TRESHOLD, 12, GT, GT+1, GT+2) ; letmc d (GT) ; setag; compare; /* find all number that are less than treshold */ letm dseq(0,7) ;letc d(7) d(l);write; printf(" the number of pixel below is = %d the treshold is = %d\n", countag, treshold) ; letmc d (GT+1); setag; compare; /* find all number that are less than treshold */ letm dseq(0,7) ; letc;write; printf(" the number of pixel below is = %d the treshold is = %d\n", countag, treshold) • return 0; /****************************************************** ************* /* Procedure for comparison of fields. */ /* if F > S then gt-bit set; */ /* if F<= S then le-bit set; cont - candidate bit */ ******************************************************* ************ cmpr(int F,int S,int size, int gt,int le,int cont) { int i; letmc d(cont) setag;compare; letm d(gt) (le) ; letc;write; /*Clear */ for(i=size-l;i>=0; i—) { letm d(cont) d(gt) d(le) d(F+i) d(S+i); letc d(cont) d (F+i) ; setag; compare; /* 10 */ letc d(cont) d(F+i) d(gt); write; letc d(cont) d(S+i) ; setag; compare; /* 01 */ letc d(cont) d(S+i) d(le);write; } return 0; } int histogram(int src) { int i , t; letm dseq (src, src+7) ; for (i = 0 ; i < 256 ; i++) { letc dvar (src, src+7, i) ; setag;compare; t = countag ; if (t > 0 ) printf(" color is = %d and histogram = %d \n",i,t); } return 0; } APPENDIX G /******* CURVES PROPAGATION BY ASSOCIATIVE PROCESSOR ******* ****************************************************** / /***************** MEMORY ORGANIZATION /* |__| |__| */ */ /* MARK not use EO V /* bit-7 bit-0 V /******************** MAIN PROGRAM **************** ^define MEM_SIZE 100 /* 10 x 10 image size example */ ^define WORD_LENGTH 8 ^include "asslib.h" main( ) int growth; int growth_threshold = 0; int old_condition = 0; int new_condition = 1; int MARK = 7; int E0 = 0; int b = 10; /* long shift constant */ l oad ; letmc d(E0); setag; compare; /* TAG <— EO */ while ( (growth = (new_condition - old_condition) ) > growth_threshold) { shiftag(-b); shiftag(-l); write; shiftag(l); write; shiftag (1); write; setag; compare; letc; write; /* clear EO */ letmc d(MARK); compare; letmc d(E0); write; /* new edges in EO */ shiftag (1); write; shiftag (-1); shiftag (-1); write; setag; compare; letc; write; /* clear EO */ letmc d(MARK); compare; letmc d(E0); write; /* new edges in EO */ shiftag (b); shiftag (1); write; shiftag (-1); write; shiftag (-1); write; setag; compare; letc; write; /* clear EO */ letmc d(MARK); compare; letmc d(E0); write; /* new edges in EO */ old_condition = new_condition; new_condition = countag; printf("%d %d\n", growth, new_condition save; print_cycles; APPENDIX H /****************************************************** ********************* /* ASSOCIATIVE "HORN & SCHUNCK" OPTICAL FLOW (O.F.) ALGORITHM */ /****************************************************** ********************* ************** INPUT ************ */ /* Gray level images of n & n+1 frames. */ ************** OUTPUT *** * ******** */ /* Optical flow patterns. */ ************** PROCESS ****** ****** */ /* The memory organization: */ /* 1 1 14 14 10 10 20 18 11 11 10 8 8 */ /* I_I_I i i____i____i i 1____i 1 - — I — 1 — I */ * I.I_I i 1_____i_—i i 1____i____i I i i */ /* m t V U Vav Uav Ac Sc Et Ey Ex Enl En */ /* a e */ /* r m */ / * k p */ /* En : Gray level of frame n. */ /* Enl : Gray level of frame n+1. */ /* Ex : Derivative estimation in X direction. */ /* Ey : Derivative estimation in Y direction. */ /* Et : Time rate of change in intensity. */ /* Sc : Accumulator to compute the scale factor D where */ /* D = alfa*alfa + Ex*Ex + Ey*Ey. */ /* It is also used to store Ex/D and Ey/D. */ /* Ac : Accumulator to compute Ex*Uav + Ey*Vav +Et. */ /* Uav : Local average of U. (It also computes Ex/D at first iteration) */ /* Vav : Local average of V. (It also computes Ey/D at first iteration) */ /* U : X component of O.F. (Also used as intermediate results storage) */ /* V : Y component of O.F. (Also used as intermediate results storage) */ /* temp, mark : Flags. */ * */ /* * / ************************ * ****** MAIN PROGRAM ****************************** / ^define MEM_SIZE 64 /* 8 X 8 image size */ ^define WORD_LENGTH 137 ^include "asslib.h" /**** FIRST BIT POSITIONS DEFINITION ***/ ^define En 0 ^define Enl 8 ^define Ex 16 #define Ey 27 #define Et 38 #define Sc 49 #define Ac 67 ^define Uav 87 #define Vav 97 ^define U 107 #define V 121 ^define temp 135 ^define mark 136 ^define b 8 /* Long shift length */ main() { int bit_count, index, cy, Ey_sqr, iterations; int alfa = 1; int no of iterations-!; load: /*** COMPUTE Ex Ey & Et ***/ /* We compute the derivatives by shift and add according to the */ /* following table: */ /* I DATA Ex Ey Et Order Of Execution 1 */ /* */ /* |Ei+l, j+l,n+l I */ /* |Ei+l,j+l,n I */ /* |Ei+l,j,n I * /* |Ei+l,j,n+l I */ /* |Ei,j,n I /* |Ei,j,n+l I */ /* |Ei,j+l,n I */ /* |Ei,j+l,n+l + I V /* /*** shift up fields En & Enl b+1 places ***/ shift fields(En,16,b+l,-l) ; /*** perform op. 1 ***/ printf ("opl\n") ; /** write field Enl into Ex Ey & Et **/ for(bit_count=0; bit_count<8; bit_count++) { letm d (Enl+bit_count) d (Ex+bit_count) d (Ey+bit__count) d(Et+bit_count) ; letc d(Enl+bit_count) ; setag; compare; letc d(Enl+bit_count) d (Ex+bit_count) d(Ey+bit_count) d(Et+bit_count) ; write; } /*** perform op. 2 ***/ printf ("op2\n") ; add(En, Ex, 8, 3,mark) add(En,Ey, 8, 3,mark) sub(En,Et, 8, 3,mark) /*** perform op. 3 & op. printf ("op3,4\n") ; shift_fields (En, 16,1,1); /* shift En & Enl one place down */ sub(En,Ex, 8, 3,mark) ; add(En,Ey, 8, 3,mark) ; sub(En,Et, 8, 3,mark) ; sub(Enl, Ex, 8,3,mark) ; add(Enl, Ey, 8, 3,mark) ; add(En, Et, 8, 3,mark) ; /*** perform op. 5 & op. 6 ***/ printf ("op5,6\n") ; shift_fields (En, 16, , 1) ; /* shift En & Enl b places down V sub(En, Ex, 8, 3,mark) ; sub(En, Ey, 8, 3, mark) ; sub(En, Et, 8, 3,mark) ; sub(Enl, Ex, 8, 3,mark) ; sub(Enl, Ey, 8, 3,mark) ; add(En,Et, 8, 3,mark) ; /*** perform op. 7 & op. 8 ***/ printf ("op7,8\n") ; shift_fields (En, 16, 1,-1) ; /* shift En & Enl 1 place up */ add(En,Ex, 8, 3,mark) ; sub(En,Ey, 8, 3,mark) ; sub(En,Et, 8, 3,mark) ; add(Enl,Ex, 8, 3,mark) ; su (Enl, Ey, 8, 3,mark) ; add(En,Et, 8, 3,mark) ; shift_fields (En, 16, 1, 1) ; /* shift back */ /************* convert Ex Ey & Et to absolute value and sign *******/ convert_to_abs_and_sign(Ex+2, 9) convert_to_abs_and_sign(Ey+2, 9) convert_to_abs_and_sign (Et+2, 9) printf ("Computing D\n"); /*************** Compute D = alfa*alfa+Ex*Ex+Ey*Ey ****************** /*** _ Compute alfa*alfa+Ex*Ex by look-up-table, into field "Sc" ***/ /*** 2. Compute Ey*Ey by look-up-table and sum accumulate in "Sc" ***/ printf ("ok\n") ; /** Step 1 **/ for(index=0; index<256; index++) { letm dseq(Ex+2,Ex+9) ; letc dvar (Ex+2, Ex+9, index) ; setag; compare; letm dseq(Sc, Sc+17) ; letc dvar(Sc, Sc+17, alfa*alfa+index*index) ; write; } /** Step 2**/ printf ("ok\n") ; for(index=0; index<256; index++) { /** Compute Ey*Ey in Ac **/ Ey_sqr = index*index; letm dseq(Ey+2,Ey+9) ; letc dvar(Ey+2,Ey+9, index) ; setag; compare; lelm dseq(Ac,Ac+16) ; letc dvar(Ac,Ac+16,Ey_sqr) ; write; } ad (Ac, Sc, 16, l,mark) ; /********************** COMPUTE Ex/Sc and Ey/Sc ********************** /* To compute Ex/Sc (or Ey/Sc) , Ex (Ey) is moved to unused buffer */ /* Vav+Uav) . This buffer calles "D", is used to subtract Ex from Sc, */ /* in division process. The results are saved in "U" ("V"). */ /* It shout be noted that Ex (Ey) value is started in bit position */ /* Ex+1 (Ey+1) . The sign bit in bit position Ex+9 (Ey+9) . * /* the division process will be carried out only on magnitude and */ /* will be copied to the suitable positions at the end. */ /* * *** compute Ex/Sc *****/ div(Ex,U); /* Compute Ex/Sc into U */ div(Ey,V); /* Compute Ex/Sc into V */ /** Mov Ex/Sc (Ey/Sc) magnitude and sign into first (last) 9-bit of Sc */ letm dseq(Sc, Sc+17) ; letc; setag; write; /* clear Sc field */ for(bit__count=0; bit_count<8; bit_count++) { letmc d(U+bit_count) ; setag; compare; /** move magnitude of Ex/Sc **/ letmc d(Sc+bit_count) ; write; letmc d(V+bit_count) ; setag; compare; /** move magnitude of Ey/Sc **/ letmc d(Sc+bit_count+9) ; write; } letmc d(Ex+9); setag; compare; /* move sign of Ex */ letmc d(Sc+8); write; letmc d(Ex+9); setag; compare; /* move sign of Ey */ letmc d(Sc+17); write; *************** ITERATIVE STEP **********/ for(iterations=0; iterations<no_of_iterations; iterations++) { /** Computing Uav and Vav **/ laplace (U,Uav) ; /* convolve U and output to Uav */ laplace (V,Vav) ; /* convolve V and output to Vav */ /** Computing Ex*Uav+Ey*Vav+Et in field Ac**/ / ******************************************* / letm dseq(U,U+17) dseq (Ac, Ac+19) ; letc; setag; write; /* clear working fields*/ /* 1. Copy Et with sign extention into field Ac. for(i=0; i<9; ι++) { letmc d(Et+2+ι); setag; compare; letmc d(Ac+i); write; } letmc dseq(Ac+10, Ac-ι-19); write; /* 2. Computing Ex*Uav in the working field U */ convert_to_abs_and_sιgn (U, 9) ; /*express Uav as a mag. & sign. */ mul (Ex, 9, Uav, 9,U,mark) ; /*perform U<—Ex*Uav (product is given as mag. & sign) . */ convert_to_abs_and_sιgn (U, 17) ; /*express the product as 2's complement*/ /* 3. Perform Ac <— Ac+U = Et+Ex*Uav add (Et,Ac, 17, 2,mark) ; /* 4. Computing Ey*Vav in the working field U */ convert_to_abs_and_sιg (Vav, 9) ; /^express Vav as a mag. & sign. */ mul (Ey, 9,Vav, 9,U,mark) ; /*perform U<—Ey*Vav (product is given as mag.& sign) . */ convert_to_abs_and_sιgn (U, 17) ; /*express the product as 2's complement*/ /* 5. Sum the products in Ac */ add(U,Ac, 17, 2,mark) ; /* 5. Express results as mag. & sign */ convert_to_abs_and_sign (Ac, 19) ; /* 6. Convert back Uav and Vav to 2 ' s complement */ convert_to_abs_and_sign (Uav, 9) ; convert_to_abs_and_sign (Vav, 9) ; /** COMPUTING U COMPONENT OF MOTION **/ letm dseq(U, U+27) ; letc; setag; write; /* clear working field*/ mul (Sc, 9,Ac, 20,U,mark) ; /* U <— Sc(x)*Ac */ sub(U+20,Uav, 9,0,mark) ; /* U <— (Sc(x)*Ac) save results in Uav (round results starts in U+20)*/ /** COMPUTING V COMPONENT OF MOTION **/ letm dseq (U, U+27) ; letc; setag; write; /* clear working field*/ mul (Sc+9,9,Ac, 20,V,mark) ; /* U <— Sc(y)*Ac */ sub(U+20,Vav, 9, 0,mark) ; /* V <— (Sc(y)*Ac) save results in Uav */ /* Move -(-U) and -(-V) to "U" and "V" */ letm dseq(U,U+27) ; letc; setag; write; /* clear "U" and "V"*/ sub(Uav,U, 9, 0,mark) ; sub(Vav,V, 9, 0,mark) ; } save; print_cycles; } /******* CONVERT TO ABSOLUTE AND SIGN ********/ /* This procedure converts "nc" bits starting at bit position "field" */ /* to absolute and sign, just wordes marked by the sign convert_to_abs_and_sιgn(field, nc) int field, nc; { int sign, bιt_count; bιt_count = field; sign = field + nc - 1 ; letm d(temp); letc; setag; write; /* clear temp */ letmc d(mark); setag; compare; letm d(temp); write; letm d(mark) d(temp) d(sιgn) d(bιt_count) ; while (bιt_count < sign) { letc d(mark) d(sιgn) d (bιt_count) ; setag; compare; letc d(mark) d(temp) d(sιgn) d(bιt_count) ; write; bιt__count++ ; letm d(mark) d(temp) d(sιgn) d (bιt_count) ; letc d(mark) d(temp) d(sιgn); setag; compare; letc d(mark) d(sιgn) d (bιt_count) ; write; letc d(mark) d(temp) d(sιgn) d (bιt_count) ; setag; compare; letc d(mark) d(temp) d(sιgn); write; } } '************ ADD *************** /* This procedure adds "nc" bits of field starting in */ /* bit position "so" into field starting at bit position "de" */ /* and propagate carry "pc" bits. */ /* The addition process is carried out only on candidates wordes */ /* signed by "mr. * add(so,de, nc,pc,mr) int so,de, nc, pc,mr; { int bit_count; f or (bit_count=0; bit_count<nc; bit_count++) { letm d(mr) d(de+bit_count) d(temp) d(so+bit_count) ; letc d(mr) d(temp); setag; compare; letc d(mr) d(de+bit_count) ; write; letc d(mr) d(de+bit_count) d(temp); setag; compare; letc d(mr) d(temp) ; write; letc d(mr) d(de+bit_count) d(so+bit_count) ; setag; compare; letc d(mr) d(temp) d(so+bit_count) ; write; letc d(mr) d(so+bit_count) ; setag; compare; letc d(mr) d(de+bit_count) d(so+bit_count) ; write; /*** clear "temp "***/ letm d(temp); letc; setag; write; /****** propagate carry *******/ for( ; bit_count< nc+pc; bit_count++) { letm d(mr) d(de+bit_count) d(temp) d(mr); letc d(mr) d(temp) d(mr); setag; compare; letc d(mr) d(de+bit_count) d(mr); write; letc d(mr) d(de+bit_count) d(temp) d(mr); setag; compare; letc d(mr) d(temp) d(mr); write; } } /************************ ** * *** ***** SUB ******************************** /* This procedure subtract "so" field from "de", each of length "nc", */ /* and output in "de". The last bit is propagates "pb" bits. */ /* The subtraction is carried out only on candidate wordes signed by "mr" */ sub(so,de, nc, pb,mr) int so,de, nc, b,mr; { int bit_count; letm d(temp); letc; setag; write; /*clear temp*/ for(bit_count=0; bit_count<nc; bit_count++) { letm d(mr) d(so+bit_count) d(de+bit_count) d(temp); letc d(mr) d (so+bιt_count) ; setag; compare; letc d(mr) d (so+bιt_count) d (de+bιt_count) d(temp); write; letc d(mr) d(de+bιt_count) d(temp); setag; compare; letc d(mr); write; letc d(mr) d(so+bιt_count) d(de+bit_count) ; setag; compare; letc d(mr) d(so+bit_count) ; write; letc d(mr) d(temp); setag; compare; letc d(mr) d (de+bit_count) d(temp); write; } /** propagate borrow **/ for(; bit_count<nc+pb; bιt_count++) { letmc d(mr) d(de+bit_count) d(temp); setag; compare; letc d(mr); write; letc d(mr) d(temp); setag; compare; letc d(mr) d(de+bιt_count) d(temp); write; } ************************** DIVISION ****************************** /* This function computes en/Sc and output results to rs*/ div(en, rs) int en, rs; { int nc=8; /* result field length */ int D = 87; int bit_count, le; /* clear working fields */ letm dseq(D,D+17) ; dseq(rs, rs+nc-1) ; letc; setag; write; /* mov magnitude of en to D+9+1 */ /* ( Moving to D+9 is to expand the numerator word length (8-bit) to the denominator (18-bit) . Because the the numerator is value is less than the denominator, it is shifted one bit more to the left) . */ for(bit_count=0; bit_count<nc; bit_count++) { letmc d(en+2+bit_count) ; setag; compare; letmc d(D+10+bit_count) ; write; } /* Perform rs <— D/Sc */ for(bit_count=0; bit_count<nc; bit__count++) { le = rs+nc-l-bit_count; compare_field(Sc, D, nc+1, le, temp,mark) ; letm d(temp) d(le); letc; setag; compare; letmc d(le); write; sub(Sc,D, nc, 1, le) ; shift_left(D,nc+l) ; } /************************ **** COMPARE FIELD ************************** /* This function testing field fl against f2, each of length nc. */ /* It is condition flag to indicate if fl < f2, while gt indicates */ /* if fl > f2. Comparison is carried out only on words marked by "mr" */ compare_field(f1, f2, nc, It, gt,mr) int fl, f2, nc, It, gt, mr; { int bit_count; letm d(gt) d(lt); letc; setag; write; /* clear greater &less than flags */ for(bit_count=nc-l; bit_count>=0; bit_count—) { letm d(mr) d(gt) d(lt) d (fl+bit_count) d(f2+bit_count) ; letc d(mr) d(fl+bit_count) ; setag; compare; letc d(mr) d(gt) d(fl+bit_count) ; write; letc d(mr) d (f2+bit_count) ; setag; compare; letc d(mr) d(lt) d(f2+bit_count) ; write; } } /******** * ************** * SHIFT LEFT ************************** /* This function is shifted left one position the operand "op" */ /* of size "nc" */ shift_left (op, nc) int op, nc; { int bit_count; for(bit_count=op+nc-2; bit_count>=op; bit_count—) { letmc d (bit_count) ; setag; compare; letc; write; letmc d(bit_count+l) ; write; } } /*** shift fields ***/ /*** This procedure shifts "nc" bits starting at bit- position "sO" ***/ /*** "pi" places down if dir=l or up if dir=-l ***/ shift_fields (sO, nc,pi,dir) int sO, nc,pi,dir; { int bit_count, shift_count, long_shift_count, short_shift_count; long_shift_count = pl/b; short_shift_count = pi - long_shift_count*b; for(bit_count=sO; bit_count<sO+nc; bit_count++) { letm d(bit_count) ; letc d (bit_count) ; setag; compare; letc; write; letc d (bit_count) ; for(shift count=0; shift count<long_shift_count; shift_count++) shiftag (dir*b) ; for (shift_count=0; shift_count<short_shift_count; shift_count++) shiftag (dir) ; write; } } /*********** Estimating the Laplacian *************/ /* This is done by convolving U and V with the kernel 1/4 1/2 1/4 1/2 0 1/2 1/4 1/2 1/4 * / laplace (in,out) int in,out; { int bit_count, shift_index; letm dseq(out, out+9) ; letc; setag; write; /* clear output field */ shift_fields (in, 9, 1, 1) ; /* shift "in" field one place down */ add(in+l, out, 8, 2,mark) ; /* Compute The West term */ shift_fields(in,9,2,-l) ; /* shift "in" field tow places up */ add(in+l, out, 8, 2,mark) ; /* Compute The East term */ shift_fields(in,9,b, 1) ; /* shift "in" field b places down */ add(in+2, out, 7, 3,mark) ; /* Compute The S-E term */ shift fields (in, 9, 1,-1) ; /* shift "in" field one place up */ add(m+1, out, 8, 2,mark) ; /* Compute The S term */ shιft_fιelds (in, 9, 1,-1) ; /* shift "in" field one place up */ add(m+l, out, 8, 2,mark) ; /* Compute The S-W term */ shιft_fιelds(m,9, 1,-b) ; /* shift "in" field b places up */ add(m+2, out, 7, 3,mark) ; /* Compute The N-W term */ shιft_fιelds (in, 9, 1, 1) ; /* shift "in" field one place down */ add(m+1, out, 8, 2,mark) ; /* Compute N term */ shιft_fιelds(m,9, 1, 1) ; /* shift "in" field one place down */ add(m+2, out, 7, 3,mark) ; /* Compute NE term */ } ***************************** MUL ****************************x******** / /* This function performs integer multiplication, between Multiplicand "mcd" of length "s_mcd" bits, by Multiplier "ralr" of length "s_mlr" bits, and output product results into "prd", to all wordes signed by "mr" . V mul (mcd, s_mcd,mlr, s_mlr,prd,mr) int mcd, s_mcd,mlr, s_mlr, prd,mr; { int add_offset, bιt_count, f_ιndex; for(add_offset=0; add_offset<s_mlr; add_offset++) /** add and propagate s_mlr-add_offset positions, only where mlr+add_offset is sets. * * add(mcd,prd, s_mcd, s_mlr-add_offset,mlr+add_offset) ; } /**** sign calculation *****/ letmc d(mcd+s_mcd) ; setag; compare; letmc d(prd+s_mcd+s_mlr-l) ; write; letmc d(mlr+s_mlr) ; setag; compare; letmc d(prd+s_mcd+s_mlr-l) ; write; APPENDIX I yyuv.C This program demonstrate the RGB -> YUV operation and display the Y componet of the 128 X 128 Image . #defme Pixel 0 PIXELSIZE 8 ^define PixelSign Pixel + PIXELSIZE fdefme Yg Yr+. RedPixel 24 GreenPixel RedPιxel+8 ^define BluePixel GreenPιxel+8 addb(mt src ,ιnt src_len,ιnt dst , t dst_len,ιnt c_bιt) ; add(mt src , mt src_len,mt dst , int dst_len,mt c_bιt) ; enum color {RED, GREEN, BLUE }; mam(mt , char *argv[]) { mt ,ι ; int color ; confifo (0) ; letm dseq (0, 23) ; letc; setag;write, • letm dseq (24, 47);write; letm dseq(48, 71) ; rite; printf ( "Runnig Asp Simulator : %s \n\n", argv[0] ) ; load (24L,48L); for ( i = 0 ; i < 24 ; i++) { letmc d(71-i) ; setag; compare; letmc d(24+i) ;write; } for (color = 0 ; color < 256 ; color++ ) { letm dseq( RedPixel, RedPixel+PIXELSIZE- i); letc dvar (RedPixel, RedPixel+PIXELSIZE- 1, color) ; setag; compare; letm dseq ( Yr, Yr+PIXELSIZE-1) ; letc dvar ( Yr, Yr+PIXELSIZE-1, (int) (0.299 * color) ) ; write; } for (color = 0 ; color < 256 ; color++ ) { letm dseq( GreenPixel, GreenPixel+PIXELSIZE-1) ; letc dvar (GreenPixel, GreenPixel+PIXELSIZE-l, color) ; setag; compare; letm dseq ( Yg, Yg+PIXELSIZE-1) ; letc dvar (Yg, Yg+PIXELSIZE- l,0.587*color) ; write; } for (color = 0 ; color < 256 ; color++ ) { letm dseq( BluePixel,BluePixel+PIXELSIZE-l) ; letc dvar (BluePixel, BluePixel+PIXELSIZE-1, color) ; setag; compare; letm dseq ( Yb, Yb+PIXELSIZE-1) ; letc dvar ( Yb,Yb+PIXELSIZE-1, (int) (0.114 * color) ) ; write; } addb(Yg, PIXELSIZE, Yr, PIXELSIZE, 8) ; add(Yb, PIXELSIZE, Yr, 9, 9) ; letm dseq(48, 71) ; letc; setag;write; for (i= 0 ; i< 8;i++) { letmc d (i) ; setag; compare; letmc d(55-i) ;d(63-i) ;d(71-i) ;write; } save(24L, 48L) ; return 0; addb(int src , int src_len,int dst , int dst_len,int c_bit) { int cnt ; /* clear carray bit */ // letm d(c_bit) ; setag ; // letc; // write; letm d(dst) d( src); letc d(src); setag; compare; letc d(dst) ; write; letc d(dst) d( src); setag; compare; letc d(c_bit) ; write; for(cnt=l; cnt<src_len; cnt++) { letm d(dst+cnt) d( c_bit) d( cnt+src); letc d(c_bit); setag; compare; letc d(dst+cnt) ; write; letc d(dst+cnt) d( c_bit) ; setag; compare; letc d(c_bit) ; write; letc d(dst+cnt) d( cnt+src); setag; compare; letc d(c_bιt) d( cnt+src) ; write; letc d(cnt+src); setag; compare; letc d(dst+cnt) d( cnt+src); write; /* carry propogation */ for (; cnt < dst_len ; cnt++) { letm d(dst+cnt) d( c_bιt) ; letc d(c__bιt); setag; compare; letc d(dst+cnt) • write; letmc d(dst+cnt) d( c_bιt) ; setag; compare; letc d(c_b t) ; write; } return 0; } add ( int src , ιnt src_len , ιnt dst , int dst_len , mt c_bit) { int cnt ; /* clear carray bit */ letm d(c_bιt) ; setag ; letc; write; for(cnt=0; cnt<src_len; cnt++) { letm d(dst+cnt) d( c_bit) d( cnt+src); letc d(c_bit); setag; compare; letc d(dst+cnt) ; write; letc d(dst+cnt) d( c_bit) ; setag; compare; letc d(c_bit) ; write; letc d(dst+cnt) d( cnt+src); setag; compare; letc d(c_bit) d( cnt+src) ; write; letc d(cnt+src); setag; compare; letc d(dst+cnt) d( cnt+src); write; /* carry propogation */ for (; cnt < dst_len ; cnt++) { letm d(dst+cnt) d( c_bit) ; letc d(c_bit); setag; compare; letc d(dst+cnt) ; write; letmc d (dst+cnt) d( c_bιt) ; setag; compare; letc d(c_bιt) ; write; return 0; } shift_2 ( int pos , int len , int res , int shift_factor) { int i ; /* clean the result operand */ letm dseq (res, res+ len + shift_factor-1) ; setag; letc ; write ; /* copy the operand from pos to res +shift_factor using the tag register */ for ( i = 0; l < len ; ι++ ) { letmc d( pos + l) ; setag ; compare ; letmc d( res + shift_factor + i); write ; } return 0 ; APPENDIX J /* ASSOCIATIVE PROCESSOR IMPLEMENTATION, TO FIND * /* LINES DIRECTIONS IN IN 9X9 NEIGHBORHOOD. */ /****************************************************** *************** / /******************* MEMORY ORGANIZATION *****************************/ /* */ /* WE ORGANIZE THE MEMORY AS FOLLOWES: V /* */ , __ , */ / * ! __ ! __ , 1 |__|*/ /* M T G23 G22 . . . Gl GO L15 L14 . . . LI LO D */ /* A E */ /* R M */ /* K P */ /* * /* BIT 0 IS THE EDGE FLAG "D" ( D = 1 EDGE AT THIS POINT) */ /* BITS 1- 16 ARE 16 ADDRESS OF THE LINES PRESENTED AT TABLE 1. */ /* BITS 17-40 ARE THE 24 BITS OF THE REDUCTION LOGIC. * /* BIT 41 IS TEMP (TEMPORARY) */ /* BIT 42 IS MARK */ /******************************************************* ************** /******************** * MAIN PROGRAM ********************************** / ^define MEM_SIZE 400 /* 20 x 20 image size example*/ ^define WORD_LENGTH 43 ^include "asslib.h" #define NW2 17 /* group-0 bit position */ ^define N2 18 /* group-1 bit position */ ^define NE2 19 /* group-2 bit position */ ^define NW1 20 /* group-3 bit position */ ^define Nl 21 /* group-4 bit position */ ^define NE1 22 /* group-5 bit position */ ^define NW 23 /* group-6 bit position */ ^define N 24 /* group-7 bit position */ ^define NE 25 /* group-8 bit position */ ^define W2 26 /* group-9 bit position */ ^define Wl 27 /* group-10 bit position */ ^define W 28 /* group-11 bit position */ ^define E 29 /* group-12 bit position */ #define El 30 /* group-13 bit position */ ^define E2 31 /* group-14 bit position */ ^define SW 32 /* group-15 bit position */ ^define S 33 /* group-16 bit position */ ^define SE 34 /* group-17 bit position */ ^define SWI 35 /* grcup-18 bit position */ ^define SI 36 /* group-19 bit position */ ^define SE1 37 /* group-20 bit position */ ^define SW2 38 /* group-21 bit position */ ^define S2 39 /* group-22 bit position */ ^define SE2 40 /* group-23 bit position */ main ( ) int b = 20; /* long shift constant */ int index, bit_count, seg_address, il,i2; int seg_count = 0; int D = 0; /* edge data bit position*/ int LO = 1; /* first segment address bit position */ int GO = 17; /* "G" field first bit position */ int TEMP = 41; int MARK = 42; static int seg[24] [3] = { { E,E1,E2 } , { E,NE1,E2 }, { NE,NE1,NE2 }, { NE,NE1,N2} { N,N1,N2 }, { N,NW1,N2 }, { NW,NW1,NW2 }, { NW,NW1,W2 } { W,W1,W2 }, { W,SW1,W2 }, { SW,SW1,SW2 }, { SW,SW1,S2 } { S,S1,S2 }, { S,SE1,S2 }, { SE,SE1,SE2 }, { SE,SE1,E2 } { NE,NE1,E2 }, { N,NE1,N2 }, { NW,NW1,N2 }, { W,NW1,W2 } { SW,SW1,W2 }, { S,SW1,S2 }, { SE,SE1,S2 }, { E,SE1,E2 } }; load; *********************** update "G" field ************************* /**** CLEAR ****/ letm dseq(LO,TEMP) ; letc; setag; write; /**** m ove "D" to "TAG" and shift 4 LINES AND 4 PIXELS DOWN * * * * / letmc d(D) d(MARK); setag; compare; for(index=0; index<4; index++) shiftag (b) ; for(index=0; index<4; index++) shiftag (1) ; ****** GROUPING ****** letmc d(NW2); write; shiftag (-1); write; for(index=2; index<7; index++) { letmc d(N2); shiftag (- 1); write; } letmc d(NE2); shiftag (-1); write; shiftag (-1); write; shiftag (-1) ; shiftag (-b) ; for(index=8;index>5; index—) { letmc d(NE2); shiftag (1); write;} for( ;index>2; index—) { letmc d(N2); shiftag(l); write; } for(; index>-l; index—) { letmc d(NW2); shiftag (1); write; } shiftag (-b) ; letmc d(W2); write; letmc d(NW2); shiftag (-1); write; letmc d(NWl); shiftag (-1); write; letmc d(NWl); shiftag (-1); write; letmc d(Nl); shiftag (-1); write; letmc d(NEl); shiftag (-1); write; letmc d(NEl); shiftag (-1); write; letmc d(NE2); shiftag(-l); write; letmc d(E2); shiftag(-l); write; shi f tag ( -b ) ; letmc d(E2); write; letmc d(E2); shiftag (1); write; letmc d(NEl); shiftag (1); write; letmc d(NE); shiftag(l); write; letmc d(N); shiftag (1); write; letmc d(NW); shiftag (1); write; letmc d(NWl); shiftag (1); write; letmc d(W2); shiftag (1); write; letmc d(W2); shiftag (1); write; shiftag (-b) ; letmc d(W2); write; letmc d(W2); shiftag (-1) ; write; letmc d(Wl); shiftag(-l); write; letmc d(W); shiftag (-1); write; letmc d(E); shiftag (-1); shiftag (-1); write; letmc d(El); shiftag (-1); write; letmc d(E2); shiftag (-1); write; letmc d(E2); shiftag (-1); write; shiftag (-b) ; letmc d(E2); write; letmc d(E2); shiftag (1); write; letmc d(SEl); shiftag (1); write; letmc d(SE); shiftag (1); write; letmc d(S); shiftag (1); write; letmc d(SW); shiftag (1); write; letmc d(SWl); shiftag (1); write; letmc d(W2); shiftag (1); v^rite; letmc d(W2); shiftag (1); write; shiftag (-b) ; letmc d(W2); write; letmc d(SW2); shiftag (-1); write; letmc d(SWl); shiftag (-1); write; letmc d(SWl); shiftag (-1); write; letmc d(Sl); shiftag (-1); write; letmc d(SEl); shiftag (-1) ; write; letmc d(SEl); shiftag (-1); write; letmc d(SE2); shiftag (-1); write; letmc d(E2); shiftag (-1); write; shiftag (-1) ; shiftag (-b) ; for(index=0;index<3; index++) { letmc d(SE2); shiftag (1); write;} for( ;index<6; index++) { letmc d(S2); shiftag (1); write; } for(;index<9;index++) { letmc d(SW2); shiftag (1); write; } shiftag (-b) ; letmc d(SW2); write; shiftag (-1); write; for(index=6;index>l; index—) { letmc d(S2); shiftag (- 1); write;} letmc d(SE2); shiftag (-1); write; shiftag (-1); write; /********************* SEGMENTS CLASSIFICATION ****************** / for(seg_count=0; seg_count<24; seg_count++) { if (seg_count>15) seg address = LO + 2*(seg_count -15) - 1; el se seg_address = LO + seg_count; /*** test if hamming_distance < = 1 ****/ *************************************** letm d(D) d(seg seg_count] [0] ) d(seg[ seg_count] [1] ) d (seg_address d(MARK) ; letc d(D) d(seg seg_count] [0] ) d(seg [ seg_count] [ 1] ) d(MARK) ; setag; compare; letc d(D) d(seg seg_count] [0 ] ) d (seg [ seg_count] [1] ) (seg_address d(MARK); write; letm d(D) d(seg seg_count] [ 0 ] ) d (seg [ seg_count] [2] ) d(seg_address d(MARK) ; letc d(D) d(seg seg_count] [ 0] ) d(seg[seg count] [2]) d(MARK) ; setag; compare; letc d(D) d(seg seg_count] [0 ] ) d(seg[ seg_count] [2] ) d(seg_address d(MARK); write; letm d(D) d(seg seg_count] [ 1 ] ) d (seg [ seg_count] [2] ) d(seg_address d(MARK) ; letc d(D) d(seg seg_count] [ 1 ] ) d(seg[seg_count] [2] ) d(MARK) ; setag; compare; letc d(D) d(seg seg_count] [ 1 ] ) d (seg [ seg_count] [2] ) d(seg address d(MARK) ; write; /** process segments **/ ********************** for(il=L0; il<L0+16; il+=2) { i2 = il - 1; letmc d(i2<L0 ? 15 : i2) d(il) d(il+l) d(MARK); setag; compare; letc d(il) d(MARK); write; letmc d(i2<L0 ? 15 : i2) d(il) d(MARK); setag; compare; letc d(il) d(MARK); write; letmc d(il) d(il+l) d(MARK); setag; compare; letc d(il) d(MARK); write; } /** set TEMP if lines or corners were found **/ *********************************************/ for(il=L0; il<L0+16; il++) for(i2=L0; i2<L0+16; i2++) if (il != i2) { letm dseq(L0,L0+15) d(TEMP) d(MARK); letc d(il) d(i2) d(MARK); setag; compare; letmc d(TEMP); write; } save; print_cycles; APPENDIX K /****************************************************** ******************/ /* CONTOUR LABELING BY ASSOCIATIVE PROCESSOR */ ****************** /******************** MEMORY ORGANIZATION *****************************/ /* Image size is N X N pixels, i.e. coordinates fields are 2Log2 (N) */ /* bits in length. */ /* 2Log2 (N) 2Log2 (N) 1 1 1 1 1 2Log2(N) 1 */ / * j j l __ i __ i __ I __ I __ I 1-1 V /* j χy_coord | operand | —| —| —| — | —| label | ~| */ /* temp sf It gt edge */ /* mark */ /* INPUT FIELDS : * /* 1) xy_coord gives position of all pixels. V /* 2) edge indicates edge points. */ /* INTERMEDIATE (WORKING) FIELDS : */ /* 1) label gives x-y coordinates of all edge points. */ /* 2) operand gives label of connected edge to be tested. */ /* 3) It, gt indicate if operand is less than or greater */ /* than the label field. */ /* 4) sf switch-flag indicates if label was changed in */ * current iteration. */ /* 5) mark indicates if label was ever exchanged. */ /* 6) temp holds edge flag of neighbor under test. */ /* OUTPUT FIELDS : */ /* 1) label gives label of contours, */ /* 2) mark marks contour starting points. */ /****************************************************** ******************/ #define MEM_SIZE 64 /* 8 x 8 image size example */ #define WORD_LENGTH 24 #include "asslib.h" main() /** Initialize bit positions **/ int edge = 0; int label = 1; int gt = 7; int It = 8; int sf = 9; int mark = 10; int temp = 11; int operand = 12; int xy_coord = 18; int label_size = 6; int growth_threshold = 0; int new_condition = MEM_SIZE; int bit_count, growth, window_index; load; /** Clear working fields **/ letm dseq (label,mark) ; letc; setag; write; /*** Mark and label all edge points ***/ letmc d(edge); setag; compare; letmc d(mark); write; for(bit_count=0; bit_count<label_size; bit_count++) { letmc d(xy_coord+bit_count) d(edge); setag; compare; letmc d(label+bit_counr.) ; write; } while ( new_condition > growth_threshold) { printf ( "%d\n" , new_condition) ; letm d(sf) letc; setag; write; /*clear switch flag * / /****** CONNECTIVITY TESTING ******/ for (window_index=0; window_index<8; window__index++) { /** Shift "edge" and "label" into "temp" and "operand" **/ letm dseq (temp, operand+label_size-l) ; letc; setag; write; for(bit_count=0; bιt_count<label_size+l; bit_count++) { letmc d(edge+bιt_count) ; setag; compare; letmc d (temp+bit_count) ; general_shift (wmdow_index) ; write; } /** Test if "operand" < "label" **/ letm d(gt) d(lt); letc; setag; write; /* clear greater & less than flags */ for(bit_count=label_sιze-l; bit_count>=0; bit_count—) { letm d(edge) d(temp) d(gt) d(lt) d(operand+bit_count) d(label+bit_count) ; letc d(edge) d(temp) d(operand+bit_count) ; setag; compare; letc d(edge) d(temp) d(gt) d(operand+bit_count) ; write; letc d(edge) d(temp) d(label+bit_count) ; setag; compare; letc d(edge) d(temp) d(lt) d(label+bit_count) ; write; } /** At all points where "It" is set, do the following: 1. Clear mark. 2. Set switch flag "sf". 3. Copy "operand" into "label". ** / letmc d(lt); setag; compare; /* clear "label" and "mark", set switch flag */ letm dseq (label, label+label_size-l) d(mark) d(sf); letc d(sf); write; /* exchange */ for(bit_count=0; bit_count<label_size; bit_count++) { letmc d(operand+bit_count) d(lt); setag; compare; letmc d (label+bit_count) ; write; } } /** Test for termination **/ letmc d(sf); setag; compare; new_condition = countag; } letmc d(mark); setag; compare; /*** Display the number of contours ***/ printf (" THERE ARE %d CONTOURS IN THE IMAGE\n", countag) ; save; print cycles; / * *** ****** ****** GENERAL SHIFT IN 3 X 3 NEIGHBORHOOD ************** / /* This function shifts the Tag register according to the following*/ /* table: */ * */ * 2 (b+1) I 1 (b) I 0 (b-1) */ /* */ /* 3 (1) I I 7 (-1) V /* */ /* 4 (-b+1) I 5(-b) I 6 (-b-1) */ /* */ /* where the pixel index 0-7 points to the required shift given in */ /* parentheses. */ general_shift(index) int index; { int b = 8; /* long shift */ if(index<=2) shiftag(b); if(index>=4 && index<=6) shiftag(-b) ; if(index==0 || index==6 || index==7) shiftag(-l); if(index>=2 && index<=4) shiftag(1); APPENDIX L ******************************************************* ******** /* */ /* ASSOCIATIVE SALIENCY .NETWORK */ /* */ /******************************************************* ********* /* * * * \ I / \ I / E8 El E2 \ I / \ I / / I \ / I \ E6 E5 E4 / I \ / I \ Memory Format 1 1 mrk tmp T2 Tl E8 sig8 E2 sig2 El sigl ' / ^define MEM_SIZE 64 ^define WORD_LENGTH 90 ^include "asslib.h" main( ) { static int sig[8] = {0, 9, 18, 27, 36, 45, 54, 63}; /* sigma bit position*/ static int E[8] = {1,10, 19, 28, 37, 46, 55, 64}; /* seliency measures bit positions */ static int BrachConnect[8] [ 5 ] = { { 1,0,8,1,2 }, /* neighboring braches, connecting to brach 1 */ { 1,-1,1,2,3 }, /* neighboring braches, connecting to brach 2 */ { 0,-1,2,3,4 }, /* neighboring braches, connecting to brach 3 */ { -1,-1,3,4,5}, /* neighboring braches, connecting to brach 4 */ { -1,0,4,5,6 }, /* neighboring braches, connecting to brach 5 */ { -1,1,5,6,7 }, /* neighboring braches, connecting to brach 6 */ { 0,1,6,7,8 }, /* neighboring braches, connecting to brach 7 */ { 1,1,7,8,1 } /* neighboring braches, connecting to brach 8 */ } int Tl = 72; /* 8 bit temporary */ int T2 = 80; /* 8 bit temporary */ int tmp = 88; int mrk = 89; /*************** clear Temporary Fields ***************** letm dseq(Tl,Tl+8) ; letc; setag; write; /** Compute E, the salieny seasure, to every brach, connected to P **/ for(branch_cnt=0; brach_cnt<8; brach_cnt++) { shift_and_do (brach_cnt, 0, Tl) ; /* perform Ej*Fij —> Tl for curv_cnt=0 */ fo (curv_cnt=l; curv_cnt<2; curv_cnt++) { shift_and_do (brach_cnt, curv_cnt, Tl) ; /* Ej*Fij —> Tl */ max_field(Tl,T2) ; / '*• maximum(T1,T2) —> T2 */ } Sum_Acc (brach_cnt, T2, E); /* SIGi + ROUi*MAX(Ej*Fij) —> Ei */ } } /************ SHHIFT AND DO * * *** *** ** ** **/ shift_and_do (be, cc, xO) int be, cc, xO; { int bit_cnt, long_shift, short_shift; int b=8; if (CC==0 I I CC==2) START=1; if(CC==l) START=0; for(bit_cnt=START; bit_cnt<8; bit_cnt++) { letmc d(E [BrachConnect[be] [cc+2 ] ]+bit_cnt) ; setag; compare; long_shift = b*Brach_connect[be] [ 0 ] ; short_shift= brach_connect[be] [ 1 ] ; if (long_shift != 0 ) shiftag (long_shift ) ; if (short_shift != 0 ) shiftag (short_shift) ; letmc d(x0+bit_cnt) ; write; } } /************ MAX FIELD*************/ max_field(t0, tl) int tO,tl; { int bit_count, next_bit_tO, next_bit_tl; /********* Set "tmp" if to > tl *********/ letm d(tmp); letc; setag; write; /* clear "tmp" */ for(bit_count=7; bit_count>=0; bit_count—) { next_bit_tO = to + bit_count; next_bit_tl = tl + bit_count; letm d (tmp) d(next_bit_tO) d (next_bit_tl) ; letc d(next_bit_tO) ; setag; compare; letc d(tmp); write; } /********* Copy tO to tl if "tmp" = 1 *********/ letmc d(tmp); setag; compare; letm dseq (tl, tl+7) ; letc; write; /* clear "tl" field */ for(bit_count=0; bit_count<8; bit_count++) { letmc d(tO+bιt_count) ; setag; compare; letmc d(tl+bιt_count) ; write; } } /** Shift the Suitable Braches given in BrachConnect Array, to Tl**/ /** Compute: Tl<—Tl*fιj **/ APPENDIX M HOUGH TRANSFORM FOR LINES ^define WORD_LENGTH 53 ^define MEM_SIZE 4 ^define IFILE "hδ.inp" ^define OFILE "hδ.out" ^define thmax 8 /* pow2 (outbitth) */ ^define romax 8 /* pow2 (outbitro) */ ^include "asslib.h" ^include <math.h> ^include "funlib5.h" int bitcount, carry, theta, ro,mthl, place; int outbitth=3; /* Length of theta in the output */ int outbitro=3; /* Length of ro in the output */ int spsin=2; /* Starting bit of sin(th) */ int spcos=14; /* Starting bit of cos(th) */ int spro=15; /* Starting bit of ro */ int spy=24; /* Starting bit of y, absolute value & sign */ int spx=33; /* Starting bit of x, absolute value & sign */ int spth=42; /* Starting bit of theta */ int temp=23; /* Position of temporary bit * int cand=52; /* Position of edge point flag int lenth=10; /* Length of theta * int lenx=9; /* Length of x and y */ int lensin=9; /* Length of sine and cosine * int lenro=9; /* Length of ro, x*cos(th) and y*sin(th) */ int histogram[thmax] [romax] ; /* The accumulator array */ ******************************************************* ************* /* I I */ /* I 1 I 10 I 9 I 9 I 1 I 8 I 1| 2 |1| 6 I 2 |1 |1| 1 I */ /* I I * /* |cand|theta| x | y |temp| cos(th) | guard | sin(th) I I */ /* I I * /* |cand|theta| x | y |temp| x* cos(th) | guard| sin(th) I guard | */ /* I I * /* |cand|theta| x | y | x*cos(th) 2's c | |y*sin(th) 2's| | temp| */ /* I I * /* |cand|theta| x | y | ro | | ItempI */ /* I j * /****************************************************** ********************** main( ) { int spysin=(spsin+l) +lensin-lenx; /* Starting bit of y*sin(th) */ int spxcos=spcos+lensin-lenx; /* Starting bit of x*cos(th) */ load; letm dseq (0, spy-1) ; letc; setag; write; /* Lookup table with modified theta sharing the sine field */ lookup2 (spsin, spcos, spth, lenth, temp, spcos-1) ; letm d(temp) dseq (spsin+lensin, spcos-1) ; letc; setag; write; /* Truncated multiplication of x by cos(th) */ tr_multiplication(spx, lenx, spcos, lensin, temp) ; /* Make all zero values positive */ letm dseq(spxcos-3, spxcos+lenro-2) ; letc; setag; compare; letm d (spxcos+lenro-1) ; write; /* Reset temporary and last guard bit */ letm d(temp) d(spxcos-3); letc; setag; write; /* Move sm(th) to its proper position */ for (bιtcount=lensm-2;b tcount>-l; bitcount—) { letm d ( spsm+bitcount) d ( spysm+bitcount) ; letc d (spsm+bitcount) ; setag; compare; letc d (spysm+bitcount) ; write; } /* Truncated multiplication of y by sιn(th) */ tr_multιplιcatιon(spy, lenx, spsm+l, lensm, temp) ; /* Make all zero values positive */ letm dseq ( spysm-3 , spysιn+lenro-2 ) ; letc; setag; compare; letm d ( spysm+lenro-1 ) ; write; /* Reset temporary bit */ letm d(temp); letc; setag; write; twoscomp(spxcos-2, lenro+2, temp) ; letm d(temp); letc; setag; write; twoscomp(spysm-3, lenro+3, temp) ; letm d(temp); letc; setag; write; temp=0; /* Copy sign bit */ letmc d(spxcos+lenro-1) ; setag; compare; letmc d (spxcos+lenro) ; write; /* Add to obtain ro */ addition (spysιn-2, spxcos-2, lenro+2, temp, cand) ; /* Complete the addition */ letm d (spro+lenro-1) d(temp) d (spysin+lenro-1) ; letc d (spysin+lenro-1) d (spro+lenro-1) ; setag; compare; letc d(temp) d (spysin+lenro-1) ; write; letc d (spysin+lenro-1) ; setag; compare; letc d (spro+lenro-1) d(spysin+lenro-1) ; write; letc d(temp); setag; compare; letc d(spro+lenro-l) ; write; letc d(temp) d(spro+lenro-1) ; setag; compare; letc d(temp); write; /* Correct the addition */ letm d(spro-l) d(spro-2); letc d(spro-l); setag; compare; letc d(spro-2); write; for (bitcount=0;bitcount<lenro;bitcount++) { letm d (spro+bitcount) d(spro-2); letc d(spro-2); setag; compare; letc d(spro+bitcount) ; write; letc d(spro-2) d (spro+bitcount) ; setag; compare; letc d(spro-2); write; } /* Accumulate and read out histogram */ /* If upper bit of ro not significant shift down one place */ place=l; letm d (spro+lenro-1) d (spro+lenro-2) d(cand); letc d(spro+lenro-l) d(cand); setag; compare; if (PAR.RSP) place=0; letc d (spro+lenro-2) d(cand); setag; compare; if (PAR. RSP) place=0; letm dseq (spth+lenth-outbitth, spth+lenth-1) dseq (spro+lenro-outbitro-place, spro+lenro-1-place) d(cand) ; for (theta=0;theta<thmax; theta++) { for (ro=0;ro<romax;ro++) { if (ro != pow2 (outbitro-1) ) { letc dvar(spth+lenth-outbitth, spth+lenth- 1, theta) dvar (spro+lenro-outbitro-place, spro+lenro- l-place,ro) d(cand); setag; compare; histogram[theta] [ ro]=countag; } } } save; } APPENDIX N HOUGH TRANSFORM FOR CIRCULES ^define WORD_LENGTH 63 ^define MEM_SIZE 4 ^define IFILE "cirl.inp" ^define OFILE "cirl.out" #define xmax 128 /* pow2 (outbitxO) */ ^define ymax 128 /* pow2 (outbityO) */ ^include "asslib.h" ^include <math.h> ^include "funlibδ.h" int x,y, bitcount; int R=29; /* The radius value * int lenR=5; /* Length of R, Rcos(th) Rsin(th) */ int spyO=0; /* Starting bit of yO */ int spx0=9; /* Starting bit of xO */ int spsin=15; /* Starting bit of sine */ int spRsin=18; /* Starting bit of Rsin(th) * int spcos=21; /* Starting bit of cosine */ int spRcos=24; /* Starting bit of Rcos(th) * int spy=30; /* Starting bit of y in 2's complement mt spx=39; /* Starting bit of x in 2's complement */ int spth=48; /* Starting bit of theta */ int temp=59; / Position of temporary flag */ int overl=60; /* Position of the first overflow flag */ int over2=61; /* Position of the second overflow flag */ int cand=62; /* Position for the edge point flag */ int lenth=ll; /* Length of theta, in absolute value and sign */ int lenx=9; /* Length of x, y, xO, yO in 2 ' s complement */ int lencos=9; /* Length of cos, sin */ int outbιtx0=7; /* Length of xO in the output */ int outbity0=7; /* Length of yO in the output */ int histogram[xmax] [ymax] ; /* Accumulator array */ ******************************************************* ************ /* */ /*|1 |1 |1 |1| 11 I 9 I 9 I 6 I 3 I 3 |2|1| 6 I 9 |*/ /* i I /*|c |ol |o2 |T| theta I x | y | cos(th) | | sin(th) I |*/ / * i I */ /*|c |ol|o2|T|theta| x | y | Rcos(th) | sin(th) | |* / * i |*/ /*|c |ol|o2|T| thetaI x | y | Rcos (th) | Rsin(th) | xO I yo |V /* V /* V /* c : (cand) flag for edge point */ /* ol : (overl) overflow for xO */ /* o2 : (over2) overflow for yO V /* T : (temp) temporary flag V ****************************************************** *********************/ main( ) { load; letm dseq(0, spy-1) d(temp); letc; setag; write; /* Load cosine and sine */ lookup2 (spxO, spcos, spth, lenth-1, temp, spxO-1) ; letm d(temp) d(spxθ-l); letc; setag; write; /* Multiplication cos(th) by R */ r multiplication(spcos, lencos, R, lenR, temp) ; letm dseq (spxO+lencos, spRcos-1) d(temp); letc; setag; write; /* Transfer sine to its proper position */ for (bitcount=lencos-2;bitcount>-l;bitcount—) { letm d(bitcount+spxO) d (spsin+bitcount) ; letc d(bitcount+spxO) ; setag; compare; letc d(spsin+bitcount) ; write; } /* Multiplication sin(th) by R */ r multiplication (spsin, lencos, R, lenR, temp) ; ***************************x*************************** /* */ /* Find centers of white circles V /* */ /******************************************************* letm dseq(spyO, spRsin-1) d(temp); letc; setag; write; /* Copy R*cos(th) and R*sin(th) to xO and yO, respectively, right justified */ for (bitcount=0;bitcount<lenR;bitcount++) { letmc d(bitcount+spRcos) ; setag; compare; letmc d(bitcount+spxO) ; write; letmc d(bitcount+spRsin) ; setag; compare; letmc d(bitcount+spyO) ; write; } /* Copy sign of R*cosιne and R sme inverting when theta<0 */ letmc d(spth+lenth-1) ; setag; compare; letmc dseq (spyO+lenR, spyO+lenx-1) ; write; letm d(spth+lenth-l) d (spRcos+lenR) dseq(spxO+lenR, spxO+lenx-1) ■ letc d(spth+lenth-1) ; setag; compare; letc d(spth+lenth-l) dseq(spxO+lenR, spxO+lenx-1) ; write; letc (spRcos+lenR) ; setag; compare; letc d(spRcos+lenR) dseq (spxO+lenR, spxO+lenx-1) ; write; /* Make every zero value positive */ letm dseq (spxO, spxO+lenR-1) ; letc; setag; compare; letm dseq(spxO+lenR, spxO+lenx-1) ; write; letm dseq(spyO, spyO+lenR-1) ; setag; compare; letm dseq (spyO+lenR, spxO+lenx-1) ; write; twoscomp(spxO, lenR+1, temp) ; letm d(temp); letc; setag; write; twoscomp (spyO, lenR+1, temp) ; letm d(temp) d(overl); letc; setag; write; /* Look for the possible overflows of xO and mark them */ letm d(spx+lenx-1) d (spxO+lenx-1) d(overl); letc d(spx+lenx-l) d (spxO+lenx-1) ; setag; compare; letc d(overl) d(spx+lenx-1) d (spxO+lenx-1) ; write; letc; setag; compare; letc d(overl); write; addition (spx, spxO, lenx, temp, cand) ; /* Find the overflows of xO * letm d(overl) d(temp) d (spxO-lenx-1) ; letc d(overl) d(temp) d (spxO-lenx-1) ; setag; compare; letc d (spxO+lenx-1) ; write; letc d(overl); setag; compare; letc; write; /* Look for the possible overflows of yO and mark them */ letm d(temp) d(over2); letc; setag; write; letm d(spy+lenx-1) d (spyO+lenx-1) d(over2); letc d (spy+lenx-1) d (spyO+lenx-1) ; setag; compare; letc d(over2) d (spy+lenx-1) d (spyO+lenx-1) ; write; letc; setag; compare; letc d(over2); write; addition(spy, spyO, lenx, temp, cand) ; /* Find the overflows of yO */ letm d(over2) d(temp) d(spyO+lenx-1) ; letc d(over2) d(temp) d(spyO+lenx-1) ; setag; compare; letc d(spyO+lenx-1) ; write; letc d(over2); setag; compare; letc; write; /* Histogram of white circle location */ letm dseq (spxO+lenx-outbitxO, spxO+lenx-1) dseq(spyO+lenx-outbityO, spyO+lenx-1) d (overl) d(over2) d (cand) ; for (x=0;x<xmax;x++) { for (y=0;y<ymax;y++) { letc dvar(spxO+lenx-outbitxO, spxO+lenx-l,x) dvar (spyO+lenx-outbityO, spyO+lenx-l,y) d(cand) ; setag; compare; histogram[x] [y]=countag; } } /*******************************************************/ * V /* Find centers of black circles */ * V *******************************************************/ letm dseq (spyO, spRsin-1) d(temp); letc; setag; write; /* Copy R*cos(th) and R*sin(th) to xO and yO, respectively, right justified */ for (bitcount=0;bitcount<lenR;bitcount++) { letmc d(bitcount+spRcos) ; setag; compare; letmc d(bitcount+spxO) ; write; letmc d (bitcount+spRsin) ; setag; compare; letmc d(bitcount+spyO) ; write; } /* Copy sign of R*cosine and R*sine inverting when theta>0 */ letm d (spth+lenth-1) dseq (spyO+lenR, spyO+lenx-l) ; letc; setag; compare; letc dseq (spyO+lenR, spyO+lenx-l) ; write; letm d(spth+lenth-l) d (spRcos+lenR) dseq (spxO+lenR, spxO+lenx-1) ; letc; setag; compare; letc dseq (spxO+lenR, spxO+lenx-1) ; write; letc d (spRcos+lenR) d (spth+lenth-1) ; setag; compare; letc d (spRcos+lenR) d (spth+lenth-1) dseq(spxO+lenR, spxO+lenx-1) ; write; /* Make every zero value positive */ letm dseq(spxO, spxO+lenR-1) ; letc; setag; compare; letm dseq(spxO+lenR, spxO+lenx-1) ; write; letm dseq(spyO, spyO+lenR-1) ; setag; compare; letm dseq(spyO+lenR, spyO+lenx-l) ; write; twoscomp(spxO, lenR+1, temp) ; letm d(temp); letc; setag; write; twoscomp(spyO, lenR+1, temp) ; letm d(temp) d(overl); letc; setag; write; /* Look for the possible overflows of xO and mark them */ letm d(spx+lenx-1) d (spxO+lenx-1) d(overl); letc d (spx+lenx-1) d (spxO+lenx-1) ; setag; compare; letc d(overl) d (spx+lenx-1) d (spxO+lenx-1) ; write; letc; setag; compare; letc d(overl); write; addition (spx, spxO, lenx, temp, cand) ; /* Find the overflows of xO */ letm d(overl) d(temp) d (spxO+lenx-1) ; letc d(overl) d(temp) d(spxO+lenx-1) ; setag; compare; letc d(spxO+lenx-l) ; wrice; letc d(overl); setag; compare; letc; write; /* Look for the possible overflows of yO and mark them */ letm d(temp) d(over2); letc; setag; write; letm d (spy+lenx-1) d (spyO+lenx-l) d(over2); letc d (spy+lenx-1) d (spyO+lenx-l) ; setag; compare; letc d(over2) d(spy+lenx-1) d (spyO+lenx-l) ; write; letc; setag; compare; letc d(over2); write; addition(spy, spyO, lenx, temp, cand) ; /* Find the overflows of yO */ letm d(over2) d(temp) d (spyO+lenx-l) ; letc d(over2) d(temp)- d (spyO+lenx-l) ; setag; compare; letc d(spyO+lenx-l) ; write; letc d(over2); setag; compare; letc; write; /* Histogram of black circle location */ letm dseq (spxO+lenx-outbitxO, spxO+lenx-1) dseq (spyO+lenx-outbityO, spyO+lenx-l) d(overl) d(over2) d(cand); for (x=0;x<xmax;x++) { for (y=0;y<ymax;y++) { letc dvar(spxO+lenx-outbitxO, spxO+lenx-1,x) dvar(spyO+lenx-outbityO, spyO+lenx-l,y) d(cand) ; setag; compare; histogram[x] [y]-countag; } } save; APPENDIX 0 VORONOI #define COLOR_SIZE 8 ^define color 0 ^define TM color+COLOR_SIZE ^define CN TM+1 ^define CL CN+1 #define VN CL+1 ^define VL VN+1 ^define S VL+1 ^define b 128 process (int window_index) ; general_shift(int index); main(int, char *argv[]) { int i; int window_index; printf("Running asp simulator - %s\n",argv[0] ) ; /* here start the ASP program */ // confifo(0); letm dseq(0,23) ; letc ;setag ; write ; /*clear the output area */ letm dseq(24,47) ; letc ; setag ; write ; /*clear the output area */ letm dseq(48,71) ; letc ;setag ; write ; /*clear the output area */ // save(8L, 64) load(8L, 64L) ; // confif0(8) ; /* insert a PICTURE */ // for(ι=0;l<2054; 1++) nop; conflfo (0) ; for (1 = 0 ; 1 < COLOR_SIZE;i++) { letmc d(71-ι) ; setag; compare; letmc d(ι) ;write; } // confιfo(8); letmc d (S) ; setag; write; letmc dseq(color, color+COLOR_SIZE- 1) ; setag; compare; letm d (S); letc;wrιte; letm d(CL) d (VL) ; letc; setag;write; letmc d (S) ; setag;compare; letmc d(CL) ,-write; letm d (VL);letc; ; setag;write; letmc d(VL) ; setag; firsel;write; { shιftag(128) ;wrιte; } letmc d(VL) ; setag; compare; shiftag (-1) ;wrιte; letm dseq (0,7); letc; setag; compare; letmc d(VL) ;write; /// while (rsp) for (i = 0 ; l < 14 ; ι++ ) { for(window_mdex=0 ; window_index < 8 ; window_index++) { letm d ( CN) d (VN);letc ; setag ;write; letmc d(CL); setag; compare; letmc d(CN) ;general_shift(window_mdex) ;write; letmc d(VL) ; setag; compare; letmc d(VN) ;general_shift(window_index) ;write; process (window_index) ; } // letm d(CL) ;letc; setag; compare; } // save (8,0); // letmc d(VL) ; setag;compare; // letm dseq(color, color+COLOR_SIZE-l) ;letc; write; confifo (0) ; for ( i =0; i< COLOR_SIZE ; i++) { letm d (TM) ; letc; setag;write; letmc d(ι) ; setag; compare; letm d(TM) d(ι);letc d(TM);write; letmc d (71-i) ; setag;compare; letm d(i) d(71-i);letc d(i);write; letmc d (TM) ; setag; compare; letmc d (71-ι);write; 2054 ; l + + ) proces s ( int wιndow_mdex ) { mt i ; for(1=0 ; l < COLOR SIZE ; ι++] { letm d(TM) ; letc ; setag; write; letmc d(color+ι); setag ; compare; letmc d(TM); general_shιft(wmdow_ιndex) ; write; letm dseq(TM,VL) d (color+i) ; letc d(CL) d(CN) d(TM) ; setag;compare; letmc d(VN);wrιte; letm dseq(TM,VL) d(color+ι); letc d(CL) d(CN) d(color+i) ; setag; compare; letmc d(VN) ;write; letm dseq(TM,VL) d(color+ι); letc d(CN) d (color+i) ; setag;compare; letm d (color+i); letc;write; letm dseq(TM,VL) d(color+ι); letc d(CN) d (TM) ; setag; compare; letmc d(color+i);write; } letm d(CL) d(CN) d(VL); letc d(CN) ; setag; compare; letmc d(CL) ; write; return 0; } general_shift(int index) { if (index ==4 | | index == 0 | | index==6) shiftag(b); if (index ==5 | | index == 1 | | index==7) shiftag(-b); if (index ==6 | | index == 3 | | index==5) shiftag(l); if (index ==4 || index == 2 | | index==7) shiftag(-l); return 0; } It will be appreciated by persons skilled in the art that the present invention is not limited to what has been particularly shown and described hereinabove. Rather, the scope of the present invention is defined only by the claims that follow:

Claims: CLAI MS 1. Associative signal processing apparatus for processing an incoming signal comprising a plurality of samples, the apparatus comprising: a two-dimensional array of processors, each processor including a multiplicity of content addressable memory cells, each sample of an incoming signal being processed by at least one of the processors; and a register array including at least one register operative to store responders arriving from the processors and to provide communication, within a single cycle, between non-adjacent processors. 2. Associative signal processing apparatus comprising: an array of processors, each processor including a multiplicity of associative memory cells, at least one of the processors being operative to process a plurality of samples of an incoming signal; a register array including at least one register operative to store responders arriving from the processors and to provide communication between processors; and an I/O buffer register operative to input an incoming signal and to output an outgoing signal. 3. Apparatus according to claim 2 wherein the processor array, the register array and the I/O buffer register are arranged on a single chip. 4. Apparatus according to claim 1 wherein the register array is operative to perform at least one multicell shift operation. 5. Apparatus according to either of claims 2 or 3 wherein the register array is operative to perform at least one multicell shift operation. 6. Associative apparatus comprising: a plurality of comparing memory elements each of which is operative to compare the contents of memory elements other than itself to respective references in accordance with a user-selected logical criterion, thereby to generate a responder if the comparing memory element complies with the criterion; and a register operative to store the responders. 7. Apparatus according to claim 6 wherein the criterion comprises at least one logical operand. 8. Apparatus according to any of the preceding claims 2, 3, or 5 wherein said I/O buffer register and said processors are operative in parallel. 9. Apparatus according to any of the preceding claims 2, 3, or 5 wherein the word length of the I/O buffer register is increasable by decreasing the wordlength of the associative memory cells. 10. Apparatus according to any of claims 1, 2, 4 or 5 which is operative in video real time. 11. Apparatus according to any of claims 1, 2, 4, 5 or 9 wherein the signal comprises an image. 12. Apparatus according to claim 7 wherein said at least one logical operand comprises a reference for at least one memory element other than the comparing memory element itself. 13. Apparatus according to claim 6 wherein each memory element comprises at least one memory cell. 14. Apparatus according to any of claims 6 - 7 or 12 - 13 wherein the plurality of comparing memory elements are operative m parallel to compare the contents of a memory element other than themselves to an individual reference. 15. A method for image correction comprising: computing a transformation for an output image imaged by a distorting lens which compensates for the lens distortion; and applying the transformation in parallel to each of a plurality of pixels in the output image. 16. A method according to claim 15 wherein the distorting lens comprises an HDTV lens. 17. An array of processors which communicate by multicell and single cell shift operations, the array comprising: a plurality of processors; a first bus connecting at least a pair of the processors which bus is operative to perform at least one multicell shift operation; and a second bus connecting at least a pair of the processors which bus is operative to perform single cell shift operations. 18. A signal processing method for processing a signal comprising: for each consecutive pair of first and second signal characteristics within a sequence of signal characteristics, counting in parallel the number of samples having the first signal characteristic; and subsequently, counting in parallel the number of samples having the second signal characteristic. 19. A method according to claim 18 wherein the counting comprises generating a histogram. 20. A method according to any of the preceding claims 18 - 19 wherein the signal comprises a color image. 21. A method according to claim 20 wherein at least one characteristic comprises at least one of the following group of characteristics: intensity; noise; and color density. 22. A method according to claim 21 and also comprising scanning a medium bearing the color image. 23. Apparatus according to claim 11 wherein the image comprises a color image. 24. An edge detection method comprising: identifying a first plurality of edge pixels and a second plurality of candidate edge pixels; identifying, in parallel, all candidate edge pixels which are connected to at least one edge pixel as edge pixels; and repeating the identifying in parallel at least once. 25. A feature labeling method m which a signal is inspected, the signal including at least one feature, the feature comprising a set of connected samples, the method comprising: storing a plurality of indices for a corresponding plurality of samples; in parallel for each individual sample from among the plurality of samples, replacing the stored index of the individual sample by an index of a sample connected thereto, if the index of the connected sample is ordered above the index of the individual sample; and repeating the replacing at least once. 26. A method according to claim 25 wherein the replacing is repeated until only a small number of indices are replaced in each iteration. 27. A method according to any of claims 1 - 5, 8 - 11, 18 - 23, 25, and 26 wherein the signal comprises an image. 28. A method according to claim 26 wherein the signal comprises a color image. 29. Image correction apparatus comprising: a transformation computer operative to compute a transformation for an output image imaged by a distorting lens which transformation compensates for the lens distortion; and an in-parallel transformer operative to apply the transformation in parallel to each of a plurality of pixels in the output image. 30. An associative memory comprising: an array of PEs including a plurality of PEs, wherein each PE includes: a processor of variable size; and a word of variable size including an associative memory cell, wherein all of the associative memory cells from among the plurality of associative memory cells included in the plurality of PEs are arranged in the same location within the word and wherein the plurality of words included in the plurality of PEs together form a FIFO. 31. Apparatus according to claim 30 wherein the word of variable size includes more than one associative memory cell. 32. A method for modifying contents of a multiplicity of memory cells and comprising: performing, once, an arithmetic computation on an individual value stored in a plurality of memory cells; storing the result of the arithmetic computation in a plurality of memory cells which contain the individual value. 33. A method according to claim 32 wherein the storing is carried out in all memory cells in parallel. 34. A method for constructing associative signal processing apparatus for processing an incoming signal, the method comprising: arranging, on a module, an array of processors, each processor including a multiplicity of associative memory cells, each sample of an incoming signal being processed by at least one of the processors; arranging, on the same module, a register array including at least one register operative to store responders arriving from the processors and to provide communication between processors; and arranging, on the same module, an I/O buffer register for inputting and outputting a signal. 35. Apparatus according to claim 1 wherein at least one sample is processed by two or more of the processors. 36. Apparatus according to claim 1 wherein at least one of the processors processes more than one sample. 37. Apparatus according to claim 1 wherein the register array comprises a plurality of registers. 38. Apparatus according to claim 2 wherein the order in which the I/O buffer inputs an image differs from the row/column order of the image. 39. Apparatus according to claim 2 wherein the order in which the I/O buffer inputs the samples differs from the order of the samples within the incoming signal. 40. Apparatus according to claim 1 wherein the register array includes a plurality of registers operative to store responders arriving from the processors . 41. Apparatus according to claim 1 wherein the at least one register provides communication between the processors . 42. Apparatus according to claim 41 wherein the at least one register provides communication between processors which are processing non-adjacent samples. 43. Apparatus according to claim 1 and also comprising an I/O buffer register operative to input and output a signal. 44. Apparatus according to claim 43 wherein the processor array, the register array and the I/O buffer register are arranged on a single module. 45. Apparatus according to claim 43 wherein the processor array, the register array and the I/O buffer register are arranged on a single silicon die. 46. Apparatus according to claim 45 wherein the I/O buffer register includes a plurality of buffer register cells whose number is at least equal to the number of processors in said two-dimensional processor array.

Inventors: AKERIB AVIDAN, AKERIB, AVIDAN
Applicants: AKERIB AVIDAN, ASP SOLUTIONS USA INC, AKERIB, AVIDAN, ASP SOLUTIONS USA, INC.
Application year: 1994
Main classification: G06F7
IPC codes: G06F15, G06F17, G06T7, G11C15