Scaling contest

Casper Boemann cbr at boemann.dk
Thu Jun 30 23:35:38 CEST 2005


On Thursday 30 June 2005 23:15, Michael Thaler wrote:
> 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.
Yes that is a problem. I'll to try fix it quickly.

> 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?
It most certainly has. On my computer it takes about 80 seconds ! but the 
tilemanager is working heavily all the time.

> 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.
correct

> 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.
hmm looking forward to that. :-/

> 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.
Thanks for the kind words.
Also my code handles selections on the fly. Clears the original and places the 
transformed image back. Your code would never be able to do that unless it 
too had to copy the images to a temporary paintdevice, and I have a strong 
feeling that this is where I'm loosing time.

> 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.
Well If I shifted by a whole pixel I could, but I don't, so I can't. The 
weights work on subpixel precision.

Thanks, for the great work

-- 
best regards / venlig hilsen
Casper Boemann


More information about the kimageshop mailing list