Log in

View Full Version : Fritz Photo


Pages : 1 [2] 3 4

Archimedes
9th June 2010, 11:20
It seems, GradFun2DBMod needs a mod4 input. :o As we are working with double sized YY12 images, we need mod8 before feeding it to GradFun2DBMod.

In such cases, I simply crop the pixels on the right and bottom side.

Here is the corrected script.

# ==============================================================================
# http://forum.doom9.org/showthread.php?t=144537
# ==============================================================================
thr = 1.2
thrC = 1.2
mode = 2
str = 0.8
strC = 0.0
temp = 50
adapt = 64
custom = "empty"
mask = True
radius = 2
range = 2
# ==============================================================================
# thr = True, False, Beginner, Strength for the luma channel | float
# thrC = True, False, Beginner, Strength for the chroma channel | float
# mode = True, False, Beginner, PickList, {1, 2, 3}, Mode for the addition of 16 pixels around the image | int, [1, 3]
# str = True, False, Beginner, Standard deviation (strength) of the luma noise | float
# strC = True, False, Beginner, Standard deviation (strength) of the chroma noise | float
# temp = True, False, Beginner, Strength for temporal stabilization | int
# adapt = True, False, Beginner, Threshold for luma-adaptative grain | int
# custom = True, False, Expert, PickList, {"empty"}, Use your own grain generator instead of AddGrain | string
# mask = True, False, Beginner, Adaptative deband mask | bool, {False, True}
# radius = True, False, Beginner, Radius for the mask | int
# range = True, False, Beginner, Range used in the mask | int
# ==============================================================================

LoadPlugin("plugins\AddGrainC\AddGrainC.dll")
LoadPlugin("plugins\GradFun2DB\gradfun2db.dll")
LoadPlugin("plugins\GScript\GScript.dll")
LoadPlugin("plugins\MaskTools 2\mt_masktools.dll")
LoadPlugin("plugins\RemoveGrain 1.0\RemoveGrain.dll")

Import("lib\FritzPhoto\FritzPhoto.avs")
Import("lib\GradFun2DBMod\GradFun2DBMod.avs")

isYV12() ? GEval("""
fp_GradFun2DBMod(thr, thrC, mode, str, strC, temp, adapt, custom, mask, radius, range)
""") : GEval("""
if (%%KeepAlphaChannel%%) {
fp_alpha = last
}
else {
NOP()
}
RGB32toYV12()
fp_GradFun2DBMod(thr, thrC, mode, str, strC, temp, adapt, custom, mask, radius, range)
if (%%KeepAlphaChannel%%) {
YV12toRGB32()
MergeARGB(fp_alpha.Crop(0, 0, last.Width, last.Height), last, last, last)
}
else {
NOP()
}
""")

function fp_GradFun2DBMod(clip input, float thr, float thrC, int mode, float str, float strC, int temp, int adapt, string custom, bool mask, int radius, int range) {
input = input.Crop(0, 0, -(input.Width % 8), -(input.Height % 8))

luma = thr < 1.0 ? input : input.PointResize(input.Width / 2, input.Height / 2).\
GradFun2DBMod(
\ thr = thr,
\ thrC = 1.0,
\ mode = mode,
\ str = str,
\ strC = 0.0,
\ temp = temp,
\ adapt = adapt,
\ custom = custom,
\ mask = mask,
\ radius = radius,
\ range = range
\ ).\
PointResize(input.Width, input.Height)

chroma = thrC < 1.0 ? input : input.\
GradFun2DBMod(
\ thr = 1.0,
\ thrC = thrC,
\ mode = mode,
\ str = 0.0,
\ strC = strC,
\ temp = temp,
\ adapt = adapt,
\ custom = custom,
\ mask = mask,
\ radius = radius,
\ range = range
\ )

luma.MergeChroma(chroma, 1)
}

Later on this day I will upload an update with the corrected script. I've also added the new SmoothAdjust plugin.

Archimedes
9th June 2010, 12:11
Hi Archimedes. I wonder if is possible/usefull to use temporal filtering on photos. Mean using more shots and combining them using motion compensation scripts.
Sorry for not answering immediately. I tested this once, but the results was not very impressive. So i gave it up. May be, it was my fault.

Terka
9th June 2010, 12:45
Archimedes, thank you for reply and testing. Have small experience with Fritzphoto, do i understand correctly, the functionality of combining more pictures is available? Where?

Archimedes
9th June 2010, 13:07
Not implemented at the moment. First i need some feeling of success outside of the program.

Terka
9th June 2010, 14:05
eg median could be useful when eg taking a picture of building and want to remove people in the front.

Archimedes
9th June 2010, 14:07
New update is available.

Changes:
lib:
- Removed SmoothLevels.
- Added "blah" (http://forum.doom9.org/showthread.php?t=155030 ) - a new sharpening function.

plugins:
- Updated MaskTools 2 and FFmpegSource2.
- Added SmoothAdjust (http://forum.doom9.org/showthread.php?t=154971).
- Added MedianBlur (required for "blah").

Templates:
- Changed SmoothLevels.
- Added SmoothCurve and SmoothTweak.
- Fixed GradFun2DBMod (works now with mod4 resolutions).

Archimedes
9th June 2010, 14:53
eg median could be useful when eg taking a picture of building and want to remove people in the front.
There are many other scenarios, where multiple images can help, like denoising and so on. My problem was, i always got blurred images, when using temporal informations in a script.

May be, the "motion" between the shots was to big. :D

Heaud
10th June 2010, 00:07
The new change to the gradfun2dbmod works fine, no more mod4 errors. One problem I have with it is that there is a loss of pixels. Is there any way to prevent that?

Archimedes
10th June 2010, 11:44
Adding (black) borders to an image before filtering and cropping the added borders afterwards is not always a good idea (depends on the filter), so i generally crop the needles pixels at the right and/or bottom side, if needed.

If the missing pixels are a problem for you, just add borders before filtering and crop the added borders afterwards.

Example:
# clip is RGB32 or (double sized) YV12

m = 4 # must be a power of 2, when clip is YV12
right = Width % m == 0 ? 0 : m - Width % m
bottom = Height % m == 0 ? 0 : m - Height % m

AddBorders(0, 0, right, bottom)

# Filter()

Crop(0, 0, -right, -bottom)

Heaud
11th June 2010, 00:42
The script is giving out odd numbers for cropping (if the mod4 remainer is an odd number) and that's causing trouble with cropping. 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?

foxyshadis
11th June 2010, 01:27
Add this to your script, top or bottom, or save it to an avsi file in your \avisynth 2.5\plugins folder:

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.

Terka
11th June 2010, 09:16
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.

Archimedes
14th June 2010, 23:13
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". :rolleyes: See the script only as a simple example, not as a ready to use solution which handles all possible input values.

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):
FritzPhotoModStart
GradFun2DBMod
FritzPhotoModEnd

Archimedes
15th June 2010, 00:00
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 (http://logicnet.dk/Analyzer/). Super Slow Sharpen (rad >= 0.5) in combination with a denoiser are also a good candidate for strong sharpening tasks.

foxyshadis
15th June 2010, 01:56
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.

Terka
15th June 2010, 08:50
Thank you both for reply! I know image analyzer. Have tried http://www.adptools.com/en/deblurmyimage-description.html. Best results got with astroart, but it is not free.
My source is raw image from nikon d70.

Archimedes
15th June 2010, 13:52
Update available.

Changes:
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!

markanini
16th June 2010, 01:03
Great stuff that FritzPhotoMod! :D

Archimedes
17th June 2010, 02:40
Here is an example of an out of focus image (in combination with motion blur).

Original:
http://img51.imageshack.us/img51/4948/img8547kopie.th.jpg (http://img51.imageshack.us/i/img8547kopie.jpg/)

SSSharp and TNLMeans:
http://img197.imageshack.us/img197/8248/img8547kopie0900x0600ss.th.png (http://img197.imageshack.us/i/img8547kopie0900x0600ss.png/)

Terka
17th June 2010, 08:42
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

Archimedes
17th June 2010, 11:50
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.

http://img171.imageshack.us/img171/8248/img8547kopie0900x0600ss.th.png (http://img171.imageshack.us/i/img8547kopie0900x0600ss.png/)

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:
rad = 1.25
ssw = False
strength = 15.0
iter = 1
ss = True
denoise = 0

TNLMeans:
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

Terka
17th June 2010, 12:08
which order?
1.nlmeans, 2. SSSharp or
1. SSSharp 2.nlmeans
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.

Archimedes
17th June 2010, 12:21
Same order as i posted. 1. SSSharp. 2. TNLMeans.

*.mp4 guy
17th June 2010, 12:41
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 (http://img291.imageshack.us/img291/8252/snapshot20100617072831.png)
Example2 (http://img228.imageshack.us/img228/4309/snapshot20100617072918.png)
Example3 (http://img638.imageshack.us/img638/4424/snapshot20100617072953.png)

Archimedes
17th June 2010, 12:41
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 (http://forum.doom9.org/showthread.php?p=1258304#post1258304) (not really usable). So i add a border (mirrored pixels) around the image before filtering and crop them after filtering. This helps.

*.mp4 guy
17th June 2010, 13:11
I'm not sure if that was directed at me, but the examples I posted were not generated with sssharp.

Archimedes
17th June 2010, 13:32
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. :)

Terka
17th June 2010, 15:04
*.mp4 guy, nice one, could i ask bout your code?
Have you some experience with decovolution methods like Lucy, Wiener..

*.mp4 guy
17th June 2010, 21:57
*.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.

Terka
18th June 2010, 08:38
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

*.mp4 guy
18th June 2010, 10:30
Actually all the talk of Deconvolution, helped me think of a name, "Reconvolution (http://forum.doom9.org/showthread.php?p=1409582#post1409582)" since there isn't any reason to believe that its doing anything but making the picture look sharper by convolving it (albeit in a sneaky way). Also it works fine on stuff that isn't out of focus.

Settings for the posted examples were:
1 ReCon(str=8, rad=2, lmode=0)
2 ReCon(str=8, rad=2, lmode=1)
3 ReCon(str=8, rad=2, lmode=3)

Except from an older version, and therefore a bit worse overall. lmode 1 is now better, and lmode 2 pretty much replaces 3.

rfmmars
18th June 2010, 17:35
I have only one tab and the screen doesn't look like on page one. Load Avisynth 2.58, and installed your program twice, what am I doing wrong? Have no problem with AVSp or AVSpMod.

Thanks

http://img696.imageshack.us/img696/4615/fritzphotoopening.jpg (http://img696.imageshack.us/i/fritzphotoopening.jpg/)

Uploaded with ImageShack.us (http://imageshack.us)

Archimedes
19th June 2010, 12:35
On Windows 7 i prefere to use the Windows Classic Style, that’s why the screenshots looks different. When you start the program, you will always see only one tab. After loading at least on image, you can click "Next" and then you will see the next tab and so on.

Archimedes
19th June 2010, 13:28
Added "ReCon" (http://forum.doom9.org/showthread.php?p=1409582#post1409582) to the sharpening templates. May be someone would like to test it.

markanini
19th June 2010, 16:56
Just played with the parameters of ReCon. Seems to work well!

rfmmars
19th June 2010, 16:59
I have only one tab and the screen doesn't look like on page one. Load Avisynth 2.58, and installed your program twice, what am I doing wrong? Have no problem with AVSp or AVSpMod.

Thanks

http://img696.imageshack.us/img696/4615/fritzphotoopening.jpg (http://img696.imageshack.us/i/fritzphotoopening.jpg/)

Uploaded with ImageShack.us (http://imageshack.us)

Thanks, that made it work for me, vert nice.

Richard

Archimedes
21st June 2010, 15:10
Updated ReCon.

markanini
26th June 2010, 10:43
Archimedes, how about a difference tab in addition to before-after? I think it would be very useful for denoising.

Archimedes
28th June 2010, 08:38
This can be realized also with a simple script. I will think about it.

Terka
28th June 2010, 13:45
good idea!

dlnm
28th June 2010, 16:53
Is there a script to remove some jpeg artifacts near the edges? or may be just use a deringing script such as HQDering?
Thanks.

Archimedes
28th June 2010, 21:10
TNLMeans (maybe with Bx=By=0)?

Source (20 % JPG Quality) (http://img30.imageshack.us/img30/5812/img23890800x0600.png)
TNLMeans (http://img638.imageshack.us/img638/3888/img23890800x06000800x06.jpg)

Terka
29th June 2010, 08:42
look at fft3d:
http://www.aquilinestudios.org/avsfilters/spatiotemp.html

dlnm
29th June 2010, 17:56
Thanks both Archimedes and Terka.
I have tried both TNLMeans and dfttest before but the results are not satisfied. It seems that fft3d did better in this case.

Reuf Toc
29th June 2010, 18:53
Maybe you can try Deblock_QED (http://avisynth.org/mediawiki/Deblock_QED) in addition with FFT3D or TNLMeans (I didn't tested so I don't know if it works with Jpeg artifacts)

Archimedes
27th July 2010, 11:05
Updated the plugins NNEDI2 and EEDI3. The updates for NNEDI3 and the ImageMagick libraries already updated in the last "silent" update. Thanks to tritical and Wilbert.

For anti aliasing I added the script "SantiagMod" (http://forum.doom9.org/showthread.php?p=1419815#post1419815 ) (could be improved with an edge mask, but this requires YV12 as input).

Source (PointResize from 3264x2448 to 1024x768) >> (http://img137.imageshack.us/img137/1784/sn850643pointresize.png)

SantiagMod(type="EEDI3", strh=1, strv=1) >> (http://img43.imageshack.us/img43/7374/sn850643santiagmodeedi3.jpg)
SantiagMod(type="EEDI3", strh=2, strv=2) >> (http://img29.imageshack.us/img29/7374/sn850643santiagmodeedi3.jpg)

SantiagMod(type="NNEDI3", strh=1, strv=1) >> (http://img641.imageshack.us/img641/6032/sn850643santiagmodnnedi.jpg)
SantiagMod(type="NNEDI3", strh=2, strv=2) >> (http://img815.imageshack.us/img815/6032/sn850643santiagmodnnedi.jpg)

markanini
28th July 2010, 01:14
Awesome!

Terka
8th September 2010, 10:58
Archimedes,
regarding my request for adding mo-compensation in Fritz Photo, please see:
http://forum.doom9.org/showthread.php?p=1160020#post1160020

Archimedes
28th September 2010, 18:51
Program didn't start in one case. So I've changed the windows message calls for registering and unregistering fonts.

Updated the plugins "FFmpegSource2", "Mask Tools 2" , "NNEDI3" and "SmoothAdjust".

Revgen
30th September 2010, 08:28
Any chance you can add VCMohan's Seamer Resizer? http://forum.doom9.org/showthread.php?t=135735