1. Install VIPER and mount standard libraries. Follow the directions. Feel free to use the machines in the first floor lab which are described on the class web page.
2. You will need a function that computes the histogram of an RGB color image. The function should accept a variable N which specifies the number of bins to use for each of the R, G, and B axes. So the total number of bins would be N^3. Your histogram should be normalized so that the sum over all of the bins equals 1. We can interpret the number in each bin as the probability of encountering pixels with the corresponding range of RGB values.
For example, in a gray-scale image each pixel has a value between 0 and 255. Using a histogram with 10 bins, we would find the following mapping of gray scale values to bins: Bin 0: 0-24; Bin 1: 25-49; Bin 2: 50-74; etc. Note that the last bin would contain values 225-255. This includes 5 extra values since 256 is not evenly divisible by 10.
3. It's a good idea to test your function with a small number of bins and a hand-constructed test image for which you know exactly what the right answer should be.
4. Write a function called detectpixels which identifies the pixels in an input image which have high probability with respect to a histogram model. This function takes a histogram, an image, and a threshold and computes a label for each pixel. The first step is to compute the probability for each pixel as measured by the histogram. This is done by computing the associated bin for a pixel and retrieving the contents of the bin as the probability. Next the probability is compared to the threshold to obtain a label of 0 (below threshold) or 1 (above). Your function should produce an output image that consists of a copy of the input image in which all of the pixels with a label of 1 have been replaced by the value (0,0,255).
For example, suppose that pixel (25,40) in the input image has RGB value (10,34,20). Suppose that it maps to bin (1,3,2) in the histogram and the probability in that bin is 0.005. With a threshold T < 0.005, the output image will contain (0,0,255) at location (25,40). Otherwise it will contain (10,34,20).
5. Write a program which reads an an input image and an AVI file and outputs an AVI file. The program should use the input image to construct a histogram with N=64 (i.e. 64 bins/channel). It should use a threshold of T=0.008 to label each pixel in each frame of the AVI file. Experiment with different threshold settings to see the effect. The result will be a new AVI file in which all of the detected pixels are drawn in blue.
6. Run the program with the following input image and AVI file. Answer the following questions:
7. Turn in your executable file, the output AVI file from part (6) using threshold of 0.008, and your answers to the questions.