OBJECT detection in general has many applications

Similar documents
Rectangle Detection based on a Windowed Hough Transform

HOUGH TRANSFORM CS 6350 C V

Lecture 9: Hough Transform and Thresholding base Segmentation

Issues with Curve Detection Grouping (e.g., the Canny hysteresis thresholding procedure) Model tting They can be performed sequentially or simultaneou

An Extension to Hough Transform Based on Gradient Orientation

Types of Edges. Why Edge Detection? Types of Edges. Edge Detection. Gradient. Edge Detection

Edge linking. Two types of approaches. This process needs to be able to bridge gaps in detected edges due to the reason mentioned above

Edge detection. Gradient-based edge operators

Lecture 15: Segmentation (Edge Based, Hough Transform)

Computer Vision. Image Segmentation. 10. Segmentation. Computer Engineering, Sejong University. Dongil Han

Anno accademico 2006/2007. Davide Migliore

Biomedical Image Analysis. Point, Edge and Line Detection

Filtering Images. Contents

HOUGH TRANSFORM. Plan for today. Introduction to HT. An image with linear structures. INF 4300 Digital Image Analysis

Rectangle Positioning Algorithm Simulation Based on Edge Detection and Hough Transform

Segmentation I: Edges and Lines

Lecture 7: Most Common Edge Detectors

Practical Image and Video Processing Using MATLAB

Fitting. Lecture 8. Cristian Sminchisescu. Slide credits: K. Grauman, S. Seitz, S. Lazebnik, D. Forsyth, J. Ponce

Lecture 8: Fitting. Tuesday, Sept 25

Distance and Angles Effect in Hough Transform for line detection

Perception IV: Place Recognition, Line Extraction

(Refer Slide Time: 0:32)

EDGE EXTRACTION ALGORITHM BASED ON LINEAR PERCEPTION ENHANCEMENT

Generalized Hough Transform, line fitting

Finding 2D Shapes and the Hough Transform

Other Linear Filters CS 211A

CS443: Digital Imaging and Multimedia Perceptual Grouping Detecting Lines and Simple Curves

Edge detection. Convert a 2D image into a set of curves. Extracts salient features of the scene More compact than pixels

Example 1: Regions. Image Segmentation. Example 3: Lines and Circular Arcs. Example 2: Straight Lines. Region Segmentation: Segmentation Criteria

Straight Lines and Hough

Example 2: Straight Lines. Image Segmentation. Example 3: Lines and Circular Arcs. Example 1: Regions

Model Fitting. Introduction to Computer Vision CSE 152 Lecture 11

Ulrik Söderström 16 Feb Image Processing. Segmentation

Topic 4 Image Segmentation

Announcements. Edges. Last Lecture. Gradients: Numerical Derivatives f(x) Edge Detection, Lines. Intro Computer Vision. CSE 152 Lecture 10

Elaborazione delle Immagini Informazione Multimediale. Raffaella Lanzarotti

Introduction. Chapter Overview

Circular Hough Transform

Fitting: The Hough transform

Multimedia Computing: Algorithms, Systems, and Applications: Edge Detection

Announcements, schedule. Lecture 8: Fitting. Weighted graph representation. Outline. Segmentation by Graph Cuts. Images as graphs

CAP 5415 Computer Vision Fall 2012

Human Activity Recognition Using Multidimensional Indexing

Edge Detection. EE/CSE 576 Linda Shapiro

Edge Detection. CSE 576 Ali Farhadi. Many slides from Steve Seitz and Larry Zitnick

[10] Industrial DataMatrix barcodes recognition with a random tilt and rotating the camera

Lesson 6: Contours. 1. Introduction. 2. Image filtering: Convolution. 3. Edge Detection. 4. Contour segmentation

A Robust Method for Circle / Ellipse Extraction Based Canny Edge Detection

CS6640: Image Processing Project 4 Hough Transform

PERFORMANCE ANALYSIS OF CANNY AND OTHER COMMONLY USED EDGE DETECTORS Sandeep Dhawan Director of Technology, OTTE, NEW YORK

Feature Detectors and Descriptors: Corners, Lines, etc.

Fitting: The Hough transform

Detecting Multiple Symmetries with Extended SIFT

Edge and local feature detection - 2. Importance of edge detection in computer vision

Fitting: The Hough transform

Estimation of Skew Angle in Binary Document Images Using Hough Transform

Estimation of Skew Angle in Binary Document Images Using Hough Transform

Robot vision review. Martin Jagersand

Digital Image Processing COSC 6380/4393

ELEN E4830 Digital Image Processing. Homework 6 Solution

Segmentation

Hough Transform and RANSAC

Extracting Layers and Recognizing Features for Automatic Map Understanding. Yao-Yi Chiang

Chapter 10: Image Segmentation. Office room : 841

Segmentation

E0005E - Industrial Image Analysis

Uncertainties: Representation and Propagation & Line Extraction from Range data

Skew Detection and Correction of Document Image using Hough Transform Method

Edges and Lines Readings: Chapter 10: better edge detectors line finding circle finding

CIRCULAR MOIRÉ PATTERNS IN 3D COMPUTER VISION APPLICATIONS

Feature descriptors. Alain Pagani Prof. Didier Stricker. Computer Vision: Object and People Tracking

Image Processing. BITS Pilani. Dr Jagadish Nayak. Dubai Campus

Cover Page. Abstract ID Paper Title. Automated extraction of linear features from vehicle-borne laser data

EE368 Project: Visual Code Marker Detection

COMPUTER AND ROBOT VISION

Edge Detection. Announcements. Edge detection. Origin of Edges. Mailing list: you should have received messages

Review for the Final

Advanced Image Processing, TNM034 Optical Music Recognition

Robust Ring Detection In Phase Correlation Surfaces

2D Image Processing Feature Descriptors

Transactions on Information and Communications Technologies vol 16, 1996 WIT Press, ISSN

CHAPTER 3 RETINAL OPTIC DISC SEGMENTATION

GENERALIZING THE HOUGH TRANSFORM TO DETECT ARBITRARY SHAPES. D. H. Ballard Pattern Recognition Vol. 13 No

Edges and Lines Readings: Chapter 10: better edge detectors line finding circle finding

BIM472 Image Processing Image Segmentation

Edge detection. Stefano Ferrari. Università degli Studi di Milano Elaborazione delle immagini (Image processing I)

Model Fitting: The Hough transform I

Coarse-to-Fine Search Technique to Detect Circles in Images

Feature Selection. Ardy Goshtasby Wright State University and Image Fusion Systems Research

Object Shape Recognition in Image for Machine Vision Application

Car License Plate Detection Based on Line Segments

Computer Vision 6 Segmentation by Fitting

Detecting Ellipses via Bounding Boxes

Machine vision. Summary # 6: Shape descriptors

Pattern recognition systems Lab 3 Hough Transform for line detection

EE 584 MACHINE VISION

Experiments with Edge Detection using One-dimensional Surface Fitting

CS334: Digital Imaging and Multimedia Edges and Contours. Ahmed Elgammal Dept. of Computer Science Rutgers University

EECS490: Digital Image Processing. Lecture #19

Transcription:

1 Implementing Rectangle Detection using Windowed Hough Transform Akhil Singh, Music Engineering, University of Miami Abstract This paper implements Jung and Schramm s method to use Hough Transform for rectangle recognition using a few pre processing methods and performing a windowed application so that the the algorithm can perform faster. Images are scanned with a sliding Hough transform window, peaks of the transform are extracted(which correspond to line segments) and rectangles are detected based on a certain geometric conditions. The algorithm proposed was effective in identifying rectangles in synthetic images and a few not so complex natural images. This method fails in the case of overlapped images. An alternate method was used for such images. Index Terms Hough Transform, Rectangle Detection, Image Processing 1 INTRODUCTION OBJECT detection in general has many applications like detecting number plates of vehicles, in microbiology(to detect the number/type of cells), aerial imaging, etc. In this project, we particularly talk about detection of rectangles in a given image. Implementation and results of windowed Hough Transform suggested by Jung and Schramm are shown and also a few modifications to the original algorithm are suggested and implemented. The easiest way to detect rectangles is to tackle it from the basic level of lines and edges. Such a method will be limited to parallel and orthogonal lines. It would fail miserably in the cases where the images are angled, do not have perfect sharp edges/intersections, etc.. There have been different methods to tackle this problem. Windowed Hough transform[2] was found to be a very efficient way to detect rectangles. The paper clearly mentions that false detection results when aligned rectangle are close to each other. In this project, we start with the implementation of their idea and modifying it to get our desired results. 2 IMPLEMENTATION 2.1 Hough Transform Hough transform is a feature extraction technique used in image analysis and digital image processing to find geometrical shapes in an image by a voting procedure. This voting procedure is carried out in a parameter space, from which object candidates are obtained as local maxima in a so-called accumulator space that is explicitly constructed by the algorithm for computing the Hough transform[1]. The idea of the transform is the fact that any line on a xy plane can be described as ρ = x cos θ +y sin θ where ρ is the normal distance and θ is the normal angle of a straight line, making the line a 2D function C(ρ, θ) that represents the number of edge points satisfying the equation. Fig. 1 shows the graphical representation of the transformation. Fig. 1: Representation of a straight line in Hough Parameters[1]

2 The local maxima of the 2 dimensional line equation obtained after the transform can be used to detect the straight line segments passing through edge points. These edge points and line intersections help us in determining various geometrical structures based on the generic equations. In our case the geometrical structure being a rectangle. 2.2 Rectangle Patterns in the Hough Space In this section, we discuss the implementation that Jung and Schramm suggested to detect rectangles in Hough space. All the images from the following section are taken from their paper. The generic rectangle has 5 degrees of freedom: two coordinates of the center, width, height and orientation. Having a 5D accumulator array to compute would be computationally very expensive and time taking. The paper talks about an easier implementation which is computational cheaper but efficient. Consider a rectangle with vertices P 1 = (x 1, y 1 ), P 2 = (x 2, y 2 ), P 3 = (x 3, y ) and P 4 = (x 4, y 4 ) with P 1 P 2 P 3 P 4 being parallel sides with length a, as well as P 2 P 3 and P 4 P 1 with length b. Also assume that the coordinate system of is located in the center of the rectangle, as shown in Fig.2. Fig. 2: Rectangle centered at the origin of the coordinate system[2] The image of this rectangle after the application of Hough transform(in Hough space) is shown in Fig.3. Clearly, the four peaks, labeled Fig. 3: Rectangle centered at the origin of the coordinate system[2] as H 1 = (ρ 1, θ 1 ), H 2 = (ρ 2, θ 2 ), H 3 = (ρ 3, θ 3 ) and H 4 = (ρ 4, θ 4 ) and those that correspond to the four sides of the rectangle (P 2 P 3, P 1 P 4, P 3 P 4 and P 1 P 1 respectively) from Fig. 2. The paper then talks about 5 geometrical observations that we can make from these peaks. 1) They appear in pairs: H 1 and H 2 are at θ = α 1, H 3 and H 4 are at θ = α 0 2) Peaks belonging to the same pair are symmetric about the ρ axis, which makes them of equal magnitude resulting in cancelling each other, i.e., ρ 1 + ρ 2 = 0 and ρ 3 + ρ 4 = 0 3) The peaks are separated by an angle of 90 i.e., θ = 90(angle between all the line segments is 90). 4) Lengths of the line segments are the represented by the heights of the peaks i.e., C(ρ 1, θ 1 ) = C(ρ 2, θ 2 ) = b and C(ρ 3, θ 3 ) = C(ρ 4, θ 4 ) = a 5) The vertical distances (ρ axis) between peaks within each pair are exactly the sides of the rectangle, i.e., ρ 1 ρ 2 = a and ρ 3 ρ 4 = b. The above mentioned relations are valid only if there is just one rectangle present in the region. Multiple edges or rectangles wouldn t give accurate results because presence of any other structure in the image would have a global influence in the Hough space. The relations 1,2 and 3 are more generic and should work globally.

3 2.3 Jung and Schramm s algorithm The basic idea of the algorithm proposed by them, was to apply Hough transform on the image, identify peaks which satisfy the conditions mentioned in the previous section and detect the rectangle. As mentioned earlier, the conditions fail when there are additional edges in the area. To overcome this defect, they used a windowed approach. 2.3.1 Windowed Hough Transform Consider a rectangle centered at (x 0, y 0 ). For the algorithm to be able to detect the rectangle, the windowed region must be large enough to contain all the edges of any possible rectangle centered at the given location. On the other hand, it should be as small as possible to avoid edges belonging to other structures. To tackle this problem, they proposed a suitable search region to be a ring with internal diameter D min and external diameter D max. The choice of these parameters is user defined where D min should be equal to the smallest possible side of the rectangle and D max should be approximately equal to the largest possible diameter. They claim that such a choice of parameters will ensure that any rectangle in the image will have all of its edges within the search region. The windowed Hough transform implementation is shown in Fig.4. Fig. 4: Windowed Hough transform implementation[2] Fig. 4 shows the edge map of synthetic image computed with Canny s operator and also the choice of parameters for the ring shaped search region with internal and external diameters to be D min and D max. This approach to the problem is very efficient in the cases of rectangles which are spaced out. In the cases where rectangles of different sizes are very close to each other, such an approach would give us multiple edges. Later in the report, an alternate way to improve this situation is suggested and implemented. Once the D min and D max are specified, Hough transform is computed using quantized orientations of θ and ρ. Discretization steps d θ and d ρ were calculated based on the size of the image as suggested by Furukawa and Shinagawa s idea[3]. If not for this method, there could possibly be infinite values of θ and ρ which would make the algorithm computationally expensive. In this case the W 0 = H 0 = D max (as the Hough transform will be performed on the ring like window specified in Fig.4) which would make the discretization steps to be given by : d θ = 2.3.2 Detecting Peaks 3π 4D max, d ρ = 3 4 After performing the Hough transform, the next step would be to identify the peaks i.e., detecting the line segments within the search region. Let us assume, that C(ρ, θ) represents the number of edge points satisfying the linear equation of Hough transform. The easiest way to calculate peaks would be set a threshold(t C ), and extract all points that are above it. This can easily go wrong in the case of noisy images. An alternate version to detect peaks is to identify and analyze butterfly patterns that arise in the vicinity of the peaks. In the paper, a simplified version of the butterfly evaluator suggested by Furukawa and Shinnagawa was used to enhance the image. The enhanced image is given by : C(ρ, θ) 2 C enh (ρ, θ) = hw h/2 w/2, (2) C(ρ + y, θ + x)dxdy h/2 w/2

4 where h and w are the height and width of the rectangular region used for this enhancement, C(ρ, θ) represents the number of edge points satisfying the linear equation of Hough transform(ρ = x cos θ + y sin θ) and C enh is the enhanced hough image. Since ρ and θ are quantized, the integral is computed through a convolution with a rectangular mask. The local maxima of the enhanced image C enh (ρ, θ) satisfying C(ρ, θ) T C where T C is minimum number of pixels for the are stored as peaks. An image showing the Hough transform of the test region with peaks is shown in Fig.5. We can observe the 6 peaks, 4 of the rectangle bounded by the test region and 2 of the neighboring object peaks(edges). symmetric with respect to θ axis which implies that ρ i ρ j. T L determines the normalized threshold i.e., if the lines are approximately the same lengths (C(ρ i, θ i ) C(ρ j, θ j )). To further extend the detection pattern, they specify that each pair of H i and H j which satisfy all the equations mentioned in this section will produce another extended peak where P k = (±ξ k, α k ) α k = 1 2 (θ i + θ j ), ξ k = 1 2 ρ i ρ j. The final step is to compare all pairs of extended peaks P k and P l and those that correspond to orthogonal pairs of parallel lines. These two extended peaks contain information about all the peaks which are potentially forming a rectangle. A rectangle is detected if : α = α k α l 90 o < T α Fig. 5: Hough transform of the test region with detected peaks[2] 2.3.3 Detecting Rectangles If H 1 = (ρ 1, θ 1 ), H 2 = (ρ 2, θ 2 ),.., H m = (ρ m, θ m ) are the m peaks that are detected in the specified region, we need to find the four peaks which satisfy the conditions specified in section 2.2. Pairs of the peaks are scanned to satisfy the following conditions: θ = θ i θ j < T θ, ρ = ρ i + ρ j < T ρ C(ρ i, θ j ) C(ρ j, θ j ) < T L C(ρ i, θ j ) + C(ρ j, θ j ) 2 T θ corresponds to the angular threshold i.e., it determines if the peaks are parallel lines, which implies that θ i θ j. T ρ is the distance threshold i.e., it determines if the lines are where T α is an angular threshold that determines if the pairs of lines determined by P k and P l are orthogonal. When a rectangle is detected, the intersection of the two pairs of parallel lines give you the vertices, α k gives you the orientation, 2ξ k and 2ξ l give you the length of the sides. 2.3.4 Removing Duplicated Rectangles Having multiple thresholds(t θ, T ρ, T α andt L ) can lead to detection of duplicated rectangles for neighboring centers. When a sliding window is used to detect the centers of various objects in the image, there can be multiple centers which can be detected for the same object. Hough Transform will be performed applying the window and each of the centers, resulting in duplicating the rectangles i.e., the same rectangle with slightly different orientations is detected for each of the centers. This happens because of the small margin of error we leave when we compute the thresholds. One way around this problem would be to set tighter(lower) thresholds. However, this may lead to wrongly identifying the actual rectangle.

5 A more efficient way is to calculate the error margin for each detected rectangle, and to choose the rectangle for which the error is the smallest. The paper suggests that there are five error measures related to each rectangle : Parallelism ( θ k, θ l ), Distance error ( ρ k, ρ l ) and Orthogonality error( α). The proposed error measure is given by: E(P k, P l ) = a( θk 2 + θ2 l + α 2 ) + b( ρ 2 k + ρ2 l ) where a and b are weights for angular and distance errors, respectively. However, measure of θ and ρ are given in degrees and α in pixels. Visually, a difference of one pixel is more significant than a difference of one degree. To compensate the visual difference, the weight for distance error should be larger(typical values are a=1, b=4). The result can be seen in Fig.6. Fig. 7: Original Image Fig. 8: Edges Fig. 6: Results before and after error correction[2] 3 RESULTS 3.1 Edge Detection Several Edge detection techniques(canny, Prewitt, Log, Sobel, Zerocorss and Roberts) were tested and Canny and Prewitt were found to be the more efficient ones detecting edges more precisely. A low pass filters were used to smoothen the edges and the image was then dilated further and edges were detected for this particular image(fig.8) using the Canny edge detection method. 3.2 Hough Transform implementation and rectangle detection In this section, the Hough transform using the sliding window was applied and the various results are shown below in figures 9, 10 and 11. As you can see the images below, there is lot or error. It initially detects the regions correctly. In fig.10 you can observe that a few rectangles are detected correctly on the left and right sides of the image, but there are a lot of squares detected because of the closeness of the edges and multiple peaks getting recognized in the process. The results for the real life images are seen in figures 12,13 and 14. The noise in the image was initially reduced and the same algorithm was applied. Lot of other components were also detected along with the rectangles. There is still a lot of scope for improvement. Results for class 3 images are shown in 15,16,17 and are pretty much garbage.

6 Fig. 9: Potential regions in the image which can be rectangles overlapped with the original image(binary) Fig. 10: All the rectangles detected without error correction Fig. 11: Rectangles detected after error correction

7 Fig. 12: Potential regions in the image which can be rectangles overlapped with the original image(binary) Fig. 13: All the rectangles detected without error correction Fig. 14: Rectangles detected after error correction

8 Fig. 15: Potential regions in the image which can be rectangles overlapped with the original image(binary) Fig. 16: All the rectangles detected without error correction Fig. 17: Rectangles detected after error correction

9 4 ADDITIONAL WORK AND IDEAS The proposed algorithm by Jung and Schramm is efficient only when there the rectangles in the images are sufficiently apart. This algorithm fails in the case of closely alligned images. An example for this failure is discussed in the original paper itself. The ring window has several disadvantages. Observe Fig. 18. The Dmin and Dmax are the side of the smallest rectangle and diameter of the largest rectangle respectively. noise,convert the image into binary and perform a few morphological operations to identify really good edges. All these edge detection result in losing a lot of information if the threshold is not decided properly. Results of my edge detection algorithm are shown in Figures 19,20,21. Fig. 19: Test Image Fig. 18: Test Image Here, the ring window is shown as a the gray area. We observe how two other rectangles are also bound by the window in this case. The algorithm totally fails in such cases as it does not know what to do. The additional peaks detected will result in satisfying the equation more than once. This would result in wrongly detecting the rectangles which are about the same orientation and. A solution to tackle this problem would be to use an elliptical window instead of a ring and also calculating the Dmin and Dmax of each object in the image individually. This might be computationally expensive but a more effective solution. A modified windowed transform is mentioned below. Fig. 20: Test Image 4.1 Modified Windowed Transform algorithm 4.1.1 Edge detection Instead of using Canny, Prewitt, Roberts, etc techniques to detect edges, we can simply dilate the image, adjust the intensity, remove Fig. 21: Test Image

10 4.1.2 Windowed Hough Transform Instead of using the ring like Hough Transform where we manually input the Dmax and Dmin of the largest and the smallest possible rectangles in the image, we can identify all the objects in an image easily and calculate the longest and shortest side of the object individually on run time using Dijkstra s algorithm. Also, to minimize the error further of the ring like window, we can chose an elliptical window and do the Hough transform of that. This is not that tough to do, considering a circle is also a form of an ellipse. The equation of an ellipse is : x 2 a + y2 2 b = 1 (3) 2 If a=b=r, then an ellipse becomes a circle with an equation x 2 + y 2 = r 2. Let us assume that our rectangle sides are Rw and Rh. We want an ellipse with the same proportions as rectangle. We need to keep the ratio of the ellipse a/b same as the ratio of the rectangle sides Rw/Rh. This gives us another equation: a b = Rw Rh (4) Solving 3 and 4, we have 2 Rh 2b a = b( Rw Rh ) + Rh 2 = 1 2b Rh = 2b Solving for both a and b we have a = Rw 2, b = Rh 2 Fig. 22: Ellipse bounded rectangle due to time constraints. Overall, with a little modification to Jung and Schramm s algorithm we can produce a very efficient algorithm for edge detection which might be expensive computationally but very efficient. 4.2 Drawbacks A major drawback is that, these algorithms do not account for overlapped rectangles. These can only detect individual rectangles that are spaced apart. Future work would be to implement such an algorithm which could detect rectangle in the case of an overlapped image as well. REFERENCES [1] Wikipedia - Hough Transform [2] C.R. Jung and R. Schramm. Rectangle detection based on a windowed hough transform. In SIBGRAPI 04: Proc. of the Computer Graphics and Image Processing, XVII Brazilian Symposium, pages 113-120, 2004. [3] Y. Furukawa and Y. Shinagawa. Accurate and robust line segment extraction by analyzing distribution around peaks in hough space. Computer Vision and Image Understanding, 92(1):1-25, October 2003. Here is an example solution shown in Fig 22. This window eliminates detection of many undesired and additional edges making the search area smaller. Also, calculation of Rw and Rh real time rather than manually giving a Dmin and Dmax value improves the efficiency of the algorithm to a great level. The modified algorithm was implemented to a certain extent and hasn t been completed