aboutsummaryrefslogtreecommitdiff
path: root/fly-tools
diff options
context:
space:
mode:
authormutantturkey <mutantturke@gmail.com>2012-07-02 11:37:31 -0400
committermutantturkey <mutantturke@gmail.com>2012-07-02 11:37:31 -0400
commitc80efaa3a6837ecb7360cb5c3b73728de98c0a14 (patch)
tree0f78db7161d9e48a9be6b841e5741247f297f21c /fly-tools
parent730d1d7ea95f756a6afbab36a93b09d46bab27e1 (diff)
added an median based background deriver
Diffstat (limited to 'fly-tools')
-rwxr-xr-xfly-tools/derive-backgroundbin0 -> 14648 bytes
-rwxr-xr-xfly-tools/derivebackground.py31
2 files changed, 31 insertions, 0 deletions
diff --git a/fly-tools/derive-background b/fly-tools/derive-background
new file mode 100755
index 0000000..a11a2b1
--- /dev/null
+++ b/fly-tools/derive-background
Binary files differ
diff --git a/fly-tools/derivebackground.py b/fly-tools/derivebackground.py
new file mode 100755
index 0000000..1679ae0
--- /dev/null
+++ b/fly-tools/derivebackground.py
@@ -0,0 +1,31 @@
+import numpy
+import sys
+import Image
+import scipy
+from scipy import stats
+if len(sys.argv) != 3:
+ print "usage:", sys.argv[0], " filelist-path output-path"
+
+filelistpath = sys.argv[1]
+outputpath = sys.argv[2]
+
+filelist = numpy.loadtxt(filelistpath, dtype=numpy.str)
+nimages = len(filelist)
+
+temp = numpy.asarray(Image.open(filelist[0]))
+height = temp.shape[0]
+width = temp.shape[1]
+
+mov = numpy.empty((nimages, height, width, 3), dtype=numpy.uint8)
+
+for i in xrange(nimages):
+ mov[i] = numpy.asarray(Image.open(filelist[i]))
+
+bg = scipy.stats.mode(mov, axis=0)
+
+#image.fromarray(numpy.uint8(bg)).save(outputpath)
+scipy.misc.imsave(outputpath, bg)
+
+print bg
+print "created", outputpath
+