A METHOD OF COMPRESSING A PLURALITY OF VIDEO IMAGES

Abstract: A video image, characterized by a plurality of pixels, is compressed by deriving at least one parameter based upon principal component analysis. An image value for each video image is then determined for the one parameter. The image value associated with each video image is compared to an image value associated with another video image to determine a difference. Any one of the image values of each video image and another video image is discarded in the event the difference is below a threshold. The remaining video images are then stored. Using this method of compression, it becomes possible to search a video database to find a match between an inquiring video scene with a video database comprising a plurality of video scenes with each video scene having a plurality of video images.

Description: A METHOD OF COMPRESSING A PLURALITY OF VIDEO IMAGES TECHNICAL FIELD The present invention relates to a method of compressing a plurality of video images (a video scene) such that the resultant compressed video images require less storage space than the compression methods of the prior art In addition, the present invention efficiently displays the compressed video images, by displaying a reduced number of images or "key" images, thereby simplifying searching (by e g viewing by a user) of the contents of the video scene The key images act similar to an index or a table of contents for the video scene BACKGROUND OF THE INVENTION As is well known in the prior art. a video image, when digitized, requires a large amount of storage A plurality ot video images (as used hereinafter "a video scene"), such as a movie, would require hundreds of megabytes or even gigabytes of storage if not compressed Methods to compress a video scene are also well known in the prior art One prior art method is to derive a parameter b> principal component analy sis for all the images ot the video scene Let us assume that each video image has N pixels Thereafter, an image value based upon the parameter chosen by principal component analysis is determined for each of the video images Thus, the resultant storage requirement, for one parameter, would be one image full of component values for that parameter (or N values) and one image value associated with each video image If more than one parameter is derived for the video images, the total amount of storage required would be multiplied correspondingly However, even with this method, if the video scene has many video images, such as a movie, the storage required for a single value of the parameter associated w ith each of the video images would still be large Since video images are displayed at a rather rapid rate, e g . thirty times per second, a two hour video movie would require 216.000 video images (2 λ 60 x 60 \ 30) and at standard TV format would require 50 gigabyte of storage Therefore, based on this method, for one parameter, there would still require N number of parameter component values, derived by principal component analysis, and 216.000 image values with one image value for each of the video images Furthermore although storage requirement is reduced b\ this method compared to the uncompressed video scene, to review or browse through the video images of this video scene would require the display of the entire collection of images, e 216.000 images To a user, viewing or searching through the entire collection of displayed images would be inefficient and cumbersome Browsing or skimming through the entire collection of video images of the video scene would require a considerable mount of time and effort Another method of compression of the prior art is to choose some of the images from a video scene as reference frames Subsequent or preceding images are compared to the reference frames, and the differences or changes are stored Thus, data for only the reference frames and the changes thereto need to be stored However, in such prior art method, the reference frames are chosen based upon every nth frame Thus, the choice of the reference frame is not optimized As the use of video images to capture information becomes more prevalent, a method must be found to efficiently store, display and search the plurality of video images, or the video scene The collection of video images displayed must be categorized in a manner permitting rapid searching Thus, not only is the compression of the video images important to minimize storage space, but the method must further facilitate the display and rapid searching of the compressed video images Hence, the present invention deals with the problems of video compression to minimize storage requirement as well as to permit a more efficient method of displaying and searching video images from a video scene SUMMARY OF THE INVENTION In the present invention, a plurality of video images is compressed Each image is characterized by a plurality of pixels The method comprises the steps of deriving at least one parameter for the plurality of video images The one parameter can be derived based upon principal component analysis An image value is determined for each video image for that one parameter An image value associated with each video image is compared to an image value associated with another video image to determine a difference The difference is compared to a threshold, which can be fixed or adaptive In the event the difference is below the threshold, only one of the image values is stored The video images corresponding to the stored image values can be displayed and searched The aforementioned method can be used to compress a video database having a plurality of video images One or more "key " video images are selected by the foregoing described method All the other video images of the video database are compared to the "key " video images and the differences are stored The "key" video images, by themselves, or the principal component analysis image and the parameter values determined, are also stored Based upon this compression, all the video images of the video database can be faithfully reproduced In another method of the present invention a video database has a plurality of database elements with each database element being a video scene Each video scene is compressed based upon the foregoing disclosed compression method The video database is searched to find a match with an inquiring video scene, also comprising a plurality of video images The inquiring video scene may also be compressed by the foregoing disclosed compression method The stored image values associated with the inquiring video scene are compared to the stored image values associated with each video scene from the video database to find a match between the inquiring video scene and one of the video scenes from the video database BRIEF DESCRIPTION OF THE DRAWINGS Figure I is a schematic diagram showing the method ot the prior art tor compressing video images based upon principal component analysis Figure 2 is a schematic diagram showing the improved method of the present invention after a plurality of video images are compressed by the principal component analysis method of the prior art Figure 3 is a schematic diagram showing the method of the present invention used to compress and store a plurality of video images, such as a movie Figure 4 is a schematic view of a method of searching a video database to determine a match between an inquiring video scene with one of the elements of the video database, each of which comprises a video scene Figure 5 is a pictorial display of the method of the present invention to efficiently and rapidly display and search a collection of video images from a video scene Figure 6 is a flowchart of the method of the present invention for determining video images with key image parameters in accordance with the method of the present invention Figure 7 is a flowchart of the method of the present invention for compressing a plurality of video images using video images with key image parameters (or reference images), determined in accordance with the method shown in Figure 6 Figure 8 is an overview of the various methods of the present invention and their uses. DETAILED DESCRIPTION OF THE DRAWINGS Referring to Figure 1. there is a shown a schematic view of the method of compression of a video scene of the prior art. The video scene comprises a plurality of video images or video frames, labeled F , ... F . Each of the video images has a plurality of pixels labeled P j ... P N . The collection of video images is termed a video scene. In the prior art. it is known to use the method of principal component analysis to derive a principal component parameter value for the video scene. The method selects a parameter for the plurality of video images F | .. F^. Examples of parameters include intensity, or a particular color, or hue. or spatial frequency, etc. An image full of components, e.g., N components, for that one selected parameter is then derived. Thus, the component values C | ... C^ are derived. Each of the video images F | ... F^ is then compressed by determining an image value 1 | ... l^ for each video image for the parameter component C selected. The image value is derived based upon N * k - J= ∑ C P U where J is an index to the pixel number, P is the value of the Jth pixel in frame F^. From the foregoing, it can be seen that a video scene comprising of M video images would require one video image full of data (or N vaiues) for the component chosen by principal component analysis and M image values, with an image value associated with each video image Fι . As previously stated, in the event the video scene is long, e.g., a movie comprising of two hours, and each of the video images is displayed in l/30th of a second, then there would be 216,000 video images (2 x 60 x 60 x 30). Thus, even using the prior art technique of principal component analysis to compress a video scene comprising of a plurality of video images, a considerable amount of storage space would be required, where the video scene is long, for each parameter derived from principal component analysis. In addition, to display , review or search through the 216.000 video images, would require a considerable amount of effort, despite the reduction in storage requirement. Referring to Figure 2. there is shown schematically a preferred method of the present invention The preferred method of the present invention reduces the storage requirement of compressing a video scene, using the method of principal component analysis, in which principal component analysis is performed either locally, for different regions of the same video image a different parameter is used, or globally, the same parameter is used over the entire video image. However, as will be seen, the method of the present invention is not limited by the technique of principal component analysis. For example. image values derived by discrete cosine transform, Gabor filters and wavelets can also be used However, using the method of principal component analysis, one or more parameters is generated. Initialh . the discussion will focus on the method of the present invention applied to one parameter. However, as it will be clear, the method of the present invention can be applied to compression based upon a plurality of parameters derived by principal component analysis. As before, let us assume that using the method of compression based upon principal component analysis results in M image values obtained. These are shown as 11 , I T , I 3 ... 1^. Thereafter, each image value 1^., associated with a video image FK, IS compared to an image value + , , associated with a video image F^ + j , which is immediately adjacent in time to the video image F^. The absolute value of the difference between the two image values is obtained and is compared to a threshold value If the difference between the two imaεe values is less than a threshold, i.e.. I -k - -k+i I ≤ τ Then either the image value 1^ or IJ. + J is discarded The remaining image value is stored As will be seen the threshold T can be fixed threshold or an adaptive threshold This can be seen by the following example The method of the present invention begins by comparing l j to I- If the absolute value of the difference between the two image values is less than the threshold, then let us assume I ] is kept The kept image value I j is then compared to the image value I-. associated with the video image F^. which is next immediately adjacent in time thereto Again, if the absolute value of the difference is less than a predetermined threshold, then the method discards either l j or 1 3 Again, let us assume that l j is kept This technique continues until I , has been compared to all the rest of the image values, 1 e I-i through 1^ The method continues by selecting the next image value I. which has not been discarded Let us assume 14 is the next image value immediately adjacent to I j , which was stored or kept I 4 is then compared to each of the remaining image values K. until all of the remaining image values have been compared to 1^ This process continues until all of the remaining image values have been compared to each other If a particular image value, e g 1, compared another image value, e I , is greater than the threshold, then neither image value is discarded The comparison continues by taking 1^ and comparing it to the image value of I j+ | , which is associated with the video image then immediately adjacent in time thereto From the foregoing it can be seen that only image values li that have a change in magnitude greater than the threshold is kept Further compression of the plurality of image values is obtained by discarding those image values that are close in value to the immediately adjacent in time image values Although the foregoing method has been described with respect to comparing an image value I. with another image value + , which is associated with video images that are immediately adjacent in time thereto, it can be readily seen that the method of the present invention is not so limited The image value 1^ need not be compared to an image value + , which is associated with a video image immediately adjacent in time 1^ can be compared to Iι, + - 7 , for example, or even I^-. j . representing image values which are not immediately adjacent in time thereto Furthermore, the method ot the present invention can be used with the method of principal component analysis of the prior art where a plurality of the different parameters are derived by the method of principal component analysis Thus, for example, the video scene comprising of the video images F j r» j can be compressed by principal component analysis to derive a plurality of parameters C^ (where k can have the values 1. 2, etc ) For each of the parameter C, . an image value would be derived for each of the video image F, F^ Thus, if, for example, three parameters were derived, the video scene of the video images F ι F«^ would be compressed into ( 1 ) One image full of one component values C , , C i x j and an image value l j j ^ associated with one of the video images F | F^ (2) One image full of one component values C-> ] C->^ and an image value I21 - yj associated with one of the video images F | F^ (3) One image full of one component values C3 j C-^ and an image value I- j l-^ j associated with one of the video images F j F^ Where a plurality of parameters are derived by the principal component analysis, the method of the present invention further compresses these plurality of parameters by calculating the difference in image values associated with video images immediately adjacent in time in accordance with: - J k (i ki - > kj ) * - where k is an index to the plurality of parameters P is the total number of parameters I jj . is the k parameter of image value l j l j κ is the k parameter of image value I- W | . is a weighing factor for parameter k. For all the parameters, W^ can be the same or they can be different weighing each parameter differently Furthermore, as discussed previously, each of the image values I and l- can be associated with video images F j and F: that are immediately adjacent in time or they are not immediately adjacent in time. Although the above equation is disclosed for further compression using a plurality of parameters. the method of the present invention can be used by any other algorithm that calculates the difference of two image values, regardless of whether or not the image values are derived by principal component analysis Furthermore, as a result of the calculation of the difference, discussed heretofore, in the event the difference is less than a predetermined threshold, then one of the video image value being stored, and with the other image value not stored. The result is further compression of the stream of video image values As previously discussed, the threshold T can be a fixed or an adaptive threshold. The foregoing method has described the use of a fixed threshold. Alternatively, the method of the present invention provides an adaptive threshold, permitting the user (or a computer) to specify the number of image values (and correspondingly, the number of video images) to be stored The user or the computer can either specify directly the number of image values to be stored or indirectly by specifying the amount of time for displaying the video images, whose image values are stored In the latter example, the user can specify, for example, a five minute segment of image values, to be displayed, for a two hour video movie Thus, there would be (5 \ 60 x 30 = 9000) image values stored. The method proceeds by first comparing the image values of all consecutive video images, to find a difference thereof. Using the previous example the image values are labelled as I , . I->, I 3 . . 1^. Thereafter, each image value l k , associated with a video image F^. is compared to an image value I | , + | , associated with a video image Fι. + ι , which is immediately adjacent in time to the video image F^. The absolute value of the difference between the two image values is obtained, i.e D j (= | I j - I-, | ). D-, (= ) I- - I-. I ), D-. . D j ^_ | (= I l | γ | _ | - I I ), where D is the difference. The smallest difference D is then chosen and one of the image values corresponding thereto is kept. Thus, for example, if D-, is the smallest difference, then either I-, or I- is kept. Let us assume that is kept Then, of the remaining differences D, the next smallest difference, i.e. D- is chosen and one of the image values is discarded. Alternatively, the differences between consecutive image values I that remain is re-calculated, and the smallest difference is chosen. Thus, for the above example, the following differences are calculated- D , H - 1 - -3 D- D 3 ( = I f 3 * '4 I ) ' 4 *-*M- l ( = I 'M- 1 " * I ) Tne sma " est difference is chosen and one of the image values is retained In either event, this process is repeated until the desired number of video images remain This eliminates the problem of pre-specifying a threshold value and permits the threshold to be adaptively chosen based upon the video content of the video scene This can be seen by reference to Figure 5 wherein a video scene comprises forty-nine (49) video images, and using the compression method of the present invention with the user specifying a desired result of four (4) video images, four (4) video images are so determined Referring to Figure 6 there is shown a flowchart of a method of determining video images with key image parameters, or the selection of "key" images, in accordance with the foregoing described method of the present invention As can be seen from the toregoing, the method of compression of the present invention, greatly reduces the storage requirement tor a video scene In addition, however, and more importantly, the method results in a reduced number of video images, which can be readily displayed, browsed or searched The selected video images that are displayed contain video information that demonstrate the most amount of "change" in a stream of video images The selected video images that are displayed, are analogous to indices or a table of content for a textual work In this manner, searching or browsing through a video scene can be greatly simplified It should be noted that the display of "ke\ " video images, representing the most amount of change in video content in a video scene, does not have to be based upon video images compressed by the principal component analvsis For example, the method can be based upon other methods which determine one or more parameters for each video image Thereafter, using the method of comparing consecutive image values, and discarding one of the image values if the difference is small (using either a fixed threshold or an adaptive threshold), as described heretofore a number of "key " image values is calculated The video images corresponding to the "key" image values can be displayed Once the "ke\ " image values are determined the video images corresponding to those "key" image values can be used as index images tor compression ot a plurality of video images (such as a movie) into compressed data, from which the uncompressed plurality of video images can be reproduced w ithout significant loss in fidelity Referring to Figure 3 there is shown a schematic diagram of a method of the present invention used to compress and store a pluralitv ot video images, such as a movie If we assume that the movie comprises of Z frames, there would be F j F^- F j F^. F-,. number ot video images or frame images The frames F , F j , F» * . and Fγ are the index images. 1 e those video images whose key image values have been determined in accordance with the method described heretofore Thereafter each video image that is proximate to one ot the index images is compared Thus. I F l " F c I - I F c- 1 - F c l - F c- l F c- | - F j I - are calculated This is like the prior art method in that the difference between various video images and the index images is calculated "pixel by pixel" This difference along with the index images are then store Alternatively, the difference along with the "key" image values representing the index images and the principal component analysis image are stored By this compression technique, all the video images of the video base can be faithfully reproduced A flowchart of this method is shown in Figure 7 As can be seen from the foregoing, unlike the prior art method, wherein reference frames are chosen based upon every set N number of frames, the method of compression for a video database of the present invention does not limit the choice of the reference or index images to particular positions in time The benefit of the method of the present invention can be seen by the following example Let us assume that there are seventeen video images in accordance with the following I,, ι 2 , ι 3 , ι 4 , ι 17 Let us further assume that between images 1 4 and 15 and between images l j 2 and I , - represent the most amount of change (for example, an abrupt change in scene from one to another through the use of one camera to another) Between I j and I 4 , camera 1 is in a fixed location or is "panning" wherein the difference between the images is minimal Similarly, between images I5 and I , there is assumed to be also minimal changes Finally, it is assumed that between I j 3 and l j 7 there is also minimal change Therefore, there are three video scenes comprising of images 1 ,-I 4 , I 5 -I 12 , and I - 3 -l 1 7 With the method of the present invention images L . L. and I , - are determined to be index images or reference images, 1 e images whose "key" image values have been determined in accordance with the method described heretofore The compression of the images I ι -1 ] 7 would be to find the difference between l j and each of I-, I 4 storing that difference, the difference between I s and each of 'ό ' P- anc * storm s tne difference, and the difference between I , - and each of l | 4 l j - and storing the difference In addition, of course. I , , I*;, and I , - are stored either as images or the principal component analysis from which they were derived In contrast, in the method of the prior art a set number of images are chosen as the reference image Thus, tor example, if every eighth (8'th) frame. 1 e I i , I9, and I ] 7 are chosen as index or reference images, then the difference between I , and \ ^ would generate a huge difference because there is a large change in the video image data Similarly, the difference between IQ and L 3 would necessitate a large change in the video data In contrast, by using the images having the largest change as the reference images, compression can be optimized With the method of the present invention by further compressing the video images and by reducing the storage requirement, it becomes possible in another method of the present invention to search a video database The video database has a plurality of database elements with each database element being a video scene, comprising a plurality of video images Each video database element is compressed with the method of the present invention as described heretofore However similar to the previous discussion, the one or more parameters for each video image need not be derived from principal component analysis An inquiring video scene also comprises a plurality of video images The method of the present invention permits the video database to be searched to find a match between the inquiring video scene and the video scenes of the video database The inquiring video scene can be compressed in accordance with the method of the present invention described heretofore To determine if a match occurs between the inquiring video scene and one of the video database elements, the stored image values associated with the inquiring video scene are compared to the stored image values associated with each video database element to find a match between the image values One method of comparing the matches is to find an exact match However often that is not possible Another technique is to find a statistical match between the video image values of the inquiring video scene with the video image values of each of the video scenes of the video data base For example, the following comparison can be made = . Σ Σ w k (VI, k - ι lk ) 2 = l 1= 1 where k is an index to the plurality of parameters, and I is an index to the plurality of image values stored P is the total number of parameters. L is the total number of image values stored, VI. k is the k parameter of image value I from the video database. I is the k parameter of image value l j from the inquiring video scene. W is a weighing factor for parameter k In the event the value calculated is below some threshold, then a match is declared With this method of the present invention, it then becomes possible to determine based upon a "video clip" the source or the video database element from which the "video clip" came Of course, the video database need not be pre-compressed Thus, the video database data may be compressed at the same time the inquiring video images are compressed Alternatively, the searching of a video database, comprising a plurality of database elements, each being a video scene, can be accomplished based upon an adaptive technique as follows If we assume that a user is willing to wait for a period of time T to process a searching match against one of the video database elements, and the processor has a known speed/capability, that period of time T can be translated into a comparison of S number of video images Using the adaptive comparison method described heretofore, each of the video scene of the video database, can be compressed into S number of video images, and S number of image values A comparison is then made between the image values of the inquiring video scene and the S number of image values for each of the video database elements The video database element having the smallest total difference would then be the closest match between the inquiring video scene, and chosen video database element The inquiring video scene, could but need not be compressed, into the same number of video images of the video database element Moreover, any of the prior art search algorithm can be used to compare the inquiring video scene with the compressed video images From the foregoing, it can be seen that with the method of the present invention, a video scene comprising a plurality of video images can be greatly compressed to save storage requirement Furthermore, with a reduction in storage requirement it becomes possible to efficiently display, and search an inquiring compressed video scene to a video database to search the database to determine a video database element matching the inquiring video scene In the preferred embodiment, the method of the present invention is practiced bv a computer program operating on a Silicon Graphics Workstation made by Silicon Graphics. Inc of Mountain View California A copy of that program is set forth in Exhibit A An overview of the various methods of the present invention is shown in Figure 8 Sep 13 15:55 1994 User- daemon, File- Standard Input. Page 1 — File: best_fιrst_frame_merge.sa — Author: Subutai Ahmad <ahmadβιnterval.com> -- Date created: Wed Apr 6 14:48:29 1994 — Copyright (C) 1994, Interval Research Corporation — Interval Research Confidential class BEST_FIRST_FRAME_MERGE is — Best first merge a set of frame clusters until there are only — N remaining. attr fq:PRIORITY_QUE-E{FCDIST) ; attr ι_αage__ιa_nes : LIST ( STR } ; attr i_nage_pro 3 :VECTOR_LIST; attr images: IST (SGI_ IMAGE); attr fιrst_cluster:FR_____CLUST£R; attr num_clusters:__NT; create (ιn:LIST(STR) ; ip : VECTOR_LIΞT ; im : IST { SGI_IMAGE) ): SAME is res : = res. new ; res.ιmage_names:= in; res.ιmage_pro 3 := ip,- res.images:= im; res.create_frame_lιst, end; create_frame_lιst is fq:= fq. create .- f irs t_cluster : = FRAME_CLUSTER : : create_wιth_f rame ( image_nai_.es , ιmage_pro_ι , images , 0 ) ; prev:FRAME_CLUSTER:= ιrst_c luster ; ι:Z__rT:_ 1; loop until ! (i_i___s.ge_na_n.es .size) ,- f c : FRAME_CLαSTER : = FRAME_CLUSTER .- :create_wιth_frame ( ιmage_names , ιmage_pro_ , images, i) ; FRAME_CLUSTER: : lιnlc_cl_sters (prev, fc) ; fq. insert (prev.dιst_after) , prev-= fc- l:= i+l; end; num_clusters-- image_t_a__.es.s ze; end; merge_untιl(n:INT) is -- Repeatedly merge until there are 'n' clusters left. loop until! (num_clusters<=n) ; merge_once; end; end; merge_once is -- Merge the two closest clusters fd:FCDIST:= fq.pop; if not fd.invalid then .fcl.merge(fd.fc2) . nu_ι_clusters:= num_clusters-l; if fd.fcl.dιst_before /= void then fq.insert(fd.fcl. ιst_before) ; end; if fd.fcl.dιst_after /= void then q.insert(fd.fcl.dιst_after) ; end; end; end; pπnt_frame_clusters is -- Print frame clusters in a couple of different formats. fc:FRAME_CLUSTER:= fιrst_cluster; loop until! (fc=void) ; OUT: :s(fc.to_s) .s(" mee_n_image: ") .i(fc.mee_n_image) .s(" xv -expand 5 ") .s(ιmage_naιnes [fc.mean_image] ).s( " _\n"); fc:= fc. fter, end; fc:FRAME_CLUSTER:= f rst_cluster: Sep 13 15:55 1994 User: daemon; File: Standard Input; Page 2 loop until! (fc=voιd) ; OUT: :s(ιmage_names[fc.mean_ιmage] ) .s ( " "); fc:= fc.after; end; OUT: :nl; end; mean_images: IST{STR} is -- Return a list of the mean images after merging. res:= res.create; fc:FRAME__CLUSTER:= fιrst_cluster; loop until! (fc=void) ; res:= res.push(image_names [ c.mean_ιmage] ) ; fc:= fc.after; end; end; mean_image_inde :LIS (INT) is -- Fill in list of the mean images after merging. res:= res.create__sιzed(num_clusters) ; fC:FRAME_CLUSTER:= first_cluster; loop until! (fc=voιd) ; res:= res.push(fc. ean_ιmage) ; fc:= fc.after; end; end; first_image_ιndex:LIST(INT) is — Return the list of the first images in each cluster. res:= res.create__sιzed(num_clusters) ; fc:FRAME_CLUSTER:= first_cluste ; loop until! (fc-void) ; res:= res.push(fc.first) ; fc:= fc.after; end; end; last_image_index:LIST(INT) is — Return the list of the last images in each cluster. res:= res.create_sιzed(num_clusters) ; fc:FRAME_CLUSTER:= first__cluster; loop until! (fc=voιd) ; res:= res.push(fc.last) ; fc:= fc.after; end; end; random_frame(p:REAL) :FRAME_CLUSTER is -- Return a random frame, selected with probability 'p' . res:= fιrst_cluster; loop until! (RANDOM: :bιt(p) ) ; res:= res.after; if res-void then res:= fιrst_cluster; end; end; end; end; — Class BEST_FIRST_FRAME_MERGE class BFFM_TEST is -- A test of best first frame merging. main(args:ARRAY{STR} ) is m:SAME:= .new; m.do__.it(args) ,- end; attr cl:COMMAND_LINE; attr h:CL_FLAG; attr fn:CL_VAL_STR; attr nc:CL_VAL_IN ; attr ιmage_names:LIST(STR) ; attr ιmage_pro_ι :VECTOR_LIST; attr images:LIST(SGI_IMAGE) ; attr bffm:BEST_FIRST_FRAME_MERGE; do_it(args:ARRAY(STR)) is cl:= cl.create; h:= h.create("-help" , "Print this message."); cl.add_opt(h) ,- fn:= fn.createt"fn", "Image proj file name."); cl.add_req(fn) ; nc:= nc.create("nc", "Final number of clusters."); cl.add_req(nc) ; cl.parse_wιth_err(args) ; p2:PAIR2(LIST(STR),VECTOR_LIST) := DATA: :read_ιmage_pro 3 (fn.val) ; ιmage_names:= p2.ell; Sep 13 15:55 1994 User: daemon; File: Standard Input; Page 3 image_proj:= p2.el2; dl:DOUBLE:= TIME: :time; bffm:= bffm.create(image_names, image_proj , images) ; bffuι.merge__ntil (nc.val) ,- d2:DOUBLE:= TIME: :time; OUT: :s("Remaining clusters: \n" ) ; bffm,.print__frame_clusters; OUT: :s("Time to create and cluster = " ) .d(d2-dl) .s ( " secs\n"); end; end; -- class BFFM_TEST Sep 13 15:55 1994 User: daemon; File- Standard Input; Page 1 -- File: frame_cluster.sa -- Author: Subutai Ahmad <ahmad@ιnterval.com> -- Date created: Thu Mar 24 16:59:01 1994 -- Copyright (C) 1994, Interval Research Corporation -- Interval Research Confidential class FRAME_CLUSTER is -- Implements a cluster of image frames (SGI_IMAGE) . -- Each image frame is represented by a feature vector. -- Each cluster represents a time-ordered list of frames. -- Thus there are well defined "before and after" clusters -- along with distances to them. -- The distance between two clusters is the distance between the last -- frame of the first cluster and the first frame of the second cluster. attr before:FRAME_CLUSTER; attr dιst_before:FCDIST; attr after:FRAME_CLUSTER; attr dιst_after:FCDIST; attr center:VECTOR; -- The center of the image vectors in the range [first, last] -- The mean should be computed when you actually need it. — See mean_vector and mean_ιmage below. attr size:INT; attr first, last:INT; -- The cluster represents a time interval — These numbers index into central data structures, which are... attr ιmage_names:LIST{STR) ; -- These are shared among all frame clusters, attr ιmage_pro 3 :VECTOR_LIST; -- Is this really the best way?-" We could make attr images:LIS {SGI_IMAGE) ; -- them 'shared' but then we can only have one — set of frame clusters. create_wιth_frame(ιn:LIST{STR) ; ip:VECTOR_LIST; ιm:LIST(SGI_IMAGE) ; ι.INT):SAME is res:= res.new; res.ιnιt_wιth(in, ip, im, i) ; end; init_wιth(ιn:LIST(STR) , ip:VECTOR_LIST; im:LIST(SGI_IMAGE) ,- ι:INT) is ιmage_names:= in; ιmage_pro_ι := ip; images:= im; first:- l; last:= l; center:= ip[i] ; mean_ιmage_ιd := l, end; attr dirty_mean:BOOL; -- If true then mean has needs to be recomputed attr mean_ιmage_ιdx:INT; -- Index of image closest to mean mean_vector:VECTOR Is if dιrty_mean then recompute_mean; end; res:= center; end; mean_image:INT is — Return the index of the image closest to the cluster mean, if dirty_mean then recompute_mean; dbest:REAL:= ιmage_pro 3 (first) .square_dιstance_to(center) ; res:= first; Sep 13 15:55 1994 User: daemon; File: Standard Input; Page 2 ι:INT-= fιrst+1, loop until' (ι>=last) , d:REAL:= ιmage_pro 3 [i] .bounded_square__dιstance_to(center,dbest) ,- if d>=0. then dbest:- d, res:= ι; end; ι:= l+l; end, mean_ιmage_ιd := res; else res:= mean_ιmage_ιdx; end; end; lιnk_clusters(fl,f2:SAME) is -- Link the frames 'fl' and 'f2' 'fl' occurs before 'f2' -- Assumes neither are void. fl. fter:- f2; f2.before:- fl; fl.dιst__after:= FCDIST: :create(fl, f2, f1.ιmage_pro 3 [fl.last] , f2.ιmage_pro 3 [f2.first] ) f2.dιst_before:= f1.dιst__after; end; merge(f1:SAME) :SAME is -- Merge fl into current cluster. — The frames in fl occur later in time than those in self. -- fl will be GC'd after this. -- The current dιst_before and dιst_after ob 3 ects are -- invalidated and two new ones created. -- These should be subsequently inserted into the priority queue. if dιst_after /= void then dιst_af er.invalid:= true; end, if dιst_before /= void then dιst__before.invalid:= true, end; after • = f1.after; last:- fl.last; -- Append the two intervals. sιze:= last-f rst+1; dιrty_mean:= true; if before/- void then lιnk_clusters(before,self) ; end. if after/= void then af er. ιst_before.invali .= true; lιnk_clusters(self.after) , after.dιst_before:= dιst_after; end; end; recompute_mean is center:- center.create(ιmage_pro 3 .dim) ,- ι:INT:= first; loop until! (ι>last) ; center.to__sum_with(ιmage_pr03 [1] ) , l:= 1+1; end; center.scale_by(l./size) ; dιrty_mean:= f lse,- end; to_s:STR is res:= res.create; res:= res.s("FC[") .1(first) .c( ' • ' ) .ι(last) .c( '] ' ) , end; end; -- class FRAME_CLUSTER class FCDIST is -- Distances between frame clusters. attr fcl, fc2:FRAME_CLUSTER; attr mvalid:BOOL; attr dist:REAL; -- The distance between fcl and fc2 Sep 13 15:55 1994 User: daemon; File: Standard Input; Page 3 is_less_than(d2:SAME) :BOOL is res:= (dist>d2.dist) ; end; -- Used for priority queue class create(fl,f2:FRAME_CLUSTER; vl,v2:VECTOR) :SAME is -- The new distance between fl and f2. Uses distance between 'vl' and 'v2'. res:= res.new; res.fcl:- fl; res.fc2:= f2; res.dist:- vl.distance__to(v2) ; end; end; -- class FCDIST class FRAME_CLUSTER_LIST is LIST(FRAME_CLUSTER) ; end; -- class FRAME CLUSTER LIST Sep 13 15 : 56 1994 User : daemon; File : Standard Input , Page 1 — sanger_ne .sa: -- Author: Subutai Ahmad <ahmad@ιnterval.com> — Copyright (C) 1994, Interval Research Corporation -- Interval Research Confidential class SANGER_NET is -- Implements Sanger's learning algorithm for extracting the — first 'p' principal components. -- One layer, linear unsupervised network. -- First output unit is the first principal component. -- Second unit is the second, etc. -- In the one output unit case this reduces to θ 3 a's rule. -- These algorithms correspond to stable versions of Hebb's rule -- (weight vector growth is constrained) — Complexity of each iteration: θ(N*M) where N is the number of inputs — and M is the number of outputs. — Seems to require O(P) iterations where P is the number of training — patterns. LEARNED_VECTOR_MAP; attr rand_mιn,rand_ma : REAL, — Range of initial random weights (-0.5,0.5) attr n_ιnps,n_outs: INT — Number of input and output units attr ιn_state: VECTOR, -- Input unit states attr out_state: VECTOR; — Output unit states. attr wt: MATRIX -- Matrix of weights for each group wt[ι, 3 ] is the weight from the 3 ' h input to the 1'th output. attr traιn_m:VECTOR_LIST; List of training/teacher vectors. attr n_traιn:INT; Number of training patterns. attr max_ιter:INT; Maximum # of training iterations (1000) . attr learn_rate:DOUBLE; Step size (0.1) . Decreases as 1/t attr make_zero_mea :BOOL; Make vectors be zero mean (true) and ... attr neg_mean:VECTOR,- ... store the negative of the mean here. create_sιzed(nι,no:INT) :SAME is res:= res.new; res.n_ιnps:= ni, res.n_outs:= no; res.ιn_state:= res.ιn_state. reate(ni) ; res.out_state-= res.out_state.create(no) , res.wt:= res.wt.create(no,ni) ; res.ιnιt_defaults; res.randomιze_weιghts; res.make_zero_mean:= true, end; VECTOR MAP routines attr V:VECTOR; map_ιn(vi,vo:VECTO ) -- Put the value of the map on 'vi' into 'vo'. pre vi.dιm=n_ιnps is if v=voιd then v:= v.create(vi.dim) elsif v.dim /= vi.dim then v= v.create(vi.dim) ; end; if make_zero_mean then v:= vi.plus(neg_mean) else v:= v.to(vι); end; clamp(v) ; forward; vo. o(out_state) ; end; -- map_ιn Sep 13 15 : 56 1994 User : daemon; File : Standard Input ; Page 2 ιn_dιm:INT is — Dimension of the input space. res := n_ιnps; end; -- ιn_dιm -- Dimension of the output space. res := n_outs,- end; -- out_dιm LEARNED_VECTOR_MAP routines traιn(ιn,out:VECT0R_LIST) is -- Use the vectors 'in' and 'out' to train the map. -- Ignores 'out' . -- Warning: if make_zero_mean is true (the default) then — the vectors in 'in' will be changed. if make_zero_mean then neg_mean:= VU: :make_zero_mean(in) ; else neg_mean:= neg_mean.create(in. im) ; end; traιn_ιn := in; traιn_network(max_ιter) ; end; — train Network specific routines clam (vi:VECTOR) is -- We can do this since ιn_state never gets modified. ιn_state:= vi; end; forward is wt.act_on_ιn(ιn_state,out_state) ; end; -- Compute output unit values. attr It:DOUBLE; — The current learning rate at time t. traιn_network(maxι:INT) is -- Train net for 'maxi' iterations, if n_traιn =0 then n_traιn = traιn_ιn.sιze; end, nι:INT:= maxι.20+1; lt:= learn_rate; 3 :INT := 0; loop until 1 ( 3 =maxι ); cle_mp ( traιn_ιn [ 3 .mod ( traιn_m . s ze) ] ) ; forward; update_weιghts( 3 .mod(traιn_ιn.sιze) ) ; _ := 3 +1; if 3 .mod(traιn_ιn.s ze) = 0 then lt:= learn_rate/ (l+ 3 /traιn__ιn.sιze) ; end; end; -- loop end; update_weιghts(p:INT) is -- Update weights for the p'th input pattern 3:INT:= 0; loop until! (3=n_ιnps) ; e 3 :DOUBLE:- ιn_state(3]; sum:DOUBLE:= 0; ι:INT:= 0; loop until!(ι=n_outs) ; sum:- sum + out_state[1] *wt[1, j] ; wt[i,3]:= wt(ι, 3 ] + lt*out_state[ι]* (β - sum) ; 1:= i+1; end; 3 := 3+1; end,- end; -- update_weιghts randomιze__weιghts is — Use uniform distribution on ' [rand_mιn,rand_max] ' to initialize Sep 13 15 : 56 1994 User : daemon; File : Standard Input ; Page 3 -- weights. i:INT:= 0; loop until! ( i=wt.nr ); j:INT:= 0; loop until! ( j=wt.nc ); wt[i,j] := RANDOM: :uniform_range(rand__min,rand__m__x) ; j := j +1; end; i := i +1; end; end; -- randomize_weights -- Should not be redefined by descendants init_defaults is learn_rate:= 0.1; rand_min:= -.1; rand_ma := .1; train_in:= train_in.create; max_iter:= 1000; end; — init_defaults save_state(f:FILE) is f.s(wt.to_s) .nl; f.s(neg_mean.to_s) .nl; end; create_from_file(f:FILE) :SAME is s:STR:= f.get_s; w:MATRIX:= MATRIX: :create_from_s(s) ; s:= f.get_s; v:VECTOR:= VECTOR: :create_from__s(s) ; res:= res.create_sized(w.nc,w.nr) ; res.wt:- w; res.neg_mean:= v; end; end; -- class SANGER_NET class SANGER_COMPONENT is — Does one component at a time. SANGER_NET; attr components_done:IN ; attr cached_outputs:MATRIX; attr current_pattern:INT; forward_train is — Forward propagation during training. -- Compute output unit values using stored output values whenever -- appropriate. i:INT:= 0; loop until! (i=components_done) ; out_state(i] := cached_outputs[current_pattern, i] ; i:= i+1; end; i:INT:= componentε_done; loop until! (i=n__outs) ; out_state[i] := 0; j:INT:= 0; loop until!(j=in_state.dim) ; out_state[i] := out_state(i]+wt[i, j] *in_state(j] ; j:= j+1; end; i:= i+1; end; end; train_network(maxi:INT) is — Train net for 'maxi' iterations, if n_train =0 then n_train := train_in.size; end; ni:INT:= maxi/10+1; cached_outputs:= MATRIX: :create(train_in.size,n_outs) ; 1v:VECTOR:= MU: :row_lengths(wt) ; components_done:= 0; loop until! (components_done=n_outs) ,- lt:= learn_rate; Sep 13 15:56 1994 User: daemon; File: Standard Input; Page 4 length:REAL-.= lv[components_done] ,- j:INT := 0; loop until! ( j=maxi or (length-1.00) .abs < 0.01 ); current_pattern:= j . od(train_in.size) ; clamp(train_in[current_pattern] ) ; forward_train; cached_outputs.current_pattern,components_done] := out__state[components_done] ; update_weights (current_pattern) ; j == j +1; if j .mod(train_in.size) = 0 then lv:= MU: :row_lengths(wt) ; length:= lv[components__done] ; It:= learn_rate/ (1+j/train_in.size) ; end; end; -- loop components_done:= components_done+l; end; end; update_weights(p:INT) is __ Update weights for the p'th input pattern j:INT:= 0; loop until! (j=n_inps) ; sum:DOUBLE:- 0; i:INT:= 0; loop until! (i>components_done) ; sum:= sum + out_εtate[i]*wt[i, j] ; i:= i+1; end; wt[components_done,j] := wt[components_done, j] + lt*out_state[components__done] * (in_stat e[j] - sum) ; 3 := j+1; en ; end; -- update__weights end; -- class SANGER_COMPONENT Sep 13 15 : 54 1994 User : daemon ; File : Standard Input ; Page 1 -- Author: Subutai Ahmad <ahmad@interval.com> — Date created: Wed Apr 6 14:48:29 1994 -- Copyright (C) 1994, Interval Research Corporation -- Interval Research Confidential class AUT0_KEY is -- Do best first frame merging and then display on a window. main(args:ARRAY{STR} ) is m:SAME:= m.new; rn.do__.it(args) ; end; attr cl:COMMAND_LINE; attr h:CL_FLAG; attr pf:CL_KEY_STR; attr fn:CL_VAL_ST ; attr nc:CL_VAL_INT; attr first,last,sub:CL_KEY_INT; attr pc:CL_KEY_STR; attr jpg:CL_FLAG; attr qto:CL_FLAG; — Movie is in Quicktime JPEG format. attr image_names:LIST{STR} ,- attr image_proj :VECTOR_LIST; attr images:LIST(SGI__IMAGE} ; attr bffm:BEST_FIRST__FRAME_MERGE; attr qt:QT_JPEG; attr qt_file_name:STR; attr num_images:INT; attr frames_used:LIST(INT) ; attr win:SGI_WIN; attr max_frames:INT; -- The maximum number of frames that will fit in the window const win_width:IN := 1170; const win_height:INT:= 960; do_it(args:ARRAY{STR} ) is cl:= cl.create; h:= h.create("-help" , "Print this message."); cl.add_opt(h) ; jpg:= jpg.create( "-jpg" , "Image files are in JPEG format."); cl.add_opt(jpg) ; sub:= sub.create) "-sub" , "Subsa pling. ") ; cl.add_opt(sub) ,- sub.val.-_ 2; qto:= qto.create("-qt" , "Movie is a jpeg-compressed quicktime movie"); cl.add_opt(qto) ; pf:= p .create("-pf" , "Read an already parsed jpeg-compressed QT movie."); cl.add_op (pf) ; pf.val:- "qt_parse_file" ,- first:- first.create( "-first" , "First frame number (QT only)."); cl.add_opt(first) ; first, val:= 0; last:- last,create( "-last", "Last frame (QT only) ."); cl.add_opt(last) ,- last.val:- 999999; pc:= pc.create( "-pc" , "Print clusters to this file. Don't display"); cl.add_opt(pc) ; pc.va 1:= "NONE"; fn:= fn.create("fn" , "Image proj file name."); cl.add_req(fn) ; nc:= nc.create( "nc" , "Initial number of clusters."); cl.add_req(nc) ; cl.parse_with_err(args) ; xp:= xp.create,- yp:= yp.create; if pf.matched or qto.matched then read_qt_proj (fn.val) ; if qto.matched then qt:= qt.create(qt_file_name) ; elsif pf.matched then qt:= qt.create_parsed(pf.val,qt_file_name) ; end; OUT: :s("Created quicktime reader.\n") ; num_images:= fretmes_used.size; else p2:PAIR2{LIST(STR) ,VECTOR_LIST) := DATA: :read_image_proj (fn.val) ; image_names:= p2.ell; image_proj := p2.el2; num_images:= image_names.size; Sep 13 15 : 54 1994 User : daemon; File Standard Input , Page 2 end; OUT: :s("Clustering " ) .ι(num_ιmages) .s( " images... \n" ) ; images:= images.create__sIzed(num_images) ; ι:INT:= 0; loop until! (ι=num_ιmages) , images:= images.push(void) ,- ι:= l+l, end; read_ιmage(0) ; bffm: = bffm. create ( ιmage_ne_mes , ιmage_pro3 , images ) ,- bf fm.merge_untιl (nc .val ) , if pc . matched then pπnt_clusters (pc .val ) , return ; end; win:= wιn.create_sιzed("Images" ,wιn_wιdth+IMAGE_DISPLAY: :border, ιn_heιght+IMAGE_DISPLAY: :border) ; max_frames:= ( (win_.width.to_r/ ( mages[0] .width*IMAGE_DISPLAY: :border) ) .floor * (wιn_heιght.to_r/(images[0] .height*IMAGE_DISPLAY. :border) ) .floor) -1; if max_frames>ιmages.size then max_frames • = images.s ze; end, OUT::s("Max frames- ").l(max_frames) .nl, dιsplay_ιmages; merge_dynamιcally; end; attr ιm_ιdx:LIST(INT) ; -- List of image indices to display attr xp,yp:LIST(INT), -- The lower left hand coordinate of each image. ges is 0.0) ; C: :clear; bffm.mean_ιmage_mdex, ιze<ιm_ιdx.sιze then xp = xp.create_sιzed(ιm_ιdx.sιze) , yp:= yp.create_sιzed(ιm_ι dx.size) ,- end; load_necessary_ιmages(ιm_ιdx, images) ; IMAGE_DISPLAY: :sgι_ιndexed_montage(win, ιm_ιdx,xp,yp, mages) ; C: :swapbuffers; end; prιnt_clusters(fn:STR) is -- Print key clusters in file 'fn' . — Format is: -- num_clusters movιe_fιle num_ιn_cluster beg_frame_num end_frame_num mean_frame_num beg_frame_tιme end_frame_tι me mean_frame_tιme OUT::s("In punt clusters.\n") ; first:LIST{INT) := bffm. ιrst_ιmage_ιndex; last:LIST{INT) • = bffm.last_ιmage_ιndex; mean: IST(INT) := bffm.mean_ιmage_ιndex; f:FILE:= f.create; f.open_for_wπte(fn) ; f.l(bffm.num_clusters) .c( ' ' ) .s(qt_fιle_name) .nl; ι:INT:= 0; loop until! (ι=fιrst.size) ; b:INT:= first[l]+frames_used[0] ; e:INT:= last[i]+frames__used[0] ; m:INT:= mee_n[ ]+frames_use [0] ; f.i(last[i]-fιrst[ι]+l) .cC ').ι(b).c(' ') .ι(e) .c(' ' ) .1(m) .nl; l:= 1+1; end; f.close; end; read_qt_pro (fn:STR) is -- Read in a file containing Quicktime frame numbers and their pro 3 ect ons into -- some space. -- Format is: nimages ndimensions fιle_name ιmage_frame_numl ιmagel_dιml ιmagel_dim2 .... ιmage_frame_num2 ιmage2_dιml ιmage2_dιm2 . .. f:FILE:= f.create; f.open_for_read(fn) ; Sep 13 15:54 1994 User: daemon; File: Standard Input; Page 3 if f .error_val=f .open_error then ERR: : s ( "Could not open file ") .s(fn) .nl; return; end; n:INT:= f.get_i; dim:INT:= f.get_i; sc:STR_CURSO : = sc.create (f.get_s) ; sc . skip__space; qt_file_name:= sc.get_word; frames_used:= frames_used.create_sized(n) ,- image_proj : = image_proj .create_sized(n) ; image_names := image_names .create_sized(n) ,- i:INT:= 0; loop until ! (i=n) ; fnum:INT:= f.get_i; sc:STR_CURSO := sc .create (f .get_s) ; if fnum>= first.val and fnum<= last.val then frames_used:= frames_used.push(fnum) ; image_names: = image_names .push(fnum. to__s) ; v:VECTOR:= v.create (dim) ; d:INT:= 0; loop until ! (d-dim) ; v[d] := sc.get_d; d:= d+1; end; image_proj : = image_proj .push (v) ; end; i:= i+1; end; f .close,- end; read_image (i: INT) is -- Read in i' th image if pf .matched or qto.matched then images [i] := qt.create_frame_sgi (frames_used[i] ) .create_subsampled(sub.val, sub.val) ; else if jpg. atched then images[i] := SGI_IMAGE: :create_from_jpeg (image_names [i] ) .create_subsampled(sub.val, s ub.val) ,- else images [ i ] : = SGI_IMAGE : : reate_f rom_raw_ppm ( image_names [ i ] ) . create_subsampled (sub.va 1 , sub . val ) ,- end; end; end; load_necessary_images (im_idx:LIST{ INT) ,- images :LIST(SGI__IMAGE) ) is i:INT:= 0; loop until ! (i=im_idx. size) ; if images [im_idx[i] ] -void then read_image (im_idx(i] ) ; end; i:= i+1; end; end; merge_dynamically is temp:ARRAY(INT) := temp.new(4) ; tp:INT:= C: : to_c_arr(temp) ; dev: INT:= SGI_WIN: : ev_mousey+1; C: :qdevice(SGI_WIN: :dev_mousey) , - loop until! (false) ; if C::qtest /= 0 then dev:= C: :qread(tp) ,- if dev=SGI_WIN: :dev_mousey then new_y_val:IN := temp[0] .rshift(16) ; nc:IN := (max_frames*new_y_val/win_height. to_r) .round; if nc<l then nc:= 1; end; dl :DOUBLE: = TIME: : time; bffm:= bffm.create(image_names, image_proj , images) ,- bffm.merge_until (nc) ; d2 :DOUBLE: = TIME: :time; display_images; d3 :DOUBLE:= TIME: : ime; C: :qreset; OUT: :s( "Num clusters- " ) . i (nc) .s ( " , time to cluster- " ) .d(d2-dl) .s ( " , display- " ) .d(d3-d2) ,- OUT::s(", Total- " ) .d(d3-dl) .nl ; Sep 13 15:54 1994 User: daemon; File: Standard Input; Page 4 end; end; end; end; end; Sep 13 15 : 58 1994 User : daemon; File : Standard Input ; Page 1 -- scene_cluster.sa: — Author: Subutai Ahmad <ahmad@interval.com> -- Classes: SCENE_PROJECT class SCENE_PROJECT is -- Reads in a set of ppm files, representing subsa pled image files. -- Create a training set consisting of the images as input and output. — Extracts the first 'p' principal components using a SANGER_NET -- Writes out a file, that contains, for each image, the output -- of the 'p' units on that image (ordered according to -- importance) . -- Also writes out one ppm image file for each hidden unit, corresponding -- to the hidden weights. -- In order to use this program for display purposes, should normalize — each dimension individually. For clustering, should probably not do -- this. attr net:SANGER_COMPONENT; attr image_names:LIST{STR) attr images_used:LIST(STR) attr frames_used:LIST(INT) attr images:LIST{$IMAGE) ; attr inputs:VECTOR_LIST; attr outputs:VECTOR_LIST, • attr qt:QT_JPEG; -- Command line parsing attr cl:COMMAND_LINE; attr nh,cw:CL_K__Y_INT; attr first, last:CL_KEY_INT; attr pf:CL_KEY_STR; attr lr,mo,sc,sk:CL_KEY_DOUBLE; attr gr,zero_mean, jpg,vb,nd,n :CL_FLAG,- attr su,mi:CL_KEY_INT; attr qto:CL_FLAG; attr of,mf:CL_VAL_STR; main(args:ARRAY(STR)) is m:SAME:= m.new; m.do_it(args) ; end; common_arguments is cl:= cl.create; cl_help:CL_FLAG:= cl_help.create("-help", "Print this message.") ; cl.add_opt(cl_help) ; gr:= gr.create("-gr" , "Input images are grey level"); cl.add_opt(gr) ; sc:= sc.create("-sc" , "Input scaling"),- cl.add_opt(sc) ,- nd:= nd.create!"-nd" , "Normalize every dimension individually."); cl.add_opt(nd) ; sk:= sk.create("-sk", "Skip. ") ; cl.add_opt(sk) ,- su:= su.create("-su" , "Subsampling. ") ; cl.add_opt(su) ,- jpg:= jpg.create("-jpg" , "Images are in jpeg format") ; cl.add_opt(jpg) ; qto:= qto.create("-qt", "Read from a jpeg-compressed quicktime movie"),- cl.add_opt(qto) ; pf:= pf.create("-pf" , "Read an already parsed jpeg-compressed QT movie."); cl.add_opt(pf) pf.val:- "qt_parse_file" ,- first:- first.create("-first", "First frame to read."); cl.add_opt(first) ; first.val:= 0; last:- last,create("-last", "Last frame to read."),- cl.add_opt(last) ; last.val:= 999999; zero_mean:= zero_mean.create("-zm", "Shift images to zero mean."); cl.add_opt(zero_mean) ; vb:= vb.create("-v" , "Verbose mode"); cl.add_opt(vb) ; -- Required options mf:= mf.create("mfile" , "Movie file."); cl.add_req(mf) ; of:= of.create("out". "Output file"); cl.add_req(of) ; -- Defaults Sep 13 15 : 58 1994 User : daemon ; File : Standard Input ; Page 2 su.val = 10; sc.val = 1/256.0; sk.val = 6.0; Sampled at 5 frames/second (assuming digitized at 30fps) end; do_it(args:ARRA (STR)) is common_arguments; nh:= nh.create( "-nh" "No. of principal components."); cl.add_opt(nh) ,- lr:= lr.create!"-lr" "Learning rate. ") ; cl.add_opt(lr) ; mi:= mi.create( "-mi" "Max. number of iterations."); cl.add_opt(mi) ; cw:= cw.create("-cw" "Change weights every."); cl.add_opt(cw) ,- nw:= nw.create("-nw" "Don't create output weight images"); cl.add_op (nw) nh.val:= 1; cw.val:= 1; lr.val:= 0.01; mι.val:= 1000; cl.parse_with_err(args) ; if qto.matched or pf. atched then 3pg.matched:- true; end; RANDOM: :ini _with_time; create_traιnιng_set,- d:DOUBLE:- TIME::time; traιn_net; d2:DOUBLE:= TIME: :time; create_out_vectors; if pf.matched or qto.matched then create_qt_file; else create_out_file; end; if not nw.matched then create_weιght_ιmages(of.val) ,- end; end train__.net is net:= net.create_sized(inputs.dim,nh.val) ; net.verbose:= vb.matched; net.learn_rate:= lr.val; net.max_ιter:= mi.val; net.make_zero_mean:= zero_mean.matched; net.train(inputs, inputs) ,- end; attr sgi:SGI_IMAGE; create_training_set is -- Read image files and create a randomized training set. -- Don't need to normalize data to zero mean because SANGER_NET will do it. if qto.matched or pf.matched then if qto.matched then qt:= qt.create(mf.val) ; elsif pf.matched then qt:= qt.create_parsed(pf.val.mf.val) ; end; inputs : = read_qt_images ; images : = images . create ; images : = images . push ( read_qt_ιmage ( 0 ) ) ; else image_names : = DATA : : read_raw_words (mf . val ) ,- images : = read_image_f iles ( image_names ) ; inputs : = images_to_vectors ( images ) ; end; end; images_to_vectors ( im : LIST{ $IMAGE ) ) : VECTOR_LIST is res .- = res . create_sized ( im. size) ; i : INT : = 0 ; loop until ! ( i-im. size) ,- res : = res . push ( im_to_vector dm[ i ] ) ) ; ι : = i+1 ; end; end ; im_to_vector ( ιm: $IMAGE) :VECTOR is Sep 13 15 : 58 1994 User : daemon; File : Standard Input ; Page 3 res:= im.to_vector.scale_by(sc.val) ; -- OUT::s("Image vector- ") .s(res.copy.scale_by(1. /sc.val) to_s) .nl; end; read_image(fn:STR) :$IMAGE is — Read one image of the appropriate type, subsamplmg as necessary if gr.matched then if 3pg.matched then res = GREY_IMAGE: :create_from_ peg(fn) , else res:= GREY_IMAGE: :create_from_pbm(fn) ; end; else if 3pg.matched then res:= COLOR_IMAGE2: :create_from_ 3 peg(fn) .create_subsampled(su.val, su.val) ,- else res:= COLOR_IMAGE2: :create__from_pbm(fn) .create_subsampled(su.val,su.val) ; end; end,- end; read_qt_ιmage(frame:INT) :$IMAGE is -- Read given frame of Quicktime movie of the appropriate type, subsamplmg as necessary if gr.matched then res:= qt.create_frame_grey(frame) .create_subsample (su.val,su.val) , else qt.get_frame_sgι(frame,sgi) ,- res:= sgi.create_subsampled(su.val,su.val) ; end; end; read_qt_ιmages:VECTOR_LIST is res:= res.create_sιzed( (qt.num_frames/sk.val + 2).round); frames_used:= frames_used.create_sιzed( (qt.num__frames/sk.val + 2) .round), ι:REAL:= first.val; loop until! (ι>=last.val or ι>=qt.num_frames) ; res:= res.push(ιm_to_vector(read_qt_ιmage(i.round) ) ) ; frames_used:= frames_used.push(l.round) ; read_ιmage_fιles(fn:LIST{STR)) :LIST($IMAGE) is res:= res.create_sιzed( (fn.size/sk.val + 2) .round); ιmages_used:= ιmages_used.create_sιzed( (fn.size/sk.val + 2).round); ι:REAL:= first.val, loop until! (ι>=last.val or ι>=fn.sιze); res:= res.push(read_ιmage( n[l.round] ) ) ; ιmages_used:= ιmages_used.push(fn[ι.round] ) ; l:= l+sk.val, end; end; scale_shιft_lιst(vl:VECT0R_LIST) is -- Scale and shift list so numbers lie in [0,1]. -- If nd.matched then each dimension is scaled individually spread:REAL:- 0; sd:INT; spreads:VECTOR:= spreads.create(vl.dim) , mιn:VECTOR:= mιn.create(vl.dιm) ; ι:INT:= 0; loop until! (ι=vl. im) ; m n d ] • = -vl .mιn_ιn_coordιnate ( i , 0 , vl . sιze-1 ) ; s :DOUBLE : = vl . spread_ιn_coordmate ( l , 0 , vl . sιze-1 ) ; spreads [ l ] • = 1 . / s ; if s>spread then spread:= s, sd:= ι; end; ι:= l+l; end; vl.translate_by(mm) ; if nd.matched then ι:INT:= 0, loop until' (ι=vl.size) ; VU: :multιply_m(vl-dim,vl[l] ,spreads,vl[i] ) ; ι:= i+l; end; else vl.scale_by(1./spread) ; end; end; create_out_vectors is — Create output vectors and scale/translate outputs and force them to lie in [0,1] -- If nd.matched then normalizes each dimension individually -- (Scales each dimension by the max spread along that dimension) — otherwise scale all dimensions by the max spread. Sep 13 15:58 1994 User: daemon; File Standard Input; Page 4 OUT::s("Lengths of each output unit's weights: " ) .s(MU: :row_lengths(net.wt) .to_s) .nl; -- if not nd.matched then OUT: :s("Normalizing weight matrix.\n") ,- MU: :normalιze_by_row(ne t.wt) end; net.make_zero_mean:= false; — Already been made zero mean by network, outputs.-= net.map_vector_lιst(inputs) ; scale_shιft_lιst(outputs) ; end; wrιte_ιmage_prθ (ιm_name:STR; pro 3 :VECTOR; f:FILE) is -- Write the pro3βctιon of this image, f.s(ιm_name) .c( ' ' ) .s(VU: :raw_to_s(pro 3 ) ) .nl; end; wnte_frame_pro (frame_num:INT; pro3 :VECTOR; f:FILE) is -- Write the pro3ection of this frame, f.1(frame_num) .c ( ' ' ) .s(VU: :raw_to_s(proj) ) .nl, end; create_qt_file is — Write a Quicktime pro3ectιon file. f:FILE:= f.create; f.open_for_wrιte(of.val) ; f.1(inputs.size) .s(" ") 1(outputs. im) .c( ' ' ) .s(mf.val) .nl, i:INT:= 0; loop until! (ι=ιnputs.size) ; wrιte_frame_pro3 (frames_used[1] ,outputs[i] ,f) , 1:= i+l; end; f.close; end; create_out_file is -- List of images and their pro3ectιons. f:FILE:= f.create; f.open_for_wrιte(of.val) , f.1(inputs.sιze) .s(" ") .ι(outputs.dim) .nl; ι:INT:= 0; loop until!(ι=ιnputs.size) ; wrιte__ιmage_pro3 (ιmages_used[1] ,outputs[1] ,f) ,- 1:= i+l; .nd; f.close; end; create_weιght_ιmages (fn:STR) is -- Creates a series of PPM image files, fn.l.ppm, fn.2.ppm, etc. -- The 1'th image is the receptive field of the i'th output unit wt:MATRIX:- net.wt; f.FILE:= f.create; f.open_for_wrιte( n.s(" .matrix")) , net.save_state(f) ; f.close; MU: :scale_rows(wt) ; ι.INT:= 0; loop until!(ι=wt.nr) , ci:COLOR_IMAGE2:= ci.create_sιzed(images[0] .width, images[0] .height) , p:INT:= 0; C:INT:= 0; loop until! (p-ci.num_pιxels) ; if gr.matched then cι.red[p] := (255*wt[ι,c] ) .round.to_c; ci.green[p] := (255*wt[i,c] ) .round.to_c; ci.blue[p] := (255*wt[i,c] ) .round.to_c; c:- c+1; else ci.red[p] := (255*wt[l,c] ) .round.to_c; ci.green[p] := (255*wt[1,c+1] ) .round.to_c; ci.blue[p] := (255*wt[ι,c+2] ) .round.to_c,- c:= c+3; end; p:= p+1; end; s:STR:= fn.c('.').ι(l).s(".ppm") ; ci.save_to_raw_ppm(s) ; i:= i+l; end; end; Sep 13 15:58 1994 User: daemon; File: Standard Input; Page 5 end; -- class SCENE_PROJECT

Claims: WHAT IS CLAIMED IS 1 A method of compressing a plurality of video images, each image characterized bv a plurality of pixels, said method comprising the steps of deriving at least one parameter for said plurality of video images determining an image value for each video image for said one parameter. comparing an image value associated with each video image to an image value associated with another video image to determine a difference, and storing the plurality of image values associated with said plurality of video images without any one of the image value of said each video image and said another video image in the event said difference is below a threshold 2 The method of Claim 1 wherein said another video image is immediately adjacent in time to said each video image 3 The method of Claim 1 wherein said another video image is not adjacent in time to said each video image 4 The method of Claim 1 wherein said deriving step derives a plurality of different parameters, each of which is derived by principal component analysis 5 The method of Claim 4 wherein said principal component analysis is performed locally with a different parameter for a different portion of each video image 6 The method of Claim 4 wherein said principal component analysis is performed globally with the same parameter used for the entirety of each video image 7 The method of Claim 6 wherein said determining step determines a plurality of image values for each video image, with one image value associated with one parameter 8 The method of Claim 7 wherein said comparing step calculates said difference in accordance with where k is an index to the plurality of parameters P is the total number of parameters 'ιk 1S tne *** parameter of image value I ( I k is the k parameter of image value I Wι is a weighing factor for parameter k 9 The method of Claim 8 wherein each of said weighing factor W for all parameters k are the same 10 The method of Claim 9 wherein each of said weighing factor W k for all parameters k are not the same 1 1 The method of Claim 8 wherein l and I are image values associated with video images immediately adjacent in time 12 The method of Claim 8 wherein I and I are image values associated with video images not immediately adjacent in time 13 The method of claim 1 wherein said threshold is fixed 14 The method of claim 1 wherein said threshold is set adaptively 15 The method of claim ] wherein said one parameter is derived by discrete cosine transform 16 The method of claim 1 wherein said one parameter is derived by Gabor filters 17 The method of claim 1 wherein said one parameter is derived by wavelets 18 A method of compressing a plurality of video images into a lesser number of key images, with the number of said lesser number of key images being specified, with each image characterized by a plurality of pixels, said method comprising the steps of deriving at least one parameter for said plurality of video images, determining an image value for each video image for said one parameter, calculating a plurality of differences by comparing an image value associated with each video image to an image value associated with another video image, discarding the smallest difference, and one of the video images associated with an image value of said smallest difference, and continuing with said step of discarding until the number of video images remaining equal to said lesser number of key images 19 The method of Claim 18 wherein said another video image is immediately adjacent in time to said each video image 20 The method of Claim 18 wherein said deriving step derives a plurality of different parameters, each of which is derived by principal component analysis 21 The method of Claim 20 wherein said principal component analysis is performed locally with a different parameter for a different portion of each video image 22 The method of Claim 20 wherein said principal component analysis is performed globally with the same parameter used for the entiretv of each video image 23 The method of Claim 22 wherein said determining step determines a plurality of image values for each video image, with one image value associated with one parameter 24 The method of Claim 23 wherein said calculating step calculates said difference in accordance with = „ ∑ k d,k " >jk) 2 k= l where k is an index to the plurality of parameters P is the total number of parameters I lk is the k parameter of image value I I i is the k parameter of image value I VVi is a weighing factor for parameter k 25 The method of Claim 24 wherein each of said weighing factor Wι for all parameters k are the same 26 The method of Claim 25 wherein each of said weighing factor W for all parameters k are not the same 27 The method of Claim 24 wherein l and I are image values associated with video images immediately adjacent in time 28 The method of Claim 24 wherein I and I are image values associated with video images not immediately adjacent in time 29 The method of claim 18 wherein said one parameter is derived by discrete cosine transform 30 The method of claim 18 wherein said one parameter is derived by Gabor filters 31 The method of claim 18 wherein said one parameter is derived by wavelets 32 The method of claim 18 wherein the number of key images is specified by a user 33 The method of claim 18 wherein the number of key images is specified by a computer 34 A method of browsing by a user, a plurality of video images by compressing said plurality of video images into a lesser number of key images, with the number of said lesser number of key images being specified, with each image characterized by a plurality of pixels, said method comprising the steps of deriving at least one parameter for said plurality of video images, determining an image value for each video image for said one parameter, calculating a plurality of differences by comparing an image value associated with each video image to an image value associated with another video image, discarding the smallest difference, and one of the video images associated with an image value of said smallest difference, and continuing with said step of discarding until the number of video images remaining equal to said lesser number of key images 35 The method of claim 34 further comprising the step of displaying the video images remaining after the discarding step to said user for browsing 36 The method of claim 34 further comprising the step of printing the video images remaining after the discarding step to said user for printing 37 In a video database having a plurality of video scenes, each scene having a plurality of video images, each of said video images characterized by a plurality of pixels, a method for searching said video database to find a match to a first plurality of video images, said method comprising compressing the video images of each video scene of said video database by determining an image value for each video image for said one parameter, comparing an image value associated with each video image to an image value associated with another video image to determine a difference, storing the plurality of image values associated with said plurality of video images for said video scene without anv one of the image value of said each video image and said another video image in the event said difference is below a threshold, and comparing said image values associated with said first plurality of video images to said stored image vaiues associated with each video scene to find a match between said first plurality of video images and one of said video scenes 38 The method of Claim 37 wherein said another video image is immediately adjacent in time to said each video image 39 The method of Claim 37 wherein said another video image is not adjacent in time to said each video image 40 The method of Claim 37 wherein said deriving step derives a plurality of different parameters, each of which is derived by principal component analysis 41 The method of Claim 40 wherein said determining step determines a plurality of image values for each video image, with one image value associated with one parameter 42 The method of Claim 37 wherein said comparing step calculates said difference in accordance with where k is an index to the plurality of parameters P is the total number of parameters l. is the k parameter of image value I, 1 k is the k parameter of image value 1 Wi. is a weighing factor for parameter k 43 The method of Claim 42 wherein each of said weighing factor W k for all parameters k are the same 44 The method of Claim 42 wherein each of said weighing factor k for all parameters k are not the same 45 The method of Claim 42 wherein l j and I are image values associated with video images immediately adjacent in time 46 The method of Claim 42 wherein I and I are image values associated with video images not immediately adjacent in time 47 The method claim 37 further comprising the steps of compressing said first plurality of video images by deriving at least one parameter for said first plurality of video images, said one parameter derived by principal component analysis, determining an image value for each video image for said one parameter, comparing an image value associated with each video image to an image value associated with another video image to determine a difference, and storing the plurality of image values associated with said first plurality of video images without any one of the image value of said each video image and said another video image in the event said difference is below a threshold 48 In a video database having a plurality of video scenes, each scene having a plurality of video images, each of said video images characterized by a plurality of pixels, a method for searching said video database to find a match to a first plurality of video images, said method comprising compressing the video images of each video scene by determining an image value for each video image for said one parameter for said video scene, calculating a plurality of differences by comparing an image value associated with each v ideo image for said video scene to an image value associated with another video image of said video scene, discarding the smallest difference, and one of the video images associated with an image value of said smallest difference of said video scene, continuing with said step of discarding until the number of video images remaining equal to said lesser number of key images, storing said video images remaining and their image values, and comparing said image values associated with said first plurality of video images to said stored image values associated with each video scene to find a match between said first plurality of video images and one of said video scenes 49 The method of Claim 48 wherein said another video image for each scene is immediately adjacent in time to said each video image 50 The method of Claim 48 wherein said another video image for each scene is not adjacent in time to said each video image 51 The method of Claim 48 wherein said one parameter is derived by principal component analysis 52 The method of claim 48 further comprising the steps of compressing said first plurality of video images into a lesser number of key images, with the number of said lesser number of key images being specified by a user, by deriving at least one parameter for said first plurality of video images, determining an image value for each video image for said one parameter, calculating a plurality of differences by comparing an image value associated with each video image to an image value associated with another video image, discarding the smallest difference, and one of the video images associated with an image value of said smallest difference, continuing with said step of discarding until the number of video images remaining equal to said lesser number of key images, and storing said video images remaining and their associated image values 53 The method of claim 48 wherein said one parameter is derived by discrete cosine transform 54 The method of claim 48 wherein said one parameter is derived by Gabor filters 55 The method of claim 48 wherein said one parameter is derived by wavelets 56 A method of compressing a plurality of video images, each image characterized by a plurality of pixels, said method comprising the steps of selecting a plurality of reference video images from said plurality of video images by deriving at least one parameter for said plurality of video images, determining an image value for each video image for said one parameter, comparing an image value associated with each video image to an image value associated with another video image to determine a difference. selecting the plurality of reference video images based upon the image values associated with each of said plurality of reference video images having the larger difference comparing each video image to one of said plurality of reference video images to determine a plurality of video differences, and storing said video differences and said reference video images

Applicants: AHMAD SUBUTAI, INTERVAL RESEARCH CORP, AHMAD, SUBUTAI, INTERVAL RESEARCH CORPORATION
Application year: 1996
Main classification: G06K9
IPC codes: G06F17, G11B27, H04N5, H04N7