5
A Novel Approach of Image Morphing Based on Pixel Transformation Md. Tajmilur Rahman * , Al-Amin, M. A. Jobayer Bin Bakkre, Ahsan Raja Chowdhury and Md. Al-Amin Bhuiyan ¥ * Northern University, Dhaka, Bangladesh, e-mail: [email protected] Northern University, Dhaka, Bangladesh, e-mail: [email protected] Northern University, Dhaka, Bangladesh, e-mail: [email protected] University of Dhaka, Bangladesh, e-mail: [email protected] ¥ Jahangirnagar University, Savar, Dhaka, Bangladesh, e-mail: alamin_bhuiyan@yahoo.com Abstract — Image morphing has been the subject of much attention in recent years. It has proven to be a powerful tool for visual effects in film and television, depicting the fluid transformation of one digital image into another. This paper presents a new approach of image morphing based on pixel transformation that depicts the transformation of pixels with their neighborhoods. The method is organized with the replacement of the pixel values of a source image and convolving the neighbor with the help of a mask. This algorithm changes an image from a particular side or from the center. Experimental results demonstrate that the method is fast and efficient for image morphing. Keywords—Metamorphosis, Cross-Dissolve, Mash warping, Convolution, Pixel-transformation. I. INTRODUCTION Image metamorphosis, or morphing [1] in short, is commonly referred to as the animated transformation of one digital image to the other. Image morphing finds numerous applications in many fields including computer vision, animation, art, medical image processing and so on. Image warping can be defined as a method for deforming a digital image to different shapes. Morphing is a special effect in motion pictures and animations that changes (or morphs) one image into another through a seamless transition. Most often it is used to depict one figure turning into another through some magical or technological means or as part of a fantasy or surreal sequence. Traditionally such a depiction would be achieved through cross-dissolve techniques on film and telivision[2][3]. Since the early 1990s, this has been replaced by computer software to create more realistic transitions. This paper describes a new morphing technique: Image Morphing based on Pixel-Transformation. This method changes the pixels into the source image according to the target image by categorizing the pixels into different groups. A smart pixel-transformation is being performed with the pixels of the three groups in three different ways. While transformation, convolution with the neighbor pixels is making it smooth and fine to see how the source image is morphing into the destination image. To implement the algorithm primarily we are working with gray-scale images in pgm format, as it is easy to read the pixel values. The rest of the paper is organized as follows: Section II discusses about some existing techniques with their shortcomings. Section III describes the proposed method: Pixel-based Image Morphing. Working procedure of the proposed technique is clearly described with some illustrations in this Section. Section IV shows how an image is being changed while it has been morphed. Evaluation of the proposed technique with error calculations is presented in Section V with mathematical derivations and graphical representations. Section IV draws the conclusion of the paper. II. LITERARY REVIEW A fair amount of research works have been published in literature on morphing. Some of them are discussed in this section. A. Linear Image Morphing Linear Morphing is the transformation of linear images or morphing an image by segmenting the image into lines then transform them according to the target image. An example of Linear Morphing is shown in Fig. 1. Transformation of source image into the target image is clearly visible in Fig. 1. Here the end points of the lines are detecting first and then generating the mid points of the distance of the corresponding end points of the source and target line images, and then drawing the intermediary lines in between the distances of the end points. This is the most effective for the linear images but quite impossible to morph an image like facial or other figures. B. Cross-Dissolve Morphing Cross-Dissolve morphing [4] can be simulated using an image drawn on an elastic surface. By moving the corners of the elastic material to new positions, the image will deform accordingly. Image morphing combines image D1 D2 D2 D1 D1 ’’ Sc1 Sc2 Dc1 Dc2 D2 ’’ Fig. 1. Linear Morphing 1-4244-1551-9/07/$25.00 ©2007 IEEE.

[IEEE 2007 10th International Conference on Computer and Information Technology (ICCIT 2007) - Dhaka, Bangladesh (2007.12.27-2007.12.29)] 2007 10th International Conference on Computer

Embed Size (px)

Citation preview

Page 1: [IEEE 2007 10th International Conference on Computer and Information Technology (ICCIT 2007) - Dhaka, Bangladesh (2007.12.27-2007.12.29)] 2007 10th International Conference on Computer

A Novel Approach of Image Morphing Based on

Pixel Transformation

Md. Tajmilur Rahman*, Al-Amin, M. A. Jobayer Bin Bakkre, Ahsan Raja Chowdhury† and

Md. Al-Amin Bhuiyan¥

* Northern University, Dhaka, Bangladesh, e-mail: [email protected]

Northern University, Dhaka, Bangladesh, e-mail: [email protected]

Northern University, Dhaka, Bangladesh, e-mail: [email protected] † University of Dhaka, Bangladesh, e-mail: [email protected]

¥ Jahangirnagar University, Savar, Dhaka, Bangladesh, e-mail: [email protected]

Abstract — Image morphing has been the subject of much

attention in recent years. It has proven to be a powerful tool

for visual effects in film and television, depicting the fluid

transformation of one digital image into another. This paper

presents a new approach of image morphing based on pixel

transformation that depicts the transformation of pixels

with their neighborhoods. The method is organized with the

replacement of the pixel values of a source image and

convolving the neighbor with the help of a mask. This

algorithm changes an image from a particular side or from

the center. Experimental results demonstrate that the

method is fast and efficient for image morphing.

Keywords—Metamorphosis, Cross-Dissolve, Mash

warping, Convolution, Pixel-transformation.

I. INTRODUCTION

Image metamorphosis, or morphing [1] in short, is commonly referred to as the animated transformation of one digital image to the other. Image morphing finds numerous applications in many fields including computer vision, animation, art, medical image processing and so on. Image warping can be defined as a method for deforming a digital image to different shapes.

Morphing is a special effect in motion pictures and animations that changes (or morphs) one image into another through a seamless transition. Most often it is used to depict one figure turning into another through some magical or technological means or as part of a fantasy or surreal sequence. Traditionally such a depiction would be achieved through cross-dissolve techniques on film and telivision[2][3]. Since the early 1990s, this has been replaced by computer software to create more realistic transitions.

This paper describes a new morphing technique: Image Morphing based on Pixel-Transformation. This method changes the pixels into the source image according to the target image by categorizing the pixels into different groups. A smart pixel-transformation is being performed with the pixels of the three groups in three different ways. While transformation, convolution with the neighbor pixels is making it smooth and fine to see how the source image is morphing into the destination image. To implement the algorithm primarily we are working with gray-scale images in pgm format, as it is easy to read the pixel values.

The rest of the paper is organized as follows: Section II discusses about some existing techniques with their shortcomings. Section III describes the proposed method: Pixel-based Image Morphing. Working procedure of the proposed technique is clearly described with some illustrations in this Section. Section IV shows how an image is being changed while it has been morphed. Evaluation of the proposed technique with error calculations is presented in Section V with mathematical derivations and graphical representations. Section IV draws the conclusion of the paper.

II. LITERARY REVIEW

A fair amount of research works have been published in literature on morphing. Some of them are discussed in this section.

A. Linear Image Morphing

Linear Morphing is the transformation of linear images or morphing an image by segmenting the image into lines then transform them according to the target image. An example of Linear Morphing is shown in Fig. 1.

Transformation of source image into the target image is clearly visible in Fig. 1. Here the end points of the lines are detecting first and then generating the mid points of the distance of the corresponding end points of the source and target line images, and then drawing the intermediary lines in between the distances of the end points. This is the most effective for the linear images but quite impossible to morph an image like facial or other figures.

B. Cross-Dissolve Morphing

Cross-Dissolve morphing [4] can be simulated using an image drawn on an elastic surface. By moving the corners of the elastic material to new positions, the image will deform accordingly. Image morphing combines image

D1

D2D2

D1’

D1’’

Sc1

Sc2

Dc1 Dc2

D2’’

Fig. 1. Linear Morphing

1-4244-1551-9/07/$25.00 ©2007 IEEE.

Page 2: [IEEE 2007 10th International Conference on Computer and Information Technology (ICCIT 2007) - Dhaka, Bangladesh (2007.12.27-2007.12.29)] 2007 10th International Conference on Computer

warping with a method that controls the color transition in the intermediate images produced. To morph one image to another, new positions and color transition rates for the pixels in each of the images in the sequence must be calculated. Three processes are involved in this method (i) Feature specification, (ii) Warp generation and (iii) Transition control. The feature specification process, defines the control points to be used when the image is being warped. This is a difficult process that in most cases is performed manually. Warp generation is an algorithm that calculates and transforms the pixels in one image to new positions in the other image. Many algorithms have already been proposed to do warping. Once the pixels are in position, transition control blends in the colors between the two images. Transition control has also received a lot of attention. Originally, cross-dissolve was the color blending method of choice, but this method produced undesirable artifacts referred to as “ghosts”, shown in Fig. 2 (a-f), due to the computed warp function.

In the proposed approach we have implemented the sequential change in pixels rather than cross-dissolve. In cross-dissolve techniques the image at the half way of morphing process may be seemed to be a ghost effect or a gloomy zigzag image. Towards the target image and near source image it is little clear but seems like another image is rising up from the background.

C. Mesh Warping

Mesh warping [5] or Mesh morphing [6] was pioneered at Industrial Light & Magic (ILM) by Douglas Smythe for use in the movie Willow in 1988. Source and the target images have meshes associated with them. Mesh of the source image specifies the coordinates of control points, or landmarks. The second mesh of the target image specifies their corresponding positions in the target image. The meshes are respectively overlaid on source and target images. Landmarks such as the eyes, nose, and lips lie below corresponding grid lines in both meshes. Together, the meshes are used to define the spatial transformation that maps all points in source image onto target image.

The use of meshes for feature specification facilitates a straightforward solution for warp generation: bicubic-spline [7] interpolation but while meshes appear to be a convenient manner of specifying pairs of feature points, they are, however, sometimes cumbersome to use.

D. Field Morphing

This approach [8,9] has the benefit of being more expressive than mesh warping. For example, rather than requiring the correspondence points to all lie on a mesh,

line pairs can be drawn along the mouth, nose, eyes, and cheeks of the source and target images. Therefore only key feature points need to be given.

Although this approach simplifies the specification of feature correspondence, it complicates warp generation. This is due to the fact that all line pairs must be considered before the mapping of each source point is known. This global algorithm is slower than mesh warping, which uses bicubic interpolation to determine the mapping of all points not lying on the mesh. A more serious difficulty, though, is that unexpected displacements may be generated after the influence of all line pairs are considered at a single point. Additional line pairs must sometimes be supplied to counter the ill effects of a previous set. The mesh warping and field morphing algorithms have both been used to produce startling visual effects.

Existing Mesh warping techniques show a good distortion behavior but have a critical drawback in specifying features. They always require a control mesh on an image whose features may have an arbitrary structure.

III. PROPOSED METHOD: IMAGE MORPHING BASED ON

PIXEL-TRANSFORMATION

Pixel-based morphing is achieved by the replacement of pixel values followed by a simple neighboring operation. The algorithm first searches those pixels that differ from the target image, and then separates them into three groups according to three different conditions. After finding the pixels morphing process is initiated over the pixels that will be changed. In this stage, the method takes three pixels from each of the category and replaces the pixels according to the pixels of target image win the same location. For each of the pixel we will take a mask from the target image, which contains the pixel itself at the centre, and the eight neighborhood [10] pixels around it like as follows:

19 37 37

19 37 39

21 52 68

Then calculate a neighborhood operation like convolution in the source image, which will change the neighbors of the pixel according to the mask.

A. Process Description

Let It be the target and Is the source grayscale images, respectively, for the morphing process. The gray values for the images are shown in Fig. 3.

First of all the two images are compared to find out which pixels are to be replaced in the source image. Whenever a pixel is found where the value in the source image is not equal to the value of the destination image, that pixel should be categorized according to the three conditions.

We have defined three criteria of pixels to be considered for categorization:

The pixels those are white in the target image not in source image (C1).

Target

(f)Source

(a)

Fig. 2 (a-f). Example of cross-dissolve morphing in our

proposed approach the image will be viewed as it is

changing slowly to the target image by time.

Page 3: [IEEE 2007 10th International Conference on Computer and Information Technology (ICCIT 2007) - Dhaka, Bangladesh (2007.12.27-2007.12.29)] 2007 10th International Conference on Computer

The pixels those are white in the source image not in target image (C0).

The pixels those are of any other gray level (except 0 or 255) in target image (C).

If the pixels fall in any of the above criteria then it will be considered as the corresponding pixel-structure. Each of the structure contains the row and column address of the pixel.

After categorizing the pixels in source image according to the above criteria, if we transform the white pixels from one side and the grayscale pixels from another side in parallel then it will seem to be the white pixels are replacing by picking up the grayscale pixels and the image is rearranging according to the target image.

The starting direction for morphing process depends on the target image. If the target image is right transformed then starting will be from the left as if it seems to be transforming towards right slowly.

Replacement of the pixels can be accomplished from the central point also (shown in Fig. 4).

To establish this we must find out the mid point of the image plane and at each iteration increase towards the corners and then side pixels.

This will decrease the number of iterations but each iteration will contain the complexity:

C = N2 – 1 ……………….... (1)

where N is the number of category and C is the complexity of replacement of pixels. In the case of replacement of pixels from a side, the complexity equation reduces to:

C = N ….. (2)

For each iteration three pixels of different categories are replacing and eight neighbor pixels of each of them are getting an average value from the mask of that position from the target image and it can be said half transformed.

The equations that we have used for this calculation are:

i) For replacing pixel:

jMidiMidMaskjiY _,_, …. (3)

ii) For half-transformation:

]2

},,{[,

jiXjiMaskjiY … (4)

Since we are using mask, the marginal pixels will be replaced by using “circular” or “reflected” indexing. For circular indexing of x component if the value of x becomes less than 0 then M will be added to x where M is the width of the image, otherwise M will be subtracted from x. That is:

If x < 0 then

x = x + M Else if x >= M then

x = x - M

End If When a half transformed pixel is the neighbor of

another pixel before being replaced itself by target pixel then it will be transformed again according to Eqn. 4. This will give a smooth look to morph the pixels. The flowchart of the entire process is illustrated in Fig. 5 on the next page.

IV. EXPERIMENTS FOR ANIMATED SEQUENCE

In order to justify the effectiveness of the method, experiments were carried out with different sets of target and source images. This study examined several popular image representations, computed by local operators, and often considered relatively insensitive to illumination changes applied to face images. The animated sequence for the morphing of a human face image in the proposed algorithm is shown in Fig. 6. The source image is the first one at the top left most and the target image is the bottom right most.

(b)

Fig. 3. (a) Source Image Is and (b) Target Image It.

(a)

(a)

(b)

Fig. 4. (a) Source Image (b) Target Image (c) Direction of

Transformation

(c)

Page 4: [IEEE 2007 10th International Conference on Computer and Information Technology (ICCIT 2007) - Dhaka, Bangladesh (2007.12.27-2007.12.29)] 2007 10th International Conference on Computer

V. ERROR CALCULATION

Error is considered here as the difference of the source image and target image at each iteration. After replacing and half-transforming, in one iteration, we can find what amount of error is remaining according the following equation:

],

},,{[,

jiMask

jiYjiMaskjie …. (5)

For three pixels in each iteration total neighborhoods are 8*3 = 24 and the total error e will be:

3

0

3

0

),(i j

jiee … (6)

Average error E for each iteration is:

100*27

eE % … (7)

So error with respect to the total image:

jiT

jiYjiTjie

,

},,{, … (8)

1max_

0

1max_

0

,i

i

j

j

jiee … (9)

Total remaining error E of an image after one iteration is:

100*max_*max_ ji

etE % … (10)

Fig. 7 shows the error vs iteration graph for the Morphing process where the error is minimizing at each iteration until being 0 (when reaches to the target image).

Error vs Iteration

Iteration

Err

or

Fig. 7. Error vs Iteration Graph

Fig. 6. Sequence of morphing (top-left to right-bottom)

Fig. 5. Flowchart of the morphing algorithm

Page 5: [IEEE 2007 10th International Conference on Computer and Information Technology (ICCIT 2007) - Dhaka, Bangladesh (2007.12.27-2007.12.29)] 2007 10th International Conference on Computer

CONCLUSION

This paper presents a very simple but efficient method for morphing images. It is often useful to morph between two sequences of live action, rather than just two still images. The morph technique can easily be extended to apply to this problem. In the proposed approach, the transformation is performed according to the neighbourhoods of the pixels and hence no abrupt changes are found. This proposed method of morphing is useful and effective for those kinds of images where morphing is needed in unidirectional (Left to right, or top to bottom, or centre to margin or vice-versa). Although grayscale images are used in the proposed method, it is possible to employ color images. Our future work is to address the problems related to automation of morphing among different classes of images and video sequences.

REFERENCES

[1] G. Wolberg, “Image Morphing”, The Visual Computer Vol. 14, 360-372, 1998.

[2] G. Wolberg, “Digital Image Warping”, IEEE Computer Society Press, Los Alamitos CA, 1990.

[3] P. Litwinowicz et. el., “Animating Images with Drawings”, Proceedings of the SIGGRAPH Annual Conference on Computer Graphics, 409-412, 1994.

[4] G. Wolberg, “Recent Advances in Image Morphing”, Computer Graphics International, Pohang Korea, June 1996.

[5] S. Karungaru et. al., “Morphing face images using automatically specified features”, 46th IEEE International Midwest Symposium on Volume 2, Issue , 27-30 Dec. 2003 pp. 741 - 744 Vol. 2.

[6] W. Aaron, et al., “Multiresolution Mesh Morphing”, Proceedings of the SIGGRAPH Annual Conference on Computer Graphics, 343-350, August 1999.

[7] W. H. Flannery et.al., W. T. Numerical Recipes, “The Art of Scientific Computing, - 2nd ed.”, Cambridge, England: Cambridge University, Press, pp. 118-122, 1992.

[8] T. Nishita, et.al “Metamorphosis using Beziier clipping.”, In Proceedings of the First Pacific Conference on Computer Graphics and Applications, pp. 162-173, Seoul, Korea, 1993.

[9] T. Beier and et.al.,. “Feature-based image metamorphosis”, Computer Graphics (Proc. SIGGRAPH ’92), 26(2), pp 35–42, 1992.

[10] R. Gonzalez and et.al., “Digital Image Processing”, Addison-Wesley Publishing Company, 1992.