Scaling contest

Michael Thaler michael.thaler at ph.tum.de
Thu Jun 30 23:15:40 CEST 2005


On Thursday 30 June 2005 18:01, Casper Boemann wrote:
> Hi I have added scaling to the transform visitor.
>
> Michael, could you make measurement against the scale visitor. It could be
> fun to see how we compare. Also try and see if the visual result is the
> same.
>
> To be fair, you should replace the scale visitor with the transform visitor
> at the point of call.
>
> Also you should use the simple filter in the scalevisitor, as that is the
> only thing the transform visitor supports (for now)

O.K., here are the results:

Casper's code:

I called it in KisPaintDevice in the following way:

void KisPaintDevice::scale(double xscale, double yscale, 
KisProgressDisplayInterface * progress, enumFilterType ftype)
{
        KisTransformVisitor visitor;
        accept(visitor);
        visitor.transform(xscale, yscale, 0,  0, 0, 0, progress);
}

Image: 1600 x 1200, scaling down to 50% (800 x 600):
krita: time needed for scaling: 3415ms
krita: time needed for scaling: 3421ms
krita: time needed for scaling: 3437ms
krita: time needed for scaling: 3414ms
krita: time needed for scaling: 3409ms
Rendering errors: first line is missing

Image: 1600 x 1200, scaling up to 150% (2400 x 1800):
krita: time needed for scaling: 16609ms
krita: time needed for scaling: 16914ms

Image: 385 x 612, scaling up to 150% (578 x 918):
krita: time needed for scaling: 928ms
krita: time needed for scaling: 942ms
krita: time needed for scaling: 939ms
krita: time needed for scaling: 957ms
krita: time needed for scaling: 967ms

My code:

Image: 1600 x 1200, scaling down to 50% (800 x 600):
krita: time needed for scaling: 1224ms
krita: time needed for scaling: 1217ms
krita: time needed for scaling: 1254ms
krita: time needed for scaling: 1227ms
krita: time needed for scaling: 1209ms

Image: 1600 x 1200, scaling up to 150% (2400 x 1800):
krita: time needed for scaling: 3521ms
krita: time needed for scaling: 3584ms

Image: 385 x 612, scaling up to 150% (578 x 918):
krita: time needed for scaling: 480ms
krita: time needed for scaling: 482ms
krita: time needed for scaling: 506ms
krita: time needed for scaling: 471ms
krita: time needed for scaling: 480ms

Some remarks: there is something wrong with Casper's code or the way I call it 
because there is no progress bar displayed. Also the results for scaling up 
the 1600 x 1200 image is very strange. Could it be that it has something to 
do with allocating new tiles?

In general my code seems about a factor 2 faster. Casper's code does not 
precalculate the filter weights, so in the case of 1600 x 1200 it has to 
calculate 1600 x 1200 filter weights, where my code only has to calculate 
1600 + 1200, if I am not totally mistaken.

But I am not convinced that Casper's code works correctly, anyway. The results 
really don't look too good. I will sent you the results in private.

Anyway, given that Casper wrote the code from scratch and I basically used the 
code from the Graphic Gems book and I spend the the last couple of days 
optimizing the scaling code, the results are really not bad at all.

By the way, you can also precalculate filter weights for shearing because you 
shift each pixel in a line or column by a constant value. I think I will 
start to work on the rotate code. As far as I remember, it has some problems 
anyway, giving wrong results at the borders.

Greetings,
Michael


More information about the kimageshop mailing list