Automated mask arithmetic in QuPath

Hi all,

I’m a bit new to QuPath and couldn’t really get the following to work (as a script). Here’s my case:

I have a picture of a histological section (large object) within which I manually contour an annotation. I have a well-working classifier for the background as well:

Now, is there an (automated way) to generate an annotation for the checkered area based on the annotations of Background and “Annotation”? It’s not a difficult process: The checkered area = intersection(not(Annotation), not(Background)) - I just don’t know how to do it programmatically in QuPath.

Thanks in advance!

Sounds very similar to what was mentioned here:

And here if you want to do it manually:

Subtraction is now in the context menu*->Annotations->Edit multiple->Subtract selected*.

Now that I look in the scripts, there is also this: https://gist.github.com/Svidro/5829ba53f927e79bb6e370a6a6747cfd#file-object-subtraction-groovy