How to delete object detections keeping the the annotation?

Hi Everyone,

I need to delete all the object detections from my image but keep my area annotations intact. I have tried to run the following script found in Github for “Remove detections outside annotations”. But its not working.

selectObjects{p -> (p.getLevel()==1) && (p.isAnnotation() == false)};
clearSelectedObjects(false);

Is there any way to solve this ?

Thanks in advance!

Sample image and/or code

  • Upload an original image file here directly or share via a link to a file-sharing site (such as Dropbox) – (make sure however that you are allowed to share the image data publicly under the conditions of this forum).
  • Share a minimal working example of your macro code.

Background

  • What is the image about? Provide some background and/or a description of the image. Try to avoid field-specific “jargon”.

Analysis goals

  • What information are you interested in getting from this image?

Challenges

  • What stops you from proceeding?
  • What have you tried already?
  • Have you found any related forum topics? If so, cross-link them.
  • What software packages and/or plugins have you tried?

If you go through the Objects menu there should be a delete all detections option:
image
Which in the workflow tab comes out to:
clearDetections();

The script listed, as the title suggests, only deletes detections that are not currently “inside” of another object, and is probably functioning as intended.

1 Like

Thanks a million !! It worked!

1 Like

My primary intend was to delete only the objects outside the annotations, but its not working in that way. All the objects are still there. But now I deleted all the objects and running cell detection again, this time only inside my annotations.

Odd, something else is going on then - I was just able to run the script to remove the cells outside of ANY annotation.