for i = 1 to pixels do begin
CHAPTER 4. SCAN CONVERSION AND SCALING OF IMAGES.
4"1 Introduction ;
As discussed in chapter 1, murray polygons can be used to scan rectangles of different, sizes. A rectangle can be scanned either by using horizontal murray scans or by using vertical murray scans. By a horizontal murray scan we mean that the displacement in the y-direction will only be of one unit, either increment or decrement and vice-versa. As discussed earlier, the basic direction of the scan from horizontal to vertical can be changed by making the least significant radix take value 1. Further a vertical scan can be obtained by changing the positions for the radices and the values,
corresponding to the x-part and the y-part, more detail follows.
An image represented by an n*n array of pixels would need too much space to store it in uncoded form. The exact data compression can be achieved by runlength encoding. By exact data compression we mean, to restore the same image, without any distortion from the collection of runlengths.The runlength sequences and their associated colour information are produced by scanning an image with a murray scan.The murray scan will pass through each and every pixel recording the colour information and the number of
consecutive pixels of that colour. The data can further be compressed by coding the runlengths. We can compress the data either to give the exact compression or to give an approximate compression. By approximate data compression we mean, once the data has been compressed we cannot restore the same image from the collection of runlengths. Here some of the
information is going to be lost.The runlengths can be scaled up or down as required. The only point to remember is that, if we have to scale the image in the x-direction then we will use a horizontal murray scan to scan the image and for the y-direction scaling we will use a vertical murray scan. If we want to scale an image in the x-direction as well as in the y-direction the simplest
CHAPTER 4. SCAN CONVERSION AND SCALING OF IMAGES.
way of doing it is to scale the image horizontally/vertically then draw the image on the screen using the compressed runlengths and then scan this scaled image vertically/horizontally to get the sequence of runlengths, which can be scaled in the vertical/horizontal direction. Drawipg and scanning part of the image will be time consuming, so it would be better if we only work on the runlengths without going back to the image, to get the runlengths for the another scan(i.e. vertical or horizontal). We discuss how this can be done.
In this chapter the conversion from horizontal murray scan to vertical murray scan, or vertical murray scan to horizontal murray scan, is described. We call this process scan conversion. In this chapter we will refer to horizontal murray scans as scan1 and to vertical murray scans as scan2.
Scaling the images either in one direction (i.e. x or y-direction) or in both directions is described. All the algorithms derived use only runlengths. Finally the results are compared for the different images shown in chapter 3. The language used for the algorithms Is the Outline System of PS-algol[Carrick, Cole, and Morrison(1987), and Morrison(1988)j and C[Kernighan, and
Ritchie(1978), and Kelley, and Pohl(1984)].
4-2 Scan Conveision :
Here two methods are discussed for the conversion of scant into scan2 and vice-versa. Both the methods use the murray run length encoding and
murray radices as input.The efficiency of both methods is compared for different images.The result obtained are shown in the following sections.
4-2.1 Method 1 :
Before we describe this method, we will review some of the
definitions previously defined. As shown earlier murray scans can be forced to go either in the x-direction or in the y-direction by incrementing or
CHAPTER 4. SCAN CONVERSION AND SCALING OF IMAGES.
decrementing the x-part or the y-part by one unit. This can be obtained simply by using a radix value of one. Another way of achieving this is by changing the x-part and the y-part. For example let r^, rp-i be the radices and dp .dp-i be the corresponding digits.The radix rp .i forces the scan to move rp-i steps in the x-direction whereas the next radix rp force the scan to repeat the
previous step rp times in the y-direction.If we interchange the radices i.e. Rp, Rp_1 where, Rp = rp_i and Rp_i = rp and the digits also ( i.e. Dp = dp.-j and Dp_i - dp ), then the scan will go firstly in the y-direction then in the x-direction, since all odd digits now corresponds to the y-part and all even digits corresponds to the x-part. This is discussed below.
Mathematically :
Let N be the nth point on a given scan (say scant) and,
let d = dp,dp--j ...d i be the equivalent murray integer with the radices r = rp,rp_i,...ri ^ where n = 2k and k is an integer. Now our problem is to find the corresponding mth(say) point on a second scan, i.e., scan2. Let c = Cp,Cp_i...ci be the Gray coded transformation of a murray integer d, where
G| = dj iff S dj is even, (for j = i+1, n) --- (A) = rj-1-dj otherwise
Let A = Ap,Ap_i,... A«j be the Gray coded integer where Aj = C| + i iff i rem 2 is not equal to zero --- (B)
= Cj_i otherwise
Since we have interchanged the Gray coded integer (i.e. A-j = C2, A2 = ci , etc), we also have to change the radices correspondingly .
CHAPTER 4. SCAN CONVERSION AND SCALING OF IMAGES.
,R •} be the corresponding radices such that for Let R= Rp,Rp_“j,...
each i ,
0 < - Aj < R{ where
Rj - rj + 1 iff i rem 2 is not equal to zero --- (C) = r|_i otherwise.
The two scans may now be defined as :
Scan 1
(or Horizontalscan ) :
To get a horizontal scan we will consider our x-part and y-part to take the values,
X' = Cn-i,Cn.i,... ,0-} and,
y = ^nf^n-2>... *... ' %
Now simply de-gray code x* and y* parts and then convert back to
ordinary integers giving (x,y) as expiained in chapter 2.