# How to "de-dupe" similar lines (detected using the Hough Transform as rho/theta pairs)

I'm trying to identify an object (a cube) in a set of photos. Using Canny/Sobel/Hough I've managed to get the photo down to a set of lines that are pretty accurate; however if I plot these lines on my image there are a lot of duplicates where the angle/distance varies only a tiny amount. Here's a cut down sample:

I thought I could reduce these by simply looking for lines that have a `rho`/`theta` values within a certain tolerance. However, the problem I discovered is that the more vertical a line is (the further the intersection at x=0) the greater the difference in the `rho` value for the same angle:

This doesn't seem like a problem maths can't fix; but it seems like there should be tried-and-tested method for doing this yet I'm failing to find any good info online about the best way to do this (either maths to allow for this, or a generally better way of merging similar lines within the image space for the output of Hough Transform).

I did wonder if converting them to x/y pairs for the edges of my image (eg. the points to use to render a line) and then comparing them might be a better idea. I'm going to give this a go; but if it's not the "normal" way to do it, I'd like to know!

• What was the reasoning behind computing `rho/theta`? Without thinking about the geometry, I'd recommend trying doing some kind of normalized RMS. Mar 15, 2016 at 18:48
• That seemed to be the way to do Hough Lines (a way of combining lines that are close in location and angle). I'm totally new to all this, so it's entirely likely I'm not doing th ebest things, but I'm struggling to find good info on this (lots of stuff on edge detection, less on detecting an object like a 3D cube) :( Mar 16, 2016 at 8:38