uk.ac.ed.inf.sdp2012.group7.vision
Class Thresholding

java.lang.Object
  extended by uk.ac.ed.inf.sdp2012.group7.vision.Thresholding

public class Thresholding
extends java.lang.Object

Does fucking everything. Needs to be broken up

Author:
s0951580

Constructor Summary
Thresholding(ThresholdsState ts)
          The constructor for the class
 
Method Summary
 java.awt.Point fixParallax(java.awt.Point p, MovingObject m)
          Correct for parallax Take in a point and what object it belongs to and unparallax it
 java.awt.Point[] getBlueGreenPlate4Points()
          Get the points that make of the green plate of the blue T
 java.awt.image.BufferedImage getThresh(java.awt.image.BufferedImage img, int left, int right, int top, int bottom)
          Our do everything method Goes through every pixel, working out which object it should belong to, calculates positions etc
 java.awt.Point[] getYellowGreenPlate4Points()
          Get the points that make of the green plate of the yellow T
 boolean isBlue(java.awt.Color c)
          Check if a pixel is blue robot blue
 boolean isGreen(java.awt.Color c, int GB, int RG)
          Check if part of green plate
 boolean isRed(java.awt.Color c, int GB)
          Check if a pixel is ball red
 boolean isYellow(java.awt.Color c)
          Check if pixel is yellow robot
 void setCs(int x, int y, int right, int left, int top, int bottom, java.awt.image.BufferedImage img)
          Does the connected component stuff Use a bastardised 8 connected component method, is supposed to have clustering tacked on to the end, but I just use it for reducing noise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Thresholding

public Thresholding(ThresholdsState ts)
The constructor for the class

Parameters:
ts - A thresholdsstate object so we can initialise the thresholds
Method Detail

getThresh

public java.awt.image.BufferedImage getThresh(java.awt.image.BufferedImage img,
                                              int left,
                                              int right,
                                              int top,
                                              int bottom)
Our do everything method Goes through every pixel, working out which object it should belong to, calculates positions etc

Parameters:
img - The frame of video
left - Left boundary of pitch
right - Right boundary of pitch
top - Top boundary of pitch
bottom - Bottom boundary of pitch
Returns:
the frame we just took, probably to display

fixParallax

public java.awt.Point fixParallax(java.awt.Point p,
                                  MovingObject m)
Correct for parallax Take in a point and what object it belongs to and unparallax it

Parameters:
p - The point to correct
m - The object it belongs to, i.e. robot centroid, necessary so we can get height
Returns:
The corrected point in type Point

setCs

public void setCs(int x,
                  int y,
                  int right,
                  int left,
                  int top,
                  int bottom,
                  java.awt.image.BufferedImage img)
Does the connected component stuff Use a bastardised 8 connected component method, is supposed to have clustering tacked on to the end, but I just use it for reducing noise. Currently it is this method that makes the yellow T zigzaggy. It checks a points surrounding pixels to work out if it is noise or not.

Parameters:
x - - x coordinate of point
y - - y coordinate of point
right - To check if we go out of bounds of pitch
left - To check if we go out of bounds of pitch
top - To check if we go out of bounds of pitch
bottom - To check if we go out of bounds of pitch
img - To get the colour of the neighbouring pixels

isBlue

public boolean isBlue(java.awt.Color c)
Check if a pixel is blue robot blue

Parameters:
c - Colour to check
Returns:
True if blue

isRed

public boolean isRed(java.awt.Color c,
                     int GB)
Check if a pixel is ball red

Parameters:
c - - Colour to check
GB - - Difference between green and blue channel
Returns:
True if red

isGreen

public boolean isGreen(java.awt.Color c,
                       int GB,
                       int RG)
Check if part of green plate

Parameters:
c - Colour to check
GB - Difference in green and blue channel
RG - Difference in red and green channel
Returns:
True if green

isYellow

public boolean isYellow(java.awt.Color c)
Check if pixel is yellow robot

Parameters:
c - Colour to check
Returns:
True if part of yellow T

getBlueGreenPlate4Points

public java.awt.Point[] getBlueGreenPlate4Points()
Get the points that make of the green plate of the blue T

Returns:
the points

getYellowGreenPlate4Points

public java.awt.Point[] getYellowGreenPlate4Points()
Get the points that make of the green plate of the yellow T

Returns:
the points