$24
Written Part: (20 points)
Each question has marks displayed
Q.1 Suppose a camera has 450 lines per frame, 520 pixels per line, and 25 Hz frame rate. The color sub sampling scheme is 4:2:0, and the pixel aspect ratio is 16:9. The camera uses interlaced scanning, and each sample of Y, Cr, Cb is quantized with 8 bits
Q.2 The following sequence of real numbers has been obtained sampling an audio signal: 1.8, 2.2, 2.2, 3.2, 3.3, 3.3, 2.5, 2.8, 2.8, 2.8, 1.5, 1.0, 1.2, 1.2, 1.8, 2.2, 2.2, 2.2, 1.9, 2.3, 1.2, 0.2, -1.2, -1.2, -1.7, -1.1, -2.2, -1.5, -1.5, -0.7, 0.1, 0.9 Quantize this sequence by dividing the interval [-4, 4] into 32 uniformly distributed levels (place the level 0 at -3.75, the level 1 at -3.5, and so on. This should simplify your calculations).
Q.3 Temporal aliasing can be observed when you attempt to record a rotating wheel with a video camera. In this problem, you will analyze such effects. Assume there is a car moving at 36 km/h and you record the car using a film, which traditionally record at 24 frames per second. The tires have a diameter of 0.4244 meters. Each tire has a white mark to gauge the speed of rotation.
Programming Part: (80 points)
This assignment will help you gain a practical understanding of Quantization and Subsampling to analyze how it affects visual media types like images and video.
We have provided you with a Microsoft Visual C++ project and a java class to display two images side by side (left – original and right – output of your program). Currently both left and right correspond to the same input image. You are free to use this display program as a start, or write your own in a language of your choice.
Input to your program will be five parameters where
To invoke your program we will compile it and run it at the command line as
YourProgram.exe C:/myDir/myImage.rgb Y U V Q
where Y U V Q are the parameters as described above. Example inputs are shown below and this should give you a fair idea about what your input parameters do and how your program will be tested.
There are 256 values (8 bits) per R G and B, and no subsampling in the Y, U or V -> which implies that the output is the same as the input
There are 64 values (6 bits) per R G and B and no subsampling in Y, U or V.
There are 256 values (8bits) per R, G and B (no additional color quantization), but the U and V channels are subsampled by 2. No subsampling in the Y channels.
Now for the details - In order the display an image on a display device, the normal choice is an RGB representation. This is what the format of the input image is. However, for YUV processing reasons, you will have to convert the image in YUV space, process your subsampling and reconvert it back to RGB space to show the output to display. Here is the dataflow pipeline that illustrates all the steps.
This code is already provided to you, if you choose to make use of it
1. Read Input Image
4. Adjust up-sampling for display
Display Input Image
2. Convert to YUV space
3. Process YUV subsampling
5. Convert back to RGB space
Display Input Image
The RGB to YUV with the conversion matrix is given below
Sub sample Y U and V separately according to the input parameters
Adjust sample values. Although samples are lost, prior to conversion to RGB all the channels have to be in the same size
6. Quantize RGB channels
Apply the inverse matrix to get the RGB data
Quantize the color channels according to the input parameter and display
Given R, G and B values the conversion from RGB to YUV is given by
Y 0.299 0.587 0.114 R
U = 0.596 -0.274 -0.322 G
V 0.211 -0.523 0.312` B
Remember that if RGB channels are represented by n bits each, then the YUV channels are also represented by the same number of bits.
RGB values are positive, but YUV can take negative values!
Given R, G and B values the conversion from RGB to YUV is given by
R 1.000 0.956 0.621 Y
G = 1.000 -0.272 -0.647 U
B 1.000 -1.106 1.703 V
Remember that if YUV channels are represented by n bits each, then the RGB channels are also represented by the same number of bits.
YUV channel can have negative values, but RGB is always positive!
Sub sampling, as you know will reduce the number of samples for a channel.
E.g. for the input parameters
In this example, the YUV image is not subsampled in Y, but by 2 in U and by 2 in V resulting in
When converting back to the RGB space, all the YUV channels have to be of the same size. However the sampling throws away samples, which have to be filled in appropriately by average the neighborhood values. For example, for the above case a local image area would look like
The missing values may be filled in as
U12 = (U11 + U13)/2 V12 = (V11 + V13)/2
U14 = (U13 + U15)/2 V14 = (V13 + V15)/2
…. And so on, to get
Note the samples that you take to fill in values will change depending on the subsampling parameters. The YUV components can now be converted to RGB space.
RGB Color Quantization.
Assume that the quantization levels are uniformly distributed. Initially we have 8 bits per pixel per channel to start with. So the Q input value to your program can take on values from the range 255 – 0. For instance
So design your quantization function accordingly.
Analysis Question 1:
Subsampling obviously degrades the image quality. Here you are going to analyze this degradation. Can you formulate a way to quantify this degradation as an error number or error percentage?
Compute this value for output images where each input Y, U, V is individually varying while the other two remain constant. (Assume Q is constant at 256). Plot your error metric values for each.
Do you see any patterns in the curves?
What conclusion(s) can you draw from your analysis?
Analysis Question 2:
You will see that your analysis varies for different images. If you had to improve the quality of your results for each case above (Y varying but U, V constant) or (U varying but Y, V constant) or (V varying, but Y, U constant), what changes can you implement to your code and where can you implement them?
Can you make these changes and submit some output images with before and after the change? You may screen grab images and paste them into your document. Remember not to scale the images – that could introduce additional artifacts.
Note you do not want to submit the changed source code since we will not be able to test it. Your visual images along with explanations in your document should be fine.