Log in

View Full Version : Using AviSynth To SuperSample A Photo


EpheMeroN
11th December 2007, 20:25
I have a low-res 640x480 photo I am trying to get printed onto a mousepad for a Christmas gift. The website says an image of this resolution will print out very poorly. Can supersampling / sharpening / filtering produce anything of higher quality?

The image I want to use is here:

http://img153.imageshack.us/img153/6595/5fixedfs4.jpg

Blue_MiSfit
11th December 2007, 20:51
AviSynth is probably more than you need. I would use Photoshop or Paint.net to bicubic (sharp) resize to something higher like 1920x1440. Then apply some color noise reduction, and maybe hit it with an unsharp mask or some kind of sharpening. Hard to say.

Garbage in garbage out as they say... :)

Most of the magic in AviSynth comes from the fact that a lot of filters work temporally. Having one static frame isn't ideal.

~Misfit

Dark Shikari
11th December 2007, 20:56
AviSynth is probably more than you need. I would use Photoshop or Paint.net to bicubic (sharp)Why not Lanczos or Spline? They tend to give better results for large upscaling values.

Blue_MiSfit
11th December 2007, 21:00
Sure, but not all graphics editing apps have lanczos built in. I know Photoshop doesn't - maybe GIMP or Paint.NET do, not sure, I don't use them :)

Bicubic is pretty safe.

If you want to use AviSynth you surely can.

ImageSource("c:\image.bmp")

Spline36Resize(1920,1440)



is a place to start :)

I like Photoshop CS3's color denoising. Noise Ninja is even better

~MiSfit

EpheMeroN
11th December 2007, 21:14
If I used Spline36Resize to resize it to a huge res, would I then want to sharpen with LSF, and then hit it with a noise reduction like that of FFT3DFilter?

Blue_MiSfit
11th December 2007, 21:27
You certainly could. I doubt the effectiveness of these lovely filters on a single frame though. Worth a try!

Remember, your sample has really bad chroma noise, so set fft3dfilter's plane argument to 3

so:
fft3dfilter(plane=3, sigma=3) or whatever sigma you like.

~Misfit

EpheMeroN
11th December 2007, 21:30
Could the bad chroma noise come from re-encoding the photo to JPEG twice? The pic I am using I already did levels/color correction with in PhotoShop CS2 (well tried to, I let the auto-configure options handle it). I know Avisynth can do color correction, but I am very poor at figuring that out.

Blue_MiSfit
11th December 2007, 21:46
Go ahead and do color correction in Photoshop, but output a BMP or a TIFF, not a JPEG. Try to submit in these formats as well. JPEG is evil for intermediates and submission! It should only be used for internet publishing or (maybe) acquisition.

Dark Shikari
11th December 2007, 21:52
Sure, but not all graphics editing apps have lanczos built in. I know Photoshop doesn't - maybe GIMP or Paint.NET do, not sure, I don't use them :)I'm pretty sure Photoshop has Lanczos. I know for sure GIMP does.

Of course, if you really want high quality, use NNEDIresize ;)

IanB
11th December 2007, 21:57
You probably want Triticals NNEDI (http://forum.doom9.org/showthread.php?t=129953) (Edge Detect Interpolator) filters. It is the state of the art for doubling the size of an image in one dimension.

It is actually intended to interpolate the other field when doing a Bob operation but can be easily used as a general size doubler.

Script flow would be something like this (you will have to research the NNEDI parameters ;) )ImageSource("Dog.jpg")
ConvertToYV12(matrix="PC.601") # Max range
NNEDI(....) # *2 V
TurnLeft()
NNEDI(...) # *2 H & V
TurnRight()
NNEDI(....) # *4 V, *2 H
TurnLeft()
NNEDI(...) # *4 H & V
TurnRight()
ConvertToRGB(matrix="PC.601")
BlackmanResize(2048, 1536) # Choose final ouput size

EpheMeroN
11th December 2007, 22:47
Would you guys mind giving the original image your own AviSynth tweaks when it comes to SuperSampling? I'd appreciate any help because I need to order it today to get it by Christmas Eve!

Here is the original JPEG image that came from a webcam (yes I know):

http://img147.imageshack.us/img147/3954/picture17ll5.jpg

Dark Shikari
11th December 2007, 23:04
Here's my attempt... (http://i17.tinypic.com/8242v6x.jpg)

Your source had lots of JPEG artifacting so I had to smoothdeblock() it and do some creative work with addGrain().

Chainmax
12th December 2007, 02:22
That's some amazing use of AddGrain, it adds a great illusion of detail and is hardly noticeable at the same time. Which settings did you use for it?

Dark Shikari
12th December 2007, 02:52
That's some amazing use of AddGrain, it adds a great illusion of detail and is hardly noticeable at the same time. Which settings did you use for it?Script:

ImageSource("image.jpg")
ConvertToYV12()
SmoothDeblock4(density=4,passes=10)
nnediresize_YV12()
nnediresize_YV12()
fft3dfilter(sigma=0,sharpen=2)
gradfun2db(1.1)
AddGrain(35,0.6,0.6)
AddGrain(20,0.2,0.2)
I used one pass of AddGrain to add a less fine but stronger grain layer, and then a weaker but very fine layer.

EpheMeroN
12th December 2007, 05:47
@Dark Shikari: Thank you much! The image looks great. Do you know how to add in levels/color correction as well? To remove that reddish-pinkish tint that the original has?

Dark Shikari
12th December 2007, 05:55
@Dark Shikari: Thank you much! The image looks great. Do you know how to add in levels/color correction as well? To remove that reddish-pinkish tint that the original has?Try the Levels() or Tweak() commands in Avisynth. Check the docs for detailed commands.

Leak
12th December 2007, 10:25
To remove that reddish-pinkish tint that the original has?
To be honest I'd do that in some image editing program, as you simply can't beat having sliders to play with and getting a realtime preview... :)

ajk
12th December 2007, 10:34
Here's a version (http://tinypic.com/view.php?pic=8gg6po4) of DS's work with some colour balance and levels adjustment in Paint Shop Pro. I used the (birch?) tree in the background as a key point. Somewhat a matter of taste always but I think it looks rather natural with these settings.

DarkT
12th December 2007, 17:26
"Unit A to Base RESPOND! Unit A to Base RESPOND!"
"Base - we hear you loud and clear, what is the situation?"
"Sir! We're surrounded! They are well disguised, but they are EVERYWHERE! Arrrrgh, Nooooo *chrrrrr* they're attacking!"
"Who? Son, who's out there?"
"IT'S THE RAINBOWWWWSSSSSSS"

*connection terminated*


*Ahem* here's my version :).

http://i4.tinypic.com/7yex2m8.png

Edit: oh, btw - it came out a bit, errr, big... 3mb... So let it load :).

Also, you might wanna tweak the light level as well as some other stuff... Me, I prefer dark stuff :).
Also, you might want to denoise it, as I didn't do much of that...

Archimedes
19th December 2007, 13:12
You certainly could. I doubt the effectiveness of these lovely filters on a single frame though. Worth a try!
FFT3DFilter does also a good job on single frames (photos), as you can see here (http://forum.gleitz.info/showthread.php?t=33835).

JanBing
19th December 2007, 13:29
My version:

CLICK (http://img4.imagebanana.com/img/xwbywdj2/dog.jpg)

I've used Alienskin's BlowUp (for Photoshop). Plus I've added a few layers of noise, since I think the more you denoise an upscaled image, the blurrier it looks. By actually ADDING noise, you're adding some kind of artificial detail, which makes an upscale hold up better.

Archimedes
19th December 2007, 14:13
BlackmanResize, FFT3DFilter and LimitedSharpen (Fritz Photo (http://forum.gleitz.info/showthread.php?t=33835)).

http://img172.imageshack.us/img172/4808/5fixedfs4blackmanresizemq4.jpg

2Bdecided
19th December 2007, 14:45
My attempt, via EEDI2 and Corel PhotoPaint.

There's aliasing and blocking in the original, which doesn't make it a great candidate for upsizing.

If it had been a video, there might have been some redundancy in there which would have helped the process.

It might be worth trying some soft focus, or arty back-and-white effects to hide some of the defficiencies and produce a "nice" looking result. I've attached an example - you'd have to pay me to cut the dog out properly! ;)

Cheers,
David.

Archimedes
6th February 2008, 16:20
It is the state of the art for doubling the size of an image in one dimension.
The dog photo isn’t really a candidate to show the differences between different interpolation methods. On the example below you can see, how good NNEDI works comparing to EEDI and LanczosResize.

Original (256x192) >> (http://img515.imageshack.us/img515/5788/1070730ju0.jpg)
LanczosResize (1024x768) >> (http://img210.imageshack.us/img210/4378/1070730ju01024x0768lancas4.jpg)
EEDI2 (1024x768)>> (http://img151.imageshack.us/img151/6956/1070730ju01024x0768eediff9.jpg)
NNEDI (1024x768) >> (http://img184.imageshack.us/img184/8307/10707301024x0768nnedirews0.jpg)

*.mp4 guy
7th February 2008, 18:40
What are you talking about, the dog photo is a great way to compare resizing algorithms, it's a neer worst case scenario in many respects, and most importantly it reflects real world usage of interpolation algorithms.

dog photo, again (http://img402.imageshack.us/img402/5331/s51gj9.jpg).

smok3
7th February 2008, 18:58
i would try making a faked DOF first, then play with 'magic' filters.
example;
http://somestuff.org/dog.jpg
+ a bit of warming filter to kill that 'wrong white balance' look.

(it is a bad example, obviously you would need to do some good mask and do gradual blur based on object distance from lens, photoshop is your obvious tool.)

Soulhunter
7th February 2008, 21:22
You noticed that it was supposed to be a X-Mas gift n that we already have February now? ;D Anyway, for a print-out I probably just would have corrected the levels/colors -> neutral upsizer to 2MPix -> photo grain simulation to fill the emptiness where should be details. For a small size print-out like the OP wanted [a mousepad] it should look good! :]


Bye

Archimedes
8th February 2008, 15:05
What are you talking about, the dog photo is a great way to compare resizing algorithms, it's a neer worst case scenario in many respects, and most importantly it reflects real world usage of interpolation algorithms.
The dog photo doesn't really show the typical problems with linear interpolation methods when upscaling images. On sharper images (like digital photos) you will see a lot of bluring, aliasing and ringing when using a linear interpolation method (BicubicResize, LanczosResize etc.).

*.mp4 guy
8th February 2008, 15:33
The dog photo doesn't really show the typical problems with linear interpolation methods when upscaling images. On sharper images (like digital photos) you will see a lot of bluring, aliasing and ringing when using a linear interpolation method (BicubicResize, LanczosResize etc.).

It shows all the typical problems with linear interpolation (http://img208.imageshack.us/img208/3734/artifactsel1.jpg).

Aliasing: red boxes
ringing: always present when aliasing is present
bluring: everywhere, seriously, but specific examples are in cyan boxes

Archimedes
8th February 2008, 20:49
Thanks for pointing out that.