Picture Resize Methods Linear, Cubic, Sinc Larcosz
I sarch for an extension or a method that can resize in the linear way, cubic, Sinc Larcosz. Not at runtime, but as a saveable result.
What i mean is this. Overlay and Image Manipulator resizes without any method. Results in a 1:1 resizing with sharp borders when i resize a 5X5 pixel picture with some black pixels at it up to 128 pixels.
http://reinerstileset.4players.de/ext/softresize1.jpg
What i need is one of the following methods though:
Linear:
http://reinerstileset.4players.de/ext/softresize2.jpg
Cubic:
http://reinerstileset.4players.de/ext/softresize3.jpg
sinc (lanczos3), my Favourite. This one would be best:
http://reinerstileset.4players.de/ext/softresize4.jpg
Is there a method to achieve such a resized result in Overlay? Or is there even an extension that can resize in one of the mentionend methods that i have overlooked?
Re: Picture Resize Methods Linear, Cubic, Sinc Larcosz
Overlay has a feature "enable antialiasing". Doesn't it work ?
Or can't you just paste a resampled active in the overlay ?
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
Thanks for your suggestions. Those methods doesn't work though.
Antialias is either on or off. Nothing to resample a picture with. The result is therefore that i may get more squares in the result, with a grey colour. Or just a two pixel border around my black blocks.
Acitves cannot load pictures at runtime afaik, nor can it save a picture then. So there is no way to use its resampling.
What i'm tinkering around with at the moment is to read the greyscale values into an array. And try to resample it there. Let's have a look.
Best method would be an extension though. Because Overlay and Array in Fastloop is slow as hell.
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
The beta version of the new overlay object can do one of these resampling algorythms but I don't know when it will be finished...
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
Quote:
... but I don't know when it will be finished...
Argh :D
What can i do to speed the release date up ? :)
Okay, this means i have to go the overlay/array/fastloop route then.
But I spit blood and water here with my array solution though. My favourite annoyer strikes back here. Only 9 values through nine gives, correct, five points ... :sick:
http://reinerstileset.4players.de/ex...oocomplex2.jpg
Comeon, this is not a really complex formula. It is simple math :/
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
I've trashed the array and use counters now to set the surrounding pixels. Works now Even when it takes nearly 10 seconds for this 128x128 pixel picture.
But i do nevertheless something wrong. The result doesn't look correct. Not even near the result of the above methods. Either the result is not soft enough or the whole white area becomes grey like in the picture here. What am i doing wrong?
http://reinerstileset.4players.de/ext/softresize5.jpg
How can i achieve the resample methods that are shown above?
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
youve got a blackborder cause its trying to get the colours from outside the image bounds. And the whole thing turns greyish cause (i think) you're getting adjacent pixels that you've already changed in the previous loop. Instead, loop through an image source, and create the blur in another image - target.
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
Thanks for posting.
I still use a source and a target picture. And i always calculate from the one to the other ;)
What i wonder is not so much the border. I have to change the loop to take the borders into account when done. That part is not finished yet.
What i wonder is that i don't come close to the above results. That i cannot get this clear white areas. In none of the above methods i have such a strong bleeding. Not in linear, not in cubic nor sinc (lanczos3). But with my method i have. As the picture shows.
What's the correct formula for linear for example? Current Pixel + cross surrounding ones? Means the one up, the one left the one down the one right, and the result through 5?
Or cubic? Is it really all surrounding pixels through 9?
Do those method even take the current pixel into account?
I tried some methods now. It looks close to what i have shown here. There must be something different.
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
Ah, getting closer. I have to check pixels further away. The further away the less samples are necessary. And the less it bleeds.
This is a result that checks pixels which are 3 pixels away, five samplings:
http://reinerstileset.4players.de/ext/softresize6.jpg
Would be nevertheless interesting to know the exact formulas. My current method to intend the wheel again is a bit time consuming :grin:
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
First step is always to divide the coordinates of the point you are drawing in the destination so that they are in the source image. If the source is 4x4, and dest is 12x12, then pixel 4,5 in the dest is 1.333,1.666 in the source.
Obviously there is no pixel at 1.333,1.666, so you have to blend the surrounding pixels to get it. For linear, this is simply:
ColourAt(1,1)*(1-0.333)*(1-0.666) + ColourAt(1,2)*(1-0.333)*(0.666) + ColourAt(2,1)*(0.333)*(1-0.666) + ColourAt(2,2)*(0.333)*(0.666)
Linear basically uses 2x2 samples. Cubic uses samples further away to fit a cubic curve, and reads off the point at the appropriate coordinates. Cubic preserves detail better than linear, which tends to blur.