0

I have been doing a fair bit of searching around for an answer to my issue here.. hopefully someone can tell me where im going wrong.

im trying to replicate matlabs regionprops function to calculate major/minor axis lengths, and think i understand most of what it's doing but im a little lost.

my understanding was that the axis lengths are equal to the eigenvalues of the covariance matrix (of the regions pixel coordinates) but the numbers i am getting are far from what matlab is returning.

so far i am: 1)extracting coordinates as an n-by-2 matrix. 2)subtracting the x/y means from the matrix. 3)calculating covariance matrix (matrix'.matrix)/num_pixels 4)calculating eigenvalues from the covariance matrix

but the values i get are way away from what matlab is returning. am i doing completely the wrong thing here or am i just making a mistake in the working?

  • do you have a trial code? – Brethlosze May 28 '15 at 17:22
  • Hi hypfco, actually i have been looking at this mainly [link](http://stackoverflow.com/questions/1532168/what-are-the-second-moments-of-a-region). unfortunately i cannot comment on that question to query it; i understand how to calculate e.values and vectors; but the values are not going to be the right size (unless by chance). i have also been looking at the actual matlab code (regionprops) at the axis length part; but i cannot draw similarities between the scripts and the previous answer; so im a bit lost. – James Mapp May 29 '15 at 12:27
  • the scripts do actually calculate a covariance matrix of a sort, but then dont go on with the eigen methods previously described.. – James Mapp May 29 '15 at 12:32
  • Ummm i dont know how to help you... Replicating code line by line sometimes require to replace some core functions which may or may not depend on compiled fragments which could not be available under Octave..... If yes, just, debug, line by line, number by number, until you get the difference you are tracking. I fear there is not other better option.... If you manage to detect and allocate the difference, just message me.... – Brethlosze May 29 '15 at 18:35
  • Hello again.. thanks for your help anyway.. i have come to the conclusion that matlab does perform some e.value calculations (sort of) but there is another function then used to calculate the axis lengths. essentially matlab calculates the e.values using standard factorization equation and then modifies the answer... : axes = 2*sqrt(2)*sqrt(-b +- sqrt(b^2 + 4ac)) what i dont understand is where the 1/2a has gone, and where the *2*sqrt(2) has come from. – James Mapp Jun 02 '15 at 13:56
  • it seems that each eigenvalue is multiplied by 4, rooted, and multiplied by 2. or, multiplied by 16 then rooted.. what i am struggling is, where does that come from. – James Mapp Jun 02 '15 at 14:53

0 Answers0