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):
def run_gui(): def run_gui():
app = QApplication(sys.argv) import traceback
mia = MtorImageAnalysis()
app.exec_() try:
if mia.analysis_parameters is not None: app = QApplication(sys.argv)
pw = prescan_workflow(**mia.analysis_parameters) mia = MtorImageAnalysis()
iw = image_workflow(pw.parameters) app.exec_()
dw = data_workflow(iw.data, iw.parameters)
fw = postprocessing_workflow(dw.data, dw.parameters) if mia.analysis_parameters is not None:
pdf_path = fw.parameters.data_dir / "report.pdf" pw = prescan_workflow(**mia.analysis_parameters)
if sys.platform.startswith("win"): iw = image_workflow(pw.parameters)
os.startfile(str(pdf_path)) dw = data_workflow(iw.data, iw.parameters)
else: fw = postprocessing_workflow(dw.data, dw.parameters)
if sys.platform.startswith("darwin"): pdf_path = fw.parameters.data_dir / "report.pdf"
cmd = ["open", str(pdf_path)] if sys.platform.startswith("win"):
os.startfile(str(pdf_path))
else: else:
cmd = ["xdg-open", str(pdf_path)] if sys.platform.startswith("darwin"):
Popen( cmd = ["open", str(pdf_path)]
cmd, else:
shell=False, cmd = ["xdg-open", str(pdf_path)]
stdin=None, Popen(
stdout=None, cmd,
stderr=None, shell=False,
close_fds=True, stdin=None,
) stdout=None,
stderr=None,
sys.exit() 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 (
def open_as_array(tif_image): def open_as_array(tif_image):
with tif_image.path.open("rb") as filehandle: 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) image_array = numpy.array(image, dtype=numpy.int32)
return TifArray( return TifArray(
path=tif_image.path, frame=tif_image.frame, data=image_array path=tif_image.path, frame=tif_image.frame, data=image_array

2
mtor/prescan.py

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

Loading…
Cancel
Save