# XY: coordinates of vertices of polygon with more than 4 edges # ParGini: initial parameter vector c(coordinates of cell center(1:2), semi-major-axis, semi-minor-axis, Angle) library(conicfit) XY <- matrix(c(540.0, 980.0,649.0, 966.0,681.0, 1042.0,597.0, 1063.0,536.0, 1062.0,520.0, 1044.0),,2,byrow=TRUE) ParGini <- matrix(c(587.2, 1026.3,80,60,0),ncol=1) LambdaIni=0.1 fit.ellipseLMG(XY,ParGini,LambdaIni) # Plot fitted ellipse library(conicfit) library(conics) XY <- matrix(c(540.0, 980.0,649.0, 966.0,681.0, 1042.0,597.0, 1063.0,536.0, 1062.0,520.0, 1044.0),,2,byrow=TRUE) ParGini <- matrix(c(587.2, 1026.3,80,60,0),ncol=1) LambdaIni=0.1 G <- fit.ellipseLMG(XY,ParGini,LambdaIni) A <- GtoA(G[[1]]) v <- c(A) conicPlot(v, asp=1) points(XY[,1],XY[,2],col = "blue") # XY: coordinates of 4 vertices of 4-gons and 4 midpoints # ParGini: initial parameter vector c(coordinates of cell center(1:2), semi-major-axis, semi-minor-axis, Angle) library(conicfit) XY <- matrix(c(697,456.00,760.00,411.00,842.00,467.00,752.00,561,728.50,433.50, 801.0,439,797.0,514,724.5,508.5),,2,byrow=TRUE) ParGini <- matrix(c(763.30,473.80,80,60,0),ncol=1) LambdaIni=0.1 G <- fit.ellipseLMG(XY,ParGini,LambdaIni) XY <- matrix(c(697,456.00,760.00,411.00,842.00,467.00,752.00,561),,2,byrow=TRUE) ParGini <- matrix(c(G[[1]]),ncol=1) fit.ellipseLMG(XY,ParGini,LambdaIni) # Plot fitted ellipse library(conicfit) library(conics) XY <- matrix(c(697,456.00,760.00,411.00,842.00,467.00,752.00,561,728.50,433.50, 801.0,439,797.0,514,724.5,508.5),,2,byrow=TRUE) ParGini <- matrix(c(763.30,473.80,80,60,0),ncol=1) LambdaIni=0.1 G <- fit.ellipseLMG(XY,ParGini,LambdaIni) XY <- matrix(c(697,456.00,760.00,411.00,842.00,467.00,752.00,561),,2,byrow=TRUE) ParGini <- matrix(c(G[[1]]),ncol=1) G <- fit.ellipseLMG(XY,ParGini,LambdaIni) A <- GtoA(G[[1]]) v <- c(A) conicPlot(v, asp=1) points(XY[,1],XY[,2],col = "blue")