Hacking:Porting filters to GEGL

From GIMP Developer Wiki
Revision as of 17:18, 14 May 2013 by Scl (Talk | contribs)

Jump to: navigation, search

How to port

This is the general process to write a new GEGL operation:

  1. Gather information.
    1. Read the plugin you want to port, understand the algorithm hidden in it.
    2. Read carefully the GEGL website. There is lot of information here.
    3. Read the Babl website and understand the difference between color models.
    4. You may want to find a similar existing operation and get inspiration from it.
  2. Choose a base class. This is the general structure of your operation, the number of input/output, what kind of optimization GEGL can do.
  3. Create a new file for your operation. No need to register it in some Makefile, the build system will build every C file present in the operations directory. The exact directory where you should put your file is explained in the GEGL website.
  4. Copy another operation with the same base class and clean it to have your operation skeleton. GEGL use a macro system called GEGL chant, that avoid you to write all the GObject boilerplate, and register easily parameters for your op. Look other operation to see how it works.
  5. Use the prepare function to indicate what color model your op will operate, for each input/output.
  6. Create your op's parameter using the chant system. You can have integer, floats, string, color, curve, enum ... There is some predefined enum in the GEGL core, for instance GeglSamplerType. You can register your own, like in the ripple op.
  7. Write your operation in the process function. Some tips here:
    1. GEGL store data in tile, so it impose some restriction, especially for transform op. You usually need to write your algorithm backward, ie iterate over the output, compute where the data come from, use a sampler to get it and affect the output.
    2. ROI mean region of interest, it's the area your are currently working on.
    3. Sometimes you need to know the size of the full input, not just the roi. You can have it using gegl_operation_source_get_bounding_box.
    4. Rather than carry a lot of parameter in you different functions, you can register a custom structure in the chant system, like the WarpPrivate structure in the warp op.
    5. When you fetch data outside of the input buffer (in it's abyss) you get by default zeroed memory. The abyss policy allow you to chose what you want here, and in particular, you can choose to clamp to the border, loop in the buffer extent ... It allows to write more clever algorithm. For instance, see the ripple op. Setting the abyss policy to GEGL_ABYSS_LOOP add the tileability to the op for free.
  8. Test your operation. You can use the gegl binary to run an xml file, or use the GEGL tool in GIMP.

Porting matrix (as of 08.05.2013)

You can sort the following tables by clicking the little arrow symbol in the column headers. If that doesn't work out of the box, please activate Javascript for this page.

Processing, color grading and effects

GIMP filter GEGL operation OpenCL version Comment
Alien Map No No
Align Visible Layers No No
Antialias unknown No
Apply Canvas No No
Apply Lens No No
Assign Color Profile No No
Autocrop Image No No
Autocrop Layer No No
Border Average No No
Bump Map No No
Cartoon Yes No
Channel Mixer No No
Checkerboard Yes No
CML Explorer No No
Color Enhance No No
Color Exchange No No
Color to Alpha Yes No
Colorcube Analysis No No
Compose No No
Convert to Color Profile No No
Convolution Matrix work in progress No
Crop Tool Yes No
CSS stylesheet No No
Cubism work in progress No
Curve Bend No No
Decompose No No
Deinterlace work in progress No
Depth Merge No No
Despeckle No No
Destripe No No
Difference of Gaussians Yes No The port is missing Normalize and Invert options
Diffraction Patterns No No
Dilate No No
Displace No No
Drop Shadow Yes No The GEGL port doesn't have an option for the shadow color and doesn't seem to work in the Mac build.
Edge... No No
Emboss work in progress No
Engrave No No
Erode No No
Filmstrip No No
Filterpack No No
Flame No No
Foreground Select Tool work in progress No See patches to bugs #699780 and #699834.
Fractal Explorer Yes No
Fractal Trace work in progress No
From Webpage No No Probably doesn't need porting
Gaussian blur Yes Yes Needs abyss policy
Gfig No No Probably doesn't need porting
GIMPressionist No No
Glass Tile No No
Gradient Flare No No
Gradient Map No No
Grey Yes Yes
Grid Yes No Missing intersection option, is it needed ?
Hot No No
HSV Noise Yes No
Hurl Yes No
IFS Fractal No No
Illusion No No
Image Map No No Probably doesn't need porting
Invert Yes Yes
iWarp No No To be replaced with Warp Transform tool
Java map No No Probably doesn't need porting
Jigsaw No No
Laplace Yes No
Lens Distortion Yes No
Lens Flare No No
Levels Tool Yes Yes
Lighting Effects No No
Make Seamless No No
Maximum RGB No No Will be removed without replacement
Maze No No
Mosaic No No
Motion Blur Yes Yes The GEGL port is incomplete (no type and center selection)
Neon No No
Newsprint No No
NL Filter No No
Normalize No No
Noise Spread work in progress No
Oilify Yes Yes
Optimize (Difference) No No
Optimize (for GIF) No No
Pagecurl No No
Palette Map No No
Paper Tile No No
Photocopy Yes No
Pick Yes No
Pixelize Yes Yes Needs abyss policy
Plasma work in progress No
Playback No No Probably doesn't have to be ported ?
Polar Coordinates Yes No
Posterize Tool Yes No
Qbist No No
Recompose No No
Red Eye Removal work in progress No
Retinex No No
RGB Noise Yes No
Ripple Yes No Complete in abyss branch
Rotate Colors work in progress No
Sample Colorize No No
Selective Gaussian Blur No No
Shift Yes No
Sinus No No
Slur Yes No
Smooth Palette No No
Sobel Yes Yes
Softglow Yes No
Solid Noise No No
Sparkle No No
Sphere Designer No No
Spread Yes No
Stretch Contrast Yes No Not sure we need that with GEGL being the core of GIMP
Stretch HSV No No
Supernova No No
Transform Tools (Rotate, Scale, Shear, Translate) Yes No
Threshold Tool Yes Yes The GEGL port misses setting the upper bound (=the right slider triangle in the GIMP tool).
Tile Yes No
Unoptimize No No
Unsharp Mask Yes No
Value Invert Yes Yes
Value Propagate No No
Van Gogh (LIC) No No The filter has nothing to do with van-Gogh-style art and has no obvious function. We should remove it.
Video No No
Warp work in progress No
Waves Yes No Missing reflective option that produce strange result, I suggest dropping that.
Whirl and Pinch work in progress No
Wind Yes No
Zealous Crop unknown No

File loaders/savers

GIMP filter GEGL version OpenCL version Comment
file-aa Yes No
file-bmp Yes No
file-cel Yes No
file-csource Yes No
file-desktop-link Yes Yes doesn't need to be ported
file-dicom Yes No
file-exr-load Yes No
file-exr-save Yes No -
file-faxg3 Yes No
file-fits Yes No
file-fli Yes No
file-gbr Yes No
file-gif-load Yes No
file-gif-save Yes No
file-gih Yes No
file-glob No No for file globbing -> is GEGL-port necessary?
file-header Yes No
file-html-table Yes No
file-ico Yes No
file-jp2-load Yes No -
file-jpeg Yes No -
file-mng Yes No
file-pat Yes No
file-pcx Yes No
file-pdf-load No No -
file-pdf-save Yes No
file-pix Yes No
file-png Yes No -
file-pnm Yes No -
file-ps work in progress No -
file-psd No No -
file-psp Yes No
file-raw No No see GEGL-op gegl:raw-load
file-sgi Yes No
file-sunras No No -
file-svg No No extra GEGL-op gegl:svg-load exists for loading SVG and SVGZ format
file-tga Yes No
file-tiff-load Yes No
file-tiff-save No No
file-wmf No No -
file-xbm Yes No
file-xmc No No -
file-xpm Yes No
file-xwd No No -

New File loaders/savers

These file loaders/savers are implemented in GEGL, but not part of GIMP (yet). Currently they are listed here for completeness.

GEGL filter GIMP filter OpenCL version Comment
ff-load No No FFmpeg video frame importer
ff-save No No FFmpeg video frame output sink. GEGL op is work in progress.
rawbayer-load No No RAWBAYER and RAWBAYERS format. GEGL op is work in progress
rgbe-load No No for Radiance HDR format with extensions HDR and PIC
rgbe-save No No for Radiance HDR format with extensions HDR and PIC
svg-load No No for SVG and SVGZ format

Port of new GEGL ops to OpenCL

GEGL operation OpenCL version Comment
Bilateral filter Yes
Box blur Yes
Box max No GEGL op is work in progress.
Box min No GEGL op is work in progress.
Box percentile No GEGL op is work in progress.
Brightness and Contrast Yes
Buffer cache No GEGL op is work in progress. Does this need an OpenCL port?
C2g Yes HDR related
Cielch Noise No
Color No
Color Reduction No
Color Temperature Yes
Contrast Curve No
Demosaic (bimedian) No GEGL op is work in progress.
Demosaic (simple) No GEGL op is work in progress.
Disc percentile No GEGL op is work in progress.
Display No Does this need an OpenCL port?
Ditto No GEGL op is work in progress. Test op - does this need an OpenCL port?
Dot No
Exp combine No HDR related
Exposure No HDR related
Fattal02 No HDR related
gluas No GEGL op is work in progress. Does this need an OpenCL port?
HStack No GEGL op is work in progress.
Image compare No
Introspect No Does this need an OpenCL port?
Kuwahara No GEGL op is work in progress.
Lens correction No GEGL op is work in progress.
Line profile No GEGL op is work in progress.
Linear gradient No GEGL op is work in progress.
Mandelbrot No GEGL op is work in progress.
Mantiuk06 No HDR related
Mirrors No
Mono mixer Yes
Noise No Perlin noise generator
Noise Reduction Yes
Over No Porter Duff operation over (d = cA + cB * (1 - aA))
Radial gradient No GEGL op is work in progress.
Reinhard05 Yes HDR related
Remap No
SNN (mean) Yes
SNN (percentile) No GEGL op is work in progress.
SVG Hue rotate No
SVG Luminance to Alpha No
SVG Matrix No
SVG Saturate No
Unpremul No GEGL op is work in progress.
Vignette Yes
Weighted Blend No