Re: Picture Resize Methods Linear, Cubic, Sinc Lar
Many thanks for your help :)
So the calculation is done while resizing, and not at the resized picture? Because that's what i do here. I resize it without any method, then resample it. (With that method i get mad with the border by the way. I cannot prevent to get a black border, no matter how i setup the fastloop :( )
What i don't understand with your explanation is that you only use four pixels. Wouldn't this lead to a in one direction stretched picture? Which Pixels are used for the calculation then? Let's say C is the centerpixel, and S are the pixels around to test. How does it look like then? Which of the following pixels gets tested?
CS
SS
SC
SS
SS
CS
SS
SC
Edit, got it working without borders. Phew, what a battle ...
http://reinerstileset.4players.de/ext/softresize7.jpg
I will have a look to optimize it and will put it into the file archive then. Then we have a better base to talk about :)
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
In linear upscaling, if the pixel in the destination image falls exactly on a pixel in the source, no interpolation happens, you get exactly that pixel. It's only if the pixel in the destination is technically in the middle of a block of 4 in the source that it interpolates between them to find out what colour it should be.
This means that you don't have a center pixel, only the four pixels "around" the location you're trying to sample.
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
Ah, so it's a thing that looks like this:
.S.
S.S
.S.
Or more this?
SS
SS
Hmm, i am in trouble to understand it. How would you calculate Pixel 1 here? And Pixel 2?
http://reinerstileset.4players.de/ext/softresize8.jpg
Oh how neat would be a working example *hint* :grin:
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
The 2nd one:
SS
SS
Here's a practical example using your image above:
Point 1 is at coordinates 1,1 (and Point 2 is at 2,2) counting from the top-left.
Divide by Size-1 of the destination image (4-1=3) and multiply by Size-1 of the source image (2-1=1) giving 0.333,0.333
(I'll ignore Point 2 from now on)
Then floor your coordinates to get the base pixel, and take just the fractional part to get the blend amounts. So BaseX=0,BaseY=0, BlendX=0.333, BlendY=0.333
Then use the following formula to get the colour:
Code:
Colour("Source",BaseX, BaseY) *(1-BlendX)*(1-BlendY) +
Colour("Source",BaseX+1,BaseY) *(BlendX) *(1-BlendY) +
Colour("Source",BaseX, BaseY+1)*(1-BlendX)*(BlendY) +
Colour("Source",BaseX+1,BaseY+1)*(BlendX) *(BlendY)
Note that the corner pixels of the destination image always match the corner pixels of the source image, and the edges of the image are all 1-d blends (BlendX or BlendY 0)
EDIT: If you don't get it from this, then I'll make a working example after work.
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
Quote:
Acitves cannot load pictures at runtime afaik, nor can it save a picture then. So there is no way to use its resampling.
You can load frames inside actives. Then You can paste them into the overlay to save them. But if I remember when you paste a resized active on the overlay it pastes the original not the resized one so it may not work.
But if you don't bother showing the picture at screen and the size fits on it you can just use an active picture and save it via the screen capture object.
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
Sure you can load frames inside actives. But you cannot load external files. And that's what i need. Besides the hurdles you have told: i have to resize. That's all this about. And that i may need to work with 4096 pixel big pictures under some circumstances. I don't think that you can capture such a size :P
Nevertheless thanks for your input :)
Dynasoft, i am a very visual person. Explain me something and it can take eons until i understand it. Show me something and i understand it very quick. So an example is very very welcome :)
I have uploaded my own try now to the file archive. Have a look for the cubic resampling thread :)
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
http://www.dynamicarcade.co.uk/examples/MMF2/Scaling.zip
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
This is genious. And pretty quick. Thank you very much for this example :)
I think i understand now what's going on. Now let's rewrite it for cubic :)
EDIT, nope, again beaten by the "Expression too complex limit". I hate it :cry:
Re: Picture Resize Methods Linear, Cubic, Sinc Lar
Okay, i give up. Bicubic interpolation is behind my horizon. Not so much the idea, but getting anything out of the available formulas. For most of the used letters i even don`t know how to type them at my keyboard here :grin:
And so there is no way to even set a single counter to any value. I know i need nine. But that's it, basically. Wiki talks about 16 coefficients and eight equations though. Something to get mad at ...
Dynasoft, i know it is a big favour, but could you be so kind to give me also an example for the bicubic interpolation?
Or can an extension developer be so kind to write a picture extension that can resize in linear and bicubic and load and save a picture?