Go Back    Forum > Digital Video > Video Project Help > Restore, Filter, Improve Quality

Reply
 
LinkBack Thread Tools
  #1  
05-04-2015, 06:47 PM
SimpsonsRule SimpsonsRule is offline
Free Member
 
Join Date: Apr 2015
Posts: 13
Thanked 0 Times in 0 Posts
So I'm at my infancy in learning how to restore old VHS tapes. My understanding is that I should address color correction before anything else because I may lose color information if I muck about with other things first. To that end, I've learned how to use AVISynth to crop the black from my video and display histograms to determine what needs correction.

If anyone comes across this post in the future and doesn't know how, here is a sample of my AVISynth script:

Code:
AVISource("FILE LOCATION")
Crop(8,0,-28,-12)
# Histogram(mode="Classic") # Needs to be YUV
# ConvertToYV12(interlaced=true) # Converts video to YV12
# Histogram(mode="Levels") # Needs to be YV12
ConvertToRGB32(matrix="Rec601",interlaced=true)
My videos are captured in YUV so I didn't need to convert it to use the "Classic" histogram, but I converted it to YV12 for the "Levels" histogram and then I converted it to RGB for the - surprise - "RGB" histogram that is displayed using the ColorTools histograms filter in VirtualDub.

Okay, onto my question! Can someone help me to interpret the histograms below and tell me how I should correct the problems they display?







Attached Images
File Type: jpg Histogram-Classic.jpg (36.2 KB, 329 downloads)
File Type: jpg Histogram-Levels.jpg (30.8 KB, 319 downloads)
File Type: jpg Histogram-RGB.jpg (48.2 KB, 318 downloads)
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Ads / Sponsors
 
Join Date: ∞
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
05-04-2015, 07:32 PM
lordsmurf's Avatar
lordsmurf lordsmurf is offline
Site Staff | Video
 
Join Date: Dec 2002
Posts: 13,633
Thanked 2,458 Times in 2,090 Posts
I don't agree at all. I color correct very last.
It's precisely because you may much up the color in the earlier steps, thereby making any early color correction work void.

- Did my advice help you? Then become a Premium Member and support this site.
- For sale in the marketplace: TBCs, workflows, capture cards, VCRs
Reply With Quote
  #3  
05-04-2015, 07:39 PM
SimpsonsRule SimpsonsRule is offline
Free Member
 
Join Date: Apr 2015
Posts: 13
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by lordsmurf View Post
I don't agree at all. I color correct very last.
It's precisely because you may much up the color in the earlier steps, thereby making any early color correction work void.
I don't know which advice to follow then. I'll quote what someone said from another topic so you understand where I'm coming from.

Quote:
Your original parade sample was YUY2. However, it was converted to RGB when you applied the mask filter. Regardless of what you select for input or output color, whenever you run RGB filters in any NLE, the video is converted to RGB. The vast majority of VDub filters work only in RGB. Once you engage RGB processing, any crushing or clipping in RGB can't be undone by saving back to the original colorspace. Once it's gone, it's gone. If you want those details back again, you have to go to the original source and modify the processing.
Quote:
It would be difficult to advise how to fix black levels, color and borders from your submitted sample. Highlights have already been blown out by conversion from the original YUV to RGB. Clipped highlights means that bright detail beyond a certain point are kaput, gone, destroyed, non-existent. Restoring the full dynamic range of color and contrast levels is seriously limited after that. Levels in YUV should be corrected first, before conversion.
lordsmurf, what is your recommended workflow if I'm starting with interlaced YUV and my end goal is 720x480 BluRay?
Reply With Quote
  #4  
05-04-2015, 08:49 PM
lordsmurf's Avatar
lordsmurf lordsmurf is offline
Site Staff | Video
 
Join Date: Dec 2002
Posts: 13,633
Thanked 2,458 Times in 2,090 Posts
I'm not understanding where the colorspace conversion is coming from. I never crush or clip.

- Did my advice help you? Then become a Premium Member and support this site.
- For sale in the marketplace: TBCs, workflows, capture cards, VCRs
Reply With Quote
  #5  
05-04-2015, 09:57 PM
SimpsonsRule SimpsonsRule is offline
Free Member
 
Join Date: Apr 2015
Posts: 13
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by lordsmurf View Post
I'm not understanding where the colorspace conversion is coming from. I never crush or clip.
My understanding was that certain filters only work in YV12 or RGB and need to be converted as such prior to being used. So in other words, if you tried to apply other filters that needed to convert the colorspace before you addressed color problems, you would lose information.

Is this incorrect?
Reply With Quote
  #6  
05-05-2015, 07:18 AM
lordsmurf's Avatar
lordsmurf lordsmurf is offline
Site Staff | Video
 
Join Date: Dec 2002
Posts: 13,633
Thanked 2,458 Times in 2,090 Posts
I don't really worry about colorspace correction that much. The main damage comes from 0-255 <> 16-235, so that needs to be avoided. For the videos I deal with, colorspace conversion is the least of their problems.

- Did my advice help you? Then become a Premium Member and support this site.
- For sale in the marketplace: TBCs, workflows, capture cards, VCRs
Reply With Quote
The following users thank lordsmurf for this useful post: archivarious (09-29-2020)
  #7  
05-05-2015, 11:54 AM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 3,648
Thanked 1,308 Times in 982 Posts
Quote:
Originally Posted by SimpsonsRule View Post
So I'm at my infancy in learning how to restore old VHS tapes. My understanding is that I should address color correction before anything else because I may lose color information if I muck about with other things first.
To echo lordsmurf's comments, if you set up perfect color correction and then start applying a bunch of other filters later, your color work will be modified. Color correction is affected, for instance, by filters that reduce color bleed -- most of them play with saturation to do their work. Chroma denoisers also change the intensity of one or more colors. First, correct levels to prevent problems later in RGB. Then denoise, then tweak color.

Conversion from original 4:2:2 or YUY2 down to RGB 16-235 YV12 or 4:2:0, done repeatedly, involves interpolation and rounding errors. Eventually they add up. Don't be too squesmish about it. People trade colorspaces all the time, observing proper functions in Avisynth that call for interlaced or progressive video. Just don't be haphazard about it.

Quote:
Originally Posted by SimpsonsRule View Post
My videos are captured in YUV so I didn't need to convert it to use the "Classic" histogram, but I converted it to YV12 for the "Levels" histogram and then I converted it to RGB for the - surprise - "RGB" histogram that is displayed using the ColorTools histograms filter in VirtualDub.
Well, to be picky about it, your videos are captured in YUY2 which isn't "technically" generic YUV. But for all practical purposes, YUY2 and YV12 are both said to be "YUV" color spaces. Geeks like to be picky about it, but don't go anal here. YUV stores luma (Y) separately from chroma (U and V). RGB stores luma and chroma information in the same pixel.

Color correction in YUV is limited in that it's tough if not impossible to isolate a single luma or color range, such as adjusting brightness/hue for colors in the narrow range RGB 60 - 90 for example, without affecting other areas of the image. Of course such fine corrections might not be needed. It all depends on the video.

This cropping and converting is only temporary for assessing what has to be done. In a real workflow you'd avoid back-and-forth colorspace changes. With a really problematic video, that avoidance might not be possible. The workflow as I learned it and see it practised most often, other than initial temporary mods for checking out a video, is this:
1. With YUY2 video, first use filters that work in YUY2 when possible.
2. Go to YV12 when required, which will be the usual case. Denoise in Avisynth first.
3. Then work in RGB. Denoise first if RGB is needed for noise filters, then tweak color last.
4. For final output, a last reconversion to YV12 is usually needed for encoding. Many encoders (e.g., TMPGEnc) make that conversion for you -- but I always like to do it myself when I can. HCenc's encoder expects YUV input and won't make the conversion on its own.

Some Avisynth color filters like ColorYUV and Tweak work in YUY2 and YV12,and others. Filters like Crop() and the resizers work in all allowed colorspaces. RGBAdjust obviously works only in RGB. There are a few specialty filters that work in YUY2 or YV12: TIVTC (inverse telecine) and yadif work in YUY2 and YV12. QTGMC, MCTemporalDenoise, SmoothAdjust, the 16-bit dither package and most (but not all) other denoisers work in YV12. Avisynth documentation and the docs that come with Avisynth filters tell you what colorspace can or can't be used.
'
YUV is usually necessary for setting basic valid levels properly. Sometimes this alone can be sufficient. But with something ornery like VHS with its nonlinear color response, you'll pretty much have to go to RGB later for more precise correction. I haven't mentioned some color filters that work in both YUV and RGB. The color filters in TMPGEnc's encoders have YUV components. So do heavy duty filters that come with Premiere Pro and AfterEffects (like ColorFinesse and Colorista, which are available as Adobe plugins or as stand alone apps). But we'll confine the discussion for now to Avisynth and VirtualDub. Besides, those two apps are free!

Most VirtualDub filters work in RGB. There are exceptions. The "brightness/contrast (UI enhanced)" filter from AveryLee and Donald Graft will work in YUV if it's the top filter in the filter chain. The gradation curves filter works in several colorspaces. A sophisticated denoiser like NeatVideo expects RGB input and gives RGB output, but internally it operates in a proprietary YUV colorspace, and it even separates interlaced fields internally. The general rule is this: if you apply a VirtualDub filter or use "full processing mode", that YUV video will be converted to RGB. For other processing modes RGB is used only for display: the actual output isn't affected in "direct stream copy".

Quote:
Originally Posted by SimpsonsRule View Post
Can someone help me to interpret the histograms below and tell me how I should correct the problems they display?
Almost all histograms display the same data. They just present it differently. But they do have some things in common: dark pixels are on one side of the graph (usually the left or the bottom), bright pixels are on the other side (usually the right or the top).

The "Classic" histogram shows how many pixels are in certain values in various parts of the image. The Classic is a luminance-only histogram and is in a format known more properly as a Waveform Monitor. Darks are at the left, brights at the right. The middle green line equates to RGB 128. The shaded areas on the side borders are invalid dark and bright areas respectively. With the image you supplied, the waveform monitor tells you that the image has very low contrast -- no very dark darks, and very little information at the bright side except for the lamp in the left part of the image. Most of the other data stops at the midpoint across the range, which equates to RGB 128. Overall, the histogram tells you that the image is improperly exposed. The bright lamp on the left skewed the luma reponse and pulled most values down to middle gray, while the darkest objects were pulled upward. The original scene had a contrast range that the camera couldn't handle.

You might already know this, but Avisynth's installed documentation explains how various histograms are laid out. You access the docs by going to All Programs, find the Avisynth program group, expand it, and click on "Avisynth documenation". When the docs open, the left-hand side has a table of contents index with alphabet letters from A to Z. Click on "H", then find the "Histogram" function in the list of "H" entries on the right hand side. Voila! But yiu likely know all that by now.

The "Levels" histogram shows the same information in the top luma channel. That white graph shows no values below about RGB 30 and hardly anything beyond the middle point. Note that the bulk of "white" data is packed at the left-hand side, so most data is on the dark side just below the midpoint. Again, it's a very low contrast image. For color use, "Levels" isn't all that accurate -- but note that the color peaks are very narrow, which often indicates low color density. If there's no color ("black", as in tape leader), a real RGB zero black will be right in the middle of the U and V area.

The RGB histogram tells you you same thing -- very low contrast range -- but with more detailed info. Notice that the white luminance level stops at the left at about RGB 30. The black levels are too high, the gamma (midtones) are suppressed to the dark side, and the brights hardly exist. Notice that Blue in the RGB graph is squished toward the left-hand side, indicating a deficit of blue (look at the grays and whites, and you'll see that the pic has a green color cast).

The ColorTools histogram has other display modes. It has a WaveForm Monitor mode that many use, shown below. Again, the waveform monitor shows low contrast, a low gamma level, and the only brights are in the table lamp. The waveform has a grid showing data sectors and invalid dark and bright levels. Darks are at the bottom, brights at the top. As you can see the brightest brights are at the left-hand side of the graph, which is where they are located in the image.



ColorTools also has a Vectorscope mode. Same information, different layout, shown below. A chroma level for middle gray (RGB 128) lies at the exact center of this graph. The orange lines divide the graph into color sectors, with letters that identify primary and secondary colors. The diagonal line that extends from the center toward the upper left represents the normal range of skin tones. The small rectangles around the circle indicate the limits for safe RGB 235 brights and saturation. Along the right hand side in each channel you'll see some thin "wavelets" that I think are the contours in that window shade.



The letters represent these colors: primary colors are R (Red), G (Green), B (Blue). Secondary colors are Y (yellow = R+G), C (Cyan = G+B), and M (Magenta = B+R). That waveform shows a small cluster of color squished down into the low-saturation, low-contrast gray area (center), a trail of overly green pixels, and a deficit of blue. In warmly lighted interior scenes, you wouldn't expect a flood of blue pixels, but there should be more than shown here.

Not every image will have pixels that fill up all histograms. A night scene will have a lot of dark pixels, a smattering of midtones, and perhaps a few bright highlights. A scene with lots of sky and trees will have a lot of green and blue. A foggy, misty scene will have low saturation and pastel colors, mostly midtones. This scene has one bright, warmish tungsten source and falloff beyond that source.

I should caution that you'll find underexposed images in artificial light to be extremely difficult to correct, especially with this image. It's also tougher to work with because it's been converted to RGB for graphics. One thing you'll find when you increase saturation here is that there's far more noise and color disruption than you can see at first. Consumer cameras are really noisy in low, artificial light. If you increase contrast (juice up the brights), all detail in that beside lamp will disappear and turn into bright blobs. The green in that off-white window shade will persist because most it is right in the middle of the midtones and skin tones, where you also need to correct the light grays and subdued whites. Because of the lighting used, the color balance should be slightly warmish -- but certainly not green. It would be better to work with a short piece of the original YUY2 video, and even that would be difficult.

For more about histograms, contrast, tonal ranges, clipping, etc., take a look at two free tutorials from a Photoshop website. The RGB histograms are from still cameras, but the principles of luminance and chroma as shown in the tutorial are the same for stills and video. After all, a video is a stream of still images.
Histograms Part 1: Tones and Contrast
Histograms Part 2: Luminosity and Color


Attached Images
File Type: png RGB_Waveform.png (138.8 KB, 307 downloads)
File Type: png Vectorscope.png (21.6 KB, 305 downloads)

Last edited by sanlyn; 05-05-2015 at 12:07 PM.
Reply With Quote
The following users thank sanlyn for this useful post: SimpsonsRule (05-05-2015)
  #8  
05-05-2015, 02:03 PM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 3,648
Thanked 1,308 Times in 982 Posts
Well, here's a quickie. So quick, I don't even remember WTH I did! I just threw some color and levels filters up there an started tweaking. Fixed levels first, then individual color and gamma channels with ColorMill, gradation curves, and the VDub Levels filter. Note that I didn't mention "Brightness" or "Contrast" filters, which are useless here.

Still a long way to go, and this is not a piece of the original YUY2 capture (I had to crop to get a mod-8 frame size, or some of the filters wouldn't run). Anyway, I guess it shows that the shot can be improved. Also shows I must be crazy today.



If you see some vague vertical yellowish bars on then right wall, they're a peview of the the noise that's in the original. You'll have to fix levels, then denoise, then RGB color. Would be a good project for AfterEffects, but that's beyond our pay grade for now.


Attached Images
File Type: jpg VDub_work2a_400.jpg (70.5 KB, 305 downloads)
Reply With Quote
  #9  
05-07-2015, 07:59 PM
lordsmurf's Avatar
lordsmurf lordsmurf is offline
Site Staff | Video
 
Join Date: Dec 2002
Posts: 13,633
Thanked 2,458 Times in 2,090 Posts
You can tweak out the yellow. I like to use VirtualDub Colormill filter for removing only dark/mid/high color values. In this image, I'd look to remove yellow in the mids and highs, but leave it in darks. How much is removed depends on what you see, but it can work very well.

sanlyn gave a nice quickie sample of post-capture color correction.

- Did my advice help you? Then become a Premium Member and support this site.
- For sale in the marketplace: TBCs, workflows, capture cards, VCRs
Reply With Quote
The following users thank lordsmurf for this useful post: archivarious (09-29-2020)
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
VirtualDub advice to correct 2nd-gen+ VHS copies? TylerDurden389 Restore, Filter, Improve Quality 18 12-14-2014 09:23 PM
Review of vReveal software, to stabilize and color-correct video guokamoli Restore, Filter, Improve Quality 3 06-16-2011 04:06 AM
DV color space harmful to analog color quality? Verify? DeXeSs Capture, Record, Transfer 6 06-27-2010 01:48 AM
Correct monitor hook up during capturing 777sp2 Capture, Record, Transfer 1 09-28-2005 04:10 PM




 
All times are GMT -5. The time now is 01:21 AM