Liquid Rescale GIMP Plug-In version 0.7 help page
The Liquid Rescale GIMP Plug-In is an implementation of the content-aware resizing by
seam carving algorithm by Shai Avidan and Ariel Shamir.
It aims at resizing pictures non uniformly while preserving the features of the picture,
i.e. avoiding distortion of the important parts of the picture.
It can also be used to remove portions of the picture in a consistent way.
It works both ways, shrinking and enlaging (enlarging is performed in successive steps), and
it can use extra layers as masks to select which features of the image should be
preserved and which should be discarded.
The plugin works on the active layer or floating selection. It can also operate on multiple layers
through the
"Filter all layers" plugin and using the GIMP Animation Package facilities for
video editing (see
this section for details).
The plugin only works on whole layers, if a selection is present it is saved to a channel and removed.
If the layer has a transparency mask, an option is given to select the behaviour (apply/discard).
The plugin can also be operated in batch mode from the command line, see
this section for details.
User interface description (non-interactive mode)
Select new width and height
In this section it is possible to choose the final size.
It is advisable to rescale always in one direction at a time. If both
the width and the height are changed, rescaling is performed by default on the
width first, then on the height. This can be changed in the "Advanced" tab.
The two small buttons on the right can be used to reset the size parameters
to the image size (top) or set them to the last used values (bottom), while the
bigger button to the right switches to the interactive mode (see the
corresponding section for more details).
Note that the final size can be set automatically when removing objects, see below.
Feature masks
Quick guide
The easiest way to manually select the features of the image that you want to protect
or discard is the following:
-
Select the layer you want to resize (not a floating selection) and invoke the plugin
-
Press the "New" button in the "Feature preservation mask" section
(this will create a transparent layer, with 50% opacity, and pick an appropriate
colour; also, the plugin main dialog will be substituted by a small dialog).
-
Paint on the areas of the image you want to preserve, e.g. with the paintbrush
-
When you're done, press OK in the small window: the main dialog will appear again.
-
Repeat everything for the features you want to discard
If you want to remove portions of the image, you can press one of the two
buttons besides the "Auto size" label to determine
the final size automatically (this is only reliable when dealing with very simple
masks).
Note #1: object removal is only possible when shrinking. By default,
feature discard masks are ignored when enlarging, because in that case the masked
areas would be inflated rather then removed. If you actually want to get this effect,
you need to unset the corresponding option in the "Advanced" tab (or use
interactive mode).
Note #2: preservation of features is not possible if enlarging too much,
because the inflation process is the exact reverse of the shrinking process,
so the maximum amount of pixels you can add to a layer corresponds to the
amount of pixels which are not protected. For example, if you have a 1000 pixel
wide image and you have marked a 800 pixel wide area for protection, the final
width should be less than 1200 pixels. If you want to enlarge more, do it in
steps, or set the "Max enlargment per step" option in the advanced settings
to an appropriate value.
Full description
In the "Feature preservation mask" section
it is possible to specify if there are regions of the image which
should be preserved from modification, by checking the "Activate feature preservation"
box, and by choosing a layer among the ones which belong to the current image (excluding the active one)
in the "Available layers" menu.
The "New" button creates a transparent layer with 50% opacity and an appropriate name,
sets it as the selected layer mask and switches to a "mask editor" mode, in which there only is a reduced,
always-on-top dialog, and in which the foregroud colour is set to green. When you exit the "mask editor" mode,
the previous foreground colour is restored and the plugin main dialog is presented again with the updated
information.
The "Edit" button invokes the "mask editor" mode over the currently selected preservation mask.
Note that the "mask editor" mode is useless if the plugin is invoked on a floating selection unless a new layer
is created from it, because GIMP does not allow to work on other layers in such case.
The intensity of the effect of the mask on each pixel is obtained as
the average on the pixel's colour channels, multiplied by the alpha channel. Thus, for an RGB layer
with an alpha channel, the maximum value is achieved on white pixels, while black ones
and transparent ones are ignored.
In general, it is advisable to use a single colour for each mask, and, if needed, fine-tune the strenght
of the mask for different areas by using the transparency value, instead of lightness or saturation.
The size and position of the selected layer can be arbitrary, the plugin will only use
those portions which overlap with the active layer.
The "Strength" scale can be used as a global parameter to modulate the feature preservation.
Note that thinner selection areas (in the sense of the resizing) need higher strength values, and
vice-versa.
When a preservation mask is selected, the small green icon under the layer thumbnail on the left will
become active, and its tooltip will give you the name of the selected preservation layer. The remaining two
icons serve the same purpose for the discard mask (red) and the rigidity mask (blue).
The Feature discard selection section is nearly identical to the previous one,
but the effect is reversed, and the default colour for the "New" and "Edit" buttons is red instead of green.
Furthermore, there are two additional buttons besides the "Auto size:" label, which can be used for
"quick & dirty" object removals. When one of these buttons is pressed, the plug-in tries to compute the exact
amount of rescaling which is needed in order to remove the areas of the image marked by the current discard mask,
and sets the final size accordingly (in the "Select new width and height" section).
These buttons will always produce a single-direction rescale: the "Width" button changes just the width
and sets the height to its original value, the "Height" button does the opposite.
Note that this option is only suitable for naïve object removals, and it may fail if the masks are
non-trivial.
[Technical information: the final size is determined by simply finding out the maximum number of
pixels in a line for which the mask value is above a given threshold, which is set to the 50% of a full
RGB colour (e.g. red in the default setting).]
Output
This tab has a number of options related to the output of the plugin.
- Output target
-
Specifies if the resized image should be written on the currently selected layer, or on
a new one, or on a new image. In the latter case, the newly created image will contain all the
output from the plugin, including the rescaled auxiliary layers and the seams map (see below).
By default, it is set to the selected layer.
- Resize image canvas
-
Specifies whether the image canvas should be resized to meet the new size of the active
layer. By default, it is on.
- Resize auxiliary layers
-
Specifies whether the layers used to manually select the features of the image
or to specify a rigidity mask will be resized along with the active layer.
If this option is checked, those layers will be first cropped to the active layer's size,
then they will undergo the same seam carving and inserting process as the active layer.
By default, it is on, but it is only active when some layers are selected in
the "Feature masks" tab or if a rigidity mask is being used (see below).
- Output the seams on a new layer
-
Specifies whether to create a new layer with the seams map in interactive mode.
The two buttons on the right of it let the user choose the seams colour range.
The seams are computed on the original layer as far as they are needed for the new size
(e.g. there will be 100 seams if reducing or enlarging by 100 pixels), the remaining
areas are transparent. In order to read the result, use this option with the
"Output target" set to "new layer", and overlay the seams map to the original layer.
If you rescale in two directions at once, you will obtain two maps, but the second
one will be computed over an invisible intermediate image, so this is not very useful.
The same applies in the case you choose to rescale back to the original size with LqR,
or when the resizing goes beyond the limit set with "Max enlargment per step".
Note that this option is ignored in interactive mode, except for the colours you choose,
which are used when dumping the seam maps manually.
- Scale back to the original size
-
Specifies whether to perform a scale back operation after the liquid rescale operation
has been performed.
This can be useful for example for object removal and content enhancement.
If this option is checked, a menu appears below it to let the user
choose the details of the operations: it is possible to revert to the opriginal width
and height using either liquid rescale or the standard scaling algorithm, or it is
possible to perform a uniform scaling with the standard algorithm and reach back only
the original width, or only the original height.
Note that this option is ignored in interactive mode.
Advanced
This tab has some options which can be used to tweak the plugin behavior.
Seams control
- Max transversal step
-
This option lets you choose the maximum transversal step that the pixels in the seams can
take. In the standard algorithm, corresponding to the default value step = 1, each pixel
in a seam can be shifted by at most one pixel with respect to its neighbors.
This implies that the seams can fo