PDA

View Full Version : Advice sought, on sharpening (?)


JMP
6th August 2006, 10:05
I'm currently trying to work with this material (example frame - hope you can see it...)
http://misio.homelinux.net/~jmp/frame.png
Yes, there are ugly "halos" around the black lines, but, thanks to the excellent advice found on this forum, I alredy know how to remove them :). I want to draw your attention to the horizontal lines: as you see they appear wider but lighter than the vertical ones (a by-product of PAL conversion?). I'd like to have them thin and black again. Resizers of course reduce the thickness, but are reluctant to make them any darker. So i probably need some sharpening...

Unfortunately my experiments with the sharpeners were unsuccessful up till now: either the lines stayed too light, or the vertical ones got thick and ugly, with lots of aliasing. Can anybody suggest a filter that would fix those horizontal lines without ruining the rest too much? Thanks in advance.

JMP

Mug Funky
6th August 2006, 16:59
here's a hack of DeHalo_alpha for PAL conversions.

only works vertically, and hence it's called "dehalo_vertical"

function DeHalo_vertical(clip clp, float "r", float "darkstr", float "brightstr", float "lowsens", float "highsens", float "ss")
{
r = default( r, 2.0 )
darkstr = default( darkstr, 1.0 )
brightstr = default( brightstr, 1.0 )
lowsens = default( lowsens, 50 )
highsens = default( highsens, 50 )
ss = default( ss, 1.0 ) # 1.5

LOS = string(lowsens)
HIS = string(highsens/100.0)
DRK = string(darkstr)
BRT = string(brightstr)
ox = clp.width()
oy = clp.height()
uv = 1
uv2 = (uv==3) ? 3 : 2

halos = clp.bicubicresize(ox,m4(oy/r)).bicubicresize(ox,oy,1,0)
are = yv12lutxy(clp.mt_expand(mode="0 1 0 0 0 -1",U=uv,V=uv),clp.mt_inpand(mode="0 1 0 0 0 -1",U=uv,V=uv),"x y -","x y -","x y -",U=uv,V=uv)
ugly = yv12lutxy(halos.mt_expand(mode="0 1 0 0 0 -1",U=uv,V=uv),halos.mt_inpand(mode="0 1 0 0 0 -1",U=uv,V=uv),"x y -","x y -","x y -",U=uv,V=uv)
so = yv12lutxy( ugly, are, "y x - y 0.001 + / 255 * "+LOS+" - y 256 + 512 / "+HIS+" + *" )
lets = maskedmerge(halos,clp,so,U=uv,V=uv)
remove = (ss==1.0) ? clp.repair(lets,1,0)
\ : clp.lanczosresize(ox,m4(oy*ss))
\ .logic(lets.mt_expand(mode="0 1 0 0 0 -1",U=uv,V=uv).bicubicresize(ox,m4(oy*ss)),"min",U=uv2,V=uv2)
\ .logic(lets.mt_inpand(mode="0 1 0 0 0 -1",U=uv,V=uv).bicubicresize(ox,m4(oy*ss)),"max",U=uv2,V=uv2)
\ .lanczosresize(ox,oy)
them = yv12lutxy(clp,remove,"x y < x x y - "+DRK+" * - x x y - "+BRT+" * - ?",U=2,V=2)

return( them )
}

dehalo'ing alone can increase sharpness in oversharpened sources, as it acts a little like the limiting part of limitedsharpen. it'll bring the edges closer together.

now, a good thing about dehalo_alpha is that dark and light haloes can be treated differently. what we want is to clamp the light haloes but leave the dark ones as-is (because more than likely they are on black lines). so set darkstr=0, brightstr=whatever and you'll get some line horizontal line darkening on top of the halo reduction.

JMP
7th August 2006, 21:02
Thanks, I have tried that today - after some editing for MaskTools 2.0 and changing the ss value (your default of 1.0 causes the script to throw exception at me) :). The effect is however not exactly what I wanted. Even with darkstr=0 the dark horizontal lines don't really get any darker. They expand a bit and, where there are two horizontal or nearly-horizontal lines close to each other, the area between them darkens a bit. Well, maybe I should experiment with other parameters (and I'm trying it even now) - but somehow I feel it is not really THE solution to the problem. So thanks again and any other ideas?

JMP
8th August 2006, 13:07
OK, so I had finally an idea... And came up with this (please don't laugh, I'm still learning...)
lines=mt_convolution(horizontal="1",vertical="1 -1 0 -1 1",total=2.5,saturate=true)
mt_lutxy(Last,lines,u=2,v=2,yexpr="y 12 < x x y 40 > 40 y ? - ?")
Which seems to work for me in this particular case. Usefulness for any other material is doubtful, so I don't event try to make it into a function and parametrize. The post is only for completeness :).

Thanks again for your attention and help (including help I received by reading other threads).

Chainmax
10th August 2006, 00:41
I found that aWarpSharp(depth=16,cm=1), aside from doing excellent line thinning, also slightly reduces halos. If only someone took a look at HQDering and solved its issues...