IV. ANÁLISIS Y DESARROLLO
4.3 Metodología SCRUM
One way of superimposing one image on top of another Is to copy the changed part on to the image. This expression will persist so long as it is on the screen. There will be no change in the runlengths. Next time to obtain this changed plane, we have to do the same calculations again. This is not
convenient for an animated movie where we have to run, say 20 frames a second to get the moving expression. Another way of superimposing one image on top of another is to copy the changed part in such a way that the previous runlengths will change to give the sequence of runlengths for the new plane.
Here we present a algorithm which has the capability of superimposing one image on top of another by changing the runlengths. The only information which is required is the size of the image which is going to be superimposed and the starting point on the image where it is going to be superimposed. The starting point can be obtained with the help of the function lo cato r' which gives the position of the mouse relative to the screen. The size of the image is required to decide about the x and the y-radices.
Both the images (say A and 8) are stored in the database, whereas image A is the initial image and image B is going to be superimposed on image A. Initially image A will be scanned using a murray scan and the corresponding sequence of runlengths will then be stored either In the database or in a file. The algorithm will now take image B and the runlengths corresponding to image A as an input. Output will be the collection of runlengths corresponding to image A with image B superimposed on it. We will discuss this in the next section. Once the desired runlengths have been obtained, the image can be
CHAPTER 5. SUPERIMPOSITION, AND SET OPERATIONS ON IMAGES.
drawn on the screen. The data structure used to store the runlengths and the Implementation part is discussed in the next section.
3-3.1 Implementation :
Consider two images of different sizes as shown,
(X,Y)
(xgyâ
(0,0) (x,y) (0,0) wherey
2y f
y
Xg- x^=xwhere 'a' is the initial image and 'c' is the image which has to be superimposed on the image 'a'. The position where the image has to be superimposed has been marked. Let (x-j.y-j) be the starting point in an image 'a' for the image 'o' to be superimposed. Our first step Is to scan the image ’a' to give the sequence of runlengths. The image ’a’ can be removed once we have obtained the
corresponding runlengths. The image 'c' can similarly be removed once
scanned, and the corresponding runlengths can be used to superimpose 'c' on 'a'. But the scanning part and the superimposition part, of 'o' on *a‘ can be done simultaneously, which is discussed later. Time can be saved by not rescanning the image ’c'. The data structure used for the list to store the runlengths is same as used before. We define our data structure as,
structure integer.list(int runlength, Sum ;string colour;pntr left,next) The linked list obtained after scanning the image 'a' uses the above structure to store the runlengths. Each cell contains information about the
CHAPTER 5. SUPERIMPOSITION, AND SET OPERATIONS ON IMAGES.
consecutive pixels of the same colour. All the items used in the data structure are discussed in chapter 4 .
Let r-i, rg, r^ be the runlengths corresponding to the image 'a' . Each runlength corresponds to a colour. The colour information for each runlength is given in the item ’colour* defined in the structure. Since we are considering black and white images, the item ’colour’ contains either 'w' i.e., white or 'b' i.e. black, as the two values. The linked list is as shown,
Consider the image *c' which has to be superimposed on image 'a'. We will scan this image using a murray scan. The first point on this image is
(x,y) = (0,0). But since the starting point for the image 'c' on the image 'a’ is ( x i, y i ) , we will shift this point by (x-j.y-j) i.e., the new values for the
x-coordinates and the y-coordinates will be given as, x(fin al) = X + x-j = 0 +x^ = x-j y (fin a l) = y + y-j * 0 +y-j = yi
Using the transformation f(x,y) — > n (discussed earlier), we can find the corresponding nth point on the image 'a*. Now scan the list obtained for image 'a' and consider that cell where this nth point belongs. The colour on both the images will now be compared.
If the colour corresponding to the initial point (x,y) (= (0,0), say) in image 'c' and the colour corresponding to the final point (x,y) in an image 'a* is black then there will be no change in the list.
CHAPTER 5. SUPERIMPOSITION, AND SET OPERATIONS ON IMAGES.
If the colour corresponding to a point in image 'c' is black and the colour corresponding to the point (x,y) in an image ’a' is white then we will change the runlengths by turning that pixel to black.
If the colour corresponding to a point in image 'c' is white then there is no need to consider that point.
For all the points in an image 'o', which are black we will repeat the above scheme. The output will be another frame (or image) with the slight change, in comparison to the previous one. This method is similar to finding a union between two images. Set operations are discussed in the next section.
5.4 Set Operations Using Mmxay Polygons :
The set operations which are considered in this section are, i. Union,
ii. Intersection, iii. Difference.
If A and B are two images which are black and white , then we define,
A U B = the set of all the black pixels which are In A as well as In image B
a Q B = the set of all the black pixels which are common in image A
and in image B.
CHAPTER 5. SUPERIMPOSITION, AND SET OPERATIONS ON IMAGES.
A A B = (A U B) - (A n B),
i.e. the set of ail the black pixels which are in A and in B except those which are common to both the images. The images can be merged either by using the images themself or by using the different sets of runlengths obtained by scanning the different images. In the first case, the whole image must be in the system while processing. This will require a large amount of memory for images having a few thousand surfaces(or planes). Secondly it can be time consuming, since we have to compare each pixel of an image to the other one. A second approach can be more efficient than the first one. We do not require all the planes at the same time. Here we scan the planes one by one to get the sequences of runlengths, and then merge them together to give a single sequence of runlengths. The points to be remembered are that the size of aH the Jrnages should be same. The x-radices and the y-radices can be same or different for all the images. This is discussed later on.
5-4.1 Union :
Let r = r*|,r2,... .r^ and s = s^.sg...s ^ be the collection of runlengths corresponding to the two images which we have to merge. The radices used to scan the images should be same. Here our problem is to obtain the sequence t = t-) ,t2, ,t|; such that the sequence t has black runlengths where either the sequence r or the sequence s or the both sequences have black runlengths.
Now to obtain the sequence t we will traverse both the sequences r and s together. Three cases are possible between the two sequences r and s.They are,