Browse Source

explicit converting tif images to mode "I"

master
Holger Frey 6 years ago
parent
commit
0a6f07a087
  1. 59
      mtor/gui.py
  2. 2
      mtor/imageproc.py
  3. 2
      mtor/prescan.py

59
mtor/gui.py

@ -217,30 +217,37 @@ class MtorImageAnalysis(QWidget): @@ -217,30 +217,37 @@ class MtorImageAnalysis(QWidget):
def run_gui():
app = QApplication(sys.argv)
mia = MtorImageAnalysis()
app.exec_()
if mia.analysis_parameters is not None:
pw = prescan_workflow(**mia.analysis_parameters)
iw = image_workflow(pw.parameters)
dw = data_workflow(iw.data, iw.parameters)
fw = postprocessing_workflow(dw.data, dw.parameters)
pdf_path = fw.parameters.data_dir / "report.pdf"
if sys.platform.startswith("win"):
os.startfile(str(pdf_path))
else:
if sys.platform.startswith("darwin"):
cmd = ["open", str(pdf_path)]
import traceback
try:
app = QApplication(sys.argv)
mia = MtorImageAnalysis()
app.exec_()
if mia.analysis_parameters is not None:
pw = prescan_workflow(**mia.analysis_parameters)
iw = image_workflow(pw.parameters)
dw = data_workflow(iw.data, iw.parameters)
fw = postprocessing_workflow(dw.data, dw.parameters)
pdf_path = fw.parameters.data_dir / "report.pdf"
if sys.platform.startswith("win"):
os.startfile(str(pdf_path))
else:
cmd = ["xdg-open", str(pdf_path)]
Popen(
cmd,
shell=False,
stdin=None,
stdout=None,
stderr=None,
close_fds=True,
)
sys.exit()
if sys.platform.startswith("darwin"):
cmd = ["open", str(pdf_path)]
else:
cmd = ["xdg-open", str(pdf_path)]
Popen(
cmd,
shell=False,
stdin=None,
stdout=None,
stderr=None,
close_fds=True,
)
except Exception as err:
traceback.print_exc()
input("Press enter to close this window")
finally:
sys.exit()

2
mtor/imageproc.py

@ -12,7 +12,7 @@ from .commons import ( @@ -12,7 +12,7 @@ from .commons import (
def open_as_array(tif_image):
with tif_image.path.open("rb") as filehandle:
image = Image.open(filehandle)
image = Image.open(filehandle).convert(mode="I")
image_array = numpy.array(image, dtype=numpy.int32)
return TifArray(
path=tif_image.path, frame=tif_image.frame, data=image_array

2
mtor/prescan.py

@ -11,7 +11,7 @@ def scan_tifs(parameters): @@ -11,7 +11,7 @@ def scan_tifs(parameters):
for tif in tqdm(parameters.tif_list):
with tif.path.open("rb") as filehandle:
image = Image.open(filehandle)
image = Image.open(filehandle).convert(mode="I")
mi, ma = image.getextrema()
lowest = min(lowest, mi)
highest = max(highest, ma)

Loading…
Cancel
Save