<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="id5680451">
  <name>Implementation: Detecting the LEDs</name>
  <metadata>
  <md:version>1.1</md:version>
  <md:created>2007/12/19 18:50:03.547 US/Central</md:created>
  <md:revised>2007/12/19 20:15:22.652 US/Central</md:revised>
  <md:authorlist>
      <md:author id="tanwee">
      <md:firstname>Tanwee</md:firstname>
      
      <md:surname>Misra</md:surname>
      <md:email>tanwee.misra@rice.edu</md:email>
    </md:author>
      <md:author id="kriti">
      <md:firstname>Kriti</md:firstname>
      
      <md:surname>Charan</md:surname>
      <md:email>kriti@rice.edu</md:email>
    </md:author>
      <md:author id="jchow">
      <md:firstname>Janice</md:firstname>
      
      <md:surname>Chow</md:surname>
      <md:email>jchow@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="tanwee">
      <md:firstname>Tanwee</md:firstname>
      
      <md:surname>Misra</md:surname>
      <md:email>tanwee.misra@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="kriti">
      <md:firstname>Kriti</md:firstname>
      
      <md:surname>Charan</md:surname>
      <md:email>kriti@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="jchow">
      <md:firstname>Janice</md:firstname>
      
      <md:surname>Chow</md:surname>
      <md:email>jchow@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>Detect LED</md:keyword>
    <md:keyword>LEDs</md:keyword>
    <md:keyword>RGB thresholds</md:keyword>
  </md:keywordlist>

  <md:abstract>This module carries instructions to detect the LEDs in each frame using Red, Green, Blue threshold values.</md:abstract>
</metadata>
  <content>
    <section id="id-484766724921">
      <name>RGB in Each Individual Frame</name>
      <para id="id7674728">Given the acquired frames, the first step is to locate the LEDs. The color of the LEDs can be described by the intensity of red, green and blue. These are represented by values between 0 and 255 (going from null intensity to full intensity) in the RGB matrices for each image. We can detect the LEDs by setting threshold values for Red, Green and Blue. For example, to find the Red LED, you are looking for the part of the frame with high Red values and low Blue and Green values. We would recommend using the data cursor to analyze RGB values of the LED in the colormap. Play around with threshold values until you get the right thresholds, i.e., only the LED you are trying to detect shows up.</para>
      <figure id="id4095038"><name>A Sample Frame</name>
        <media type="image/jpg" src="graphics1.jpg">
          <param name="height" value="393"/>
          <param name="width" value="361"/>
        </media>
      </figure>
      <para id="id7674832">
        <figure id="id7674835"><name>Spy Plots of the LEDs</name>
  <subfigure id="subfig1">
    <media type="image/jpg" src="graphics2.jpg">
            <param name="height" value="348"/>
            <param name="width" value="309"/>
          </media>
<caption>Red LED</caption>
  </subfigure>
  <subfigure id="subfig2">
          <media type="image/jpg" src="graphics3.jpg">
            <param name="height" value="348"/>
            <param name="width" value="343"/>
          </media>
<caption>Green LED</caption>
  </subfigure>
          
        </figure>
        
      </para>
      <para id="id7541807">In our project, we used the find function to look at the red, green and blue matrices separately and set ones wherever the conditions were satisfied. We multiply the three matrices of ones and zeros to produce one final matrix with ones where all three color thresholds are satisfied and the LED is detected.</para>
    </section>
    <section id="id-417344304157">
      <name>Turn Off the LEDs</name>
      <para id="id7541823">If the LEDs are not detected for 75% of the frames, it means that the LEDs are either turned off or not in the frame at all, and the program stops running. However, if the LEDs have been found, you can move on to detecting when the drums are hit.</para>
      
      
      
      
      
      
      
      
    </section>
  </content>
</document>
