Adding filled overlays to OverlayOutlines


I’m playing with the scratch wound assay pipeline and thought it would be neat to make a movie with the Tissue objects overlayed as filled objects rather than outlines.

At the bottom, I provide a dropbox link to my quick attempt at modifying

Where I’m stumped is that there is a OULTINE_COLOR attribute for outlines but not for the fill color. Specifying CPLD_MODE: CPLDM_ALPHA colours each object according to the CPLD_ALPHA_COLORMAP.

Could you add a FILL_COLOR property? Or am I missing something and there is a way round? This is the bit of code I added (for the display, I haven’t altered the code for the image returned yet):

if self.wants_filled.value == WANTS_FILLED: d = { CPLD_NAME:name, CPLD_LABELS:ldict[name], CPLD_OUTLINE_COLOR: color, CPLD_MODE: CPLDM_ALPHA, CPLD_LINE_WIDTH: 0, #self.line_width.value, CPLD_ALPHA_VALUE: self.object_opacity.value/100.} else: d = { CPLD_NAME:name, CPLD_LABELS:ldict[name], CPLD_OUTLINE_COLOR: color, CPLD_MODE: CPLDM_OUTLINES, CPLD_LINE_WIDTH: self.line_width.value } cplabels.append(d)

Problems attaching files, must me my first post.

The code:

The result so far (would like both sides to be overlayed in red):

EDIT OK, looking further into the get_outline() method, and if I understand this correctly, I need test the values returned by distance_transform_edt to basically say “any pixel within the objects” rather than “pixels within a width distance from the border”. Then there’s the alpha value to take care of for the overlay. Complicated! :smile:

Kind regards,

Hi Egor,

I’m wondering whether there might a workaround for what you want, using DisplayDataOnImage:

  • Select the objects you want to display.
  • Select the measurement you want to display. You could use Number: Object_Number to display the object labels.
  • Select “Yes” to using a guiding image, and pick the image of choice (presumably the same one you’d use for OverlayOutlines).
  • This is the big one -> Set “Display mode” to “Color”

I think this gets you similar results, though arguably the opacity could be adjusted.


Hi Mark,

I’m getting there. I had a look at “” to find how the object pixels were counted and found this:

area_occupied = np.sum(objects.segmented > 0)

Using objects.segmented in my get_outlines() gets to this image:

Updated code (filled only works with objects for now):

EDIT Managed to sort out the opacity. As easy as

if self.wants_filled.value == WANTS_FILLED: output_image:, :, 3] = self.object_opacity.value/100.