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

From GIMP Developer Wiki
Jump to: navigation, search
(Update on 09.04.2013 (Port of new GEGL ops to OpenCL))
(Mark filters from the directory 'workshop' as 'work in progress')
Line 71: Line 71:
 
|Convert to Color Profile || 0 || 0 || -
 
|Convert to Color Profile || 0 || 0 || -
 
|-
 
|-
|Convolution Matrix || ? || 0 || source file not found (1)
+
|Convolution Matrix || ? || 0 || work in progress
 
|-
 
|-
 
|Crop Tool || X || 0 || -
 
|Crop Tool || X || 0 || -
Line 77: Line 77:
 
|CSS stylesheet || 0 || 0 || -
 
|CSS stylesheet || 0 || 0 || -
 
|-
 
|-
|Cubism || ? || 0 || source file not found (1)
+
|Cubism || ? || 0 || work in progress
 
|-
 
|-
 
|Curve Bend || 0 || 0 || -
 
|Curve Bend || 0 || 0 || -
Line 83: Line 83:
 
|Decompose || 0 || 0 || -
 
|Decompose || 0 || 0 || -
 
|-
 
|-
|Deinterlace || ? || 0 || source file not found (1)
+
|Deinterlace || ? || 0 || work in progress
 
|-
 
|-
 
|Depth Merge || 0 || 0 || -
 
|Depth Merge || 0 || 0 || -
Line 103: Line 103:
 
|Edge... || 0 || 0 ||  
 
|Edge... || 0 || 0 ||  
 
|-
 
|-
|Emboss || ? || 0 || source file not found (1)
+
|Emboss || ? || 0 || work in progress
 
|-
 
|-
 
|Engrave || 0 || 0 || -
 
|Engrave || 0 || 0 || -
Line 119: Line 119:
 
|Fractal Explorer || X || 0 || -
 
|Fractal Explorer || X || 0 || -
 
|-
 
|-
|Fractal Trace || ? || 0 || source file not found (1)
+
|Fractal Trace || ? || 0 || work in progress
 
|-
 
|-
 
|From Webpage || 0 || 0 || Probably doesn't need porting
 
|From Webpage || 0 || 0 || Probably doesn't need porting
Line 187: Line 187:
 
|Normalize || 0 || 0 || -
 
|Normalize || 0 || 0 || -
 
|-
 
|-
|Noise Spread || X || 0 || -
+
|Noise Spread || ? || 0 || work in progress
 
|-
 
|-
 
|Oilify || X || X || -
 
|Oilify || X || X || -
Line 207: Line 207:
 
|Pixelize || X || X || Needs abyss policy
 
|Pixelize || X || X || Needs abyss policy
 
|-
 
|-
|Plasma || ? || 0 || source file not found (1)
+
|Plasma || ? || 0 || work in progress
 
|-
 
|-
 
|Playback || 0 || 0 || Probably doesn't have to be ported?
 
|Playback || 0 || 0 || Probably doesn't have to be ported?
Line 219: Line 219:
 
|Recompose || 0 || 0 || -
 
|Recompose || 0 || 0 || -
 
|-
 
|-
|Red Eye Removal || 0 || 0 || -
+
|Red Eye Removal || ? || 0 || work in progress
 
|-
 
|-
 
|Retinex || 0 || 0 || -
 
|Retinex || 0 || 0 || -
Line 227: Line 227:
 
|Ripple || X || 0 || Complete in abyss branch
 
|Ripple || X || 0 || Complete in abyss branch
 
|-
 
|-
|Rotate Colors || ? || 0 || source file not found (1)
+
|Rotate Colors || ? || 0 || work in progress
 
|-
 
|-
 
|Sample Colorize || 0 || 0 || -
 
|Sample Colorize || 0 || 0 || -
Line 253: Line 253:
 
|Spread || X || 0 || -
 
|Spread || X || 0 || -
 
|-
 
|-
|Stretch Contrast || X || 0 || not sure we need that with GEGL being the core of GIMP
+
|Stretch Contrast || X || 0 || Not sure we need that with GEGL being the core of GIMP
 
|-
 
|-
 
|Stretch HSV || 0 || 0 || -
 
|Stretch HSV || 0 || 0 || -
Line 277: Line 277:
 
|Video || 0 || 0 || -
 
|Video || 0 || 0 || -
 
|-
 
|-
|Warp || 0 || 0 || -
+
|Warp || ? || 0 || work in progress
 
|-
 
|-
 
|Waves || X || 0 || Missing reflective option that produce strange result, I suggest dropping that.
 
|Waves || X || 0 || Missing reflective option that produce strange result, I suggest dropping that.
 
|-
 
|-
|Whirl and Pinch || ? || 0 || source file not found (1)
+
|Whirl and Pinch || ? || 0 || work in progress
 
|-
 
|-
 
|Wind || X || 0 || -
 
|Wind || X || 0 || -
Line 316: Line 316:
 
|-
 
|-
 
| file-ff-load || X || 0 || FFmpeg video frame importer
 
| file-ff-load || X || 0 || FFmpeg video frame importer
 +
|-
 +
| file-ff-save || ? || 0 || FFmpeg video frame output sink. GEGL op is work in progress.
 
|-
 
|-
 
| file-fli || ? || 0 || source file not found (1)
 
| file-fli || ? || 0 || source file not found (1)
Line 362: Line 364:
 
|-
 
|-
 
| file-raw || X || 0 || for RAW, RAF, NEF, CRW, CR2, DNG, ERF, MRW format (wrapper around the dcraw library)
 
| file-raw || X || 0 || for RAW, RAF, NEF, CRW, CR2, DNG, ERF, MRW format (wrapper around the dcraw library)
 +
|-
 +
| file-rawbayer-load ||? || 0 || for RAWBAYER and RAWBAYERS format. GEGL op is work in progress
 
|-
 
|-
 
| file-rgbe || X || 0 || for Radiance HDR format with extensions HDR and PIC
 
| file-rgbe || X || 0 || for Radiance HDR format with extensions HDR and PIC
Line 390: Line 394:
 
|}
 
|}
  
 
+
(1) This filter was marked as GEGL ported in the previous version of this document, but the source file could not be found in GEGLs master branch. Is there a confusion with the file loaders/savers in GIMP?
(1) This filter was marked as GEGL ported in the previous version of this document, but the source file could not be found in GEGLs master branch.
+
  
 
= Port of new GEGL ops to OpenCL=
 
= Port of new GEGL ops to OpenCL=
Line 401: Line 404:
 
|-
 
|-
 
|Box blur || 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 || -
 
|Brightness and Contrast || X || -
 +
|-
 +
|Buffer cache  || 0 || GEGL op is work in progress. Does this need an OpenCL port?
 
|-
 
|-
 
|Cielch Noise || 0 || -
 
|Cielch Noise || 0 || -
Line 415: Line 426:
 
|-
 
|-
 
|Contrast Curve || 0 || -
 
|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?
 
|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 ||
 
|Dot || 0 ||
Line 425: Line 444:
 
|-
 
|-
 
|Fattal02 || 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 || -
 
|Image compare || 0 || -
 
|-
 
|-
 
|Introspect || 0 || Does this need an OpenCL port?
 
|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
 
|Mantiuk06 || 0 || HDR related
Line 441: Line 474:
 
|-
 
|-
 
|Over || 0 || Porter Duff operation over (d = cA + cB * (1 - aA))
 
|Over || 0 || Porter Duff operation over (d = cA + cB * (1 - aA))
 +
|-
 +
|Radial gradient || 0 || GEGL op is work in progress.
 
|-
 
|-
 
|Reinhard05 || X || HDR related
 
|Reinhard05 || X || HDR related
Line 446: Line 481:
 
|Remap || 0 || -
 
|Remap || 0 || -
 
|-
 
|-
|snn-mean || X || -
+
|SNN (mean) || X || -
 +
|-
 +
|SNN (percentile) || 0 || GEGL op is work in progress.
 
|-
 
|-
 
|SVG Hue rotate|| 0 || -
 
|SVG Hue rotate|| 0 || -
Line 455: Line 492:
 
|-
 
|-
 
|SVG Saturate || 0 || -
 
|SVG Saturate || 0 || -
 +
|-
 +
|Unpremul || 0 || GEGL op is work in progress.
 
|-
 
|-
 
|Vignette || X || -
 
|Vignette || X || -

Revision as of 17:34, 10 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 for now zeroed memory. In the future, the abyss policy will 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 will allow to write more clever algorithm. For instance, see the ripple op. In the future, setting the abyss policy to GEGL_ABYSS_LOOP will add the tileability to the op for free. If you need behavior like this, it's better to not rewrite your own algorithm and wait a little.
  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)

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  ? 0 work in progress
Crop Tool X 0 -
CSS stylesheet 0 0 -
Cubism  ? 0 work in progress
Curve Bend 0 0 -
Decompose 0 0 -
Deinterlace  ? 0 work in progress
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  ? 0 work in progress
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  ? 0 work in progress
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  ? 0 work in progress
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  ? 0 work in progress
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  ? 0 work in progress
Retinex 0 0 -
RGB Noise X 0 -
Ripple X 0 Complete in abyss branch
Rotate Colors  ? 0 work in progress
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  ? 0 work in progress
Waves X 0 Missing reflective option that produce strange result, I suggest dropping that.
Whirl and Pinch  ? 0 work in progress
Wind X 0 -
Zealous Crop  ? 0 -

File loaders/savers

GIMP filter GEGL version OpenCL version Comment
OpenRaster 0 0 -
file-aa  ? 0 source file not found (1)
file-bmp  ? 0 source file not found (1)
file-cel  ? 0 source file not found (1)
file-csource  ? 0 source file not found (1)
file-desktop-link 0 0 -
file-dicom  ? 0 source file not found (1)
file-exr-load X 0 currently as C++ source
file-exr-save X 0 -
file-faxg3  ? 0 source file not found (1)
file-fits  ? 0 source file not found (1)
file-ff-load X 0 FFmpeg video frame importer
file-ff-save  ? 0 FFmpeg video frame output sink. GEGL op is work in progress.
file-fli  ? 0 source file not found (1)
file-gbr  ? 0 source file not found (1)
file-gif-load  ? 0 source file not found (1)
file-gif-save  ? 0 source file not found (1)
file-gih  ? 0 source file not found (1)
file-glob 0 0 -
file-header  ? 0 source file not found (1)
file-html-table  ? 0 source file not found (1)
file-ico  ? 0 source file not found (1)
file-jpeg X 0 -
file-jp2-load X 0 -
file-mng  ? 0 source file not found (1)
file-pat  ? 0 source file not found (1)
file-pcx  ? 0 source file not found (1)
file-pdf-load 0 0 -
file-pdf-save  ? 0 source file not found (1)
file-pix  ? 0 source file not found (1) or is this pixbuf.c?
file-png X 0 -
file-pnm X 0 -
file-ps 0 0 -
file-psd 0 0 -
file-psp  ? 0 source file not found (1)
file-raw X 0 for RAW, RAF, NEF, CRW, CR2, DNG, ERF, MRW format (wrapper around the dcraw library)
file-rawbayer-load ? 0 for RAWBAYER and RAWBAYERS format. GEGL op is work in progress
file-rgbe X 0 for Radiance HDR format with extensions HDR and PIC
file-sgi  ? 0 source file not found (1)
file-sunras 0 0 -
file-svg-load X 0 for SVG and SVGZ format
file-svg-save 0 0 -
file-tga  ? 0 source file not found (1)
file-tiff-load  ? 0 source file not found (1)
file-tiff-save  ? 0 source file not found (1)
file-wmf 0 0 -
file-xbm  ? 0 source file not found (1)
file-xmc 0 0 -
file-xpm  ? 0 source file not found (1)
file-xwd 0 0 -

(1) This filter was marked as GEGL ported in the previous version of this document, but the source file could not be found in GEGLs master branch. Is there a confusion with the file loaders/savers in GIMP?

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 -