International Journal of Recent Advances in Engineering & Technology (IJRAET)
_______________________________________________________________________________________________
________________________________________________________________________________________________
ISSN (Online): 2347 - 2812, Volume-6, Issue -12, 2018 8
Shape Recognition & Matching using Chain Code
Jayendra Barua & Sachin Chirgaiya
Comp Sci. Department, Malwa Institute of Technology, Indore Abstract – Shape recognition is a major problem in
image understanding and computer vision. This paper focuses on recognize a shape and shape matching based on their chain codes. This approach has four important module namely, Image pre- processing and Edge Detection, Thinning, Feature Extraction, Feature Matching. So initially we take an image and apply image processing and convert it into the Gray scale and after this we apply canny edge detector to generate binary image from Gray scale image so that it contain edge of each shape. After that generate a chain code of each shape of binary image which is invariant to translation, rotation and scaling. For matching purpose this unique chain code of the shape representation, the translation rotation and scaling of two different images has been calculated. Finally, the shape matching has been done based on the unique chain code for each shape of the same image. The main goal of this paper is to matching two or more images with different shape based on their chain code.
Keywords – Image Processing, Feature Extraction, Feature Matching, Chain code.
I. INTRODUCTION
Shape recognition is a major problem in image understanding and computer vision. Applications of shape recognition can be found in many areas, such as, medicine, space exploration, manufacturing, face detection, text analysis, defense and many others [1].
Pattern recognition aims to classify data (patterns) based on either a priori knowledge or on statistical information extracted from the patterns. The patterns to be classified are usually groups of measurements or observations, defining points in an appropriate multidimensional space.
A complete pattern recognition system consists of a sensor that gathers the observations to be classified or described, a feature extraction mechanism that computes numeric or symbolic information from the observations, and a classification or description scheme that does the actual job of classifying or describing observations, relying on the extracted features. The so- called "raw data" is the set of measurements provided by a sensor ( e.g. The pixels of an image provided by a
digital camera). The first steps of the pattern recognition process are pre-processing and feature extraction that may include some signal processing such as smoothing and noise filtering and the extraction of higher level features for which human knowledge about the task is essential.
In this paper object shape has been considered as an important feature of images for shape matching. It is used to find a shape representation, which is invariant to scale, translation and rotation, and a similarity measure, which conforms to human perception and suitable for content-based image retrieval. In this current work, an efficient method for shape matching is focused, in which object’s shape has been considered as an important feature of images. For shape representation, one eight- directional chain code is used which is invariant to translation, rotation and scaling. The unique chain code is suitable for shape matching on which shape similarity can be computed easily.
The Human Visual System can instantly perform matching that two shapes are matched or not matched with deceptive effortlessness. To understand the difficulty of getting a computer to do the same and design a system that can take a image (collection of patterns or objects) and any image pattern to be identified and matching of different shape based on their chain code.
So my paper deals with the representation and recognition of different types of shapes or patterns based on their chain codes and other features. A software system needs to be developed which can not only matching of shapes but also be able to show the output at intermediate steps involved. To the most basic functionality system should be able to work with monochrome images. Basic two dimensional images in a jpeg or png format should be handled.
Chain codes are one directional codes. They are invariant to rotation, translation, scaling. So there is a problem in matching of two shape. So I design a solution which is variant to translation, rotation, scaling.
.II. SOLUTION DOMAIN
PROBLEM CAN BE BROKEN DOWN INTO SUB PROBLEMS:
International Journal of Recent Advances in Engineering & Technology (IJRAET)
_______________________________________________________________________________________________
________________________________________________________________________________________________
ISSN (Online): 2347 - 2812, Volume-6, Issue -12, 2018 9
1. Image Processing and Edge Detection 2. Thinning
3. Feature Extraction 4. Feature matching
1. Image Processing Phase and Edge Detection:- Pre-processing is the name used for the operations on the images at the lowest level of abstraction-both input and output are intensity images, It is necessary to realize that preprocessing does not increase image information content and also is very useful in variety of situations since it helps to suppress information that is not relevant to the specific image processing or analysis task. Thus the task of pre-processing is an improvement of the image data that suppress undesired distortions or enhances some features important for further processing.
Local neighborhood pre-processing-: Preparation of the image also involves scanning and capturing of image and converting the image into standard formats like JPEG, PNG, and BMP etc. It involves smoothing and filtering of the image to remove any kind of noise and/or to prepare images for further processing such as edge detection. It also includes converting the colored image into the gray scale image for the implementation of edge detection algorithms.
Edge Detection:-
In this phase also detect the edge of the shape by edge detection algorithm. Here I use canny edge detection algorithm to find the edges or boundary of the shape. After applying edge detection method our complexity is reduced because we have only edges. So we get the boundary of the shape and rest of pixels are discarded.
Canny edge detection algorithm:- It is known as the optimal edge detector. It is an enhancement of many existing edge detectors. It will be used due to following reasons:
(a) The first and most obvious reason is low error rate. It is important that edges occurring in images should not be missed and that there be NO responses to non-edges.
(b) The second criterion is that the edge points be well localized. In other words, the distance between the edge pixels as found by the detector and the actual edge is to be at a minimum.
A third criterion is to have only one response to a single edge.
2. Thinning:-
Thinning algorithm is used for convert the edge detected image to 1-pixel thick line. So we easily extract the chain code from thick single line. So for this I use skeleton algorithm.
The Thinning algorithm (Skeleton algorithm) to be followed is: Edges are assumed to have a value 1 and background points have value 0.The method consists of successive passes of two basic steps applied to the contour points of the given edge (a contour point is any pixel with value 1 and having at least one eight- neighbor valued ). This algorithm flags a contour point p1 (center pixel of 3x3 matrix) for deletion if the following conditions are satisfied:
(i) 2<=N (p1) <=6 (ii) T (p1) =1 (iii) P2.p4.p6=0 (iv) P4.p6.p8=0
Where N (p1) is the number of the nonzero neighbors of p1 that is N (p1)=p2+p3…+p8+p9
T (p1) is the number of 0-1 transition in the ordered sequence p2, p3,……p8,p9,p2
In step2 conditions (i) and (ii) remain the same but condition (iii) and (iv) are changed to p2.p4.p8=0, p2.p6.p8=0
Step 1 is applied to every border pixel in the binary region under consideration. If all the conditions are satisfied it is flagged for deletion, But the point is not deleted until all the border points have been processed.
After step 1 has been applied to all border points, those that were flagged for deletion are deleted (changed to 0).Then step 2 is applied to the resulting data in exactly the same manner as step1.
Applying step1 to flag border points for deletion.
1) Deleting the flagged points.
2) Applying step2 flag the remaining border points for deletion .
3) Deleting the flagged points.
3. Feature Extraction:-
After canny edge detection and thinning we extract the feature of different shape by using chain code. So here we used chain codes for representing a shape of an objects. Hence, one conventional eight directional chain code (Fig. 1) is used to represent the shape of each object in the image. The edges of a shape are partitioned by fixed size line segment. The chain code of a line segment depends on the previous line segment based on the direction as shown in Fig. 1.
Fig. 1 : Eight-direction Chain Code
International Journal of Recent Advances in Engineering & Technology (IJRAET)
_______________________________________________________________________________________________
________________________________________________________________________________________________
ISSN (Online): 2347 - 2812, Volume-6, Issue -12, 2018 10
A. Invariant Chain Code for Rotational Shape:- An object’s shape is shown in Fig. 2. Using eight directional chain code, the chain code sequence of the shape is 0, 0, 2, 2, 4, 4, 6, 6; assuming A as the starting point. Similarly, assuming E as the starting point, the chain code sequence of the same shape is as follows 4, 4, 6, 6, 0, 0, 2, 2
A B C
H D
G F E
Fig. 2 : Chain Code of object
In circular way, both the chain code sequences are same, thus, this representation is invariant to rotation of a shape.
B. Invariant Chain Code for Scaled Shape Representation:-
The chain code sequence for the shape in Fig. 2 is 0, 0, 2, 2, 4, 4, 6, 6; considering A as the starting point.
A B C D
L E
K F
J K L M
Fig. 3 : Scaled objects shape of fig.2.
The chain code sequence of the scaled shape in Fig.
3 is listed below assuming the same starting point. 0, 0, 0, 2, 2, 2, 4, 4, 4, 6, 6, 6; but If we add x in all the direction of scaled shape. 0, 0, x, 2, 2, x, 4, 4, x, 6, 6, x;
Then after If we remove the all x from the sequences then two sequences are same, thus, object’s shape representation is invariant to scaling. Here x is scaling factor. If you want to scale two times then add x two times and then remove. The above representation is valid for any shape that is scaled.
C. Invariant Chain Code for Translation Shape Representation:-
For rotational shape representation we calculate rotation factor. So here first we calculate angle between any two point on x-y axis in Fig. 4.
Fig. 4 : Shape contain values on x-y axis.
After that clockwise rotation, we calculate the angle between same two point on x-y axis.
Fig. 5 : 45° clockwise rotation on x-y axis of fig.4 4. Feature Matching
Feature matching is used to measure the similarities between the different images after feature extraction is applied. In feature matching phase we match the object’s shape based on chain code. Feature matching is the process of detecting features in separate images that can be compared. In this paper, create the algorithm that is used to match the chain code of two shapes and find out the scale, rotation and translation factor of two images. The steps of the algorithm is following.
Step 1: Input two images and apply image processing algorithm, that reducing noise in that images and also generate two Gray scale images.
Step 2: After that apply edge detection method that generate binary images that contains the edges of each shapes.
Step 3: After edge detection apply thinning algorithm to get the one pixel thick line. And after thinning we use images to generate chain code.
Step 4: Generate the chain codes of two Thinned images and store them in two temporary array X & Y.
Step 5: After feature extraction match the two images based on their chain codes.
International Journal of Recent Advances in Engineering & Technology (IJRAET)
_______________________________________________________________________________________________
________________________________________________________________________________________________
ISSN (Online): 2347 - 2812, Volume-6, Issue -12, 2018 11
Step 6: If any variation likes scaling, rotation or translation are come in feature matching process then we calculate different factors.
Step 7: The scale factor S of second shape over first shape is the ratio of the chain code length of Y and the chain code length of X.
Step 8: The chain code X and Y are matched in circular way. The chain of non-zero elements of X and Y should be same (matched) in circular fashion if two shapes are same.
Step 9: Number of zeros between two neighbouring non-zero element of chain X is n then number of zeros between corresponding two neighbouring non-zero element of chain code Y should be {(n+1)* S-1}, where the scale factor is S of chain code Y over chain code X.
Step 10: X and Y sequence are matched, then track any code from X and from that, detect the two endpoints (x1, y1) and (x2, y2) of its corresponding line segment, and find the corresponding matched code from Y and from that, detect the two end points (w1, z1) and (w2, z2) of its corresponding line segment.
Step 11: Factor of second image over first image is Ө degree,
where Ө= (Ө1- Ө2).
Ө1= tan-1 ((y1-y2)/(x1-x2)) and Ө2= tan-1 ((z1-z2)/ (w1- w2)).
Step 12: Translation factor for x and y direction is (x1- w1) and (y1- z1) respectively for the point (x1, y1) of first image and the point (w1, z1) of second image.
IV. CONCLUSIONS
In this paper, the basic chain code concept is extended to obtain the unique chain codes for shape representation. This is quite significant because the unique chain code is invariant to translation, rotation and scaling. Based on the chain code sequence, the rotation, scale and translation factor of different images of objects have been derived. Shape matching is one of the most important tasks when integrating and analysing
information from various sources. Major works under the scope of the shape recognition and matching include implementation of matching of shapes in two images. In future scope, object’s 3D shape can be considered for Shape recognition and matching.
V. REFERENCES
[1] Dr. Azzam Talal Sleit, “A Chain Code Approach for Recognizing Basic Shape”
[2] ILVA LEVNER, Shape Detection Analysis and Recognition, 2000
[3] Dr V.Kamakshi Prasad, T.Venu Gopal
“A Novel Approach to Shape Based Image Retrieval Integrating Adapted Fourier Descriptors and Freeman” International Journal of Computer Science and Network Security, VOL.8 No.6, June 2008.
[4] Krishnan Nallaperumal, Senior Member, IEEE, Justin Varghese, S.Saudia, Jennifer J. Ranjani, Prof.Comdr.K.Velu, S.Senthamarai Kannan An Efficient Extension to Chain Codes for External Image Representation.
[5] Xiaolong Dai and Siamak Khorram A Feature- Based Image Registration Algorithm Using Improved Chain-Code Representation Combined with Invariant Moments IEEE transaction on geoscience and remote sensing, vol 37, no. 5 sept 1999.
[6] Digital Image Processing- Pitas digital image processing fundamentals-Shape description.
[7] H.S. Alhichri, M. Kamel, “Virtual circles: a new set of features for fast image registration”, Pattern Recognition Letters, Vol. 24, pp 1181–
190, 2003.
[8] B. Zitova, J. Flusser, “Image registration methods: a survey”, Image and Vision Computing Vol. 21, pp 977–1000, 2003.