Skip to content

Nested detections render poorly when filled #2112

@petebankhead

Description

@petebankhead

Bug report

Describe the bug

When detections are nested in the object hierarchy, their opacity is adjusted too eagerly - with the result that the appearance can be very odd.

This was (I think) introduced so that subcellular detections could be seen more easily, but it isn't good general behavior.

To Reproduce

Steps to reproduce the behavior:

  1. Open an image and create a selected rectangle annotation
  2. Run the following script
var pathObject = getSelectedObject()
var roi = pathObject?.getROI()
if (roi == null || !roi.isArea())
    throw new RuntimeException("I need an area ROI!")

pathObject.clearChildObjects()
for (int i = 0; i < 3; i++) {
    double diam = Math.min(roi.getBoundsWidth(), roi.getBoundsHeight())
    roi = RoiTools.buffer(roi, -diam / 4.0)
    var newObject = PathObjects.createDetectionObject(roi, getPathClass("Class " + i))
    pathObject.addChildObject(newObject)
    pathObject = newObject
}
  1. Check how it appears in the viewer - including with 'Fill detections' toggled on.

Expected behavior

Two things should improve:

  1. The default behavior should (at most) adjust the opacity in a more reserved way that is more general. Making no opacity changes with nested objects is probably undesirable, since there is a risk of masking child objects entirely.
  2. Metadata values for fillOpacity should be respected.

The second refers to a trick that QuPath can use to smuggle in object-specific rendering hints.
Adding the following line to the script can change the default opacity of the objects

newObject.metadata['fillOpacity'] = '1'

but this doesn't have any influence upon how the opacity is adjusted when the objects are nested. I think that probably setting the metadata should enable the opacity to be locked, irrespective of nesting.

Screenshots

Image

Desktop (please complete the following information):

  • OS: macOS (but all)
  • QuPath Version: v0.7.0 (and earlier)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions