# Segmenting out an Ellipse from Image

I am working on segmenting the platter from hard disks at various angles (my data set comprises ~250 grayscale images and I would need this to work for each of those). I've attempted using the hough transform to detect this (it operates on the edge image) -->MATLAB code and related blog post linked here:

but unfortunately that oftentimes does not detect it at all or detects it incorrectly.

I've played around with the parameters but aside from using the entire search space of points in the function linked above to detect the ellipse, which greatly increases computation time, I cannot see any other way to do this (and even then it is not robust).

Is there any other way to achieve this segmentation using image processing algorithms or would I have to resort to supervised learning?

Suggestions welcome!

• i looked at your file and do not know working details of the Hough algorithm. My guess is, since it was not mentioned, that this is working on every pixel of the image to start. If my guess is correct, I would suggest doing this on a crude decimated image, like blending each 4x4 block into a single pixel. Get some candidate ellipses with a smaller bit map. Then use that data to fine-tune the location of the significant points with the original higher-resolution bit map. Jul 15, 2022 at 22:25
• And it seems to me that you're looking for an elliptical annulus. An inside ellipse and an outside ellipse on the same plane. Jul 15, 2022 at 22:27
• Hi Robert, thanks for your response! I convert the grayscale image above to a binary edge image using the canny edge detector and pass it through to the hough transform. The algo then operates on all possible non zero point pairs. If total number of points are N, then it operates on NN pairs. Unfortunately in my case, that would be of the order of 10^4*10^4=O(10^8) and computation would take forever. I modified the search space from NN to N*(2-10) by using the randomization parameter that randomly picks out point pairs and drastically reduces the search space. That gives me poor results :( Jul 16, 2022 at 5:44
• And yes, in an ideal world, I'd love to segment out that annulus, sans any occlusions too (like the write head that partially obscures the platter in this case) but I think that's much too complex a problem to solve in one go (unsupervised at least!). I think getting the whole ellipse (platter) first successfully would be a good starting point and then hopefully I could segment the remainder out using connected components/other algos Jul 16, 2022 at 5:48
• I don’t know what algorithm you are using, but Hough does not work on pixel pairs, it works on individual pixels. Jul 17, 2022 at 18:17

## 1 Answer

I'd recommend a two-step solution. The lighting on your image is a little poor. My suggestion is:

• Find the center ellipse first using an edge-detected image (see below).

• Use this as the starting point and gradually increase the search radius to find the outermost edge.

Just using an online image processing site, I can get these edges (in red). Clearly the bright lights are not what you want, but the center ellipse comes up pretty well. Run the Hough ellipse detector on that.

• Thanks Peter, I like the idea of using the central ellipse as the start radius and gradually increasing it from there to try to detect the bigger one! I will try this out and update shortly! Jul 25, 2022 at 5:26