Difference between revisions of "Hacking:Porting filters to GEGL"

From GIMP Developer Wiki
Jump to: navigation, search
(Port of new GEGL ops to OpenCL: color coding of states)
(Processing, color grading and effects: add cross references to git log to quickly check for updates)
Line 38: Line 38:
{| class="wikitable" style="text-align: center;"
{| class="wikitable" style="text-align: center;"
!style="text-align: left;"|'''GIMP filter'''
!style="text-align: left;"|'''GIMP filter'''
!style="text-align: center;"|'''GEGL operation'''
!style="text-align: center;"|[https://git.gnome.org/browse/gimp/log/plug-ins '''GEGL operation''']
!style="text-align: center;"|'''OpenCL version'''
!style="text-align: center;"|[https://git.gnome.org/browse/gegl/log/opencl '''OpenCL version''']
!style="text-align: left;"|'''Comment'''
!style="text-align: left;"|'''Comment'''

Revision as of 19:18, 29 April 2013

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 09.04.2013)

X finished
0 unfinished
W.I.P. work in progress

Processing, color grading and effects

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

File loaders/savers

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

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 0 0 FFmpeg video frame importer
ff-save 0 0 FFmpeg video frame output sink. GEGL op is work in progress.
rawbayer-load 0 0 RAWBAYER and RAWBAYERS format. GEGL op is work in progress
rgbe-load 0 0 for Radiance HDR format with extensions HDR and PIC
rgbe-save 0 0 for Radiance HDR format with extensions HDR and PIC
svg-load 0 0 for SVG and SVGZ format

Port of new GEGL ops to OpenCL

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