[Zooimage-commits] r191 - pkg/zooimage/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 25 12:25:35 CEST 2010


Author: kevin
Date: 2010-08-25 12:25:35 +0200 (Wed, 25 Aug 2010)
New Revision: 191

Modified:
   pkg/zooimage/R/utilities.R
Log:
debug calc.vars

Modified: pkg/zooimage/R/utilities.R
===================================================================
--- pkg/zooimage/R/utilities.R	2010-08-24 12:04:18 UTC (rev 190)
+++ pkg/zooimage/R/utilities.R	2010-08-25 10:25:35 UTC (rev 191)
@@ -218,15 +218,17 @@
 	# calculated variables!
 	
 	# A small hack to correct some 0 (which can be problematic in further calcs)
-	noZero <- function (x)
+	noZero <- function (x){
 		x[x == 0] <- 0.000000001
+		return(x)
+	}
 	# Euclidean distance between two points
 	distance <- function (x, y)
 		sqrt(x^2 + y^2)
 	
 	x$Minor <- noZero(x$Minor)
 	x$Major <- noZero(x$Major) 
-	x$Elongation <- x$Major / x$Minor
+	x$AspectRatio <- x$Minor / x$Major 
 	x$CentBoxD <- distance(x$BX + x$Width/2 - x$X, x$BY + x$Height/2 - x$Y)
 	x$GrayCentBoxD <- distance(x$BX + x$Width/2 - x$XM, x$BY + x$Height/2 - x$YM)
 	x$CentroidsD <- distance(x$X - x$XM, x$Y - x$YM)
@@ -242,7 +244,15 @@
 	x$logMinor <- log(x$Minor)
 	x$Feret <- noZero(x$Feret)
 	x$logFeret <- log(x$Feret)
-
+	x$MeanDia <- (x$Major + x$Minor) / 2
+	x$MeanFDia <- (x$Feret + x$Minor) / 2
+	x$Transp1 <- 1 - (x$ECD / x$MeanDia)
+	x$Transp2 <- 1 - (x$ECD / x$MeanFDia)
+	x$Transp2[x$Transp2 < 0] <- 0
+	PA <- x$Perim.^2/16 - x$Area
+	x$Elongation <- ifelse(PA <= 0, 1, x$Area / (x$Perim./4 - PA^.5)^2)
+	x$Compactness <-  x$Perim.^2/4/pi/x$Area  # env. 1/Circ.
+	x$Roundness <- 4 * x$Area / (pi * sqrt(x$Major))
 	return(x)
 }
 



More information about the Zooimage-commits mailing list