Commit 68cabad9 authored by aknecht2's avatar aknecht2

Updates for osg sql aggregation.

parent 1d11eb26
......@@ -431,6 +431,15 @@ class Image(object):
self.image = cv2.equalizeHist(self.image)
return
def equalizeColor(self):
if self._isColor():
b, g, r = cv2.split(self.image)
b = cv2.equalizeHist(b)
g = cv2.equalizeHist(g)
r = cv2.equalizeHist(r)
self.image = cv2.merge([b, g, r])
return
def show(self, title = None, state = None):
"""
:param title: The title to give the display window, if left blank one will be created.
......@@ -1265,14 +1274,17 @@ class Image(object):
Returns a list with the following form: [height, width]
"""
bounds = self.getBounds()
height = bounds[1] - bounds[0]
width = bounds[3] - bounds[2]
if self.conn:
self._addColumn("height")
self._addColumn("width")
self.conn.execute("update images set height=?,width=? where pegasusid=?", (self.y, self.x, self.dbid))
self.conn.execute("update images set height=?,width=? where pegasusid=?", (height, width, self.dbid))
self.conn.commit()
return
else:
return [self.y, self.x]
return [height, width]
def extractMinEnclosingCircle(self):
"""
......
......@@ -679,6 +679,7 @@ class ImageProcessor(Workflow):
maprc = open(self.basepath + "/" + loc + "/map.rc", "a")
binDep = []
aggIn = {}
aggIn2 = {}
for type in self.workflow["workflows"]:
for q in range(0, clusternum[type] + 1):
arguments = self.workflow["extract"]["workflows"][type]["arguments"]
......@@ -694,11 +695,13 @@ class ImageProcessor(Workflow):
arguments["--createdb"] = ""
arguments["--inputs"] = " ".join([x for x in exInput[type][q].keys() if ".png" in x])
self._addFile(type + str(q) + ".db", type, "output")
self._addFile(type + str(q) + "_2.db", type, "output")
self._addJob(type + "_extract" + str(q), "ih-extract-multi", exInput[type][q], {"db": {"file": type + str(q) + ".db", "transfer": False}}, arguments, exDep[type][q], walltime = 300)
self._addJob(type + "_extract" + str(q), "ih-extract-multi", exInput[type][q], {"db": {"file": type + str(q) + ".db", "transfer": False}}, arguments, [], dax = self.exdax, walltime = 300)
maprc.write(type + str(q) + ".db" + " file://" + self.basepath + "/output/" + type + str(q) + ".db" + " pool=\"local\"\n")
binDep.append(type + "_extract" + str(q))
aggIn[type + str(q) + ".db"] = {"file": type + str(q) + ".db", "transfer": False}
aggIn2[type + str(q) + "_2.db"] = {"file": type + str(q) + "_2.db", "transfer": False}
aggIn["db"] = {"file": "img.db", "transfer": False}
self._addJob("sql_aggregate1", "ih-sql-aggregate", aggIn, {"img2.db": {"file": "img2.db", "transfer": False}}, {"--db": "db", "--output": "img2.db", "--inputs": " ".join([aggIn[x]["file"] for x in aggIn if x != "db"])}, binDep, walltime = 180)
self._addJob("sql_aggregate1", "ih-sql-aggregate", aggIn, {"img2.db": {"file": "img2.db", "transfer": False}}, {"--db": "db", "--output": "img2.db", "--inputs": " ".join([aggIn[x]["file"] for x in aggIn if x != "db"])}, binDep, dax = self.exdax, walltime = 180)
......@@ -723,16 +726,17 @@ class ImageProcessor(Workflow):
for q in range(0, clusternum[type] + 1):
arguments = {}
arguments["--db"] = "db"
arguments["--copydb"] = "copydb"
arguments["--inputs"] = " ".join(exInput[type][q].keys())
exInput[type][q]["db"] = {"file": type + str(q) + ".db", "transfer": False}
exInput[type][q]["binfile"] = {"file": map[type] + "_hist_bins.json", "transfer": False}
arguments["--bins"] = "binfile"
self._addJob(type + "_extractBins" + str(q), "ih-extract-multi", exInput[type][q], {}, arguments, ["bin_creation"], walltime = 480)
self._addJob(type + "_extractBins" + str(q), "ih-extract-multi", exInput[type][q], {}, arguments, ["bin_creation"], dax = self.exdax, walltime = 480)
self._addJob(type + "_extractBins" + str(q), "ih-extract-multi", exInput[type][q], {"copydb": {"file": type + str(q) + "_2.db", "transfer": False}}, arguments, ["bin_creation"], walltime = 480)
self._addJob(type + "_extractBins" + str(q), "ih-extract-multi", exInput[type][q], {"copydb": {"file": type + str(q) + "_2.db", "transfer": False}}, arguments, ["bin_creation"], dax = self.exdax, walltime = 480)
binDep.append(type + "_extractBins" + str(q))
aggIn["db"] = {"file": "img2.db", "transfer": False}
self._addJob("sql_aggregate2", "ih-sql-aggregate", aggIn, {"img3.db": {"file": "img3.db", "transfer": True}}, {"--db": "db", "--output": "img3.db", "--inputs": " ".join([aggIn[x]["file"] for x in aggIn if x != "db"])}, binDep, walltime = 180)
self._addJob("sql_aggregate2", "ih-sql-aggregate", aggIn, {"img3.db": {"file": "img3.db", "transfer": True}}, {"--db": "db", "--output": "img3.db", "--inputs": " ".join([aggIn[x]["file"] for x in aggIn if x != "db"])}, binDep, dax = self.exdax, walltime = 180)
self._addJob("sql_aggregate2", "ih-sql-aggregate", aggIn2, {"img3.db": {"file": "img3.db", "transfer": True}}, {"--db": "db", "--output": "img3.db", "--inputs": " ".join([aggIn[x]["file"] for x in aggIn if x != "db"])}, binDep, walltime = 180)
self._addJob("sql_aggregate2", "ih-sql-aggregate", aggIn2, {"img3.db": {"file": "img3.db", "transfer": True}}, {"--db": "db", "--output": "img3.db", "--inputs": " ".join([aggIn[x]["file"] for x in aggIn if x != "db"])}, binDep, dax = self.exdax, walltime = 180)
z = 2 if "histogram-bin" in self.workflow["extract"] else 1
indb = "img3.db" if "histogram-bin" in self.workflow["extract"] else "img.db"
......
......@@ -4,10 +4,12 @@ import traceback
import ih.imgproc
import os
import sqlite3
import shutil
parser = argparse.ArgumentParser(description = "Extracts numerical information from multiple images.")
parser.add_argument("--inputs", dest="inputs", nargs="+", help="Path to processed image.", required = True)
parser.add_argument("--db", dest="db", help="Path to database to write", required = True)
parser.add_argument("--copydb", dest="copydb", help = "Copy database file specified by db to new output db specified by argument.")
parser.add_argument("--createdb", dest="createdb", default=False, action="store_true", help = "Create database file specified by db")
parser.add_argument("--dimensions", dest="dimensions", default=False, action="store_true", help="Extract dimensions.")
parser.add_argument("--dimfromroi", dest="dimfromroi", default=[], nargs="+", help="Path to roi files for modified dimensions extraction.")
......@@ -21,7 +23,10 @@ parser.add_argument("--circle", dest="circle", default=False, action="store_true
args = parser.parse_args()
try:
if args.createdb:
if args.copydb:
shutil.copyfile(args.db, args.copydb)
args.db = args.copydb
elif args.createdb:
conn = sqlite3.connect(args.db)
conn.execute("drop table if exists images")
conn.commit()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment