After writing about a few quite long and pretty complex scripts (which turns out to be exhausting!), here’s a simple one.
Sometimes we might wish to perform analysis in regions of a specific size (rather than across a full image).
Or perhaps we want to extract image patches for the development of an algorithms elsewhere.
Drawing the annotations by hand would be much too slow and inaccurate, and some kind of help is needed.
This problem can actually be solved through the GUI with Objects → Specify annotation and Objects → Duplicate annotation, but it’s a bit cumbersome.
The script below can be used to create rectangle annotations centered on the part of the image currently being viewed.
It also applies a classification ‘Region’ to that annotation, which could be used later to distinguish annotations generated this way from others.
I have the idea of making some classifications ‘special’ in future QuPath editions… and ‘Region’ currently looks like being one of them. Annotations classified in this way might be used differently, e.g. not contribute when training a classifier, and not be ‘filled in’ whenever other annotations are displayed as ‘filled’.
However as yet I’m not certain if that is necessary, or if the lack of a classification is enough to serve this purpose. Opinions welcome…