View Full Version : Lanczos3 Filter Resize.


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.

Dark-Cracker
13th September 2002, 14:31
hi,

for those who are interested to make some tests u can find my tool (autodub) here : http://forum.doom9.org/showthread.php?s=&threadid=24678

test the v1.6 it come bundle with the lanczos filter and u can make a compressibility test of course it support the codec divx3/4/5 & xvid

bye.

Marc FD
13th September 2002, 16:21
Just a question :

- why do you all want to sharpen your image when you downsize ? :confused:

If i want the best image possible, i would keep 720x...

I don't see why you need to downsize if you want to achieve a bigger filesize.

I thinked the problem in ripping was to get a low enough file to put it on 1-2 CDs.

I think i've missed something.... let's re-read the whole doom9 forum....

drizztcanrender
13th September 2002, 16:34
Originally posted by Marc FD
Just a question :

- why do you all want to sharpen your image when you downsize ? :confused:

If i want the best image possible, i would keep 720x...

I don't see why you need to downsize if you want to achieve a bigger filesize.

I thinked the problem in ripping was to get a low enough file to put it on 1-2 CDs.

I think i've missed something.... let's re-read the whole doom9 forum....

Well in my encodes, lanczos3 doesn't increase the filesize,not more than sharp bicubic at least.And encodes on full resolutions are hard to make,even with 2 cds.At least for my eyes some resizing looks better than none...

Marc FD
13th September 2002, 17:12
for my eyes

That's the reason why RV9 as so many adepts.
It "looks" so good.

But i'm not a serial ripper.
pratically, you're right.
theorically, not.

drizztcanrender
13th September 2002, 18:30
A lot of stuff have a theoretical advantage but they don't have much practical significance.And the encoding procedure is indeed based on a theoretical background but it all comes down to practical results.So, imho,if it looks better then it is better.After all isn't that what we are trying to do?Make our film content look better?
The only problem of course would be the effect that lanczos3 resize would have in compressability and therefore in the final filesize.But, in my tests, lanczos resize and (even)sharp bicubic encodes have the same final filesize and display almost the same compressability and lanczos3 resize looks better,at least with divx5(it really needs the extra sharpening effect to diminish the blurring of divx5 encodes).

FuPP
13th September 2002, 19:57
@MARC :

Quote :
---------------------------------------------------------------------
- why do you all want to sharpen your image when you downsize ?

if i want the best image possible, i would keep 720x...

I don't see why you need to downsize if you want to achieve a bigger filesize.
---------------------------------------------------------------------

In some case, we HAVE to resize (cf svcd , vcd, cvd specifications...). We don't all encode with XVID :)

vlad59
13th September 2002, 21:50
@iago (= serial tester ;) )

Thanks a lot for the testing.
With your screenshots it's clear the Nic's filter provide sharper picture (IrfanView 300%) and also greater compressibility. I was right to be doubtful about my Lanczos implementation in avisynth (it was too easy).

I think I should remove the dll.

droolian01
14th September 2002, 15:09
Hi there.

I've been using the lanczos3 resise for my last few encodes and i like the results. Now i know there is a bicubic directshow filter for keeping sharper output during full screen playback, i wonder if it is possible to produce al anczos3 directshow filter.

OK - please please please can one of you brainy programmers do this, i think it would really improve fullscreen playback

Waiting with baited breath

Koepi
14th September 2002, 16:00
I'm mostly impressed by the nice color representation of lanczos3. Now it's really easy to beat some group releases as the filter is the right one :)
But "from hell" looks so nice now, I'm trying zoolander as well with it. I'm so glad that I stepped back from simple resize... I like the speed of it, but the resulting picture has too many downscaling artefacts (like aliasing from "thin lines" [ the bamboo-stick in rush hour 2 where chirs tucker and jacky chan are hanging on for example looks horrible with simpleresize])

To bad that compressability lowers about 10%-15%...

Best regards,
Koepi

int 21h
14th September 2002, 16:08
I've noticed also SimpleResize making jagged artifacts. I tried using it only once for a SVCD and the quality was horrible. My only guess is that it has issues doing very large downscaling.

MaTTeR
14th September 2002, 16:26
@int 21h

I too seen problems using SimpleResize with SVCD/XVCD/KVCD's but after using the nice FitCD app for my resizing the problem went away. You must have "macroblock aligned" turned on in FitCD and the jaggies mostly go away in my experience.

Lanczos3 looks very appealing from reading all the feedback. Time for some testing and finish my Convolution3D tests up too.

iago
15th September 2002, 00:56
Originally posted by Koepi
I'm mostly impressed by the nice color representation of lanczos3... To bad that compressability lowers about 10%-15%... Yep, Koepi. Unfortunately :(. 'Cause, it's really impressing imho too...

But I guess I'll still give Matrix a try with lanczos3, cutting down on audio, throwing some light convolution3d on it, beating the black-enemy-blocks with ColorYUY2, and aiming for 1XCD ;).

@MaTTeR

I'm impatiently waiting for your test results...

kindest regards,
iago

Metalazzo
15th September 2002, 23:42
I just try on 1 min of the movie "the game"
encoded with xvid at quant 2 to see how many Bytes i could save
I tryed :
-bicubic resize (bicubicresize(x,y)) (13MB)
-bicubic resize + convolution3D(0,4,4,4,4,3,0) (11.3MB)
-lanczos resize (15.2MB)
-lanczos resize + convolution3D(0,4,4,4,4,3,0) (13.3MB)

i am very surprised of the quality of the lanczos resize : the picture is very detailed :eek: but the clip is too big :(
with lanczos resize and conv3d the result is also quite good : I think it's sharper than bicubic alone

conclusion : convolution3d and lanczos resize match very well :)

for the pics it's here :
http://membres.lycos.fr/metalazzo/thegame.zip

ps : sorry for the copy paste :D
ps2 : sorry for the crappy english :p

MaTTeR
16th September 2002, 01:42
@Metalazzo

I've also decided to use the C3D and Lanczos for most of my rips now based on a few tests I've done on Salton Sea and Rose Red. What settings did you use for BicubicResizing tests? SoftBicubic?

Metalazzo
16th September 2002, 03:10
@MaTTeR

no, i used a "simple" bicubicresize without any parameters more than res x and res y (bicubicresize(x,y))
i'll try with a soft bicubic tomorrow (well that's this afternoon...damn already 4:12 am)

cdrips
16th September 2002, 04:23
I was testing this filter out. I watched the whole movie I encoded with it. The Ice Storm, XVID, h263 quants and this resize filter. No other filters. For 3 scenes of the movie, it gave me a blank screen with sound still going, then it corrected itself. Is it possible the filter did this? Or maybe something else. I've watched other movies I've encoded w/ bicubic. None have this problem, same methods. Is it just the dvd? Any suggestions of how to avoid this problem or check any other encodes for this problem (besides watching the whole movie).

ErMaC
17th September 2002, 01:20
Is this new resizing filter appropriate for both upsizing and downsizing of footage? Also, how does it perform on animated footage?

Koepi
17th September 2002, 08:39
@Ermac:

Yes, if you'd read this thread and followed the links you'd know it's not only for upscaling, but since you know the forum rules you already found that yourself and just asked to see if you understood it correctly, right?
And: just test it on anime to find out if it works for you.

@cdrips:

No, a RESIZE filter doesn't do that, you could guess that from the RESIZE functionality that in the RESIZE filter name.
Is ther eany ASYNC mode involved? No. It's something wrong with your setup and / or your rip.

sh0dan
17th September 2002, 11:27
I merged the algorithm into Avisynth (thanks to vlad) - it works fine, and at the exact same quality as Nic's filter, after I found a rounding bug also affecting Bicubic/Bilinear.

I called it LanczosResize - to avoid any conflicts.

Anyone interested can grab it at the cvs bin site (http://cultact-server.novi.dk/kpo/avisynth/avs_cvs.html)

iago
17th September 2002, 11:41
-> I merged the algorithm into Avisynth (thanks to vlad) - it works fine, and at the exact same quality as Nic's filter, after I found a rounding bug also affecting Bicubic/Bilinear... I called it LanczosResize - to avoid any conflicts.(sh0dan)

That's really great! Thanks a lot.

best regards,
iago

EDIT: And it seems it works faster now! (came right before I was starting a rip with Nic's lanczos3.dll ;))

sh0dan
17th September 2002, 11:57
I can confirm the speed increase - Nic's runs with 22-23fps and the internal filter runs with 24-25fps - great thing! :cool:

There should actually also be a speed increase in Bilinear/BicubicResize, so everyone seems to gain from this.

ErMaC
17th September 2002, 15:33
Koepi, yes I did read this whole thread and I just re-read it to make sure I wasn't going crazy. I followed the links and I never saw anyone mention explicitly whether it was good for both upsizing and downsizing (although I admit I only skimmed the autodub thread). The only hint that it might be good for upsizing was the superman image comparison, which was an upsize but on something of that size I have no idea if it would scale to larger images the same way. All the other posts have been concerning downsizing. Therefore, I asked the question. Please point out if I missed something but I honestly looked through the whole thread to see if anyone specifically pointed out an answer to my question.
And I asked about animation because I'm in the middle of packing to move and I'm currently stuck on a laptop so I couldn't test this stuff very easily anyway.

cdrips
17th September 2002, 22:43
Sorry, I just thought that if a resize like simpleresize with the green line if not div by 4 could mess with a picture, another resize filter could also. Maybe because of dvd decrypter?

trbarry
17th September 2002, 23:14
FWIW, if you still get the green line on SimpleResize you should download a newer one. That's been fixed for some time now.

- Tom

www.trbarry.com/SimpleResize.zip

cdrips
18th September 2002, 00:59
trbarry, thanks for the link, I didn't know you fixed it already. Could my problem be a result of the playback filter? For 3 moements, sound goes while picture replaced by blackness, then picture comes back.

Dark-Cracker
18th September 2002, 01:33
hi,

@ermac
if i am right ? (sorry my english was very poor and i don't have understand all your post) u want to know if this resize filter was good for anime ?
as koepi say u must do some test to see if this is good for you but the lanczos filter keep a lot of details because it was sharp this will of course increase noise and your movie will be less compressible and finaly this will increase your finale size.
i am not sure this filter was usefull for animations, but u can try with filters, simply make tests :) :) :)

Metalazzo
18th September 2002, 03:04
i agree with Dark-Cracker
lanczos resize will keep more noise than bicubic
i tested it on a movie with xvid (quant 2 to see the difference)
the file (1min) was 15MB instead of 13MB with bicubic
more details but....more noise also :(
maybe if your source is really really clean then you can try....i will try it with a gundam wing dvd (actually there is a lot of mosquito noise)
without noise remover only resize
maybe i will post some pics if ppl are interested

Didée
18th September 2002, 07:53
Originally posted by ErMaC
Is this new resizing filter appropriate for both upsizing and downsizing of footage? Also, how does it perform on animated footage?
Hint:
For upsizing more than a little bit, use Bicubic(x,y,0.333.0.333), perhaps even (x,y,0.5,0),
followed by - - Warpsharp!

(But don´t tell neuron2, for heaven´s sake)

Sorry, Donald ;)

Have a second look at the "superman-upscales": ALL of them are c-r-a-p.

[After some years of digital still image processing...]

Metalazzo
18th September 2002, 14:08
well just finished to encode a gundam ep
the video file size was the same (around 186MB) BUT the average quality was better with bicubic :(
lanczos resize keeping more details and more noise makes impossible to have lots of frames at drf 2 :(
so if for you file size is not a problem you should try....else stick with bicubic

kilg0r3
18th September 2002, 14:28
also made a short test yesterday. the difference in file size between sharp bicubic and lanczos was some 2 percent to the favour of lanczos. but a frame per frame comparison of the resized source material shows that the difference between the frames is very and i mean VERY small. the lanczos-resized images seem to have slightly more contrast.

i can provide screenshots if anybody is interested

JayCutler
20th September 2002, 01:04
i can provide screenshots if anybody is interested

Sure! If u can I'm really intersted.

-Jay

kilg0r3
20th September 2002, 08:35
http://www.netcologne.de/~nc-allgeife8/resize.rar is the url of the screen shots.

i compared them in acdsee at 200%, with zoom lock, switching with the mouse wheel between the different images. my monitor is a samsung 757dfx 17" monitor.


repeated with 300%

jarthel
20th September 2002, 17:12
I tried this (builtin lanczosresize in avisynth.dll) recently with record of lodoss war and Rurouni kenshin. It produces an error just before the credits. change lanczosresize to simpleresize and no more errors.

Here's the new script
-----
body=mpeg2source("d:\dvdrips\lodoss16\lodoss16.d2v").trim(0,38976).Telecide(Guide=1,Gthresh=40,Threshold=20,Chroma=True,dthreshold=10,Post=true).Decimate(cycle=5).crop(14,4,692,472).temporalsmoother(5).SmoothHiQ(5,50,50,175,3).simpleresize(640,480)


return body
-------------------

the old script just uses lanczosresize.

Jayel

vlad59
20th September 2002, 17:18
Can you try it with Bilinear or Bicubic resize.


Some code is shared between the resampler in Avisynth so if the Bilinear doesn't crash then it's really because of specific Lanczos3 code.

Thanks in advance.

jarthel
21st September 2002, 00:03
The same problem occurs when using Bilinear and bicubic. Only simpleresize works.

Jayel

vlad59
21st September 2002, 08:34
So that's maybe a problem with the latest Sh0dan optimizations.
Can you try with an old avisynth (~ beta6 from videotools.net for example) and see if it crash again.

Another thing you can also try to resize only horizontaly (the aspect ratio will be off but it's only a test) and after that only vertically. Because there is two resize code : one for H and one for V.

Thanks in advance for your help.

jarthel
21st September 2002, 17:26
I will try your suggestion after I'm done with my jobs in the queue. :)

Jayel

sh0dan
22nd September 2002, 13:16
Damn... I need some info:

CPU
Colorspace (YUY2 i presume)
Size before resize.
Size after resize.

Then I should be able to find it.

jarthel
22nd September 2002, 13:24
Originally posted by sh0dan
Damn... I need some info:

CPU
Colorspace (YUY2 i presume)
Size before resize.
Size after resize.

Then I should be able to find it.

If that's for the problem I discovered:

CPU: XP2200+ thoroughbred (can use SSE)
colorspace: YUV
size before resize after crop: 692 x 472
size after resize: 640 x 480

sh0dan
22nd September 2002, 15:28
Thanks for the info!

I'm not at work, so I can't test here,but thanks for the info. Could you test 2.05 (release), using Bicubic, so I can see when the bug was introduced.
Is the crash consistent, or does it happend at random?
Does the position of crop affect the crash?
Is it "Avisynth caugth an access violation at #####"

D*mn, I hate it, when I make these mistakes. :(

jarthel
22nd September 2002, 15:48
I can't test it right now. stil encoding but it's an access violation error.

sh0dan
22nd September 2002, 16:08
ok - thanks for the efford - I'll get on it :)

Koepi
30th September 2002, 11:00
@Ewi:

see this thread? A forum search DOES help.

Koepi

Prosper
30th September 2002, 22:13
I have been using lanczos interpolators in digital photo manipulation for quite some time, and I came across this site quite a while ago, it has some quality comparisons of different interpolators.
Complete version here: http://home.no.net/dmaurer/~dersch/interpolator/interpolator.html

Interesting snippets here:
Source image:http://home.no.net/dmaurer/~dersch/interpolator/z256.GIF
Photoshop's Bicubic Interpolater: http://home.no.net/dmaurer/~dersch/interpolator/PSbicubic_z256.GIF
Photoshop's Bilinear Interpolater:http://home.no.net/dmaurer/~dersch/interpolator/PSbilinear_z256.GIF
PT's sinc256(lanczos 16x16) interpolator:http://home.no.net/dmaurer/~dersch/interpolator/PT_sinc_z256.GIF

Defiler
1st October 2002, 03:41
Prosper: Ouch. That's quite a torture-test image there.

YUV 4 2 0
1st October 2002, 11:13
Some Tests with this strange Image and the LanczosResize/BicubicResize (b=0/c=0.75) Filters from AviSynth 2.06.

Original 256x256 Pixels:
http://home.no.net/dmaurer/~dersch/interpolator/z256.GIF (46 KB)

Original resized to 192x192 Pixels:
Bicubic (http://mitglied.lycos.de/yuv420/attachment/resize/S_bicubic.png) (46 KB)
Lanczos3 (http://mitglied.lycos.de/yuv420/attachment/resize/S_lanczos3.png) (46 KB)

Original resized to 320x320 Pixels:
Bicubic (http://mitglied.lycos.de/yuv420/attachment/resize/M_bicubic.png) (119 KB)
Lanczos3 (http://mitglied.lycos.de/yuv420/attachment/resize/M_lanczos3.png) (122 KB)

Original resized to 608x608 Pixels:
Bicubic (http://mitglied.lycos.de/yuv420/attachment/resize/L_bicubic.png) (362 KB)
Lanczos3 (http://mitglied.lycos.de/yuv420/attachment/resize/L_lanczos.png) (376 KB)

kilg0r3
1st October 2002, 11:45
well, lanczos may be good for multiple resize steps and images like that circle 'perversity' but for video resizing the very minor increase in quality does not justify the extra processing time. see my post above.

serbersan
2nd October 2002, 00:14
I'm totally agree with you kilg0r3¡¡¡

I've made some test with two movies... both with sharp bicubic and lanczos resize. I haven't found any difference in the first movie.

In the second I've made the same that you made: a comparasion with 200% zoom... only in two of the 5 images I've used to compare I've noticed a very little difference in favour of lanczos very subtle and only visible at 200% and with very good attention. By the other hand, although the movie is very compressible by default, sharp bicubic has retained more details in the black sweater of John Travolta and this difference it's visible without zoom, and simply watching the screen, and lanczos has a little more mosquito noise. The compressibility is very good a 2-3 quantizers and a quality similar to dvd in the sharp bic. encode.

Has anyone images where lanczos offers a visible better quality or at least it avoided artifacts that sharp bicubic could generate??

Didée
2nd October 2002, 09:29
serbersan,

when saying "sharp bicubic", I suppose you mean the go'old (x,y,0,0.75).

This particular one I don´t use for quite some time now. I produces noticeable EE (edge enhancement).

Once I found the hint that (for (x,y,a,b) in bicubic) the least error is obtained when 2*a+b=1, I stick to that.
I think sometimes I read something about negative values were not supported in AviSynth, but I can´t confirm that - works well for me.

So, in terms of sharpness, this is my personal list:
(top-down: increasing sharpness AND DEcreasing compressability)

1. BicubicResize( x, y, 0, 0.5)
2a. LanczosResize( x, y)
2b. BicubicResize( x, y, -0.2, 0.6)
3. BicubicResize( x, y, -0.333,0.666)
...and "-0.1,0.55" should be v-e-r-y similar to Lanczos.

I should mention, I often use kind of sophisticated filtering/denoising, so in many cases I can afford to use some sharper downscaling.
This is true in particular for my TV-caps. The raw caps are of good quality, but a tad too soft for my taste, so ...

Perhaps you may want to see my little "results table" on page 3 of this thread.

Marc FD
2nd October 2002, 12:54
Originally posted by Didée

1. BicubicResize( x, y, 0, 0.5)
2a. LanczosResize( x, y)
2b. BicubicResize( x, y, -0.2, 0.6)
3. BicubicResize( x, y, -0.333,0.666)



you use BicubicResize(x,y,b,c) with negatives numbers for b, right ?
I thought the Bicubic resampler ignores b<0 and uses b==0 instead.

EDIT : I'm really not sure of this...

Originally posted by Didée
...and "-0.1,0.55" should be v-e-r-y similar to Lanczos.


Maybe the result. But they're different :

Bilinear resize is a 2 points resampler using triangle interpolation,
Bicubic resize is a 4 points resampler using b-spline interpolation,
Avisynth Lanczos resize (Lanczos3 like) is a 6 points resampler using sinc interpolation,
Classic Lanczos resize is a 8 points resampler using sinc interpolation,
and sinc256 resize, HQ lanczos, is a 16 points resampler using sinc interpolation.

To difference in speed between these resamplers is only due to the number of points used for resampling.
It's why Bilinear is faster than Bicubic who is faster than 6-points Lanczos (Lanczos3)

BTW, Bilinear, Bicubic, Lanczos, or any other interpolation method, can be used for downscaling, upscaling, and for arbitrary rotation, or any other 3D transformation too.

Regards,
MarcFD

PS : correct me if i'm wrong :D

OUTPinged_
2nd October 2002, 14:03
didee,

resizing algorithms dont produce EE.

sharpeners like unsharpmask and msharpen do.

too sharp resize results in aliasing tho (but that is not EE)

Didée
2nd October 2002, 14:11
Marc,

I see nothing to correct.

My finding "(-0.1, 0.5) very similar" referred to the pretty limited range we usually deal with: when resampling sources like DVD/TV-caps, destination size is usually >=50% for downscaling, resp. =<150% for upscaling. For these ranges, no alien algorithms are needed ;)

I thought the Bicubic resampler ignores b<0 and uses b==0 instead.
EDIT : I'm really not sure of this...That´s what I read, but ... it seems to be fixed: try it out.
There were some optimizations to the resize algorithms in AviSynth 2.05 & 2.06, maybe s'one has touched s'thing in there?

sh0dan
2nd October 2002, 15:43
Can't see any range checking on b/c in the current code, and I haven't implemented it, and I don't think dividee has changed it either.

The only thing that have changed qulitywise is:

- Proper rounding in yuy2 mode
- Picture offset by 1 pixel in RGB mode.
- Chroma wrap problems corrected.

The rest of the code produces similar results as always.

CHAOSMAN33
3rd October 2002, 03:05
im still a bit confused about how to use the lanczos resize. For the script command, what values must be entered in, the documentation says

LanczosResize(clip, int target_width, int target_height)
LanczosResize(clip, int target_width, int target_height, float "src_left", float "src_top", float "src_width", float "src_height")


which do i use the first or second, and what values must i enter in, sorry im a gknot newbie, and dont have much experience in editing.

JohnMK
3rd October 2002, 05:13
Forget about all that, just use:

LanczosResize(640,480) or whatever your resized res is.

wing1
4th October 2002, 00:38
hmmmm did not know that you can crop during resizing with lanczosresize function. The original dll doesn't allow such an option. I Need to read the documentation more often with each new releases :D.

@chaosman33

1st option just simply resizes to whatever you would like for the output to be (x,y)->(640,480). i.e. lanczosresize(640,480)=> resize whatever the source is to 640(width)x480(height).

2nd option allows you to crop the source as you resize at the same time. i.e.
(x,y,left,top,right,bottom)->(640,480,0,0,last.width-8,last.height-16). If Source frame size = 704x576, then you will be cropping 8 pixels off from the right side of the frame and 16 pixels off from the bottom of the frame. Afterward, you would resize the crop result to be what you specify as output x,y.

doing this

lanczosresize(640,480,0,0,last.width-8,last.height-16)

and this

crop(0,0,last.width-8,last.height-16)
lanczosresize(640,480)

are the same.

CHAOSMAN33
4th October 2002, 04:09
thanks for the clarification wing1 ;)

ChannelK
28th November 2002, 05:21
Sorry to ask a propably stupid question, but, i've looked and I cant seem to find where to get the latest (if there is a latest) Lanczos resize filter.

Any links?

(a convolution3D link would also be appreciate)

Thanks.

sh0dan
28th November 2002, 08:43
Lanczos is built-in from 2.06 and newer versions. No need for a plugin.
Look at avisynth.org (http://www.avisynth.org) for all the filters you can imagine.

Iznogoud
28th November 2002, 11:25
"warning!
This question may appear foolish to more advanced users"

@wing1
So I tried it and works

LanczosResize(544,304,8,74,704,428)
and
crop(8,74,704,428)
LanczosResize(544,304)

are the same, just wonder if there is something to gain or lose using the first method?

Didée
28th November 2002, 11:47
Iznogoud,

both variants work identical, but differ in speed.
In an encoding of several hours, you might either win or loose some ... seconds.

In addition, there was a discussion wether the cropping-within-resizing should be maintained or dropped in upcoming AviSynth versions - but I don't know what the status is there.

Boulder
28th November 2002, 12:00
Separate cropping is useful when you want to use filters before resizing. They'll be faster if you crop first, then apply the filters and then resize. No need to smooth those pixels that get cropped off anyway;)

Iznogoud
28th November 2002, 12:13
@Didee

Mmmmmmmm, seconds... (thinking in Homer-style)

@Boulder

Kiitos

sh0dan
28th November 2002, 13:25
Having "cropping within resizing" is a bit silly, but it's there for compatebility. Always use crop - it's faster and has more features.

Iznogoud
28th November 2002, 14:38
It is good now:) Thanks for clear answers!

jarthel
30th November 2002, 06:33
I've had problems with the following combo

temporalsmoother -->> lanczos = problem (use simpleresize instead no problem)

temporalsmoother -->> SShiQ -->> lanczosresize = problem (use simpleresize instead no problem)

temporalsmoother -->> 2DCleaner -->> lanczosresize = ok :)

jayel

3ngel
16th March 2005, 23:30
Lanczos3 has a terrific quality!
Some great guy out of you, can make a DirectShow Filter porting of this resize filter?
It would be great to include a Lanczos Resize Filter in a Graphedit chain! :eek:
Please! :rolleyes: ;)

MoonWalker
17th March 2005, 14:23
Try ffdshow..It has many kinds of resizing(lanczos too)..

MoonWalker

Wilbert
17th March 2005, 14:58
Sorry for being OT, but I have to ask this :) Couldn't you find an older thread?

Blue_MiSfit
17th March 2005, 23:23
No kidding! I started reading the first post and had to read it like 3 times before it actually connected that I was reading a 3 year old thread before avisynth had lanczos resizing built in! :O Now we even have the uber lanczos4resize.

Avisynth just kicks so much ass its ridiculous!!

~Misfit

3ngel
17th March 2005, 23:36
@Moonwalker
Mmm.. ok i'll try, thank you.

At this point another question : but ffdshow can integrate even avisynth commands?