KImageEffect status

Mosfet dan.duley at verizon.net
Fri May 13 11:48:52 BST 2005


I've finished the new KImageEffect2 class and now just have to finish the test 
app. Once that is done, (should be around Monday - I want to write a new Qt4 
pixmap view since QScrollView is being replaced),  I'll send a tarball to 
Aaron to post on the web. If you want an early one without the demo app send 
me an email and let me know.

Here is the final Changelog. I've added quite a bit more info. If you have any 
comments CC me as I'm not on this list.

-------------- next part --------------
This README is broken into four different sections:

I. KCPUInfo Changes
II. Rewritten KImageEffect Methods
III. Other Minor Changes 
IV. Things That Haven't Changed

Section I: KCPUInfo Changes.

* The CPU extensions IntelMMX, IntelSSE, and IntelSSE2 are now just
MMX, SSE, and SSE2.

* There is now both AMD3DNOW and a new AMD3DNOW2 check for both
versions of AMD 3DNow!

* There is a new IntegerSSE check for the MMX-SSE available in AMD
Athlons and above.

* SSE check bugfixes. It was being improperly reported on my Athlon.

* MMX packed data types are now in KCPUInfo instead of the KImageEffect
source. Instead of being prefixed by "KIE" they are now in the KMMX
namespace.

Section II: Rewritten KImageEffect Methods.

The following methods were rewritten from scratch or are new. A lot of
the stuff in KImageEffect was originally ported from C code and
contained messy, buggy, nasty stuff because I wanted to keep things as
much like the C code as possible to allow for easier updates. Bad idea.
Unreadable and hellua buggy. 

This has now been rewritten, heavily optimized, algorithms changed, and
in some cases inline MMX added for drastic performance increases,
(especially w/ convolve based effects). I've been posting demo tarballs
for people to try the algorithms for some time now and everything seems
alright.

* The Imlib2 smoothscale method has been ported. It's very good! It
seems to produce results similar in quality to the Qt/NetPBM method
but in 1/6th the time with MMX and still less than 1/2 without it >:)

* Grayscale: MMX SIMD support for handling 2 pixels at once. 32bpp
images can optionally reduced to 8bpp palette. This is all you need
anyways since red = green = blue, but you may not want to reduce the
image if your going to be doing more effects or scaling.

The fast mode has been removed. It wasn't used by default and didn't properly
weigh pixels. The MMX grayscale is about the same speed but with
weighted pixels.

There is also a grayscaleBrightness() method that uses the max pixel 
component. This is equivalent to the "Value" in HSV.

* Invert: MMX SIMD for this, too.

* Threshold: You can now threshold on different channels.

* Convolve, ConvolveInteger, Sharpen, Antialias, Edge, Emboss,
Charcoal, and Oil Paint:

There are two new convolve methods: an integer one and a
floating point one. You can choose which one you want to use when
applying an effect. The integer one is MMX optimized and the floating
point supports 3dNow!. Big speed increases with these. Obviously the
floating point convolve gives the best results because we can use a
more sophisticated kernel, but the integer one may be preferable if
speed is essential and the machine does not support 3dNow! This is very
exciting to me since convolve is so useful. An MMX one kicks butt >:)
It's now way faster than either ImageMagick or KImageEffect's old one.

The rewritten convolve method handles the area of the pixel neighborhood 
outside the image boundaries correctly. This means edges are now properly 
handled. These areas are now handled separately and the algorithm is 
generally much more efficient than before. No more checks to see if the pixel 
is valid when processing the middle of the image. You can also select if to 
use optimal pixel neighborhood sizes or larger, ImageMagick-compatible ones.

* Blur: There are two new blurs. The default one is based on Imlib2 and
is a good, fast blur. The second one is a Gaussian blur and is more
appropriate if you are dealing with photographs and need higher
quality. I originally ported the Gaussian blur from ImageMagick for
KDE, but it never worked like it should. It's been rewritten and fixed.
It also supports 3dNow! for a big performance increase if available.

* Despeckle: Rewritten and now takes 1/4th the memory it used to.

* Contrast: This is equivalent to the old contrastHSV() and now uses
inline HSV calculation and a lookup table for a nice speedup. There are
other small efficiency improvements and a bugfix where I was treating
brightness as luminosity.

* Edge Detection: There are now two versions. One that uses the new
convolve and a new one written from scratch using the Sobel algorithm.
Contains an inline MMX version.

* Histogram based effects (Equalize and Normalize): This now uses
faster integer histograms and maps instead of floating point and no
longer has unneeded upscale/downscale code that did nothing. The code
is now much more faster and readable. Not sure why I originally did
this in floating point other than that's how ImageMagick did it...

* Interpolation and HSV classes: I was playing around with ideas for
how to speed these operations up. MMX isn't really going to help much
here so instead I created two different classes KInlineHSV and
KInlineInterpolate. The idea here is that you create an instance of
these classes outside your main loop and it holds any data needed for
HSV or interpolating. Then you can call inline methods inside your
loop. At least it should be inlined ;-) GCC's -Winline doesn't report
anything.

* Wave, Implode, and Swirl: These have been rewritten from scratch and
use the new inline interpolation class.

III. Other Minor Changes

The following methods are largely unchanged except for some obvious
bugfixes or improvements. These are noted below.

* Modulate: Use inline HSV class instead of QColor.

* Various Blend methods: This now gets it's own source file because
it's quite big. Lots of instances fixed where const data was being
assigned. Uses the new smoothscale. These should be rewritten IMHO.

* Hash: Made lHash() and uHash() static inline.

* Desaturate: Use inline HSV.

The following methods have been removed:

* Sample: Obsolete. Use QImage::scale() with Qt::FastTransformation.

* Bumpmap: The author has said he wants to redo this.

IV. Things That Haven't Changed

addNoise(), gradient(), unbalancedGradient(), rotate(), and solarize().





More information about the kde-core-devel mailing list