Any way to "Handle" images during previews

This post is more of a feature request. Certain tools/plugins allow a “Preview” mode before an operation is executed on an image, a very useful thing. Unfortunately the dialog box takes exclusive focus, and the user cannot do basic handling, specifically zoom/pan functions. Sometimes the effect of an operation can only be seen on a zoomed view across several areas of the canvas, far beyond what a screen can reasonably display.

Current workaround is to apply the operation, inspect after the fact, and undo if not suitable, which defeats the purpose of “Preview”.

I can see individual tool/plugin authors adding a up/down/left/right buttons for panning, and slider or input box for zoom factor but this seems something that can be better handled if all subcalls could can temporarily relinquish focus back to JUST the image in question, provided the tool/plugin gets focus back, and the focus transfer is sandboxed such that no operation occurs that would de-stabilize the tool/plugin or ImageJ (or, you know, rupture the space-time continuum as we know it, because that would be bad).

What you describe is a limitation of the plugins in question. The dialog of each previewable operation could be made modeless (i.e.: non-blocking) but it would require changes to each plugin’s source code; there are good reasons not to make GenericDialog non-blocking in general.

Note also that one advantage of “Preview” is that it happens quickly. In some cases, the computation may not actually even be done across the entire image, but only on the currently visible pixels, or current image plane. Making the dialog non-blocking would require making the plugin more intelligent, to respond to changes in the current view of the image, so that the newly visible pixels get computed. This can become complicated depending on the operation being previewed.

Your idea of “sandboxing” the focus transfer would unfortunately not be feasible, in my experience. It is largely all or nothing: make the dialog blocking, or don’t. Contingently deactivating large portions of the UI would become very complex. Points for the Ghostbusters reference though!

A potential workaround for your particular scenario is to crop only the areas which will need to be inspected, stitch them together as a mosaic, then preview the operation on that mosaic. This would give you “at a glance” verification in many cases of what would happen to the original data. Not ideal, I know, but maybe faster than repeatedly applying and undoing on the full-size data.

In principle, ImageJ2 could introduce a framework to make this sort of enhanced preview possible. But we would need to think carefully about exactly how to achieve it such that every operation meeting the criteria inherits the capabilities “for free” (i.e., without extra programming effort). We have recently been discussing related/similar functionality in the ImageJ Ops project (see imagej/imagej-ops#173 for technical details), which might be a good fit for an enhanced/dynamic preview feature.

Anyway, if you feel strongly about this feature request, file an issue for it.

2 Likes

Yes, I get that it is really should be handled within the plugin, and jumping in and out leads to spaghetti code. I also understand the dangers of non-exclusive focus (non-blocking) However, the preview function is a good feature that should be found in a lot more plugins, and a natural extension of preview is the problem of panning/zooming. A common library to handle these tasks would be useful (again, there are other priorities, I’m just throwing the idea out for consideration).

Didn’t think of that. I seem to have forgotten the lessons of the early days of 3D video cards, when it was a mind-blowing concept to process only what was visible, rather than rendering the whole environment, significantly speeding up video card performance back in the day…

Good stuff. The point of the post was to get ideas out there. If developers see it and give it fair consideration, that is enough for me, it is not urgent enough to demand it.