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 Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 29th May 2004, 22:18   #1  |  Link
ajordan
Registered User
 
Join Date: May 2004
Posts: 12
Saturated colors bleed - no more

Hi! I've been working on a filter to fix a severe color bleeding problem of my low-end camcorder (JVC DVL510). I managed to fix it with this function, which works in YV12 colorspace. I hope this is usefull to somebody else.
Code:
Function FixChromaBleeding (clip input) {

  # prepare to work on the V channel and reduce to speed up and filter noise
  area = input.tweak(sat=4.0).VtoY.ReduceBy2

  # select and normalize both extremes of the scale
  red = area.Levels(255,1.0,255,255,0)
  blue = area.Levels(0,1.0,0,0,255)

  # merge both masks
  mask = MergeLuma(red, blue, 0.5).Levels(250,1.0,250,255,0)

  # expand to cover beyond the bleeding areas and shift to compensate the resizing
  mask = mask.ConvertToRGB32.GeneralConvolution(0,"0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0").ConvertToYV12

  # back to full size and binarize (also a trick to expand)
  mask = mask.BilinearResize(Width(input),Height(input)).Levels(10,1.0,10,0,255)

  # prepare a version of the image that has its chroma shifted and less saturated
  input_c = input.ChromaShift(C=-4).tweak(sat=0.8)

  # combine both images using the mask
  return input.overlay(input_c,mask=mask,mode="blend",opacity=1)
}
More details and sample images here... The pic below is an appetizer


Last edited by ajordan; 31st May 2004 at 14:16.
ajordan is offline   Reply With Quote
Old 31st May 2004, 07:16   #2  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
that's pretty good thinking there.

would a soft mask help it? (or would it just slow it down some...). i'm pretty big on soft masks, but they're not always useful.
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 31st May 2004, 07:31   #3  |  Link
t610425
Tzanampetis
 
t610425's Avatar
 
Join Date: May 2003
Location: Athens, GR
Posts: 56
Color bleeding is a pain for me, specialy when transfering old (PAL) VHS to DVD.

I'll give it a try and let you know.

tnx for sharing

all the best
__________________
takis
t610425 is offline   Reply With Quote
Old 31st May 2004, 14:58   #4  |  Link
ajordan
Registered User
 
Join Date: May 2004
Posts: 12
@Mug: You mean to use gamma > 1.0 in Level? I don't think it would slow down at all. If I can make sure the bleeding area is well covered by the soft mask, it would reduce the risk of yanking the croma of a nearby object into the correction. Thanks for the suggestion.
ajordan is offline   Reply With Quote
Old 8th November 2005, 16:38   #5  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,717
Could any MaskTools guru make a faster version of this excellent function? It seems that the discussion dried up short
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 8th November 2005, 17:48   #6  |  Link
trevlac
budala
 
Join Date: Oct 2003
Location: U.S.
Posts: 545
At the risk of introducing a different but probably not better way ....

I added some functionality to Tweak a little while ago to allow targeting specific hues and saturation levels (secondary color correction). So you can target a range of red hue and a range of saturation and then bring those pixels down. It does allow a 'softening' of the saturation window by interpolating over a range instead of a sharp cutoff. This helps to reduce banding.

http://www.avisynth.org/warpenterpri...l_20040412.zip


[edit]
#This should Target red between 115% and 75% saturation
# and bring it down to 80% of the original value.
# Smoothing defaults to 16 which will dampen saturations down to (75-16=59%)

TweakColor(sat=0.8,startHue=80,endHue=140,maxSat=115,minSat=75)

Last edited by trevlac; 8th November 2005 at 17:55.
trevlac is offline   Reply With Quote
Old 9th November 2005, 09:46   #7  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
Quote:
Originally Posted by Boulder
Could any MaskTools guru make a faster version of this excellent function? It seems that the discussion dried up short
That script could be optimised quite heavily. But beyond optimisation, a complete re-write would be much better. The script currently uses a "fixed" offset, which basically is a hack: there could be *completely other* offsets out there as well, on which the current function would just fail, in case. Also, currently there's no re-shaping of colors. But if the color bleed is a true "bleed", then re-shaping is needed as well.

For the moment, you should get a good speed gain by just replacing the slow GeneralConvolution
Code:
# expand to cover beyond the bleeding areas and shift to compensate the resizing
  mask = mask.ConvertToRGB32.GeneralConvolution(0,"0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0").ConvertToYV12
with (using MaskTools v1.5.x)
Code:
  mask = mask.DEdgeMask(0,255,0,255,"0 0 0 1 0 0 0 0 0").DEdgeMask(0,255,0,255,"1 1 1 1 1 1 0 0 0")
More speed could be squeezed, but this probably is the most cruicial part.

To produce something that's working more specific, I'd need some samples showing the problem, since I have no such ones.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 9th November 2005, 10:25   #8  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,717
I could try to dig up some frames that have lots of bleeding, it's mostly red and blue which show the phenomenon. I'll probably transfer my last VHS camcorder tape to DVD later this week before getting my first miniDV so I might find something of interest there.

In any case, removing the need to convert to RGB32 and back is already a major point, thanks for that I wish I had the time to start learning the basics of masks but it looks like I won't till I'm old and cranky
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 16th January 2006, 14:33   #9  |  Link
Chainmax
Huh?
 
Chainmax's Avatar
 
Join Date: Sep 2003
Location: Uruguay
Posts: 3,103
This script works pretty nicely as it is, so I don't think a rewrite is necessary, but a full optimization would be great if it means the new version would do the exact same thing as the original.
__________________
Read Decomb's readmes and tutorials, the IVTC tutorial and the capture guide in order to learn about combing and how to deal with it.
Chainmax is offline   Reply With Quote
Old 27th February 2006, 00:45   #10  |  Link
zlab
Registered User
 
Join Date: Oct 2003
Posts: 21
Hi,
I have difficulty when running the above script "FixChromaBleeding", it report an error: Scipt error: there is no function named "ChromaShift", could anyone give me a hand?
zlab is offline   Reply With Quote
Old 27th February 2006, 02:08   #11  |  Link
Chainmax
Huh?
 
Chainmax's Avatar
 
Join Date: Sep 2003
Location: Uruguay
Posts: 3,103
ChromaShift v2.7.
__________________
Read Decomb's readmes and tutorials, the IVTC tutorial and the capture guide in order to learn about combing and how to deal with it.
Chainmax is offline   Reply With Quote
Old 1st March 2006, 23:48   #12  |  Link
FredThompson
Registered User
 
FredThompson's Avatar
 
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,984
Did you try Reinterpolte411? Perhaps that will reduce the initial "bleed" which is really an aspect of 4:1:1, not actual "bleed".
__________________
Reclusive fart.
Collecting Military, Trains, Cooking, Woodworking, Fighting Illini, Auburn Tigers
FredThompson is offline   Reply With Quote
Old 18th September 2006, 03:40   #13  |  Link
Dr.D
Registered User
 
Join Date: Apr 2006
Posts: 70
Quote:
Originally Posted by Didée View Post
That script could be optimised quite heavily. But beyond optimisation, a complete re-write would be much better. The script currently uses a "fixed" offset, which basically is a hack: there could be *completely other* offsets out there as well, on which the current function would just fail, in case. Also, currently there's no re-shaping of colors. But if the color bleed is a true "bleed", then re-shaping is needed as well.
Is there any progress since a long time ago?
Color bleeding is a real problem for my Sony MiniDV camera. Original script doesn't help, even makes things worse. Because I have bleeding shifted to the left, author has one shifted to the right.
Optimisation of the script will be really appreciated. Thanks!
Dr.D is offline   Reply With Quote
Old 18th September 2006, 09:04   #14  |  Link
Pookie
Registered User
 
Join Date: Apr 2005
Posts: 1,339
I've found the following to be very effective:

Code:
fft3dfilter(sigma=8,plane=3,degrid=1)
Plane=3 affects only the chroma channels, so you can really turn up the sigma levels (within reason).
Try it and see if it helps. Also, the Reinterpolate411 plugin as Fred mentioned might help a lot
if it applies to your source.

Last edited by Pookie; 18th September 2006 at 09:12.
Pookie is offline   Reply With Quote
Old 18th September 2006, 19:01   #15  |  Link
Dr.D
Registered User
 
Join Date: Apr 2006
Posts: 70
Quote:
Originally Posted by Pookie View Post
I've found the following to be very effective:

Code:
fft3dfilter(sigma=8,plane=3,degrid=1)
Plane=3 affects only the chroma channels, so you can really turn up the sigma levels (within reason).
Try it and see if it helps. Also, the Reinterpolate411 plugin as Fred mentioned might help a lot
if it applies to your source.
Thank you, but strange, both ways don't help at all, make no visible difference:
Original:


Processed:

Last edited by Dr.D; 18th September 2006 at 22:47.
Dr.D is offline   Reply With Quote
Old 18th September 2006, 22:11   #16  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
@Dr.D
I tried to make your pics visible, but i didn't get it to work. I will ask the admin about it.
Wilbert is offline   Reply With Quote
Old 18th September 2006, 22:48   #17  |  Link
Dr.D
Registered User
 
Join Date: Apr 2006
Posts: 70
Quote:
Originally Posted by Wilbert View Post
@Dr.D
I tried to make your pics visible, but i didn't get it to work. I will ask the admin about it.
Can you see the pics now?
Dr.D is offline   Reply With Quote
Old 19th September 2006, 01:03   #18  |  Link
anton_foy
Registered User
 
Join Date: Dec 2005
Location: Sweden
Posts: 702
Isn't there a way to shift colour the planes with TomsmoComp?
Someone suggested me to do that when I had the same problem a long time ago. Can't find the thread though.
Im almost certain it was TomsMoComp :S

Last edited by anton_foy; 19th September 2006 at 01:06.
anton_foy is offline   Reply With Quote
Old 19th September 2006, 02:29   #19  |  Link
Dr.D
Registered User
 
Join Date: Apr 2006
Posts: 70
Quote:
Originally Posted by anton_foy View Post
Isn't there a way to shift colour the planes with TomsmoComp?
Someone suggested me to do that when I had the same problem a long time ago. Can't find the thread though.
Im almost certain it was TomsMoComp :S
Sounds strange, TomsMoComp is deinterlacing filter, my source is progressive already. Just in case, I've checked out - no difference. Thanks anyway.
Dr.D is offline   Reply With Quote
Old 17th March 2014, 12:49   #20  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
I have a mod that can control result to fit source

here (now need Zs_RF_Shared.avsi V1.143 or better)

it good idea to use it like this

Code:
FixChromaBleedingMod(-4, 2, thr=4.0, f=false, xysh=true, bic=true, strength=1.0, opacity=1.0) #Shift only
FixChromaBleedingMod(0, thr=3.0, f=false, n=true, strength=0.9, opacity=0.9) #less saturated in blue and red
and there some thing else for chroma blend/bleed/halo here and here related post
__________________
See My Avisynth Stuff

Last edited by real.finder; 12th January 2021 at 14:36. Reason: update to github
real.finder 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 04:32.


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