Move annotations for 1px to the left und 1px up by scripting

Hi,
Pete published the wonderful and perfectly running script to create annotions from binary masks:
“Importing binary masks & creating annotations”

I´d like to move all resulting/ newly created annotations for one pixel up and one pixel to the left.

Is there a way to do that by script?

Thank´s for ideas!

the challenge was solvable by increasing the resolution of the imported binary masks.
But still the function would be interesting anyway.

It’s a bit of a hack, but this should do it:

int dx = -1
int dy = -1
def annotations = getAnnotationObjects()
annotations.each {
    it.setROI(it.getROI().translate(dx, dy))
}
fireHierarchyUpdate()
2 Likes