<<

ADVANCEMENT IN COLOR PROCESSING USING

Biswajit Mishra, Peter Wilson and Bashir M. Al-Hashimi Electronic Systems and Devices, University Of Southampton Highfield, SO17 1BJ, Southampton, United Kingdom phone: + (44) 238059 6665, fax: + (44) 238059 2901, email: {bm2,prw,bmah}@ecs.soton.ac.uk web: www.ecs.soton.ac.uk

ABSTRACT to the uncorrelated monochrome techniques applied to the Due to the compact representation of vectors within n dimen- three correlated color channels. For example to smooth along sional space Geometric Algebra (GA) is a preferred frame- a particular color component within the image, component- work for signal representation and image representation. In wise filtering will give an incorrect result. The reason is due this context the R, G, B color channels are not defined sep- to the nonlinear filtering of the smoothing operation. With arately but as a single entity. As GA provides a rich of component-wise filtering the median pixel resulting from operations, the signal and image processing operations be- each component-wise operation may not yield the same me- comes straightforward and the algorithms intuitive. From dian pixel on each color plane (R, G or B) and hence the the experiments it is also concluded that the convolution op- results may contain noise and/or incorrect pixel value. But eration with the rotor masks within GA belong to a class of with median filter [4], the operation picks the correct pixel linear vector filters and can be applied to image or speech sig- because it chooses the correct median value of the pixel us- nals. The usefulness of the introduced approach was demon- ing the distance information as it treats the color as a 3D strated by analyzing and implementing two different types of vector. There also exist alternative methods where vector edge detection schemes. methods are used for non linear filtering [5] operations which give better results and is preferred to component wise filter- 1. INTRODUCTION ing. In this paper, a new method using Geometric Algebra is discussed which defines color as a single vector entity for Over the past few years, there has been a significant progress color image processing. Based on it a linear filter is proposed in color image processing [1] [2] [3]. Color signal represen- which is applied to edge detection algorithms. tations also have undergone a sea change from being mere al- This paper is organized as follows: Section 2 discusses gebraic equations and representation to more sophisti- some previous work on vector filtering methods. Geometric cated vector valued representation. This is because the color Algebra (GA) is introduced in Section 3. In Section 4, the image consists of three color planes in RGB and is inher- concepts of rotations and rotors in GA are discussed. In Sec- ently vector in nature. Therefore for color images the vec- tion 5 the color is defined as a single entity as a vector con- tor valued image processing techniques are more suitable. sisting of the individual elements of the defined Though these techniques are crucial and appropriate, are not within GA. The physical significance of the transformation very popular because of the complexity and lack of a unified of the color space is derived and discussed in Section 6. Two framework. They rely on image processing functions different edge detection techniques using GA are discussed based on monochrome techniques. in Section 7. Finally in Section 8, the results are summarized. The RGB color vector has a magnitude and direction and hence can be represented as an entity having a luminance 2. COLOR IMAGE PROCESSING AND VECTOR and chrominance component. However this is not a direct FILTERING conversion and involves a transformation of one (RGB) to another vector space (Hue-Saturation-Intensity or The standard technique to identify the critical features of the HSI) and the transformation is nonlinear in nature. Most of image in image processing applications is to use the rota- the conversions within the color space are lossy conversions tional and curvature properties of the vector fields [6]. There- due to this nonlinearity, so the algorithms are not portable fore, the convolution and correlation techniques are quite and use a lot of vector and complex vector multi- common to image processing algorithms on scalar fields. plications that also pose fundamental limitation. These techniques have been extended to vector fields for vi- In both gray scale and color images edge detection is sualization, signal analysis and applications such as detection one of the most basic operation in image processing. The of patterns within DNA images [2]. Independently in [7], the edge in gray scale images is defined in an achromatic way as author developed a hypercomplex fourier transform of a vec- the discontinuity in the brightness . The color edge tor field for image processing. This was extended in [8] [9] is an extension to this i.e. to find the discontinuities along for image processing by GA methods. In [10] the authors the adjacent regions of a color image in the 3D color space have developed the GA or Clifford convolution fourier trans- dependent on some function of metric distance of the color form method for pattern matching on vector fields which space, some function of merging of the derived edges and are used for visualization of 3D vector field flows. It has some function of imposing uniformity constraints to utilize been shown that the conventional feature detection fourier all three independent edges concurrently. However, the fun- methods based on scalar techniques are simple extensions of damental problem associated with color edge detection is due fourier transforms based on GA. It has also been proven in these works that the GA convolution techniques are superior a multivector and is called a rotational element or Rotor and because of the unified notation for convolution of scalar, vec- satisfies RR˜ = 1, where R˜ is the conjugate of R. The equation tor and multivector fields. RaR˜ works for any , any grade and any objects. Therefore taking only the scalar and parts, a gen- 3. GEOMETRIC ALGEBRA IN 3D eral rotation in 3-D can be written as shown in eqn (1):

This section describes the basics of GA in 3D. Expressions θ θ θ within GA embed and extend existing theories and meth- R = exp(n ) = cos + nsin (1) ods to express geometric relations without the need for spe- 2 2 2 cial case considerations in higher dimensions with simple yet where θ represents a rotation about an axis parallel to unit powerful techniques [11] [12] [13]. vector n and the rotation axis n is given by: n1e2e3 +n2e3e1 + E3 Let the space be defined by the or- n3e1e2 is spanned by the bivector . thonormal basis vectors e1,e2 and e3. In GA this 3D space in 3 E can be decomposed into a linear space spanned by the 5. COLOR AS A VECTOR following elements 1,e1,e2,e3,e1 ∧ e2,e2 ∧ e3,e3 ∧ e1,e1 ∧ 3 e2 ∧ e3 in G . The individual element of this linear sub- It is fair to assume that the human eye doesn’t process differ- space are called the blades and the elements of the algebra ent colors in RGB images (fig 1) separately but processes like are . The signifies the subspace i.e scalar, a continuous vector valued approach in the 3-D Euclidean vector or bivector. Hence the linear subspace consists of space. In this regard the bivector representation of color vec- a scalar (1) a 0 grade blade element, vectors (e1,e2,e3) 1 tors in GA fits neatly for the 3-D . Then the T grade blade element, bivector (e1 ∧ e2, e2 ∧ e3, e3 ∧ e1) a 2 color information of (r,g,b) vector of the color image cm,n grade blade element (the directed area segment formed from can be written as: sweeping e1 along e2 for e1 ∧ e2 which has orientation and is a 2-dimensional subspace.) and e1 ∧ e2 ∧ e3 a trivector or cm,n = rm,ne2e3 + gm,ne3e1 + bm,ne1e2. (2) the pseudoscalar. The collection of the subspaces define the 3 complete space in G . The multiplication is associative, bi- where rm,n, gm,n and bm,n are the RGB vectors of the image linear and is defined by the following rules: cm,n. Alternately, the following analysis and derivations in the next few sections holds good for the color vector cm,n = 1ei = 1ei; eiei = 1; eie j = −e jei rm,ne1 + gm,ne2 + bm,ne3 definition. In GA it is possible to add different grade vectors to form a multivector. This reveals a great power within it by ex- pressing the different grade vectors in a single product. For Upper(Color) = Upper (Red, Green, Blue) example, the multivectors in G2 in E2 would be the of the blades and will contain a scalar, vector Convolution and bivector parts: Mask Lower(Red)

a0 +a1e1 + a2e2 +a3e1 ∧ e2 Pixel |{z} | {z } | {z } scalar vector bivector In GA the multiplication of any two vectors (or multivec- tor) a and b yields the geometric product given by: ab = a · b + a ∧ b. which consists of the inner product(or dot prod- Figure 1: R-G-B plane uct) and the . It gives the information about the magnitude and orientation of the vector. For example, if a and b are collinear, then a ∧ b = 0 and the geometric product 6. TRANSFORMATION AND DIFFERENCE which now has only the , gives the magnitude of SUBSPACE the vectors. If a and b are perpendicular, then a · b = 0, the geometric product now consisting of only the outer product Though most of the algorithms extend the conventional gray a∧b gives the orientation of the bivector. If the vectors a and scale algorithms to the color images, very few have treated b are neither of the two extremes then the geometric product color as a vector or a single entity. In this paper the color will give information something in between. In essence this is defined as a single entity (eqn 2) and treat the image as is the most important element of this algebra and all the other a superset of this entity. Therefore the color edge detection meaningful operations are derived from this geometric prod- and image processing algorithms with this type of approach uct. becomes straightforward and intuitive. Let µ be the rotation axis spanned by the bivector basis 4. ROTATIONS IN THE GEOMETRIC ALGEBRA e1e2 + e2e3 + e3e1 in the color cube (fig 2) given by: 3-D SPACE µ = e1e2 + e2e3 + e3e1 The rotations in GA are represented by a pair of reflections. For any vector a reflected in a plane perpendicular to an unit For a unit transformation on the color vector the normalized vector n is −nan and followed by another reflection in an- color representation is chosen. This ensures that the orienta- other plane perpendicular to m results in another vector given tion information is kept while the distance information is nor- by −m(−nan)m = (mn)a(nm) = RaR˜ [14]. This product R is malized. For a unit transformation on the normalized color, the rotation vector is given by: If the color vector is homogeneous then of two trans- forms equates to: 1 e12 + e23 + e31 R = cosθ + √ µ sinθ = cosθ + √ sinθ 2 3 3 RCR˜ + R˜ CR = µ(r + g + b) (5) 1 e + e + e 3 R˜ = cosθ − √ µ sinθ = cosθ − 12 √23 31 sinθ 3 3 which yields the equation for the intensity of the image. Subtracting the two transforms gives: These rotations given by R and R˜ rotates any vector by an angle θ in 3D about an axis parallel to the rotation axis. 2 RCR˜ − R˜ CR = √ [(b − g)e23 + (r − b)e31 + (g − r)e12] (6) Hence the unit transformation or the convolution operation 3 on a color element C is given by: which is the difference of the color vector in the image or the 1 1 change in chromaticity or shift in hue. RCR˜ = (cθ + √ µsθ)(C)(cθ − √ µsθ) 3 3 From the above it can be concluded that if the color vec- tors are different in both the unit transformations then they cθsθ cθsθ s2θ = c2θ(C)− √ (C)µ + √ µ(C)+ √ µ(C)µ don’t cancel out and that would result in a hue or chromatic | {z } 3 3 3 shift. On the other hand if the color is same then only the I | {z } | {z } | {z } II III IV intensity component will be left out. This phenomenon gen- erates edges where sharp changes of color occurs. where C = re23 + ge31 + be12 and cθ, sθ is cosθ and sinθ respectively. 7. EXPERIMENTAL RESULTS The part of II in the above equation simplifies to 7.1 Color Difference Edge Detection by Rotor Convolu- −r − g − b − (b − g)e23 − (r − b)e31 − (g − r)e12 tion The edge detection process involves convolving masks and similarly the part of III equates to mL(x,y) (for left) and mR(x,y) (for right) of the size X ×Y with the image c(m,n) of dimension (m×n). In a rotor based −r − g − b + (b − g)e + (r − b)e + (g − r)e 23 31 12 approach the convolution involves the geometric product of Finally, the part IV equates to the vector with the rotor as shown in the convolution eqn 7: X−1Y−1 re23 + ge31 + be12 − 2(re31 + re12 + ge23 + ge12 + be23 + be31) cˆ(m,n) = ∑ ∑ mL[x,y]c[m − x,n − y]mR[x,y] (7) Putting it altogether, eqn 3 reduces to as follows: x=0 y=0 The horizontal left and right masks for the rotor convolution 2 2 cos2θ(re23 + ge31 + be12)+ sin θ µ(r + g + b) are defined in eqn 8. The vertical masks are obtained by | {z } 3 interchanging the rows and columns. A | {z } B 1 " RRR # " R˜ R˜ R˜ # + √ sin2θ[(b − g)e23 + (r − b)e31 + (g − r)e12] mL = 0 0 0 , mR = 0 0 0 (8) 3 ˜ ˜ ˜ | {z } R R R RRR C And the rotors are given by: The first element ‘A’ of the above equation is the RGB space component, the second element ‘B’ is the intensity compo- R = senπ/4 = s[cos(π/4) + nsin(π/4)] (9) nent and ‘C’ element is the color difference or the projection of the tristimuli in the Maxwell triangle. This is also known where n is the unit vector and is given by: n = (e2e3 +e3e1 + as the chromaticity (due to hue and saturation) of the vector. √ √ e1e2)/ 3 and s = 1/ 6 is the scale factor. Interestingly from the above equations if we rotate the As shown in the fig 2 the color vector is split into two = π vector by an angle θ 4 , the above equation reduces to components, (c is the component parallel to the gray axis only two components as shown in eqn 3 and eqn 4, where k and the perpendicular component is c⊥). When the masks the space component ‘A’ is cancelled. This transformation are applied on the color vector only the perpendicular com- is similar to a RGB space being transformed to an HSI like ponent c⊥ is affected but the parallel component ck is un- space and the remaining two components describes the lumi- changed [14]. After the convolution the perpendicular com- = π nance and chrominance of the image. For θ 4 ponent is rotated by an amount specified by the rotor R and by an angle 2θ. As R is a rotor in a right hand screw sense, the 1 1 RCR˜ = µ(r + g + b) + √ [(b − g)e + (r − b)e + (g − r)e ] (3) 3 3 23 31 12 rotor RaR˜ would rotate the color vector by the same amount | {z } | {z } luminance chrominance as would the rotor RaR˜ by the same amount but opposite in direction. Hence, if the color vectors are homogeneous then and similarly the opposite rotation is given by: after the masks are applied, both the components would can- cel out (as derived in eqn 5) and the pixel point would fall 1 1 R˜ CR = µ(r + g + b) − √ [(b − g)e + (r − b)e + (g − r)e ] (4) 3 3 23 31 12 somewhere on the gray axis or simply perceived as the in- | {z } | {z } luminance chrominance tensity of the image. However if the color components are Green White c 50 2⊥

| |

_

2 c c 100 1⊥ | | 2 _ c 1 c 150 c 1 Blue

200

Black Red 50 100 150 200 Figure 2: RGB vectors and the Color Cube. Figure 4: Color Blocks after rotor convolution. not homogeneous then the color vector will be rotated by an unequal amount by the two rotors. Thus the resultant vector 50 would lie somewhere else in the color cube, and not on the gray axis(eqn 6). As shown in fig 3 the rotor convolution was applied on 100 the test image of the “color blocks”1 which has an 8 × 8 ar- ray of colored squares. The result of the filtered image is 150 shown in fig 4. As discussed above, the filtered image has gray areas where the squares had uniform color and colored areas where there was a change of color between the blocks. 200 As only the horizontal masks are applied the change in color is only seen on the horizontal edges. Also the edges between the black and white blocks remain gray but the edges change 50 100 150 200 to color where there was a color difference across the edge. This is because the rotor masks would cancel out the homo- Figure 5: Lenna Image after Rotor Convolution. geneous components resulting in gray axis and have a color component present if the color components are not homoge- neous(as in eqn 5 and eqn 6). This signifies the operation 7.2 Color Sensitive Edge Detection - Red to Blue As discussed in the previous section, the rotor edge detec- tion method detects only the chromatic edges. In this sec- tion detection of homogeneous regions of particular colors C C 50 ( 1 → 2) is discussed. Here the edges between these two colors are determined by the rotor methods. Only synthetic images are considered to demonstrate the feasibility of the 100 technique on synthetic images. For natural images the crite- rion is slightly different but is a straightforward extension to the synthetic technique. 150 For this example, a unit bivector basis is considered which preserves the orientation information of the vec- 200 tor. For example, let C1 be a color vector then µC1 is a normalized color vector of C1 where µ is given by µ = e e +e e +e e 2 3 √3 1 1 2 . 250 3 50 100 150 200 250 To find the discontinuity between two regions C1 to C2 the convolution uses the following rotor filter. Figure 3: Original Color Block.

1 h µC1 µC1 µC1 i 1 h 1 1 1 i mL = √ 0 0 0 , mR = √ 0 0 0 (10) is a shift in hue (chromaticity) of the image. This type of 6 1 1 1 6 µC2 µC2 µC2 change can also be observed on the filtered images of stan- dard lenna (fig 5). The areas where the color change was flat For the convolution operation, the RGB image is converted or smoothly varying, the filtered image became grayish, oth- to a format where the GA operations can be understood. erwise colors can be observed in regions like the top edges This convolution operation on an image c(m × n) is given by of the hat of the image. eqn 7. This results in convolution operation giving non-zero scalar part and zero vector part in special cases. For exam- ple, if the masks are multiplied with the following image part 1 taken from http://privatewww.essex.ac.uk/sjs/research/colour˜ test images.html (see fig 6) where C1 = e2e3(red) and C2 = e3e1(blue) then; if µC1 = e2e3 and µC2 = e3e1, then the convolution equation detection algorithm. The discussion also touches upon the 1 qualitative analysis of the edge detection algorithm by GA would result in a scalar value 6 (−3 − 3) = −1 or generally 1 methods. is expressed as 2 (|C1| + |C2|). REFERENCES

C C C µ µ µ 1 1 1 C1 C1 C1 1 1 1 [1] A.Koschan and M.Abidi, “Detection and classification C C C 1 1 1 IEEE Signal Processing 1 0 0 0 X X 0 0 0 of edges in color images,” C C C 2 2 2 Magazine, vol. 22, no. 1, 2005. 1 1 1 µ µ µ 6 C2 C2 C2 [2] R.Lukac, B.Smolka, K.Martin, K.N.Plataniotis, and Left mask Part of the Image Right mask A.N.Venetsanopoulos, “Vector Filtering for Colour Imaging,” IEEE Signal Processing Magazine, vol. 22, no. 1, pp. 74–86, 2005. Figure 6: Red to Blue, Convolution by left and right mask [3] H. J. Trussel, E. Saber, and M. Vrhel, “Color image pro- cessing,” IEEE Signal Processing Magazine, vol. 22, This is where the pixel values will have a non zero scalar no. 1, 2005. value and zero vector value. The scalar value is the intensity of the pixel due to the convolution and is the whiter regions [4] J.Astola, P.Haavisto, and Y.Neuovo, “Vector Median shown in fig 7 at the step edges. In all other places of the Filters,” Proceedings of the IEEE, vol. 78, no. 4, 1990. image the scalar and vector will have non zero value. In fig [5] P.E.Trahanias and A.N.Venetsanopoulos, “Color edge 7, only the scalar values are plotted and the vector values are detection using vector order statistics,” IEEE Transac- ignored to simplify the discussion. tions on Image Processing, vol. 2, no. 2, 1993. As shown in fig 4 there is only one region near (6,6) [6] R. Machuca and K. Phillips, “Applications of Vector block where the red to blue (C1 →C2) color transition occurs. Fields to Image Processing,” IEEE Trans. Pattern Anal. When convolving with the mask (eqn 10) the vector part will Mach. Intell., vol. 5, no. 3, pp. 316–329, 1983. be zero in this region resulting in brightest pixel due to scalar [7] S.J.Sangwine, “Fourier transforms of colour images us- values (see fig 7 marked region). These white pixels show the ing quaternion or hypercomplex numbers,” IEE Elec- red to blue transition. The color mask convolution will have tronics Letters, vol. 32, no. 21, pp. 1979–1980, 1996. a different result when the color transition (e.g. C2 → C1) is opposite. Also the varying degree of the pixel brightness, [8] E.Bayro-Corrochano and S.Flores, “Color Edge Detec- light and dark gray, in other block edges is due to the varying tion Using Rotors,” in Applications of Geometric Al- degree of red and blue components present. gebras in Computer Science and Engineering, C. D. Leo Dorst and J. Lasenby, Eds. Birkhauser,¨ 2002. [9] B.Mishra and P.Wilson, “Color Edge Detection Hard- ware based on Geometric Algebra,” in 3rd European Conference on Visual Media Production CVMP 2006. IET, London, 2006, pp. 115–121. [10] J. Ebling, “Clifford Fourier Transform on Vector Region Fields,” IEEE Transactions on Visualization and Com- of puter Graphics, vol. 11, no. 4, pp. 469–479, 2005. Interest [11] D. Hestenes, New Foundations for Classical Mechan- ics. D.Reidel Publishing Company, 1986. [12] L.Dorst and S.Mann, “Geometric Algebra: A Compu- tational Framework for Geometrical Applications(I),” IEEE Computer Graphics and Applications, 2002. [13] R. Goldman, “Computer Graphics in its Fifth Decade: Figure 7: Convolution to detect Red to Blue. Ferment at the Foundations,” in PG ’03: Proceedings of the 11th Pacific Conference on Computer Graphics and Applications. Washington, DC, USA: IEEE Computer Society, 2003, p. 4. 8. CONCLUSION [14] J. Lasenby, W. J. Fitzgerald, A. N. Lasenby, and C. J. L. The GA representation for the color vectors is shown to be a Doran, “New Geometric Methods for Computer Vision: convenient and intuitive way for signal and image processing An Application to Structure and Motion Estimation,” applications. Experiments showed that this kind of edge de- Int. J. Comput. Vision, vol. 26, no. 3, pp. 191–213, tection is compact and is performed wholly on bivector color 1998. images. It is also concluded that the convolution operation with the rotor masks belong to a class of linear vector fil- ters and can be applied to image or speech signals [2]. The paper also presented an overview of the convolution opera- tions involving rotors for image processing applications. The usefulness of the introduced approach was demonstrated by analyzing and implementing a computation intensive edge