Previewing in G'MIC


Previewing without outputting is pretty useful. However, when working with multiple images, the thumbnail view takes a while to load (at least on my computer). Going from thumbnail view to single view is quick. Going back isn’t.

  • Is there a way to create multiple windows, one per image in the pipeline?
  • Or a way to switch between images in the single view mode?


This is what I am doing at the moment

gmic -parallel "-sp lena -display[0]","-sp tiger -display[1]"

Let me know if there is a better way.

(David Tschumperlé) #3

Yes that seems to be a reasonable way of doing it. I think I’ll even propose a command for that in the stdlib, that seems to be useful.
Anyway, I don’t understand why the default list viewer is slow. Do you have a lot of images ? Could you do a video of how slow it is ? I suppose there are ways to optimize it.

(David Tschumperlé) #4

I’ve added command ‘-display_parallel’ (eq. to ‘-dp’) which does basically this :

$ gmic -sp lena -sp tiger -sp square -dp

Should be useful.


Thanks. I will take a look once it propagates to the binaries.

(David Tschumperlé) #6

As this is just a new ‘custom’ command of the stdlib added, you can just try

$ gmic -up

to make it available. The stdlib is downloaded from the G’MIC website, and updated immediately.


A parallel counterpart to -display0 would be awesome.

Also, I was wondering if there is a flexible way to output information. Currently, I use ImageMagick’s -format option, which is powerful, but sometimes I just want to use gmic by itself.

(David Tschumperlé) #8

Good idea, I’ll add it.

You can write something like this for instance:

$ gmic -v - -sp lena -echo_stdout \"Size : \"{w}x{h}\" \(\"{w*h}\" pixels\), with \"{s}\" channels.\"

which outputs (on the terminal):

Size : 512x512 (262144 pixels), with 3 channels.

But note that contrary to ImageMagick, G’MIC doesn’t remember a lot of information about the images you are downloading: it ignores most of the metadata, the bit depth, etc…, so depending on the information you want to print, IM may be more adapted. Anyway, the math expression evaluator in G’MIC is extremely powerful, so if you want to display some calculation results from your images, it is likely that’s a good tool to work with (see for a quick tour of the G’MIC evaluator).


Nice. I will take a look.


While dp and dp0 are wonderful additions, I still find the original d and d0 commands useful. However, browsing can be awkward and tedious. E.g., take gmic sp tiger,dog,square:

  1. Going back to thumbnail view from single image view is clunky. Sometimes, I accidentally zoom in, and other times, the click doesn’t register because the mouse isn’t window active.

  2. It would be nice if I could simply proceed forward and backward through the list without going back out into the thumbnail view. A shortcut or GUI would be nice for quick browsing.

  3. It would be nice if the image aspect ratio were preserved regardless of the window’s dimensions. This would be the default behavior that could be changed if user wanted.

  4. It would be nice if, in dp and dp0 mode, I could sync the zoom level between windows.

  5. Probably not for CLI, but I do miss the ability to toggle a preview in the plugin version. In the case of the CLI, it would be the ability to stack two images with the same dimensions and be able to toggle quickly between them. I guess this would be a more specific version of #2.

(David Tschumperlé) #12

This is an interesting point. i’ll see what I can do for this.

I like to be able to change the ratio for specific images (e.g. 1xN vectors).
If you want to enlarge/reduce the window size, the convenient keyboard shortcuts CTRL+D, CTRL+C and CTRL+R are here.

What I do usually is stacking the images with append z , then use the mouse wheel to switch from one plane to another. This is a convenient way of comparing two or three images together.

(David Tschumperlé) #13

Actually, one really cool thing would be to rewrite an image viewer directly as a G’MIC command, put in the stdlib. This is possible, because G’MIC is able to manage display windows and user events.
And we would then have the opportunity to improve the command without having to update/recompile the G’MIC binaries.


Thanks for exposing more to the stdlib. As with color conversions, I am unqualified to extend such commands; I will still have to depend on the efforts of others :baby_chick:.

Concerning display_graph, it would be nice if we could

  • Control the interval size of the axes.
  • Use the mouse to query graph values by placing the mouse on the graph, as opposed to getting image coordinates and values.
  • Be able to insert threshold lines; e.g., x = 1. That would be awesome.

(David Tschumperlé) #15

This can be done using interactive command plot instead of display_graph.

Yes, probably. But for complex plot displays, GNUplot is probably a better choice :slight_smile:


Silly me, I completely overlooked plot. Thanks.

Unfortunately, it doesn’t appear to work when zoomed in.

(David Tschumperlé) #18

Actually, mouse wheel is already used in volumetric image to loop over the slices.
Maybe something like ALT+mouse instead.


I just tried plot. It would be nice if I could read the interpolated values along the line and that it would be in (x,y) format.

As long as I can alternate between 1-3 images quickly, :+1:.

(David Tschumperlé) #20

There is another point to mention : I try to reduce the use of the keyboard because there is an option in command display that is exit_on_any_key which allows the user to basically catch keyboard events when displaying images.
ALT being a modifier, it is OK, but keep in mind that adding more and more keyboard shortcuts is not really desired if we don’t want to break this key event catcher ability.

(David Tschumperlé) #21

After some experiments, Alt is not great to use (at least on Linux), because it is already use by most WM to move/resize windows, so it is not possible to have Alt+mouse working for selecting multiple slices at once.
For now, I’ve tried then CTRL+mouse to be able to alternatively select a region in a volumetric image (keeping all slices at once). Seems to work. Require mores testing obviously :slight_smile:

(David Tschumperlé) #22

So here is the solution I’ve chosen, it seems to be quite practical, at least from the quick tests I’ve done :

  • 2d images : zooming can be done with mouse wheel or mouse selection as before. When in zoomed mode, you can use SHIFT+wheel to move up/down, and CTRL+SHIFT+wheel to move left/right.

  • 3d images (volumetric) : mouse wheel is still use to loop over the slices/rows/columns as before. You can now zoom with mouse selection, CTRL + mouse selection or CTRL+mouse wheel.
    In the two latter cases, the zoom is performed in the space of the image quadrant you are on. So CTRL+wheel on the (x,y) part of the image will magnify only the (x,y) coordinates while keeping the z coordinate unchanged. See CTRL+ being a way to invoke an alternate zooming procedure.

So, now, to compare two images, it is quite easy to create a volumetric image, then use CTRL+ zoom mode to zoom in/out and then mouse wheel to compare the two images at the same zoom level.

PS : I’ll post new 2.2.0_prerelease packages today with this addition.