Make a copy of the example application:
cp videoexample.c myprojectlab.c ; cp makescript mymakescript. Modify mymakescript to compile myprojectlab instead of videoexample. Modify the
Bayer downsampling code to use two green input pixels, one red input pixel, and one blue input pixel to compute each pixel in the color output image. Currently, only one green pixel is used. In other words, each non-overlapping, 2x2 square of single-color pixels in the input image will map to one color pixel in the output image. Can you think of and implement a method that more efficiently indexes (no multiplications, few additions) the raw-input and downsampled-output images?
Now modify myprojectlab.c so that it displays three different sets of processed video, accessible via the 1-3 keys, with 1 being the default. Make the contents of each screen as follows:
- Top left: original downsampled video
- Top right: horizontally-flipped video
- Bottom left: vertically-flipped video
- Bottom right: inverted video - black becomes white and white becomes black, etc. Note that each pixel has a max value of 255.
- Top left: original downsampled video
- Top right: red channel
- Bottom left: green channel
- Bottom right: blue channel
- When the user presses the
g key, toggle between displaying the channels as shades of gray or the channel colors. Which channel best approximates a grayscale version of the image?
- Top left: original downsampled video
- Top right: Y channel
- Bottom left: U channel
- Bottom right: V channel
- When the user presses the
a key, toggle between displaying the channels in their default ranges and auto-contrasting the channels (with a single offset and single scale factor per quadrant image) so that the maximum RGB-color component of each quadrant image is 255 and the minimum 0. Which channel contains the grayscale image?
- Note that displaying one of the YUV channels in RGB form requires conversion to YUV, selecting a channel, and converting back to RGB. Think carefully about how to do the conversions efficiently before programming them; eliminate redundant and/or unnecessary operations. In other words, six matrix transformations per video frame are not required to display the YUV channels. In fact, three matrix transformations are not required. An internet search should provide many references to RGB and YUV conversion.
Make your code as modular as possible so that it is easy to follow and debug; create functions, inline functions, and/or macros for operations that will be repeatedly performed, and group similar functions/macros into separate files.
"Real-Time DSP with MATLAB"