Log in

View Full Version : remove halos


mathmax
12th May 2010, 17:04
Hi,

I got an old over sharpened VHS and I would like to remove the halos around the edges.
I uploaded a very short sample here. Could you tell me if there is something to do to fix these halos?

Here's the sample:
http://www.mediafire.com/?ydywionmkzy

Thank you in advance for any help.

PS: Didée, you asked me to poke you three weeks ago.. but I cannot send a PM because your inbox seems to be full. Hope you see this topic. ;)

mathmax

Didée
13th May 2010, 15:18
No matter what I try, nothing works out. Not even halfway. The little detail disappears much faster than the halo reflections ... when the halos are gone by 50%, the result is already 100% unusable.

The most "visually pleasing" result, to me, in fact is to just blur the crap out of it, like

bicubicresize(120,480,.5,.25).bicubicresize(720,480,1,0)


Sorry for Michael, but I don't see a way to improve this source in a reasonable manner.

mathmax
13th May 2010, 17:52
Thank you very much for trying Didée :) I know the source is very bad.
I've still an idea. Let me know what you think about it.
To remove these halos, we have to blur the image, right?... but that's a pity because we loose details.
I think we could detect the over sharpened edges and blur only a region around them.

Here is a sample picture:
http://mathmax.mynetdomain.de/top.bmp

I make it black & white and contrast it a little bit:
http://mathmax.mynetdomain.de/top_contrasted.bmp

Here, in blue, I tried to the detect the halos:
http://mathmax.mynetdomain.de/test.bmp

This is just a short script I made (it took me 10 min) and I can make a much better detection... But do you think it will be possible to blur only the region around the halos to keep as much details as possible while removing the halos?

Didée
13th May 2010, 20:00
For one, it's not just simple halos. In fact, you're dealing with halos, which have halos, which have halos.

Then, the 1st and 2nd order halos are very strong in local contrast - and in fact, the signal amplitude of those halos is much bigger than the signal amplitude of any real detail.

More problems:

- these halos can not be removed satisfyingly with a (gaussian) blur operation. The zero mean principle is not satisfied.

- generally a median filter can be fairly well (ab)used when the gaussian primitive fails. But in this case, the area affected by the halos is just too big - I found the negative sideffects too overwhelming, and didn't manage to compensate for.

- small detail, like e.g. eyes and mouths of people, and similar, are very likely to be removed in the process. Having no halos is good, but having people without a face is pretty bad.

- overall, those halos are pretty much everything the source has to offer at all. When the halos are removed, you're left with a flat, muddy, nebulous soup of nothingness.


My hopes are very low here. You can make it look different, but probably not better. Only worse in a different way.

If someone has a good strategy for this mess, I'm all ears and eyes. I like to learn and improve.

mathmax
13th May 2010, 20:22
Thank you for your answer.

I'm very novice with all these notions. Could you please explain me what is the "The zero mean principle"?


generally a median filter can be fairly well (ab)used when the gaussian primitive fails.
sorry but I don't understand this. What's a median filter and the gaussian primitive?


- small detail, like e.g. eyes and mouths of people, and similar, are very likely to be removed in the process. Having no halos is good, but having people without a face is pretty bad.
yes but if I blur only around the halos.. then all the other regions will be untouched and I'll keep small details in them.

Didée
13th May 2010, 20:47
Without diving into the depths of terminology - the difficult point is not WHERE the halos are, but rather WHAT TO DO with those areas.

See the following examples of [source], [horizontal gauss filter], [horizontal median filter]:

http://img338.imageshack.us/img338/3746/halosource.th.jpg (http://img338.imageshack.us/i/halosource.jpg/)

http://img215.imageshack.us/img215/4329/halogaussian.th.jpg (http://img215.imageshack.us/i/halogaussian.jpg/)

http://img171.imageshack.us/img171/3226/halomedian.th.jpg (http://img171.imageshack.us/i/halomedian.jpg/)


These filters were just applied to the full frame. But even when you start with masking to restrict the actual effect to certain areas, it is only of little help in this case. The "removal" or "blurring" operation just is not good / not sufficient, and so it doesn't help much to apply it only to certain areas.


Perhaps *.mp4 guy comes along with some magic kernel filter ... but I suspect it might just end up with grey-shadowed edges.

mathmax
13th May 2010, 21:15
ok.

And someone advised me to use antialiasing filter of avisynth. What do you think?

Didée
13th May 2010, 21:25
An antialiasing filter for these halos? If that was intended to be a joke, then it was a good one. A constructive advice it is not.

mathmax
13th May 2010, 22:43
ok :D
what is the antialiasing filter used for?

julius666
13th May 2010, 23:21
ok :D
what is the antialiasing filter used for?

it is used for removing aliasing :devil:

this picture shows what aliasing is:
http://upload.wikimedia.org/wikipedia/commons/8/88/Aliasing_a.png
the first letter is badly aliased, the second is antialiased.

Anyway, :search: next time.

Terka
14th May 2010, 14:12
my attempt.
blurry, but less halo.
http://yfrog.com/2dcistep

Terka
14th May 2010, 14:38
ok. better one:
http://yfrog.com/9epicture2otwp

Dogway
14th May 2010, 16:58
uooooh MJ. I saw a perfect footage of the victory tour on youtube, a few months ago. I checked this (http://www.youtube.com/watch?v=tLVj8Pyw-wo) is. I really hope they sometime release a Victory tour DVD, with MJ in his highest, I would buy it right away.

mathmax
15th May 2010, 14:51
ok. better one:
http://yfrog.com/9epicture2otwp

cannot watch this one.

Terka
15th May 2010, 17:31
it works for me
http://img338.imageshack.us/i/halosource.jpg
http://img338.yfrog.com/img338/1799/picture2otw.png
done from the Didees jpg above only = +- spatial way.

mathmax
17th May 2010, 02:56
it works for me
http://img338.imageshack.us/i/halosource.jpg
http://img338.yfrog.com/img338/1799/picture2otw.png
done from the Didees jpg above only = +- spatial way.

it's amazing !! Which filter did you apply?

Terka
17th May 2010, 10:13
dont have the script at me now. (is on my work computer)
it was something like:
shift the picture right
mix it with original
remove the rest of halos using Didees resize above.
do some temporal filtering to mix original and the halo free picture (the blurry one above)
for temporal filtering i used a part of the Didees temporalsoften routine from TGMC.
the script needs a lot of cleaning anyway, because it was a lot try-error way.
So the only idea was the picture shift and using max or min from these 2 pictures. I think a lucky try.

mathmax
17th May 2010, 10:54
thank you. :) Could you post your script here when you're on your work computer?

Didée
17th May 2010, 11:32
I tried that too -- move 5 pixels to the right, and merge by ~40% -- but then considered it not good enough to mention it. BTW, this method is quite similar to the kernel approach (via mt_convolution, usually) that I had hoped mp4guy would eventually come up with.


amount = 0.42 # vary, 0.35~0.55
source
spline36resize(width,height,-5,0,width,height).merge(last,1.0-amount)

Not a bad starting point for more elaborative in-depth fiddling ... but at the very end, it'll still be "cr*p in -> cr*p out" ...

Terka
17th May 2010, 13:47
1. yes, ill post it.
2. i used the max(clipa, clipb) or min(clipa,clipb) (dont remember), no 40%.

Didée
17th May 2010, 14:18
The problem is - it seems like - that the signal peaks of the halos have undergone some sort of clipping. As long as the signal peaks are not clipped (like in sharpen(1.0) when the result doesnt hit full-white and/or full-black), then a reasonable reconstruction can be achieved by some sort of averaging. But when the signal is clipped, then there's not enough information anymore for a good reconstruction. e.g. when the halos are so strong that they're full-white and full-black, then the resauration will always tend to deliver medium grey, no matter what the original signal once has been ...

Terka
17th May 2010, 14:55
the script was done in a hurry, while working on something else.
tried more ways, so its seen here.
the script is one big mess. not usable for video yet, only on the jpg. Didee, please have a look. im in shame for it, have not time to make a useable version now. If i can ask you to use the useable from it.

http://ulozto.cz/4852494/halosource-orig.avs

Didée
17th May 2010, 16:53
the script is one big mess.
That's oh so true.

(somewhat similar to how my scripts look during toying-around ... but if can hardly understand my own mess, how should I understand yours?) :D


The following looks like it could be what you've used for that picture ... but i didn't try, am in a hurry, have a lawn to mow before the rain comes down

bad=ImageReader("c:\halosource.jpg").Crop(left,top,-right,-bottom).TurnLeft().ConvertToYV12()
x=bad.width()
y=bad.height()

shift=4.3
#shift=4.3
ba=bad.BicubicResize(x,y,0,0,0,shift).TurnRight()
bb=bad.BicubicResize(x,y,0,0,0,2*shift).TurnRight()


bad=bad.TurnRight()
min=mt_logic(ba,bad,"min",U=3,V=3)

bad=bad.TurnLeft()
shift=3.3
ba=bad.BicubicResize(x,y,0,0,0,shift).TurnRight()
bb=bad.BicubicResize(x,y,0,0,0,2*shift).TurnRight()
bad=bad.TurnRight()
max=mt_logic(ba,bad,"max",U=3,V=3)

fix=Overlay(min,max, opacity=0.5)

BTW, why all those turnleft/rights? Did you try to remove the halos by centrifugation? :D

WorBry
17th May 2010, 20:19
BTW, why all those turnleft/rights? Did you try to remove the halos by centrifugation? :D
Aw, stop it.......I'm trying to drink my coffee.

mathmax
18th May 2010, 03:52
:D
Thank you very much.. would love to see the result of this script on a video.

Here is my technique: I mix the "sharp" and the blurred video according to the masks in which I tried to detect the halos.

http://www.youtube.com/watch?v=QWnT8a-0Mos

I worked on both fields separately... but I'll try to generate mask for the interlaced video...

What do you think?

Terka
18th May 2010, 06:42
BTW, why all those turnleft/rights? Did you try to remove the halos by centrifugation?
now i see why the result is so bad. the correct one should be:
turnleft().turnleft().turnleft()...:cool:
lets wait a while and we'll see what happens.
but if i can see properly, maybe some washing powder is needed. simple centrifugation is not enough. ill try to get back today with some. :p

Terka
18th May 2010, 11:00
it looks like wan't have time today. the 'soap' is the temporal filtering using function calm() or degrainX (in fact mvdegrain)
the turning was because of 2 reasons:
1. i was in a hurry and didnt know the syntax to shift horizotally, but had an example where i did it vertically
2. i thought i can transform the situation to already known interlace up/dn jumping lines, where the solution is known (using degrainX). (interleave the shifted and original, then apply the degrainX
so
0. original
1. shift(original)
1a min(original, shift)
2. interleave (original,shift). SomeTemporalFiltering() #this is the degrainX
or interleave (original,min). SomeTemporalFiltering() #this is the degrainX
somewhere inbetween put the didees resize, to remove the rest of halo.
tried also some separatefields+nnedi - bacause it looked to me, the didees resize left some horizontal stripes where the halo was completly gone, but some stripes where was still present.

http://ulozto.cz/4859647/degrainx.avsi

mathmax
21st May 2010, 06:34
what's new with the script?

Terka
21st May 2010, 07:56
there is nothing new.
only my mess at:
http://ulozto.cz/4852494/halosource-orig.avs
which is using a function http://ulozto.cz/4859647/degrainx.avsi.
the in-hurry part by Didee is only a part, so dont use it.
(in my messy script, there are many other scripts-parts stolen from Didee:cool:)

kopmjj
24th May 2010, 14:42
there is nothing new.
only my mess at:
http://ulozto.cz/4852494/halosource-orig.avs
which is using a function http://ulozto.cz/4859647/degrainx.avsi.
the in-hurry part by Didee is only a part, so dont use it.
(in my messy script, there are many other scripts-parts stolen from Didee:cool:)

i downloaded your script and its great! im also working on the same concert, but on some scenes the halo is visable and most scenes its not., can you tell what parameters effect the halo bit so i can try get rid completly as long as it stays the same blur level, because i can use my sharpen script to bring back some details.
the script is massive so i dont want to mess with it, also is it possible to mask only the edges and apply that script, so only the edges are effected and not the rest of the picture? will it work better?