Commit b6feb007 authored by Andrew Lyon's avatar Andrew Lyon
Browse files

Fix artifact in writing condensate_masks_color image where the corner of the...

Fix artifact in writing condensate_masks_color image where the corner of the droplet bounding box overlays green on top of red or blue pixels by zeroing green value in all pixels where red or blue value is greater than zero.
parent cf4be6c3
......@@ -16,9 +16,7 @@ def parse_args(args):
parser = argparse.ArgumentParser(description="Given images of microfluidic droplets containing biomolecular "
"condensates, return dilute and dense phase concentrations.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("--input", help="Input raw image file(s).", nargs="+", type=str,
default=["/Users/andrewlyon/PycharmProjects/processMFLLPS/stack1.tif",
"/Users/andrewlyon/PycharmProjects/processMFLLPS/stack2.tif"])
parser.add_argument("--input", help="Input raw image file(s).", nargs="+", type=str)
parser.add_argument("--dark", help="Dark image for background subtraction.")
parser.add_argument("--flatfield", help="Image for flatfield correction.")
parser.add_argument("--segchannels", help="Which color channels to use in droplet boundary segmentation.",
......@@ -584,7 +582,6 @@ def main(args):
out_areas.append(area)
if args.writeintermediates:
# Write the colored dense/dilute phase mask image
# TODO: Neither adding or overwriting is really a satisfactory approach. Probably would be best to order the droplets from largest to smallest and write the image in that order since the largest droplets are going to have the biggest effect in summing pixel intensities.
for dilute in dilute_phase_color:
# Dimension 2 is blue channel for RGB image
# The droplet boundary is determined after the watershedding step so adding intensites for each droplet
......@@ -592,14 +589,17 @@ def main(args):
img_color_mask[dilute[0][0]:dilute[0][2], dilute[0][1]:dilute[0][3], 2] += dilute[1]
for neither in neither_phase_color:
# Dimension 1 is green channel
# The pixels in each cropped droplet image outside the dilute phase mask would get double counted
# if the intensities were added, so this channel isn't directly proportional to the input pixel
# intensities.
img_color_mask[neither[0][0]:neither[0][2], neither[0][1]:neither[0][3], 1] += neither[1]
# The pixels in each cropped droplet image outside the dilute phase mask get double counted
# if the intensities were added, so this shouldn't be added. Zeroing out the some of the green pixles
# after building the image seems like the best way to handle this.
img_color_mask[neither[0][0]:neither[0][2], neither[0][1]:neither[0][3], 1] = neither[1]
for dense in dense_phase_color:
# Dimension 0 is red channel The dense phase is strictly contained inside the dilute phase mask so
# adding intensites for each droplet will not double count pixels
img_color_mask[dense[0][0]:dense[0][2], dense[0][1]:dense[0][3], 0] += dense[1]
# Zero out green pixels overlapping with red or blue pixels
img_color_mask[img_color_mask[:, :, 0] > 0, 1] = 0
img_color_mask[img_color_mask[:, :, 2] > 0, 1] = 0
step += 1
img_name = os.path.join(img_base_name, img_base_name + "_" + str(step) + "_condensate_masks_color" +
".tif")
......
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