napari-micromanager icon indicating copy to clipboard operation
napari-micromanager copied to clipboard

Rotate / Flip live image

Open CedricEsp opened this issue 3 years ago • 6 comments

Hello,

The camera chip I am using is not square and I would like to Flip and rotate the image, I can do that after acquisition in the engine but I wonder if there is an option to rotate the image on the live view as well?

Thanks! Cedric

CedricEsp avatar Jul 18 '22 22:07 CedricEsp

Curious what @tlambert03 thinks but I think I'd prefer to implement such functionality in pymmcore-plus instead of here. Something like:

core.image_transforms.append(np.flip)

and then we could create a widget that allows for re-ordering, adding, and deleting transforms

ianhi avatar Jul 19 '22 01:07 ianhi

As a hack for live view you can monkey patch core.getLastImage with a function that calls the original function and then returns the flipped image. See https://github.com/ianhi/mda-simulator/blob/3ba66e729931a92e463f2ce1cf8a5a5241c898d2/mda_simulator/mmcore/_mmcore.py#L90

an untested guess at this would be:

orig_getLastImage = core.getLastImage

def getLastImageFlipped()->np.ndarray:
    return np.flip(orig_getLastImage())

core.getLastImage = getLastImageFlipped

ianhi avatar Jul 19 '22 01:07 ianhi

Curious what @tlambert03 thinks but I think I'd prefer to implement such functionality in pymmcore-plus instead of here. Something like:

love that idea. Maybe it's time to generally attack adding functional hooks to the engine?

tlambert03 avatar Jul 19 '22 10:07 tlambert03

love that idea. Maybe it's time to generally attack adding functional hooks to the engine?

When you say "functional hooks" what does that mean?

ianhi avatar Aug 08 '22 19:08 ianhi

Meaning: it's one thing to be able to connect callbacks to events emitted by the MDA... but that's one way communication: we can't modify the events and or the image in the process. A functional hook would provide a way to modify either the event object and or the image itself before further processing and/or event emission

tlambert03 avatar Aug 08 '22 19:08 tlambert03

Ahh gotcha. Is this something that we should use a library (a la psygnal) for, or is better to go simpler with something like keeping a list of functions to evaluate?

ianhi avatar Aug 08 '22 19:08 ianhi