dahtah / imager

R package for image processing
GNU Lesser General Public License v3.0
187 stars 43 forks source link

Fitting an ellipse?? #155

Closed mconsidine closed 3 years ago

mconsidine commented 3 years ago

Hi, I have an image that is a disc or part of a disc, but is distorted. I'd like to calculate the "ellipse of best fit", including any angle/skew. Does anyone have an example of doing that in R with imager? Or suggestions on how it could be done? My googling is failing me, as is any common sense approach. Thanks, Matt

mconsidine commented 3 years ago

I think I have this figured out. The steps are to threshold the image and then use cannyEdges to get the shape profile. I get rid of data at the extremes of top, bottom, left and right so no straight lines exist. Then run the results through a fitting routine.

This is used on an image of the Sun, so I then know how much it has been distorted.

My original query was based on the hope that there was some sort of ellipse function in cimg/imager that I hadn't uncovered. If anyone knows of one, I'd still like to see it.

Matt