Skip to content

Commit

Permalink
Minor fix + call of new button generation
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaSchlucke committed Aug 4, 2024
1 parent 38b93a9 commit d28d941
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions cellpose/gui/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ def _load_image(parent, filename=None, load_seg=True, load_3D=False):
""" load image with filename; if None, open QFileDialog """
#checks if the file is a tiff
if filename and (filename.endswith('.tif') or filename.endswith('.tiff')):
parent.grayscale_image_stack = initialize_tiff_images(parent, filename)
successful_import, grayscale_image_stack = initialize_tiff_images(parent, filename)
if successful_import:
parent.grayscale_image_stack = grayscale_image_stack
parent.generate_multi_channel_ui()

if filename is None:
name = QFileDialog.getOpenFileName(parent, "Load image")
Expand Down Expand Up @@ -760,15 +763,14 @@ def initialize_tiff_images(tiff_file_path):
count=-1,
flags=cv2.IMREAD_GRAYSCALE)

if not ret:
return []

processed_images = []
for img in images:
# Convert the grayscale image to an LA image with black as transparent and white as opaque with a white background in the L channel
img = Image.fromarray(img)
white_bg = Image.new("L", img.size, 255)
img = Image.merge("LA", (white_bg, img))
processed_images.append(img)
return processed_images
if ret:
processed_images = []
for img in images:
# Convert the grayscale image to an LA image with black as transparent and white as opaque with a white background in the L channel
img = Image.fromarray(img)
white_bg = Image.new("L", img.size, 255)
img = Image.merge("LA", (white_bg, img))
processed_images.append(img)
return ret, processed_images
return ret, []

0 comments on commit d28d941

Please sign in to comment.