From The Blackfin Handy Board

RoboticsIFall2006: Lab6

Lab 6: Vision


We talked about the YUV color space. We also looked at the visible spectrum of light, considering short wavelengths (indigo) through long wavelengths (red). We came to a hypothesis that the CMOS camera consists of alternating pixels that detect "amount of blue" (U+Y) and "amount of red" (V+Y).

This was supported by the YUV-to-RGB formulas, in which red is based on luminance (brightness) plus a factor of V, and blue is luminance plus a factor of U.


The Challenge

In the OV7620 test, the heart of the code is:

After the VI _BF Device Get Buffer u16, the image data is available as a LabVIEW array of 320x240 pixels. Each pixel is a 16-bit unsigned integer where one byte is either U or V and the other byte is Y. These words alternate, so each row consists of 160 UY words and 160 VY words; i.e.:

  UY VY UY VY etc for 240 total words.

The challenge is to write LabVIEW code that interprets the image data in the LabVIEW array and does something useful based on it. Look for the text "Process Buffer Here."

You may want to start by simply displaying a bit of this data as numbers to make sure things are working.


Note from Mark & Zack about color format in memory: Each pixel is represented by 16 bits. The MOST SIGNIFICANT 8 bits hold the intensity data, the Y. So to process using the Y data, use the Upper half of the byte. A good set of tools is Functions Palette > Advanced > Data Manipulation, specifically Split and Join numbers.

Note from Mark: To see a custom buffer from labview, follow these instructions. This page will show how to find a custom labview array in VisualDSP to display in the ImageViewer.

Note from Zack: This seems to be a good resource for mapping YUV to RGB. For those interested, there is also a way to get Hue from RGB.
Converting between RGB and CMY, YIQ, YUV

Improvements to speed:

	Make sure that the caches are enabled in the Build Options menu.
	When possible, use shift registers as they prevent to copying and freeing of large data arrays.
	Don't do your calculation on every data member.  Decimate the array by every A elements in both the X and Y direction.
		Make sure this is done in two dimensions, otherwise there will be an unneccesary density of points in one direction.
	Disable Parallel execution (advice From Andrew Chandler)

dec·i·mate (děs'ə-māt') Pronunciation Key
tr.v. dec·i·mat·ed, dec·i·mat·ing, dec·i·mates

   1. To destroy or kill a large part of (a group).
2. Usage Problem
a. To inflict great destruction or damage on: The fawns decimated my rose bushes.
b. To reduce markedly in amount: a profligate heir who decimated his trust fund.
3. To select by lot and kill one in every ten of.
Retrieved from
Page last modified on October 05, 2007, at 06:15 PM