Appendix a Basic Functions
Total Page:16
File Type:pdf, Size:1020Kb
Appendix A Basic Functions Illustrations Photographs are provided at the end of this Appendix to illustrate many of these basic functions. The presence of such photographs will be indicated by the symbol "§§" after the command name. Notation • The current image has intensities A(i, j), 1 ~ i ~ ISIZE and 1 ~ j ~ JSIZE. • All A(i, j) are limited to the range 0 ~ A(i, j) ~ W. • W denotes white. Black is represented by 0 (zero). • The alternate image has intensities B(i, j), where 1 ~ i ~ ISIZE and 1 ~ j ~ JSIZE and is defined in a similar way to the current image. • In some instances, it is helpful to define a third image {C(i, j) I 1 ~ i ~ ISIZE, 1 ~ j ~ JsIZE} which is also defined in a way similar to the current image. • In cenam cases, it is ,renient ruse tbe{fllOWing simplified notation. Let denote the following 3 by 3 window in the current image, {A(i, j)}: A(i-1,j -1) A(i-1,j) A(i-1,j + 1) A(i, j - 1) A(i, j) A(i, j + 1) A(i+1,j-1) A(i+1,j) A(i+1,j+1) • The current and alternate images are displayed with the i (or x) axis vertical and the j (or y) axis horizontal. See Figure A.l. • When we consider binary image 1 2 --j---'" n processing operators, p, q, r, s, t, 1 u, v, w, x are binary variables and indicate whether or not those nine 2 pixels immediately surrounding and including the (i, j)th pixel in I the current image are black or • I· • i white. We shall allow t = A(i, j) to I • ~ • assume the value 1 (logical value l • • • TRUE, or arithmetic value unity), or 0 (logical value FALSE, or arithmetic value zero). Similarly m for p, q, r, s, u, v, w and x. • The contents of register X will be Figure A.1 Image geometry, the point (i,j) denoted by R(X). (hatched) and its 8-neighbors (spots). 166 Interactive Image Processing • The simple scalar assignment operator will be denoted by +- . • The operator ¢:: denotes a parallel assignment, performed over a 2- dimensional image~ For example, B(i, j) ¢:: A(i, j) + 100 indicates that B(i, j) is computed by adding 100 to the corresponding term A(i, j). All assignments could be performed in parallel. • Arguments of the image processing operators are denoted by aI, a2, ... , etc. • The logical AND operator will be denoted by ® and the OR operator bye, while x represents the logical inverse of x. • SWITCH indicates that the current and alternate images are interchanged. This is done by changing their labels, not the contents of the image stores. IsIZE JslZE IsIZE JSIZE • The summations 1: u 1: u and 1: 1: u i=l i=l i=l i=l will be denoted by the shorthand notation 1: u 1: u and 1: u. i i,j .L LABEL Format .L a1 Argument a1 - Integer Default None Function Thfs function does not alter any system variables. It serves merely as a label, to mark the destination for one of the various jump commands. Also See JC, JF, Jp, IT AA ASPECT ADJUST §§ Format AA a1,a2,a3 Arguments a1 - 0, to adjust the image aspect ratio; 1, to perform the inverse adjustment a2, a3 - together define the aspect ratio Defaults a1 =0; a2 =a3 = 1 initially Thereafter, (a2, a3) =last previously defined values Function AA adjusts the image geometry, by rescaling the vertical (i) axis in the aspect ratio a2:a3. If al = 1 then the image height is adjusted in the inverse ratio, a3:a2. Operates On The current image. The alternate image is overwritten and fmally the images are switched Typical Use To compensate for non-square pixels, which occur as a result of the frame-store sampling the video signal at the wrong frequency. (Many frame stores produce pixels with an aspect ratio of 4:3, in order to sample a complete 1V field.) Definition If a1 = 1, B(i, j) ¢:: A(i· [a2/a3], j) If a1 = 0, B(i, j) ¢:: A(i· [a3/a2], j) Followed by SWITCH. See Figure A.2 Appendix A: Basic Commands 167 = 4 units ....,~~~r_____ Le __ n_g_th~= __ 4_un_i_ts __ ~~1 i i: 128 p""k "I Length = Length = 3 units, 3 units 128 Data 'lost' "Jr" __________________ -' ~ Inappropriate sampling method L Preferred method Figure A.2 AA is often used to compensate for the 4:3 aspect ratio caused by sampling the image so that the pixels are not square. Manufacturers of frame stores frequently make the mistake of sampling the complete video image. As a result, a digitized circle has a different number of pixels along vertical and horizontal diameters. It is better to abandon the edges of the picture in order to obtain square pixels. The operator AA can adjust the aspect ratio, so that the pixels become square. AB - ABSOLUTE INTENSITY §§ Format AB Arguments None Output intensity Function AB replaces each pixel intensity less than half-white by white W minus that pixel intensity. All values greater than or equal to half-white are unchanged. W/2 ....... Operates On The current image. The alternate image is overwritten and finally Input intensity the images are switched. WI2 Definition W B(i, j) <= I A(i, j) - W/2 I + W/2 Figure A.3 Intensity mapping function used by AB Followed by SWITCH. See Figure A.3. AC - IMAGE SHIFT AND ACCUMULATE Format AC a1,a2,a3,a4 Arguments a1 - shift in the i direction a2 - shift in the j direction a3 - expected value a4 - weight Defaults a2 =0; a4 = 1 Function For each (i, j), the pixel intensity in the current image at position [(i+a1),(j+a2)] is compared to the expected value, a3. If they are equal, the pixel intensity in the alternate image at (i, j) is incremented by a4. Operates On The current image. The alternate image is modified. (There is no switching of the images.) 168 Interactive Image Processing Typical Use Successive calls to AC can be used to implement an N-tuple. The advantage of AC over NT is that the former allows data-dependent ftltering to be achiev~d. For example, the values of al and a2 could be altered between successive calls to AC. Definition B(' .) [B(i, j) + a4, A«i + al), G+ a2» = a3 1, J ~ B(i, j), otherwise There is no SWITCH. See Figure A.4. Input Image j Output Image j , ----a2.--.-', al -----iI Weighta3 Figure A.4 The command AC resembles an N-tuple operator with N = 1. While NT can implement an N-tuple operator in a single operation, successive calls to AC are needed to achieve the same result. However, very large N-tuples can implemented (slowly) using AC. AD - ADD Two IMAGES §§ Format ADal Arguments al - Specifies the mode Default al =0 Function The intensity of each pixel in the current image is added to that of the corresponding point in the alternate image. Two modes of addition are dermed, with and without rescaling. Operates On The current and the alternate images. The alternate image is overwritten and finally the images are switched. Definition B(i, j) => [A(i, j); B(i, j~ if al =O. B(i, j) => A(i, j) + B(i, j) ifal =1. In either case, the process concludes with a SWITCH. AL - ANGLE OF LINE Format AI.. al,a2,a3,a4,a5,a6 Arguments al - i coordinate, point 1 a2 - j coordinate, point 1 a3 - i coordinate, point 2 a4 - j coordinate, point 2 a5 - output register, angle of angle a6 - output register, length of line Appendix A: Basic Commands 169 Defaults as = 0 for output on VDU; a6 = -I for no output Function AL calculates the orientation and ,.---....-----.a2 a4 length of that line joining the points (al,a2) and (a3,a4). The orientation is measured in · . al ..... ~. tenths of a degree and is referred to the · . "Southerly" direction (vertically downward). a3 ..... : ..... ' The orientation measurement is placed in the · R(aS) register defined by as. The length of the line is Figure A.5 Geometry placed in the register defined by a6. of the command AL Definition R(a5) f 10' tan-I eft =:f] + 90' [I - SGN(a2 - a4)] R(a6) f- -V (at - a3)2 + (a2 - a4)2 See Figure A.5. AN - AVERAGE OF N FRAMES Format AN al Arguments at - The value 2a1 gives the number of video fields averaged Default al =2 Function AN digitizes 2a1 video fields in quick succession and averages them to give a single image. The averaged image is placed in the current image. Since it is necessary to hold two images during the execution of AN, the alternate image is overwritten. Typical use To reduce camera noise. The signal to noise ratio of the image is improved considerably by using AN, compared to DG. .Remarks The standard interlaced television signal comprises distinct fields (called odd and even). It is important that the averaging is performed using only even (or only odd) fields, as some cameras, most notably the pyro electric vidicon, generate quite different signals on the alternate fields. Definition Let K(h, i, j) denote the (i, j) pixel in the hth field averaged. 2a1 A(i, j) ~ L K(h, i, j) h=1 Also See DG AT ADAPTIVE THRESHOLD §§ Format AT at,a2,a3,a4 Arguments at - Minimum contrast, below which thresholding is inhibited. (0 :S at :S 255) a2 - Size of the sliding window.