7. Image Processing Image processing concerns about modifying or transforming images. Applications may include enhancing an image or adding special effects to an image. Here we will learn some of the image processing functions. The description will be based on grey-scale images. However, extending the techniques to color images is usually straight-forward. Histogram Modifications - A histogram is a plot of the frequency of occurrence, p(g), against the gray level value, g. - The distribution of gray scale values affects the quality of the image. The following diagram shows some examples: (a) If most of the gray level values in an image are small, the image will be dark. (b) If most of the gray level values in an image are large, the image will be bright. (c) If most of the gray level values in an image are within a small region, the image will have a low contrast. Therefore, both (a) and (b) are also considered as low contrast images.) (d) A high contrast image has a wide range of gray level values. - Modifying the histogram by changing the frequency of occurrence of each gray scale value may improve the image quality and enhance the contrast. - Brightness Correction is used to increase the brightness of a dark image as follows: Pixel(x,y) = Pixel(x,y) + brightness Brightness correction is therefore equivalent to shifting the histogram horizontally. - Contrast Correction is used to modify the contrast of an image as follows: Pixel(x,y) = contrast * (Pixel(x,y) – gmean) + gmean Where gmean is the mean gray scale value of the original image. Hence contrast correction is equivalent to scaling the histogram. We can reduce the contrast of an image by setting the factor contrast in the above equation to a value smaller than 1 and we can increase the contrast by setting it to a value higher than 1. 1 Editing of Intensity / Color of an Image - Very often, it may be desirable to be able to edit the gray scale values in a linear as well as non-linear way. - To do this, a curve is usually provided which indicates the relationship of the original and new values. - This curve can be edited interactively by moving the control points. - For a color image composed of red, green and blue channels, three curves can be provided so that each of the channels can be modified independently. Texture Mapping Since it is still very difficult for the computer to generate realistic textures, a method called texture mapping is developed in which a photograph of real texture is input into the computer and mapped onto the object surface to create the texture for the object. - Texture pattern is defined in an MxN array of texels or a texture map indiced by (u,v) coordinates. - For each pixel in the display: - Map the 4 corners of pixel back to the object surface (for curved surfaces, these 4 points define a surface patch) - Map the surface patch onto the texture map (this mapping computes the source area in the texture map) - The pixel values is modified by weighted sum of the texels' color. Warping - Warping is the use of image mapping functions to produce geometric distortions of images. - The basic technique is that the user specifies the contour of the object in the image to be transformed and the final contour that the object is to fit into. - A texture mapping operation is performed to map the source object into the destination shape. 2 CS3162 Introduction to Computer Graphics Helena Wong, 2001 Morphing - Morphing is used to provide a smooth transition from one image to another and thus create an illusion of image transformation. - A simple morphing may use a fade or dissolve process that gradually decreases the contribution of the source image to the output image while increases the contribution of the destination image as follows: - Depending on applications, the decrement (or increment) in contribution of the source (or destination) image into the final image may not have to be linear as in the diagram. - More advanced morphing techniques may use a warping process in addition to the fade / dissolve to slowly bring into alignment the shapes of the start and end pictures. 3