Log in

View Full Version : Lanczos3 Filter Resize.


Pages : [1] 2 3

Dark-Cracker
10th September 2002, 09:46
Hi,

for those who don't know the Lanczos is a resize algo better than bicubic resize. does someone have already worked on this filter ?
i know there is an virtualdub an an aviutl version but does someone have an yuv version of this filter who could work with avisynth script ?

thank u.

vlad59
10th September 2002, 10:30
Yep I know it, I know it from a French forum quoting a japanese web page.

I made a test (it's very easy to add in avisynth) : it's slower than bicubic and I didn't see any enhancement but I was perhaps too tired to see anything.

As soon as I get home I'll mail the modified sources to someone in the avisynth team.

Dark-Cracker
10th September 2002, 10:42
hi,

thank u very much if u could help this filter to be integrated to avisynth :)
i think with a good optimisation we can rush the same speed than bicubic and it's sure that lanczos algo was better for the details than bicubic :)

PS:i was a little frenchy too :) (bordeaux).

bye.

Nic
10th September 2002, 12:06
Heres an Intel 6 compile of the lanczos filter (avisynth & VDub)

http://nic.dnsalias.com/lanczos3.zip

in the readme is the link to where I found the filter/source...

-Nic

Ookami
10th September 2002, 13:58
Free at last!

Thank, Nic!

There was a time when I bothered everyone, that they should included Lanczos resizing in their programs...

fISH made a resizing filter for VD with many other algos, but the filter, sadly, never leaved the beta stage.

@vlad59

There is a obvious quality gain (first noticed it when using DVD2MPG Squeezer), but all the implementations I used are much slower than bicubic resizing, so there's the question if it's worth it.

There is also a AviUtl, lanczos filter out there:

http://forum.doom9.org/showthread.php?s=&threadid=19075

BTW, for VD, you need only to rename the .dll to .vdf or what? Er, will try that later...

Thanks.

Cheers,

Mijo.

Nic
10th September 2002, 14:12
you need only to rename the .dll to .vdf or what?

Yup thats all you do, but I thought giving it the .vdf extension might confuse some into thinking it wasnt fully avisynth compatible... :)

-Nic

Ookami
10th September 2002, 14:18
I'm still online... Phew...

Thanks for the clarification will, log off and try it right away!

All the best,

Mijo.

Wilbert
10th September 2002, 15:20
When adding filters in VDub you can also load dll-files (with the load button).

toshi
10th September 2002, 15:30
Originally posted by Nic


Yup thats all you do, but I thought giving it the .vdf extension might confuse some into thinking it wasnt fully avisynth compatible... :)

-Nic

Nic, you misunderstood. It can use as Avisynth plugin as it is.
ex.
LoadPlugin("lanczos3.vdf")

Original archive is this.
http://isweb42.infoseek.co.jp/computer/aetermv/arc/lanczos_02a.cab

I explain Lanczos3Resize filter history, because Nic wrote nothing
about it.
Originally, Lanczos3Resize filter was created by MOGI Kazuhiro for AviUtl filter. This Avisynth plugin ported by thejam who created fine ITVC plugin IT.

Nic
10th September 2002, 15:35
LoL...No I didnt misunderstand, I thought other people would be confused if it was called .vdf & people would think it was a VDub filter (Not everyone knows that a .vdf file is just a .dll file)

& I didn't write anything about it because I cant read Japanese :) , but did give the link to the site where I found it...

Thanks for the info though :)

Cheers,
-Nic

ps
& I recompiled it to a dll because I thought the intel compiler might help, but I doubt it as it is mainly assembler...

toshi
10th September 2002, 15:55
LoL...No I didnt misunderstand, I thought other people would be confused if it was called .vdf & people would think it was a VDub filter (Not everyone knows that a .vdf file is just a .dll file)


Oh, I'm sorry. I had misunderstanding...


& I recompiled it to a dll because I thought the intel compiler might help, but I doubt it as it is mainly assembler...

Yes. In resize.cpp, most of functions are written by assembler.
So, Compiler doen't matter.

Ookami
10th September 2002, 16:24
@toshi

Are you affiliated with the Aeternitas site? There are so many good japanese sites (for instance http://www.geocities.co.jp/SiliconValley-Sunnyvale/3109/ seems interesting), that I wish I would have had the patience to learn japanese :) . Oh, well...

BTW, do you know what happened with thejam79's filter site? I wanted to download his filters, but couldn't find anything to download :stupid: .

Thanks, and sorry for the little thread drift.

Cheers,

Mijo.

toshi
10th September 2002, 17:19
Thanks Ookami.
You can get the information about thejam's filter site at
this thread.
http://forum.doom9.org/showthread.php?s=&threadid=32863

But,lately IT 0.051 was released. It contained source code.
http://members.tripod.co.jp/thejam79/IT_0051.zip

Belgabor
10th September 2002, 18:27
@ookami: Simple way, use Babelfish (http://babelfish.astalavista.com). This page is translated pretty understandable.

Cheers
Belgabor

Ookami
10th September 2002, 18:27
Thank you very much, Toshi!

And I even got a mail from GuiltyX, where he pointed me, also, to the mentioned thread.

Can someone mail me, or upload somewhere, the ghost filter? I'm only interested in it if it is a ghost removing filter like the Exorcist ( http://www.republika.pl/vander74/virtualdub/ ) for VirtualDub.

@belgabor

In 99% such translations are unusable, especially if you use it for technical pages, but maybe the translations are better now than a few years ago... Thanks for your time.

BTW, did you saw the Avspreview program on the site I mentioned :) ?

All the best,

Mijo.

Belgabor
10th September 2002, 18:52
Originally posted by Ookami
@belgabor

In 99% such translations are unusable, especially if you use it for technical pages, but maybe the translations are better now than a few years ago... Thanks for your time.

BTW, did you saw the Avspreview program on the site I mentioned :) ?



Unfortunately, yes. But in this case it works surprisingly well.

I was just testing this AVSPreview thing. Unfortunately my Screen res of 1152x864 isnt large enough for it to fit. (He tells 1024x768 in his readme, but western and eastern windoze systems often differ in screen metrics).
Anyways, this program is buggy (at least on my western system) so as long as i don't have the source to recompile its a nice idea but unusable.

Cheers
Belgabor

vlad59
10th September 2002, 19:12
For those who are interested : I have attached a version of avisynth(the latest CVS) with a built-in lanczos resize :

ALanczos3Resize (Destination width, Destination height) (like BilinearResize)

I choose to name it ALanczos3Resize to allow you to test this filter and the filter compiled by Nic.
I haven't made any quality or speed test between them but since I already have it you can choose the version you want.

EDIT :
It seems that the built in function is faster that Nic's plugin.
I'm too tired to make quality tests.
The sources is available, I'll mail Shodan or Dividee as I don't have CVS access.

Dali Lama
10th September 2002, 23:14
I have been using Lanczos3 Resize filter in my last two encodes with excellent results. I find the detail very high. I will look into the compressability differences between it and Bilinear and Bicubic, although judging from the quality of the one cd encodings, it compresses very well, similar to bilinear.

I actually found this filter, by scouring through the japanese filter sites, they are pretty cool.

Also, many high end photo resizing programs use Lanczos3 to resize photos in high quality, so I figure it can't hurt video resizing.

Dali

Dark-Cracker
10th September 2002, 23:43
yes Lanczos resize formula was the BEST ratio quality/size i have make a compressibility test and the result was above bilinear and below the bicubic. i need do more tests but i realy think with a light convolution filter and this resize filter the result will be better than bicubic and near the biliear compressibility.

PS: on a japanese site (http://barururu.virtualave.net/avisynth.html) i have found a script with the file warsharp.dll (seems to be an yuv conversion of the virtualdub filter) does someone have this filter ?
perhaps a japanese man could translate the text about this filter.

thank u :)
Bye.

PS: for those who are interested Autodub 1.6 will be out in a few day with the support of the lanczos filter ,a compressibility test and the update of the xvid build 10-09-02 :) :) :)

unplugged
10th September 2002, 23:48
By few comparisons I have found it very very close to sharp bicubic (0.75), only a bit more sharp... I think with normal view diff. is impossible to perceive.

[Edit] Nice to hear about quality/size. Suprised :)

soujir0u
11th September 2002, 08:36
Better quality than Neutral Bicubic yet more compressible than Soft Bicubic? Sweet!

vlad59
11th September 2002, 08:49
Have somebody compared the quality of the filter compiled by Nic and the modified avisynth I posted ????

Because my implementation is maybe too simple and has maybe quality problem :(

I'll have no time to do this, I'll be away from keyboard for the next two days (working at a customer office).

HarryM
11th September 2002, 09:33
Do exist any sophisticated resize algorithm, which reduce noise and preserve sharp edges?

HarryM
11th September 2002, 09:58
Originally posted by soujir0u
Better quality than Neutral Bicubic yet more compressible than Soft Bicubic? Sweet!

Compressibility of soft-bicubic (b,c=1/3) is very comparable to bilinear...

I actually use bicubic (b=0,c=0.5), good compromise between quality and compressibility (noise sensitivity).

Avised results of LanczosResize are very hopeful for me (much better compressibility)!
LanczosResize are my futurefavourite resampling function? I must testing...

Ookami
11th September 2002, 11:03
Originally posted by HarryM
Do exist any sophisticated resize algorithm, which reduce noise and preserve sharp edges?

Some descriptions from the DVD2MPG Squeezer readme. If I remember correctly, my testings showed that the descriptions are correct :) .

Resize Filter = The used filter for resizing the source picture to output
size. The following filters are available:

- Nearest Neighbourhood: This is the fastest one. Not
recommended at all, because aliasing is present
everywhere. A lot of jagged lines and artifacts are
common.

- Triangle Filter AKA bilinear interpolation: After
nearest neighbourghood this is the 'second fastest'. It
provides a decent image with good speed.

- Hermite Filter: Unknown what it does exactly but is
as fast is the Triangle Filter.

- Bell Filter: This filter blurs the image at the same
time it resizes. If you want to smooth the video and
your source video is very noisy use this.

- BSpline Filter: One step further from 'Bell Filter'. A
bit slower and more blurred image but less noisy and
less sharp though.

- Bicubic Filter: Very good quality/ speed ratio. This
filter minimize artifacting and aliasing while
maintaining the speed. This should be the default
setting for almost everyone.

- Mitchell filter: Similar to bicubic filtering but it's
a bit slower. If you want similar performance to
bicubic filtering but your source video is noisy,
try this one.

- Lanczos windowed Sinc: Provides quality similar to that
of Hanning windowing method but it's a bit faster.

- Hanning Windowed Sinc: Provides somewhat better quality
than bicubic filtering but it's rather slow. Try it if
CPU horsepower is not a problem for you.


Hopefully some of the more knowlegable person here can comment on this one...

Cheers,

Mijo.

Dark-Cracker
11th September 2002, 11:23
hi,

here it's a picture with the most common resize algorythm, it was a snap of a picturesoft and un happuly there is not the bicubic picture and the Hanning Sinc.

PS: Nearest Neighbourhood formula was call too Box and the Triangle Filter was call Bilinear. (normaly i was not wrong :) )

Here was the snap :

unplugged
11th September 2002, 12:59
Do not be much sure about Lanczos3 compressibility :( (to be honest I was sceptical from the first view: this algo is damn detailed :)), I have made a little discouraging test with 1 minute LOTR clip (720x424) resized to 640x272:

neutral bicubic (c=0.75) resize 19000 Kb
lanczos3 resize 20200 Kb

Just to describe the content, the clip contains progressive moving parts, moving parts and statical. Content is clear and much detailed itself, entirely taken from daylight scene (LOTR frames from 11481 to 13056).
(avisynth 2.05, mpeg2dec2.dll, Virtualdub fast-repack YUV, XviD)

iago
11th September 2002, 13:15
Do not be much sure about Lanczos3 compressibility...@unplugged and all,

I had very similar results here too, with some short tests. First 3746 frames of Matrix, mostly dark content, with both motion and still scenes, resized to 640*272. I used vlad59's dll.

alanczos3 = 49750 kb
sharp (c=0.75) = 49216 kb
neutral (c=0.5) = 47546 kb
soft (c=0.33) = 46460 kb
SimpleResize = 45956 kb
bilinear = 41918 kb

(avisynth 2.05 with alanczos3 resize dll by vlad59, mpeg2dec.dll, VirtualDub fast recompress, XviD Nic's latest build with constant quant 2)

regards,
iago

EDIT: and using MPEG quantization...

vlad59
11th September 2002, 13:24
@iago
Can you try with the dll compiled by Nic.
To be sure the results are roughly the same.

Thanks in advance

iago
11th September 2002, 13:31
Originally posted by vlad59
@iago
Can you try with the dll compiled by Nic.
To be sure the results are roughly the same.

Thanks in advance @vlad59

Sure, I'll do that right away and post back the results.

regards,
iago

unplugged
11th September 2002, 13:42
Originally posted by vlad59
To be sure the results are roughly the same.
As result, mine has been obtained with Nic's lanczos dll. (19000 Kb / 20200 Kb)
To mention that Nic's version is only a bit slower than bicubic, almost how happens in my system... (~24fps / ~27fps)

[Edit] I have used fixed quantizer 3 for that test.

vlad59
11th September 2002, 13:49
In fact I'm not sure of how works Nic DLL because I found some sources of an Lanczos3 aviutl plugin where you can use to process integer (with MMX) or use float (with SSE or SSE2).

So his version could be more precise (in term of quality) as I use the main resizing engine of avisynth wich deal mainly with integer (except for the resampling pattern of course).

iago
11th September 2002, 14:14
@vlad59 and all

vlad59's dll: 49750 kb
nic's dll: 49552 kb

(difference: ~0.40%)

regards,
iago

iago
11th September 2002, 14:18
screenshot from vlad59's dll

iago
11th September 2002, 14:21
screenshot from Nic's dll

HarryM
11th September 2002, 14:28
Originally posted by iago
@unplugged and all,

I had very similar results here too, with some short tests. First 3746 frames of Matrix, mostly dark content, with both motion and still scenes, resized to 640*272. I used vlad59's dll.

alanczos3 = 49750 kb
sharp (c=0.75) = 49216 kb
neutral (c=0.5) = 47546 kb
soft (c=0.33) = 46460 kb
SimpleResize = 45956 kb
bilinear = 41918 kb

(avisynth 2.05 with alanczos3 resize dll by vlad59, mpeg2dec.dll, VirtualDub fast recompress, XviD Nic's latest build with constant quant 2)

regards,
iago

EDIT: and using MPEG quantization...

Damned :(
Wonders not exist...

unplugged
11th September 2002, 14:50
About resize, does anybody know if last bug of simpleresize.dll concerning chroma/luma shift has been solved?
Haven't find any post by trbarry talking about this... yet. :(

vlad59
11th September 2002, 15:01
Yes I remember the problem and I don't think Tom solved it (As far as I remember).

[off topic]Time to go, or I'll miss my train[/off topic]

Marc FD
11th September 2002, 15:08
Size tests are good, but quality tests are better.

ie between
Bilinear,Bicubic(soft,neutral,sharp),SimpleResize and lanczos3

The slower is not always the better in terms of quality.
See simpleresize...

toshi
11th September 2002, 15:23
Lanczos3 resize filter makes bigger image, Because it makes
sharp image.

trbarry
11th September 2002, 15:36
About resize, does anybody know if last bug of simpleresize.dll concerning chroma/luma shift has been solved?
Haven't find any post by trbarry talking about this... yet.

Sorry, some other stuff came up and I confess I haven't done anything on that. I'll try to get back to it soon.

But SimpleResize is just an optimized bilinear resize without the triangle filter. This means it goes faster but does not filter and is then (duh) best when you don't need any filtering. So if you had overly sharp material already (uncommon) then it could create aliasing artifacts if you downsized a lot. And of course it passes through all the noise, but also all the detail.

I think the more sophisticated (but slower) algorithms like BiCubic and Lanczos3 are general purpose and can do a much better job when upsizing, filling in gradients smoothly. SimpleResize probably wouldn't upsize very well, at least at ratios bigger than (swag) 1.5:1 or so. But of course for encoding purposes we are usually downsizing.

Anyway, I promise to go look for the chroma shift bug. ;)

- Tom

Blight
11th September 2002, 15:59
I wonder how my factor resizing would look in comparison, sadly, it's impossibly slow (around 400ms/frame) and I don't think I could incorporate delphi code into avisynth without someone translating headers.

Marc FD
11th September 2002, 16:42
delphi is easy to translate in C.
(i'm a former delohi user ;) )

Blight
11th September 2002, 16:56
Here's the function I wrote, rather crude but give it a shot.

procedure ImageFactorResize(SrcBitmap,DestBitmap : TBitmap; DestX,DestY,dWidth,dHeight : Integer);
var
Speed1 : Integer;
Speed2 : Integer;
Speed4 : Integer;
PixR : Integer;
PixG : Integer;
PixB : Integer;
SX,SY : Integer;
X,Y : Integer;
PixXShl : Integer;
PixYShl : Integer;
PixXRnd : Integer;
PixYRnd : Integer;
PicWidth : Integer;
PicHeight : Integer;
PixCount : Integer;
PixXPos : Integer;
PixYPos : Integer;
P : ^TMyScanLine;
PL : Array[0..4095] of ^TMyScanLine;
PDif : Integer;
begin
// Calculate memory used for each line display for quick scanline seeks (dest image)
PL[0] := SrcBitmap.Scanline[0];
PL[1] := SrcBitmap.Scanline[1];
PDif := Integer(PL[1])-Integer(PL[0]);
// Pre-Calculate scanline positions for source image
For Y := 2 to SrcBitmap.Height-1 do Integer(PL[Y]) := Integer(PL[Y-1])+PDif;

// Pre-Calcualte some repeated math
PicWidth := SrcBitmap.Width shl 2;
PicHeight := SrcBitmap.Height shl 2;
PixXShl := (PicWidth shl 8) div dWidth;
PixYShl := (PicHeight shl 8) div dHeight;
PixXRnd := Round(PicWidth / dWidth);
PixYRnd := Round(PicHeight / dHeight);
PixCount := PixXRnd*PixYRnd;

// Calculate memory used for each line display for quick scanline seeks (source image)
P := DestBitmap.Scanline[DestY];
PDif := Integer(DestBitmap.Scanline[DestY+1])-Integer(P);

// scale the image
For Y := 0 to dHeight-1 do
Begin
PixYPos := (Y*PixYShl) shr 8;
For X := 0 to dWidth-1 do
Begin
PixR := 0;
PixG := 0;
PixB := 0;
PixXPos := (X*PixXShl) shr 8;
For SY := 0 to PixYRnd-1 do
Begin
Speed1 := ((PixYPos+SY) shr 2);
For SX := 0 to PixXRnd-1 do
Begin
Speed2 := (PixXPos+SX) shr 2;
Inc(PixR,PL[Speed1]^[Speed2].MRed);
Inc(PixG,PL[Speed1]^[Speed2].MGreen);
Inc(PixB,PL[Speed1]^[Speed2].MBlue);
End;
End;
Speed4 := X+DestX;
P^[Speed4].MRed := PixR div PixCount;
P^[Speed4].MGreen := PixG div PixCount;
P^[Speed4].MBlue := PixB div PixCount;
End;
Inc(Integer(P),PDif);
End;
end;


Oh, and there's the factor value in here somewhere, I think it's the shr 2, you can up the quality by doing shr 3, shr 4 (which increase the sub-picture calculation), etc...

This is more accurate than biliniar for downscaling, but not for upscaling. Very CPU intensive

Marc FD
11th September 2002, 19:24
Argh.
I'm really bad when it comes to resamplers... never really etudied the stuff.
and this is only a portion of code....
so i don't understand it really...

I think i should do a benchmark a day between all these resampling algos to find wich is best for each purpose.

BTW, vlad, you integrated the Lanczos3 in the resampling-engine of your avisynth version, or you just added the filter ?

Defiler
11th September 2002, 22:30
Blight: What programming language is that? Delphi?
It looks a little like Ada.

Dark-Cracker
11th September 2002, 22:58
i am not sure your resize filter will be faster even if u translate it in c , try to use asm else it will be very slow .
if u are interested i think u could find the source of the lanczos aviutl filter on the site web indicated by nic (scroll up) and it seems to me there is an another filter resize with source code called "icubic convolution algorythm" perhaps this will help u to make a quick filter resize.

++

Blight
13th September 2002, 11:23
This is Delphi (Visual Pascal), and even if I converted it to ASM+MMX+SSE+SSE2 it would probably be a lot slower than bicubic as the amount of calculations is very high.

It basically does a sub-pixel calculation on a factor level, at a factor of 2 of splits a pixel into a 4x4 grid, at a factor of 3, an 8x8 grid, a factor for 4 a 16x16 grid.

Factor of 4 looks nice when downscaling. But even if optimized up the wazoo would probably take over 250ms per frame.

Didée
13th September 2002, 11:47
Matrix: Kung-Fu Scene (Neo vs. Morpheus), MPEG-quant 2, 640*256, 4min23s


Bilinear: 59776 kB
Bicubic 0.333/0.333: 61580 kB
SimpleResize: 65782 kB
Bicubic 0.0/0.5: 67102 kB
Bicubic 0.0/0.75: 69638 kB
Lanczos3Resize: 69804 kB
Bicubic -0.2/0.6: 70670 kB
Bicubic -0.333/0.666: 73056 kB
-------------------------------
Bicubic -2.0/1.5: 125194 kB <-- Just for fun

So, Lanczos is my favorite, if there are enough bits available for a sharp downscaling.
Because, where Bicubic 0/0.75 starts producing halos, Lanczos3 deals alot better for me.

ookzDVD
13th September 2002, 13:13
Yes,

the lanczos3 produce the sharper image than the neutral bicubic,
I just finish the _Monsters_Inc_ and the result is superb. ;)

@Nic,
thanks for the lanczos3.dll ;)
slower than the build-in modified avisynth, but it produce sharper
image imho, as you could see the aigo's screenshot.