software.common
Class ImageToCoordinatesInches

java.lang.Object
  extended by software.common.ImageToCoordinatesInches

public class ImageToCoordinatesInches
extends java.lang.Object

Given an image, it finds all color spots (Clusters) on that image. It created a private copy of the image that is modified as a new cluster is found. Improvments can be made to not have a private copy of the image (same important memory)

Author:
stefan

Constructor Summary
ImageToCoordinatesInches(java.awt.image.BufferedImage b, double dpi, java.util.Vector<Cluster> collorsSougth)
          The discountinuity of the color spots is given in INCHES.
 
Method Summary
 Cluster detectCircular(double startx, double starty, double halfSide, Cluster sougthCollor1)
          Looks for a cluster in concentric circles, starting from the center
 int getColumn()
           
 int getFromx()
           
 int getFromy()
           
 java.awt.image.BufferedImage getImg()
           
 Cluster getNextCluster()
          Returns the next cluster found.
 int getNumberOfColumns()
           
 int getTox()
           
 int getToy()
           
static boolean isGivenColor(java.awt.Color sougthCollor, java.awt.Color given, java.awt.Color deviation)
           
 void setFromx(int fromx)
           
 void setFromy(int fromy)
           
 void setNumberOfColumns(int numberOfColumns)
           
 void setTox(int tox)
           
 void setToy(int toy)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageToCoordinatesInches

public ImageToCoordinatesInches(java.awt.image.BufferedImage b,
                                double dpi,
                                java.util.Vector<Cluster> collorsSougth)
The discountinuity of the color spots is given in INCHES. A private copy of the image is made internally. The original image is not modified

Parameters:
b - The image to be scanned
dpi - the dpi of the image
collorsSougth - - the collors to look for. Cannot contain white (it run run out of memory - stack), as the color used for marking a pixel as visited is white.
Method Detail

getNextCluster

public Cluster getNextCluster()
Returns the next cluster found. The search is made by column. The width of the image is equally divided by the numberOfColumns, so all columns have the same width. If a cluster is found in one column, it will not be found in another one.

Returns:
- the next cluster found or null if no more clusters are found

isGivenColor

public static boolean isGivenColor(java.awt.Color sougthCollor,
                                   java.awt.Color given,
                                   java.awt.Color deviation)
Parameters:
sougthCollor -
given -
deviation -
Returns:
true if the distance between two colors is smaller then the deviation The disatnce is considered on each RGB component separately

getFromx

public int getFromx()

setFromx

public void setFromx(int fromx)

getFromy

public int getFromy()

setFromy

public void setFromy(int fromy)

getNumberOfColumns

public int getNumberOfColumns()

setNumberOfColumns

public void setNumberOfColumns(int numberOfColumns)

getTox

public int getTox()

setTox

public void setTox(int tox)

getToy

public int getToy()

setToy

public void setToy(int toy)

getColumn

public int getColumn()

getImg

public java.awt.image.BufferedImage getImg()

detectCircular

public Cluster detectCircular(double startx,
                              double starty,
                              double halfSide,
                              Cluster sougthCollor1)
Looks for a cluster in concentric circles, starting from the center

Parameters:
startx - - the X coordinate of the center
starty - - the Y coordinate of the center
halfSide - - the radius of the disk to search
sougthCollor1 - - the color shougth
Returns:
- the first cluster found in the given color