Input matrix must be two dimensional

I'm trying to use the code here .
As you can see, the demo sets the points as follows:
A set of points
x = [1 2 5 7 9 6 3 8;
7 6 8 7 5 7 2 4];
Instead of those points, I wanted to use a 2D image. Thus, I have set
x as follows:
x = imread('xyz.png');
When I try to run the demo, I get the following:
Error using fitellipse>parseinputs (line 321)
Input matrix must be two dimensional
Error in fitellipse (line 81)
[x, params] = parseinputs(x, params, varargin{:});
Error in test_main (line 8)
[z, a, b, alpha] = fitellipse(x, 'linear');
Why is that?
Thanks.

1 Comment

Did you find the solution ? Because i've the same problem

Sign in to comment.

Answers (1)

fitellipse probably expects an N rows by 2 column list of x,y coordinates. The badly-named x is probably a grayscale or color image, and from the sounds of the error message I'd bet it's a 3D array - a color image of dimensions rows-by-columns-by-3 color channels. You need to pass it the x,y coordinates of the points you want to fit an ellipse to, not an entire image.

3 Comments

Thanks for your answer. Do you know of any matlab methods through which I can pass an image with an irregular shape, and have as an output the best ellipse fit for that irregular shape?
But, I need something being used in literature, so I can refer it in my research for instance (i.e; least squares).
I also came across different code in FileExchange, but, yet, didn't find what I'm looking for.
Thanks.
Yes I do. I have the perfect paper for you: http://www.ecse.rpi.edu/homepages/qji/Papers/ellipse_det_icpr02.pdf. But no, I don't have MATLAB code for it, nor have I studied the algorithm so I can't help you with it. You can try contacting the authors.
Thanks for your kind replies.

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Asked:

on 24 Nov 2014

Commented:

on 19 Jun 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!