![]() It turns out that the algorithm is susceptible to reporting the same ellipse multiple times. Wait.what? bestFits contains paramaters for 30 detections (a manual count informs me that there are 26 ellipses wholly contained in the image), but when visualizing the results, it appears that there are far fewer. Params.numBest = 30 %(Number of chips = 26) bestFits = ellipseDetection(edgeMask, params) Params.minAspectRatio = 0.4 %1 = circle 0 = line Then I used protractor to get a sense of the orientations of the ellipses:Īfter a few minutes, I found my way to: params.minMajorAxis = 55 First, I used imdistline to measure the major and minor axes lengths: To improve the performance, I judiciously selected input parameters to reduce the computational cost. (By the way, calling ellipseDetection() on the binary mask of the warped chips without first calculating the edges took upwards of 20 minutes, and the results were even worse!) Improving the Results The operation completed in (just) less than a second, but the results were underwhelming: With this binary edge mask in hand, I was ready to search for ellipses-first, naively: bestFits = ellipseDetection(edgeMask) In just a few minutes, I had an edge image in which to detect those ellipses: Filtering the results to select the desired Major Axes Lengths and Areas ( imageRegionAnalyzer, bwpropfilt).Calculating (with carefully selected input parameters) the edges of the grayscale image ( edge).Converting the masked RGB image to grayscale ( im2gray).Re-compositing the masked planes into an RGB image ( cat).Masking the R, G, and B planes individually ( R(backgroundMask) = 0.Splitting the color image into R, G, and B components ( imsplit).Using the colorThresholder to create a mask of the background.We can start with an image containing circles, and warp it to generate ellipses: inputImage = imread( 'coloredChips.png') So let's try it out on a sample image of our creation. If randomize is 0, then the search is exhaustive-increased accuracy at a computational cost.) A Test Drive (The "randomize" parameter is not a Boolean variable, as the name suggests rather it reduces the search space from N x N to N x randomize. Martin's function provides a parameter that allows you to trade off between speed and accuracy. Even after such limits are used, an exhaustive search examines N x N candidates for major axes. You may also specify some parameters for limiting the angles of the ellipses you seek this could be very useful if you know the ellipse orientations a priori. Among these parameters, you can specify the range of major axes lengths to consider, and the minimum aspect ratio. You'll almost certainly want to operate on an "edge image" rather than a simple binary mask of your regions of interest, and to play with the function's nine input parameters to limit the search. First, recognize that ellipse detection is an expensive memory hog the computation scales with the square of the number of nonzero pixels, N, in your search image. The ImplementationĪfter playing around with Martin's ellipseDetection() for most of an afternoon, I have some thoughts to share. I love that Martin did that work for me-it makes me appreciate the File Exchange all the more. ![]() ![]() "A New Efficient Ellipse Detection Method." 1051-4651/02 IEEE, 2002) that I have had on my desk for quite some time, thinking that I would one day sit down to implement it in MATLAB code. ![]() The Sourceįortunately, and appropriately, Martin cited the source for his algorithm he used a paper (Y. Enter Martin's ellipse-detection function. And while we have nice functionality for detecting the simpler shapes ( houghlines, imfindcircles), we do not (currently) have a function to detect ellipses. Since ellipses are described by more parameters than are lines or circles, detecting ellipses is more challenging than is detecting lines or circles. Today, I want to write about detecting ellipses. I've written several times in the past about detecting circles in images ( here, here, and here).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |