Thursday, February 25, 2010

Black levels in video playback (Premiere Pro)

Take a look at this screen capture from a video file.
The video itself is just a black (R:0, G:0, B:0) matte. Or at least, it is supposed to be. Notice that the 16:9 video portion is actually dark grey -- much lighter than the surrounding true black border. I only noticed this recently, even though it has probably always been this way on my computer. Almost all of the video watched on this computer is from youtube, which goes through a different video display route than DVD video or video played from individual files.

Initially, I thought the problem was caused by Premiere itself. I created a very simple video with just a few seconds of solid black matte. When viewing the preview window in Premiere, it looked fully black. After encoding into MPG, it looked dark gray. Clearly, it must be a problem with Premiere or its encoder. I was encouraged by this bug report:
http://forums.adobe.com/thread/387845

http://forum.videohelp.com/threads/309449-Adobe-Premiere-MainConcept-s-H-264-vs-x264-open-source-encoder/page4

After upgrading to 4.0.1 and spending many hours fighting with codecs, filters, shaders, etc, I discovered that my video card driver actually has the final decision about black levels. Even if all of the video decoding software outputs a "0", the video card driver may still adjust this to be dark gray in order to be compatible with analog television output. I had to upgrade my Nvidia driver, which now includes the option to actually use 0-255 range in the video output.


The alternative to 0-255 range is 16-235. I guess analog TVs and maybe even digital TVs are setup to display a value of 16 as complete black and 235 as complete white. Why? I have no idea. It might have made sense when dealing with an analog signal, but it makes no sense with digital signaling. The difference in tonal range is technically known as pc.709 and rec.709. If you start reading about color spaces and transfer functions, your head might explode. Just try searching for YUV rec.709 YUY2 YV12 4:2:0

This is helpful:
http://avisynth.org/mediawiki/ConvertToRGB



Wednesday, February 24, 2010

Custom Topo map overlay in Google Earth

I've been trying to determine just how difficult it would be to build a house in the SF Bay Area. The first part of the process involves finding a piece of land and checking its topographical features (among myriad other things). Google Earth is great for this task, but the topographical resolution is not high enough to get a very accurate estimate of the work needed to prepare the lot for a house. I happened to have a detailed topo map that was prepared for a property in which I am interested. I editing the map in GIMP to make a transparent GIF, then imported the image into Google Earth. Unfortunately, the transparent pixels were replaced with white, but Earth still allowed me to adjust the image's overall transparency. Alignment was made easy by existing fences and lot lines.


This is really great way to visualize the land's topography.

Cool!

Tuesday, February 16, 2010

Etching zirconium oxide with hydrofluoric acid

I am currently working on a project where I need to replace a standard mouse ball with a non-metallic equivalent. Normal mouse balls are built from a steel core that has been coated with a thick layer of rubber. I can't use any metal in my project, so I must find a replacement. The main requirements are:

Ball must be very dense
Ball must be non-magnetic and non-conductive (ie non-metallic)
Ball must be coated with rubber or naturally have a high friction coefficient
Outer diameter 7/8"

My first solution was to use 7/8" glass marbles. These are not easy to find, but they are available. The problem is that the marbles are not perfectly spherical, and they are not nearly as dense as the original mouse ball. The lower density means the ball weighs less and will not track smoothly on the mousepad surface, since it sometimes skips and hops. I was able to etch them with hydrofluoric acid, spray them with primer paint, then coat with with spray-on rubber. They worked OK, but I have a better solution now.

I found a source of 7/8" dia zirconium oxide balls (http://www.ortechceramics.com/). This stuff is a ceramic, but 2-3 times as dense as glass. It's non-metallic, and the balls have very high sphericity. The problem is that the balls come very highly polished, and the paint will not stick to them. I tried etching them with standard glass etching cream, but there was no effect.

I found that a local lab supply company (http://www.lab-proinc.com/) sells 50% hydrofluoric acid (HF). I bought some and initially made a small 10% dilution. The ZrO2 showed no etching after 1 hour of full submersion in the dilution. I upped the concentration to 20%. Still no effect after 30 minutes. Finally, I submerged the ZrO2 in straight 50% HF. After 10 minutes, I could see the shine starting to disappear from the balls' surfaces. After 20-30 minutes, the balls appeared to have enough etching so that they would hold paint well.

Hydrofluoric acid is scary stuff. There are reports of it penetrating skin painlessly then dissolving bones and causing blood toxicity. Standard nitrile or latex gloves only provide splash protection -- ie if the HF is spilled on the glove, immediately remove the glove, and get a new one. HF will penetrate the gloves if left in contact for too long.

I was surprised to see the 50% HF was actually 'fuming'. When I left it in the open container, I could clearly see vapor droplets coming off the surface. If I blew across the surface of the HF, more vapors were produced. I am not sure if it is reacting with water in the air/breath or what. I didn't expect 50% to be fuming.

Friday, February 5, 2010

More Cosmiar 12.5mm f/1.4 sample images

Cosmicar 12.5mm at f/1.4




Cosmicar 12.5mm at f/8

Adapting a Cosmicar 12.5mm f/1.4 c-mount lens to the GH1

The micro four thirds (and standard four thirds) camera format makes it possible to use old c-mount lenses with decent results. The lenses with shorter focal lengths will not cover the image sensor fully, but it seems that anything 25mm or longer will have full sensor coverage. These lenses are very cheap (eg $30), and the quality is surprisingly good.

This is the cosmicar 12.5mm f/1.4. I got it here:
http://www.surplusshed.com/pages/item/l10128.html

One problem is that the fast, short focal length lenses have a very wide barrel. In fact, it is too wide to fit into the micro four thirds -> c-mount adapter. I machined both the adapter and the lens so that they would fit together and also achieve infinity focus.

The lens has a brass mounting plate with the C-mount threads on it. It comes off very easily by removing the three screws around the periphery.


I used a lathe to cut an angle onto the edge of the brass mounting plate.

I cut the same angle onto the C-mount adapter. I bought mine from an eBay seller called rainbowimaging.


I'm pretty sure infinity focus has been achieved. If you think this image looks soft, it may just be the overall characteristic of the lens. It is $30.

The real benefit of theses lenses is that they are very fast (f/1.4) and wide, so they are ideal for indoor video. The 16:9 format works a little better with the image circle produced by the lens.

This has been very helpful in choosing lenses:
http://spreadsheets.google.com/pub?key=p9kkgjwEQQQ-HJwvNDobeEw


Also note that this is my second attempt in adapting the cosmicar to the camera. I had bought a c-mount adapter previously and machined it without machining the lens. I eventually machined away so much material (accidentally) that the adapter became too weak and broke immediately. I then realized that some material must be removed from both the lens and the adapter to make it work.