Log in

View Full Version : How To Remove Red/Green Lines


Master Yoda
31st December 2004, 16:22
Just wondering what filter(s) i would need to use to get ride of these red and green lines? hopefully to losing any of the quality. if you look at the jpg you can see what i mean, look where the lamp is on the right. Im sure those lines are the problem of the colour beating on the mpeg2 encode. The lines only seem to apear along the top part of the image.It was captured using a s-video output on the back of my sky box, not a vhs capture.

http://imagehost.biz/ims/pictes/171986.jpg

Thanks

rfmmars
31st December 2004, 17:13
They look like PAL chroma phase lines.

Go to neuron2 website for the filter or

http://homepages.fh-giessen.de/~hg6423/rmPal/index.englische-uebersetzung--translated-into-english.html


richard
photorecall.net

Master Yoda
31st December 2004, 18:19
thanks for the reply but the filter on that page is a virtual dub filter, i need one for avisynth.

rfmmars
31st December 2004, 19:57
There may be a Avisynth solution but why would you dismiss using VD to solve the problem, I use both in my work. VD is visualey easier to use in some cases, and sometimes it's the only answer. You can also call this VD plugin in a Avisynth script.

richard

Master Yoda
1st January 2005, 15:51
Well i dont want to make another avi file using huffyuv to use that filter mainly because i dont have the spare space to make another 26GB file.

Do you know of any avisynth filter that does the same job ?? or can you tell me how i use a vd filter in avisynth...

Thanks

rfmmars
1st January 2005, 18:45
On Neuron's site which is now down as of last night there is a up to date master Avisynth .DLL list, it's not very discriptive but that filter may be there.

As far as having to make another file, it is not required. Frameserve from Avisynth to Virtualdub(xxx), set filter, and then frameserve out to where you want, all at the same time. No need to have a in- between file, DOUBLE FRAMESERVE.

richard

Wilbert
2nd January 2005, 01:11
I can't access the link of rfmmars, but I thought he was mentioning Rmpal. The following avs script does the same


ConvertToYUY2(interlaced=true) # or ConvertToYV12(interlaced=true); if source is RGB
clip = SeparateFields()
even = clip.SelectEven()
odd = clip.SelectOdd()
clip_even = MergeChroma(even, odd, 0.5) # U and V planes of even and odd fields are averaged, luma even untouched
clip_odd = MergeChroma(odd, even, 0.5) # U and V planes of even and odd fields are averaged, luma odd untouched
Interleave(clip_even, clip_odd)
Weave()


link: http://forums.virtualdub.org/index.php?act=ST&f=7&t=4988&

Master Yoda
2nd January 2005, 18:25
I add that to the script and then opened it in vd to see if the script works, but theres still red and green lines, but not constant, as you go frame by frame they come and go.

I could'nt get the frame server in vd to work.I installed the correct things like the guide says but when i hit frame server a box appears but does nothing, the numbers just site on 0.

Is there any other filters i could give a try.

Arachnotron
2nd January 2005, 22:11
Wilbert, are you sure that script is correct?

If I understand the problem correctly, there is an alternating shift in color between the lines *within one field*. So to fix it, you should

- separate even and odd fields
- split the even field again in a pseudo - even and odd field
- merge the chroma of these last two in an weighted way
- split and chromamerge the odd field to
- merge them together again

The way your script does it works, but only for progressive stuff. When it is interlaced, you are merging the chroma from different points in time.

[edit]
Like this?
[edit2] removed wrong script :(
[edit3] Second attempt. There is still a mistake in it I cannot find, but hopefully it illustrates what I am getting at.
AVISource("C:\cap\process\clip.avi")

clip = SeparateFields()
even = clip.SelectEven()
odd = clip.SelectOdd()
assumeframebased(even)
assumeframebased(odd)

even1 = even.SeparateFields.SelectEven()
odd1 = even.SeparateFields.SelectOdd()
clip_even1 = MergeChroma(even1, odd1, 0.5)
clip_odd1 = MergeChroma(odd1, even1, 0.5)
out1 = Interleave(clip_even1, clip_odd1).weave

even2 = odd.SeparateFields.SelectEven()
odd2 = odd.SeparateFields.SelectOdd()
clip_even2 = MergeChroma(even2, odd2, 0.5)
clip_odd2 = MergeChroma(odd2, even2, 0.5)
out2 = Interleave(clip_even2, clip_odd2).weave

interleave(out1,out2)
assumefieldbased()
weave()

Wilbert
2nd January 2005, 23:15
If I understand the problem correctly, there is an alternating shift in color between the lines *within one field*
Shouldn't be to hard to check with SeparateFields.

But, this vdub filter Rmpal assumes *within one frame*. Source can be found here:

http://homepages.fh-giessen.de/~hg6423/rmPal/rmpal101.cpp

The way your script does it works, but only for progressive stuff. When it is interlaced, you are merging the chroma from different points in time.
Yes, it merges chroma from adjacent fields. Filter description:

"This filter corrects errors in line color caused by PAL technology's phase shifts,"

Arachnotron
2nd January 2005, 23:32
@ Wilbert,

As I understand it, PAL changes the phase 180 degrees every line. when a phase shift occurs, this changes the color of one line a bit in one direction, but in the opposite direction for the next line so from a distance it averages out on a TV screen.

Since Tv is broadcast field per field, the line to do the averaging with is the next line in the same field, not the one in the next field. The moment the error changes between fields the relation breaks down to say nothing of what happens if the next field is completely different because it is from an interlaced source.

Anyway, my attempt is in the script above, but there is a bug in it I think. I think I swapped fields somewhere. Can you find it?

[edit] should ConvertToYV12(interlaced=true) not have the same effect?

Wilbert
2nd January 2005, 23:40
As I understand it, PAL changes the phase 180 degrees every line. when a phase shift occurs, this changes the color of one line a bit in one direction, but in the opposite direction for the next line so from a distance it averages out on a TV screen.
Yes, ok I agree. So, Rmpal produces wrong results?

About your script. I think assumeframebased(even) isn't used anymore further in the script. Try:

AVISource("C:\cap\process\clip.avi")

clip = SeparateFields()
even = clip.SelectEven()
odd = clip.SelectOdd()
ef = assumeframebased(even)
of = assumeframebased(odd)

even1 = ef.even.SeparateFields.SelectEven()
odd1 = ef.even.SeparateFields.SelectOdd()
clip_even1 = MergeChroma(even1, odd1, 0.5)
clip_odd1 = MergeChroma(odd1, even1, 0.5)
out1 = Interleave(clip_even1, clip_odd1).weave

even2 = of.odd.SeparateFields.SelectEven()
odd2 = of.odd.SeparateFields.SelectOdd()
clip_even2 = MergeChroma(even2, odd2, 0.5)
clip_odd2 = MergeChroma(odd2, even2, 0.5)
out2 = Interleave(clip_even2, clip_odd2).weave

interleave(out1,out2)
assumefieldbased()
weave()

Something like that. If you don't get it working, I will look more closely at it ...

Arachnotron
3rd January 2005, 00:12
ok, this one seems to work.

AVISource("C:\cap\whatever.avi")

clip = SeparateFields()
even = clip.SelectEven().assumeframebased
odd = clip.SelectOdd().assumeframebased

even1 = even.SeparateFields.SelectEven()
odd1 = even.SeparateFields.SelectOdd()
clip_even1 = MergeChroma(even1, odd1, 0.5)
clip_odd1 = MergeChroma(odd1, even1, 0.5)
out1 = Interleave(clip_odd1,clip_even1).weave

even2 = odd.SeparateFields.SelectEven()
odd2 = odd.SeparateFields.SelectOdd()
clip_even2 = MergeChroma(even2, odd2, 0.5)
clip_odd2 = MergeChroma(odd2, even2, 0.5)
out2 = Interleave(clip_odd2, clip_even2).weave

interleave(out1,out2)
assumefieldbased()
weave()

Master Yoda
3rd January 2005, 00:50
That last one seems to have done the trick, cant see any red or green lines, done a sample mpeg2 encode to test and did'nt see and coloured lines. Have to wait till i do a full encode and watch it on the tv see how well its turned out.

So this is now my script...

AviSource("my_family.avi")
Addborders(12,0,12,0)
Trim(184,73305)
clip = SeparateFields()
even = clip.SelectEven().assumeframebased
odd = clip.SelectOdd().assumeframebased

even1 = even.SeparateFields.SelectEven()
odd1 = even.SeparateFields.SelectOdd()
clip_even1 = MergeChroma(even1, odd1, 0.5)
clip_odd1 = MergeChroma(odd1, even1, 0.5)
out1 = Interleave(clip_odd1,clip_even1).weave

even2 = odd.SeparateFields.SelectEven()
odd2 = odd.SeparateFields.SelectOdd()
clip_even2 = MergeChroma(even2, odd2, 0.5)
clip_odd2 = MergeChroma(odd2, even2, 0.5)
out2 = Interleave(clip_odd2, clip_even2).weave

interleave(out1,out2)
assumefieldbased()
weave()

Now i read that it may be a good idea to denoise this will help the compressability of it.Would i add the denoiser after trim but before the rest or at the end.??

Thank you both, your help is appreciated.

Arachnotron
3rd January 2005, 00:58
Would i add the denoiser after trim but before the rest or at the end.??I would say at the end.

Since repairing PAL phase shifts depends on the original chroma information being in place, I would guess you need to do that first before any other filtering that might change it.