2010年1月22日 星期五

HW04: Color Detection


One of the most popular methods used for color detection is using the vector distance.

Let's say you are searching for "red" pixels. Pure red exists when the values of the pixels are: [B, G, R]=[0, 0, 255]. When searching for red you may want to have a "tolerance" meaning that you don't only search for pure red, but also for some other red-like combinations.

Suppose that each pixel is a vector: pixel = [B, G, R]
Also, the color combination you are looking for is another vector: red = [0, 0, 255] (reference color).

The eucledian distance between those 2 vectors is:
D = sqrt((B-0)^2 + (G-0)^2 + (R-255)^2)

So the algorithm goes:

for each pixel {
1. compute D between that pixel and the reference color
2. if D < Threshold
then
current pixel is accepted
else
current pixel is NOT accepted
}

-------------------
1. Download the HW04.cpp program from webhd.mcu.edu.tw.
2. Excute and trace the program.
3. Study the codes.
4. Extend the HW01.cpp and HW04.cpp to generate a program that can change your black hair into red hair.
5. Extend the above program to change black pixels in your video into effects shown in the above picture.
6. Extend the above program such that you can draw a picture using your hair in another window.
7. Post your results to HWShow.
8. 隱形人




沒有留言:

張貼留言