Sketch Retrieval using Contour Detection by Chain Codes

Home»Sketch Retrieval using Contour Detection by Chain Codes


Shapes existed in the nature in 3D but they are described as 2D in image representation and an image is visual object, characterized by the two dimensional spatial variation of brightness. Sensing the image is easy to a human eye and it can easily differentiate various objects by observing their shape, color, texture and features, but for a system, to recognize objects, we have to provide some intelligence to it. For this the system need to store it, which need a large amount of storage. An image represented as a 1024 x 1024 array of picture elements (pixel), with 8 bits of brightness (gray-scale) information, takes approximately a megabyte

of storage. Boundary features like perimeter, corners, which are extracted from the boundary of the shape, and regional feature like area, extracted from the region

occupied by the shape are also used to recognize the shape of the object efficiently.

Image retrieval using sketches done by using various techniques like patch hasing, angular partitioning, using key shapes, etc


  1. Patch Hashing Technique: In this technique an overlapping spatial grid is utilized to generate a pool of patches. Patch similarity is efficiently estimated with a hashing algorithm. A reverse index structure built on the hashing keys ensures the scalability and real time reranking on query updates.


  1. Angular Partitioning Technique: In this technique, SBIR is based on low-level features. Abstract images are obtained using strong edges of the model image and

thinned outline of the sketched image. Angular-spatial distribution of pixels in the abstract images is then employed to extract new compact and effective features using Fourier transform.


  1. Key Shapes Technique: In this, SBIR is based on detecting Key shapes. Key shapes over which local descriptors are computed and increase the effectiveness in the retrieval task combining key shape approach with a Bag of Feature approach allows to achieve significant improvement with respect to the effectiveness of the retrieval task.


  1. Chain Code Technique: In this paper we implement the chain codes to recognize the shape of the object, using contours used as a feature for recognize the shape of an object. Because contours play an important role in image processing and computer vision to detect various objects in image or sketch. and which is easy to implement then the other techniques.


Chain code: A Chain code is a lossless compression algorithm for monochrome images, which provide a good compression of boundary description. The first approach for representing digital boundary was introduced by Freeman in 1961 using chain codes ,which is basically a notation for recording list of edge points along a contour and which follow the contour in a clockwise manner and keep track of the directions when it move from one previous contour pixel to the current contour pixel. Chain codes are used to represent a boundary by a connected sequence of straight-line segments of specified length and direction. And the chain code depends on the start point of boundary following. In this paper chain code is applied to contour based image retrieval from hand drawn sketches in image retrieval system accuracy and speed are important terms. Developing a practical image retrieval system is still a challenging task. To make the image retrieval system as user friendly and to reduce the search and extraction time, in this paper we propose chain code implementation in Sketch Based Approach.


We propose the chain code technique to detect the contours of the objects in the sketch.

Contour detection in sketches: For the hand drawn sketches, find the contours depending on the work of freeman chain code. To find the contours based on 8connected 3X 3 window [3] traverse .the chain code traversed in either clockwise or anti-clockwise direction.


The flow for sketch retrieval in the proposed system is represented as follows:

While using chain code to recognize the shape of object, segmentation is not needed, because the algorithm works depend upon the contour only Pixels connectedness: Contours founded by using Chain code depend on 4-connectedness or 8-connectedness of the pixels. Here we use 8-connectedness to recognize the shapes of the objects more efficiently.

The sketches which are taken as input are monochrome images only. So the background is white and the object is black or vice versa. The algorithm first searches the top most pixels, in opposite value to the background value. After finding the top most left pixel (of opposite value ) p(i,j),and then search from the previous pixel, from where it moves from to current position in clock wise direction and so on.

The table below shows that, the numbers from 0 to 7 are at various positions of pixels which might occur. The next pixel positions can be obtained by referring the table

This process is continued until it reaches the end point. After the contour tracing completed it store the chain code values in an array, from this normalized chain code is founded and then these values are compared with the stored normalized chain code values which are in the dataset. If any matches are founded, such sketches are displayed.

The step by step process of the chain code technique is as follows:

By using above algorithm, test chain code is verified with the training dataset, if any matched, those sketches are displayed.

For a given input sketch, first its contour is detected depend upon 8-connectedness of the pixels, then by depending upon the direction of chain codes, chain code is

finded, from this normalized chain code is finded. Normalized chain code is the optimized chain code, which is efficient for matching and retrieving. This query

normalized chain code is compared with the dataset normalized chain codes, if any match found, such sketches are displayed. Here we displayed the sketches in which are matched more than 50% with the test chain code. The flow for searching and retrieving of the relevant image/images is carried out as shown in the flowchart:



In this drawn input sketch is a straight-line, for this normalized chain code is finded depend upon the contours, it is compared with the normalized chain codes of the data set sketches, and then the matched sketches are displayed.

Fig4. Try to give (a) Query Interface (b) Result


In this drawn input sketch is a square, for this normalized chain code is finded depend upon the contours, it is compared with the normalized chain codes of the data set sketches, and then the matched sketches are displayed.


In this drawn input sketch is a rectangle, for this normalized chain code is finded depend upon the contours, it is compared with the normalized chain codes of the data set sketches, and then the matched sketches are displayed.


By using our proposed system we can recognize the sketches with the help of free man chain code. By using the normalized chain codes, retrieval process is fast and

efficient then using the chain codes. In the retrieval process this system displayed the sketches, whose normalized chain codes are matched more than 50 % with the test chain code.

Posted by: Mohan Mahanty. in Computer , General | Date: 17/02/2016

Share this article

Other articles

Back to article listing

Find a Great Teacher

Tell us your learning needs in detail and get immediate response from qualified tutors

Terms & conditions agreed
Ask a Question