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 13th February 2005, 01:25   #1  |  Link
Trephin
Registered User
 
Trephin's Avatar
 
Join Date: Aug 2002
Location: Stockholm, Sweden
Posts: 17
ColorYUV and Histogram

When I use ColorYUV to adjust my video, I get strange patterns in the Histogram display. Can anyone explain why I get these vertical lines in classic display and the checkers when in color display? Are they rounding errors? Is this bad? In the color diagram, it seems like certain colors are eliminated entirely.



This is my script:

Code:
# --- IMPORTS ------------------------------------------------------------------
import("MVbob.avs")
# ------------------------------------------------------------------------------


# --- SOURCE -------------------------------------------------------------------
movie = OpenDMLSource("tape.1.dv.avi", audio=true, pixel_type="RGB24", fourCC="CDVC")
# ------------------------------------------------------------------------------


# --- FIX DV SOURCE ------------------------------------------------------------
movie = movie.ConvertToYUY2(matrix="PC.601")
movie = movie.ReInterpolate420(interlaced=true)
movie = movie.reYV12()
# ------------------------------------------------------------------------------


# --- DEINTERLACE --------------------------------------------------------------
movie = movie.MVbob()
movie = movie.SelectEven()
# ------------------------------------------------------------------------------


# --- ALTER COLORS -------------------------------------------------------------
movie = movie.ColorYUV(off_y=-6.0, gain_y=-14.0, cont_u=128, cont_v=128, opt="")
# ------------------------------------------------------------------------------


# --- CROP ---------------------------------------------------------------------
movie = movie.Crop(8, 0, -8, -0, true)
# ------------------------------------------------------------------------------


# --- RESIZE -------------------------------------------------------------------
#movie = movie.Lanczos4Resize(704, 528)
# ------------------------------------------------------------------------------


# --- FOR TESTING --------------------------------------------------------------
#movie = movie.Histogram(mode="classic")
movie = movie.Histogram(mode="color")
movie = movie.Trim(12600, 12600)
# ------------------------------------------------------------------------------


return movie
__________________
remember sammy jankis

Last edited by Trephin; 13th February 2005 at 12:02.
Trephin is offline   Reply With Quote
Old 13th February 2005, 01:34   #2  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
I cannot say much about the histogram, but about this:


movie = movie.ReInterpolate420(interlaced=true)
movie = movie.reYV12()

knock out reinterpolate420, if you use reYV12 and vice versa.

they should not be used together. they are not intended for this.

I recommend reYV12 alone here.
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 13th February 2005, 11:02   #3  |  Link
Trephin
Registered User
 
Trephin's Avatar
 
Join Date: Aug 2002
Location: Stockholm, Sweden
Posts: 17
Aah, thanks Scharfi! I did some additional tests now, and I can see that reYV12 alone looks more correct than combined with ReInterpolate420. My source is PAL DV. Do you think using the Canopus decoder and then reYV12 is the best thing to do here, or should I try YV12 decoding with ffdshow?

Anyone have anything on the patterns in the histogram?
__________________
remember sammy jankis
Trephin is offline   Reply With Quote
Old 13th February 2005, 11:11   #4  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
should I try YV12 decoding with ffdshow

jep.
it *should* be be faster.
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 13th February 2005, 13:31   #5  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
Could you post a screenshot of the same frame (of which you took the histogram), just taken after resizing? Also a screenshot of the same frame before any processing.

But, i really don't know. Perhaps Sh0dan can say something about this?
Wilbert is offline   Reply With Quote
Old 13th February 2005, 14:22   #6  |  Link
Trephin
Registered User
 
Trephin's Avatar
 
Join Date: Aug 2002
Location: Stockholm, Sweden
Posts: 17
I actually skipped resizing for those histograms. The linked screenshots might be useful. I saved them with image sequence from VirtualDub. I guess the chroma have to be stretched in one way or another when increasing contrast, but those gaps just looks scary. And the spikes in luma too.

Before (657 KB)
After (689 KB)

Used script:

Code:
# --- IMPORTS ------------------------------------------------------------------
import("MVbob.avs")
# ------------------------------------------------------------------------------


# --- SOURCE -------------------------------------------------------------------
movie = OpenDMLSource("tape.1.dv.avi", audio=true, pixel_type="RGB24", fourCC="CDVC")
# ------------------------------------------------------------------------------


# --- FIX DV SOURCE ------------------------------------------------------------
movie = movie.ConvertToYUY2(matrix="PC.601")
movie = movie.reYV12()
# ------------------------------------------------------------------------------


# --- DEINTERLACE --------------------------------------------------------------
movie = movie.MVbob()
movie = movie.SelectEven()
# ------------------------------------------------------------------------------


# --- FOR TESTING --------------------------------------------------------------
movie = movie.Trim(12600, 12600)
befor = movie.Histogram(mode="levels")
after = movie.ColorYUV(off_y=-6.0, gain_y=-14.0, cont_u=128, cont_v=128, opt="").Histogram(mode="levels")
movie = Interleave(befor, after)
# ------------------------------------------------------------------------------


return movie
__________________
remember sammy jankis

Last edited by Trephin; 13th February 2005 at 14:31.
Trephin is offline   Reply With Quote
Old 13th February 2005, 14:49   #7  |  Link
Arachnotron
Alias fragger
 
Arachnotron's Avatar
 
Join Date: Jul 2003
Location: the Netherlands
Posts: 863
I think this is normal. Since you are working in 8 bit digital, you only have 255 discrete values vor Y, U and V to fall in. As long as you plot those values next to each other in a histo the plot looks continuous, but in effect it is a bar-graph. So the moment you stretch out the distribution and redistribute the values over a wider range, there will be values in between you will not get. Hence the gaps in the histo.

An example: suppose your luma is between 30 and 50. that leaves 20 possible luma values in the picture. Next you stretch the luma range to 0-255. You now have 20 luma values to distribute over a range of 255 possible values. The histo will look like 20 white spikes with huge black gaps in between.

Isn't the term for this quantization error? Anyone?
Arachnotron is offline   Reply With Quote
Old 13th February 2005, 16:52   #8  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
I long ago wrote histogram equalization filters for VirtualDub. I called that effect banding. The banding is actually visible as color stepping and so I provided an anti-banding feature. This adds a small random component to the equalized pixel to fill in the gaps. See here to see an example:

http://neuron2.net/histogram.html
Guest is offline   Reply With Quote
Old 13th February 2005, 18:58   #9  |  Link
Trephin
Registered User
 
Trephin's Avatar
 
Join Date: Aug 2002
Location: Stockholm, Sweden
Posts: 17
Thanks guys, for explaining the banding effect. What about the spikes in the luma histogram? Here I am compressing the range. Are these spikes from rounding?
__________________
remember sammy jankis
Trephin is offline   Reply With Quote
Old 13th February 2005, 19:01   #10  |  Link
Arachnotron
Alias fragger
 
Arachnotron's Avatar
 
Join Date: Jul 2003
Location: the Netherlands
Posts: 863
I suppose that is the reverse effect. Suppose you have 6 luma values and compress the range to 5 values. That means that at least two values will be rounded off and end up as one single value, while the others will map to a single new value. So one luma value in the resulting histo will contain contributions of the luma values of two sets of pixels, and spike out above the rest.

Last edited by Arachnotron; 13th February 2005 at 19:06.
Arachnotron is offline   Reply With Quote
Old 13th February 2005, 19:12   #11  |  Link
Trephin
Registered User
 
Trephin's Avatar
 
Join Date: Aug 2002
Location: Stockholm, Sweden
Posts: 17
Simple as that... All right. Thanks!
__________________
remember sammy jankis
Trephin 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 08:24.


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