Interpolation Plugin

This is an interpolation plug-in for the GIMP. It works by doing plane/curve fitting and calculating weighted averages. It takes samples from a grid of pixels from 'known' image areas, trying to fit a plane or a curve to each, and then uses those samples to estimate the 'unknown' image areas.

Upper-left: original image, upper-right: result after interpolation,
lower left: selection (a.k.a. output mask), lower right: input mask

0.2 version is now based on the standard gimp-plugin-template and so should be easy to compile on any system. There are some fixes and additions. If you find any bugs in the code, please send me a patch or a bug report.

0.4 has an improved UI with a preview, support for using the active brush as a kernel, and a convenience option for internally subtracting the selection from the input mask.

0.5 can work with gamma-compressed images (internally transforming them into linear space and back again, with no loss of bit-depth, since floating-point numbers are used), can handle large images by taking samples only from a grid of points (instead of from every pixel) and has a few more new things. See the ChangeLog for details.

0.6 now supports quadratic approximation (x*x, x*y and y*y terms), has better arranged data (so as to make it easier to support new curve-fitting methods, or custom combinations of functions), can use a separate 'slopes' mask (so that the set of pixels used for calculating slopes can be different than the set of "slopes samples" used to calculate the output pixels), has sinc kernels, has 'cap' and 'base' settings for radius-based kernels, has separate horizontal and vertical kernel window settings (optional) and has a few bug-fixes. By using a separate "slopes mask" in combination with the newer "least squares" methods, you can use the filter in a completely new way: Instead of calculating a plane for each input pixel (or grid square) based on its near neighborhood, you can calculate planes (or curves) at sample points *within* the selection, based on a wide area (slopes window) that includes input pixels.

1.0 is simply 0.6 with a few bug fixes, scripting support, an option for hiding the progress bars and an updated translation. This is it.

There is also a homepage for this little project. I also wrote a small tutorial

Bitcoin donations appreciated: 12oG41zMz8uGJMo7BZbZATeRy5ZiQvxN83

AttachmentSize
interpolate.tar.gz9.26 KB
gimp-plugin-interpolate-0.2.tar.gz149.65 KB
gimp-plugin-interpolate-0.3.tar.gz150.28 KB
gimp-plugin-interpolate-0.4.tar.gz147.09 KB
gimp-plugin-interpolate-0.5.tar.gz152.11 KB
gimp-plugin-interpolate-0.6.tar.gz156.99 KB
gimp-plugin-interpolate-1.0.tar.gz160.96 KB
0
Average: 4.5 (4 votes)

Comments

I didn't see

the plug-in compiled for 32 bits so i compiled 1.0 for Windows 32.
You can get it and more info here
http://www.gimpchat.com/viewtopic.php?f=9&t=3341&p=42390#p42387

Also works in Windows 32 bit Gimp-2.7.4 versions

Not tested in Gimp-2.7.5 yet.

How to install ?

How to install on windows ?

Need more information

I'm clearly not understanding how to use this plug-in, but not for the lack of trying. The good news is that I did manage to get it compiled and running in Ubuntu. Thanks.

The instructions seem simple enough: use the color tool, select white spots, create a mask (if you fail to create a mask, the plug-in won't show it as an option, so that's clearly a given) However, I've tried running the mask inverted and non-inverted and the interpolation renders nothing at all. I'm assuming default settings on the plug-in itself will at least render your example image.

It's obvious to me that I am missing a step or not using the mask correctly or not following a set of protocol for how the plug-in should be used.

I've attempted two scenarios using your example duck image. First, I duplicated the layer, selected white spots on duplicate, created a mask, ran the plug-in. Second, I opened two identical images, converted one to a mask, ran the plug-in on the original image. What am I missing?

Confused

I am also confused how about to use the plug in. The duck picture I used as an example. Made a duplicate layer, added a layer mask (white full opacity). But after painting the duck black I cant select the white spots. How to do this?
Could someone please make a detailed step by step instruction based on the latest 0.5 version of the plugin?

Thanks

Making the input mask

Instead of painting the duck black manually, you can do this: Select the duck by using the lasso tool, invert the selection and save it to a channel. That's what I did to make the example image.

Selecting the white spots

You can select the white spots by using the "Select by color" tool from the GIMP tool-box. You can also use the "magic wand" on the water and then invert the selection.

After selecting the white spots, you should "grow" the selection by 2 pixels, so that all the pixels that are whiter than normal are included in the selection. This may vary, depending on the method you used to make the selection, so experiment a bit with different selections.

Not layers, channels

You need to make *channels*, not layers. The way I make channels is by making a selection first and then do "Selection > Save to Channel".

To do basic work with the filter, you don't have to do anything special other than select the 'object' you want and run "Interpolate" with the default options. The instructions I gave below for 0.4, also apply to 0.5 and 0.6.

The example image

To do the same thing I did with the example image, you have to do this: First, create a mask that has only the water pixels (make a white channel and paint black in place of the duck). This is the input mask that you have to save to a channel. Then, select the white spots by using the "select by color" tool (or by using the magic wand tool on the water and then inverting the selection). Expand the selection a little so that all the white-spot-affected pixels are selected (making sure the duck remains completely unselected). And then run the filter The input mask you created will be in the drop-down menu, so you won't have to do anything other than clicking OK when you see the dialog.

use 0.4

Actually, you need 0.4 for this to work. If you have a previous version, the input mask will have to exclude the white spot pixels as well (not just the duck pixels). That was difficult to do, so this is why I added the "subtract selection" option in 0.4. It will internally subtract the selection from the input mask. So, now, the input mask can be a simple white channel, with black in place of the duck.

So, with 0.4, just blacken the duck on the input mask, select the spots and you are done.

If you have a previous version you will have to do this: after you have made the selection of the white spots, go to the 'channels' tab where you saved your input mask, click the input mask channel to make it active and then do a fill with black. This will set the selected areas in the input mask to black (so the white-spot areas are not read by the filter). Then go to the layers tab and click the image layer to make it active (so that the filter is applied to the image and not to the mask channel). Then apply the filter.

Active drawable

Always make sure that the layer you are applying the filter to is the active layer (it's the selected entry in the "layers" list) because that is the surface you want to paint on. Whenever you do a "save selection to channel", GIMP will automatically make the *new channel* active. So, each time you do a "save selection to channel" you have to manually go to the layers tab and click the RGB layer you are applying the filter to, to make it "active" again.

I have this problem a lot, where I forget to click on the RGB layer and I mistakenly apply the filter to the temporary channel, instead of the image. But this is GIMP behavior, so I can't do much about it.

Masks

The simplest thing you can do is to select a white spot with the lasso tool and apply the filter with the default options. And that's it. The job of this filter is to fill the selection based on the *surrounding* colors. If you had used a simple blur filter, that would have left a faint white smudge in place of the white spot that you wanted to remove. This filter will only use the *surrounding* colors to decide what to paint inside the selection. This is why I wrote this plug-in.

The thing with this plug-in is that internally it uses two masks, an input mask and and the selection. If you don't give it an input mask, it will use the inverse of the selection by default. So a separate input mask is not really necessary. But there *has* to be a selection (the "output mask").

A separate input mask is only necessary when you don't want all the surroundings to contribute their color. For example, the spot that is right above the duck's head. On that spot, you want to paint the lake's blue-green color and not the duck's black. If you don't do something special there, the result will be a mix between the color of the water and the color of the duck. You have to tell the filter to only read from the water pixels, and not the duck pixels. You do that with an input mask. You select only the water pixels and save the selection to a channel. Then you clear this selection and select the white spot pixels that you want to overwrite, and *then* you apply the filter. The defaults should be good for most cases.

How does this compare to GMIC 'region inpainting'

A side-by-side comparison would be appreciated.

I did use G'MIC's inpaint

I did use G'MIC's inpaint feature and got similar results, but you still have to create the mask. This plugin, as I'm interpreting it, does all this automatically. Still would like to see a Windows compile of this plugin to try. :)

Interesting

Lyle, I used the Select by Color tool to select the whitest areas of the image, used Heal Selection set to about 35% and got similar results (better results IMHO) as this interpolate process (comparing to the example image shown here - I couldn't get this plug-in loaded on Ubuntu). I had to be careful and eliminate some areas around the duck using the Free Select tool on subtract, but having the images side by side, you couldn't really tell the differences in a majority of the spots, although my process took out more. Not sure on how much faster it was, other than going by stamit saying it can take awhile to run interpolate. :)

I'd prefer to test interpolate for myself, though.

I like your result Mahvin. I

I like your result Mahvin. I was a little lazy with my mask so my results were somewhat more like the author of this thread. He said that his plugins still requires a mask anyway, but I too would still like to test his plugin out. :)

Did it

Here it is. I used gimp-plugin-template and the package size jumped from 10KB to 150KB. But it should compile easily.

No automatic mask

No, there has to be a mask! It doesn't generate the mask automatically. It uses the selection as the output mask and the first extra channel as the input mask. If there is no extra channel, it uses the inverse of the selection as the input mask.

But I made the mask for this picture easily by using the "magic wand" tool and then shrinking/growing and inverting the selection.

The result looks cool; a lot

The result looks cool; a lot better then trying to run the Healing Script-fu for each object. Anyway, I don't have any idea on how to compile this one for Windows; any possibility to port the executible for Windows by chance? :)

Ok

Ok, I'm working on that. I didn't use the plug-in template. I just wrote a Makefile in my gimp plug-ins directory.

How to get it work

Could you please explain how to install his plug in. I did: "make interpolate" but the produced file was not recognized by Gimp 2.6. Thnx

I did not try on lLinux

I did not try on lLinux already, but if the Makefile did not work, I would rename interpolate.c to interpolate.cpp and:
CFLAGS= -s gimptool-2.0 --build interpolate.cpp

Errors

Just using make creates the interpolate executable, but GIMP doesn't recognize it.

Using your method results in errors regarding = note: use option -std=c99 or -std=gnu99 to compile your code.

Even using the above "noted" CFLAGS variables results in errors, namely deprecation errors from the syntax within the interpolate.c file, (e.g. gint, kernel types, etc.) Got tired of trying to get it to work.

Compiled for Windows?

Is there a version for Windows XP yet?

Not to the moment. As for me

Not to the moment. As for me I get errors from the c99 mode as usual.

Syndicate content