Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 11th June 2010, 01:27   #61  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
Add this to your script, top or bottom, or save it to an avsi file in your \avisynth 2.5\plugins folder:

Code:
function makemod(clip c,int "xmod",int "ymod",bool "crop") {
	xmod=default(xmod,16)
	ymod=default(ymod,xmod)
	crop=default(crop,false)
	c
	ox=width
	oy=height
	xm=width%xmod
	ym=height%ymod
	w=c.isrgb32() || c.isrgb24() ? 1 : 2
	right=c.crop(ox-w,0,w,0)
	right=right.stackhorizontal(right,right,right)
	right=xmod>w*4 ? right.stackhorizontal(right,right,right) : right	
	vx=ox % xmod==0 ? c : stackhorizontal(c,right.crop(0,0,xmod-(ox % xmod),0))
	bottom=vx.crop(0,oy-w,0,w)
	bottom=bottom.stackvertical(bottom,bottom,bottom)
	bottom=ymod>w*4 ? bottom.stackvertical(bottom,bottom,bottom) : bottom	
	vy=oy % ymod==0 ? vx : stackvertical(vx,bottom.crop(0,0,0,ymod-(oy % ymod)))
	cropped = c.crop(0,0,width-xm,height-ym)
	return crop == true ? cropped : vy
}
Use it as:

MakeMod(4)

It'll mirror the edge pixels so that filters don't munge a huge black border into the image. I used to use it a lot when I did a lot of upscaling & filtering of web images, and it had to be fairly memory efficient.
foxyshadis is offline   Reply With Quote
Old 11th June 2010, 09:16   #62  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
Archimedes,
regarding blurred (out of focus) photos. Have you tried some deconvolution filters? The sharpening of videos is usually different to sharpening out of focus photos.
Terka is offline   Reply With Quote
Old 14th June 2010, 23:13   #63  |  Link
Archimedes
Registered User
 
Join Date: Apr 2005
Posts: 213
Quote:
Originally Posted by Heaud View Post
The script is giving out odd numbers for cropping (if the mod4 remainer is an odd number) and that's causing trouble with cropping.
That's why i wrote "must be a power of 2, when clip is YV12". See the script only as a simple example, not as a ready to use solution which handles all possible input values.

Quote:
Originally Posted by Heaud View Post
I am not so experienced with scripting so I ask, is there a way to get the right and bottom variables to force even numbers?
Mirroring the edge pixels (see example from foxyshadis) should be the better way to add a border, if required. I already thought about this issue, but then i decide generally to crop unnecessary pixels (if required). So i didn't implement such a function yet.

Cropping unnecessary pixels already begins, when a conversion from RGB32 to YV12 takes place (if width or height of the image are not even numbers). So the best way should be a separate script (a template) which can be placed in front of any filter to make a special mod resolution.

I will provide two new scripts, called "FritzPhotoModStart" and "FritzPhotoModEnd". "FritzPhotoModStart" will have two parameters "xmod" and "ymod" (same parameters as in foxyshadis script ) and should be the very first script in the job list (where the input is RGB32). "FritzPhotoModEnd" should be placed after filtering. It crops the added borders, so the image has its original resolution again.

Example (job list):
Code:
FritzPhotoModStart
GradFun2DBMod
FritzPhotoModEnd

Last edited by Archimedes; 14th June 2010 at 23:31.
Archimedes is offline   Reply With Quote
Old 15th June 2010, 00:00   #64  |  Link
Archimedes
Registered User
 
Join Date: Apr 2005
Posts: 213
Quote:
Originally Posted by Terka View Post
Archimedes,
regarding blurred (out of focus) photos. Have you tried some deconvolution filters? The sharpening of videos is usually different to sharpening out of focus photos.
For this issue (deconvolution) i'm using Image Analyzer. Super Slow Sharpen (rad >= 0.5) in combination with a denoiser are also a good candidate for strong sharpening tasks.
Archimedes is offline   Reply With Quote
Old 15th June 2010, 01:56   #65  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
Quote:
Originally Posted by Terka View Post
Archimedes,
regarding blurred (out of focus) photos. Have you tried some deconvolution filters? The sharpening of videos is usually different to sharpening out of focus photos.
All of the sharpening filters used here already are useful approximations of deconvolution filters. *.mp4 guy, Didée and I have looked into real ones and come away with "not worth the time and effort," too much information is already thrown away by the time it gets into Avisynth. They may be more useful with 10+ bit raw photos, if you knew the exact lens curvature, but I've never had that kind of info.
foxyshadis is offline   Reply With Quote
Old 15th June 2010, 08:50   #66  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
Thank you both for reply! I know image analyzer. Have tried http://www.adptools.com/en/deblurmyi...scription.html. Best results got with astroart, but it is not free.
My source is raw image from nikon d70.
Terka is offline   Reply With Quote
Old 15th June 2010, 13:52   #67  |  Link
Archimedes
Registered User
 
Join Date: Apr 2005
Posts: 213
Update available.

Changes:
Code:
lib:
- Updated blah.

plugins:
- Updated SmoothAdjust.

Templates:
- Added FritzPhotoModBegin and FritzPhotoModEnd.
FritzPhotoModBegin has three parameters: xmod, ymod and crop. With xmod and ymod you can define your mod resolution (odd numbers are also allowed). With crop you simple crop the pixels on the right and/or bottom side to reach the specified mod resolution (normally not needed, because every script will do it automaticly, when a special mod resolution is required).

As I wrote above, FritzPhotoModBegin should be the very first script in the job list (before any color conversion is occuring). FritzPhotoModEnd should be placed at the very end of the job list. The script is cropping the added pixels and bring back the original resolution.

foxyshadis, thanks for sharing your script!

Last edited by Archimedes; 15th June 2010 at 14:01.
Archimedes is offline   Reply With Quote
Old 16th June 2010, 01:03   #68  |  Link
markanini
Registered User
 
Join Date: Apr 2006
Posts: 299
Great stuff that FritzPhotoMod!
markanini is offline   Reply With Quote
Old 17th June 2010, 02:40   #69  |  Link
Archimedes
Registered User
 
Join Date: Apr 2005
Posts: 213
Here is an example of an out of focus image (in combination with motion blur).

Original:


SSSharp and TNLMeans:
Archimedes is offline   Reply With Quote
Old 17th June 2010, 08:42   #70  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
Archimedes, thank you for nice example. (I dont think there is a motion blur there.)
Please post your settings.
On first look i thought its not good result, but on second i think - its good! Thank you,
Terka
Terka is offline   Reply With Quote
Old 17th June 2010, 11:50   #71  |  Link
Archimedes
Registered User
 
Join Date: Apr 2005
Posts: 213
Quote:
Originally Posted by Terka View Post
Archimedes, thank you for nice example. (I dont think there is a motion blur there.)
I should say, after sharpening it looks like a motion blur to me.



Quote:
Originally Posted by Terka View Post
Please post your settings.
On first look i thought its not good result, but on second i think - its good!
Don't know it exactly, what parameter i have used. Settings were something like this:

SSSharp:
Code:
rad      = 1.25
ssw      = False
strength = 15.0
iter     = 1
ss       = True
denoise  = 0
TNLMeans:
Code:
Ax  = 10
Ay  = 10
Sx  = 3
Sy  = 3
Bx  = 1
By  = 1
a   = 0.96
h_y = 3.6
h_u = 0.0
h_v = 0.0
sse = True
Archimedes is offline   Reply With Quote
Old 17th June 2010, 12:08   #72  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
which order?
1.nlmeans, 2. SSSharp or
1. SSSharp 2.nlmeans
Quote:
I should say, after sharpening it looks like a motion blur to me.
aha. i ment the original has motion blur.

maybee these areas could be eliminated. it looks like kind of ghosting. will be great if its possible.
Terka is offline   Reply With Quote
Old 17th June 2010, 12:21   #73  |  Link
Archimedes
Registered User
 
Join Date: Apr 2005
Posts: 213
Same order as i posted. 1. SSSharp. 2. TNLMeans.
Archimedes is offline   Reply With Quote
Old 17th June 2010, 12:41   #74  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
The effect is due to incompletely suppressed haloing and oversharpened "flat" blurring, you can see that the erroneous features are already slightly present in the source due to the characteristic out-of-focus blur from the camera. And yes the situation can be improved on, but its difficult to get that much sharpening without screwing up the already screwy blur-gradients.

Example1
Example2
Example3
*.mp4 guy is offline   Reply With Quote
Old 17th June 2010, 12:41   #75  |  Link
Archimedes
Registered User
 
Join Date: Apr 2005
Posts: 213
I have changed the template SSSharp (SuperSlowSharpen) a little bit. After sharpening there was very often bright thin lines around the image. And there was also a problem with the denoise parameter (not really usable). So i add a border (mirrored pixels) around the image before filtering and crop them after filtering. This helps.
Archimedes is offline   Reply With Quote
Old 17th June 2010, 13:11   #76  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
I'm not sure if that was directed at me, but the examples I posted were not generated with sssharp.
*.mp4 guy is offline   Reply With Quote
Old 17th June 2010, 13:32   #77  |  Link
Archimedes
Registered User
 
Join Date: Apr 2005
Posts: 213
Quote:
Originally Posted by *.mp4 guy View Post
I'm not sure if that was directed at me, but the examples I posted were not generated with sssharp.
No, that was not directed to you. We have just posted at the same time.
Archimedes is offline   Reply With Quote
Old 17th June 2010, 15:04   #78  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
*.mp4 guy, nice one, could i ask bout your code?
Have you some experience with decovolution methods like Lucy, Wiener..
Terka is offline   Reply With Quote
Old 17th June 2010, 21:57   #79  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
Quote:
Originally Posted by Terka View Post
*.mp4 guy, nice one, could i ask bout your code?
Have you some experience with decovolution methods like Lucy, Wiener..
Its based on some bits of blah that I am fiddling with. Technically its not significantly similar in any way to any of the deconvolution methods I've read about. Its non-iterative, only needs to have a ballpark of the blur radius to function, and the noise suppression is just part of how it works. Its more similar to sssharp (and a bit less to medsharp) than anything else I know of, and its not particularly similar to either.
*.mp4 guy is offline   Reply With Quote
Old 18th June 2010, 08:38   #80  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
The posted examples are really good! Will you provide use with this sharpener?
If you have problem with name again , i suggest to call it OFF- Out of Focus Fixer
Terka is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 14:53.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.