GLIMSView Source Code Documentation

ImageShapeFinder Class Reference

#include <ImageShapeFinder.h>

List of all members.


Detailed Description

ImageShapeFinder locates shapes within a layer based on an input vector of selectable values.

You can specify one or more selectable values. All selectable values are treated the same, so a given pixel is either selectable (value was in the input vector) or not. When done processing, a vector of ImageSelectionCubes is availible that contains all the selected shapes.

Author:
Erica Liszewski 2006-04-25
History:
2006-08-05 Deborah Lee Soltesz - modified handlePoly algorithm in an attempt to have it generate more complete, cleaner polygons, and added several functions to support this effort
History:
2006-08-06 Deborah Lee Soltesz - Minor modifications were previously made to the original algorithm (handlePoly): When the end of a path is reached that is not near the start point, the algorithm walks backwards looking for a "fork in the road." The errant path is chopped out of the current polygon and added to the selections as an independent line, and the algorithm follows a different path until the entire path has been examined (potentially resulting in a polygon and several lines).
New - Added ability to choose among three slightly different polygon drawing algorithms. The choice can be made during runtime by selecting the desired choice from a drop-down box in the Image Poly Calculator dialog box. The primary difference amongst the algorithms is how the next edge pixel to travel to is chosen. These changes are implemented in the nextBorderPoint function, which affects how the path following choices are made for the handlePoly function discussed above.

This change is temporary. When a final algorithm is developed, choices amongst the different implementations will be removed.

Todo:
dls 2006-08-06 remove algorithm choice functionality

Definition at line 62 of file ImageShapeFinder.h.


Public Member Functions

 ImageShapeFinder (int x, int y, int w, int h, std::vector< double > *vals)
 ImageShapeFinder(int x, int y, int w, int h, std::vector<double> vals); int x - the lowest x in this area int y - the lowest y in this area int w - the width of this area int h - the height of this area std::vector<double> vals - the values that make up this layer Takes in x and y, and a length and height and an array of values that make up the layer.
 ~ImageShapeFinder ()
void setAlgorithm (int choice)
void setSelectedValues (std::vector< double > sel)
 void setSelectedValues(std::vector<double> sel) std::vector<double> sel - a vector containing all values that are to be included in the selection Takes in a vector containing all valid values that should be counted as selectable.
std::vector< ImageSelectionCube * > getSelections ()
 std::vector<ImageSelectionCube> getSelections() returns a vector of the selection shapes as ImageSelectionCubes
double getValueAtLocal (int x, int y, int z)
 double getValueAtLocal(int x, int y, int z) int x - x index int y - y index int z - z index returns the value at the location specified.
double getValueAtOverall (int x, int y, int z)
 double getValueAtOverall(int x, int y, int z) int x - x index int y - y index int z - z index returns the value at the location specified, Location is specified in terms of the original image.

Public Attributes

int algorithm

Protected Member Functions

void doSelecting ()
 void doSelecting() Starts the process of creating selections based on pixel values
int nextBorderPoint (int i, std::vector< bool > &flags)
 int nextBorderPoint(int i, std::vector<bool> &flags) int i - the index of the point in question std::vector<bool> &flags - reference to the vector of boder points returns the index of the next selectable border point.
bool isSelectable (double val)
 bool isSelectable(double val) double val - the value in question Checks to see if val is in the inSelection vector.
int adjacentBorderPixs (int i, std::vector< bool > &flags)
 int adjacentBorderPixs(int i) int i - the index in question Checks to see how many border pixels are in the 8 pixels surrounding i.
int findLongestPath (int i, std::vector< bool > &flags)
 Searches for the the longest path from this location.
int findLongestPathLength (int i, std::vector< bool > &flags, int source)
 Recursive algorithm that counts the longest path from the input pixel location (i) by examining the surrounding pixels (which, in turn, call this function in examining the pixels surrounding them, etc.
std::vector< bool > checkLegalAdjacents (int i)
 checks the surroundeding 8 pixels to ensure they are all legal values (i.e.
void handlePoint (int i, std::vector< bool > &flags)
 void handlePoint(int i, std::vector<bool> &flags) int i - the index of the point to handle std::vector<bool> &flags - reference to the vector of border points handles a point that is selectable and floating by itself
void handleLine (int i, std::vector< bool > &flags)
 void handleLine(int i, std::vector<bool> &flags) int i - index of the first pixel in the line std::vector<bool> &flags - reference to the vector of border points Handles a single-pixel-width line.
void handlePoly (int i, std::vector< bool > &flags)
 void handlePoly(int i, std::vector<bool> &flags) int i - index of the first pixel in the polygon std::vector<bool> &flags - reference to the vector of border points handles a closed polygon by repeating the initial point.

Protected Attributes

std::vector< ImageSelectionCube * > selections
 the selected shapes
std::vector< double > * layer
 the entire layer to select from
std::vector< double > inSelection
 the values that are counted as selected
int lowx
 the lowest x value
int lowy
 the lowest y value
int width
 the width
int height
 the height
int curDir
 the direction nextBorderPoint looked for the next pixel the last time it was called (referencing the "layout" discussed in the nextBorderPoint documentation)
std::vector< int > * paths
bool pathsFilled

Constructor & Destructor Documentation

ImageShapeFinder::ImageShapeFinder ( int  x,
int  y,
int  w,
int  h,
std::vector< double > *  vals 
)

ImageShapeFinder(int x, int y, int w, int h, std::vector<double> vals); int x - the lowest x in this area int y - the lowest y in this area int w - the width of this area int h - the height of this area std::vector<double> vals - the values that make up this layer Takes in x and y, and a length and height and an array of values that make up the layer.

The vector must be of size length*height for this to be a valid area.

Definition at line 7 of file ImageShapeFinder.cpp.

References curDir, height, layer, lowx, lowy, pathsFilled, and width.

ImageShapeFinder::~ImageShapeFinder (  ) 

Definition at line 23 of file ImageShapeFinder.cpp.

References selections.


Member Function Documentation

void ImageShapeFinder::setAlgorithm ( int  choice  )  [inline]

Definition at line 84 of file ImageShapeFinder.h.

References algorithm.

void ImageShapeFinder::setSelectedValues ( std::vector< double >  sel  ) 

void setSelectedValues(std::vector<double> sel) std::vector<double> sel - a vector containing all values that are to be included in the selection Takes in a vector containing all valid values that should be counted as selectable.

All values are treated as either selectable (in the vector) or not selectable (not in vector). Different selectable values will not be treated as unique from each other. At this time, this method also calls the processing to do the actual selection.

Definition at line 31 of file ImageShapeFinder.cpp.

References doSelecting(), and inSelection.

Referenced by ImageCalculator::testDriver().

Here is the call graph for this function:

std::vector< ImageSelectionCube * > ImageShapeFinder::getSelections (  ) 

std::vector<ImageSelectionCube> getSelections() returns a vector of the selection shapes as ImageSelectionCubes

Definition at line 36 of file ImageShapeFinder.cpp.

References selections.

Referenced by ImageCalculator::testDriver().

double ImageShapeFinder::getValueAtLocal ( int  x,
int  y,
int  z 
)

double getValueAtLocal(int x, int y, int z) int x - x index int y - y index int z - z index returns the value at the location specified.

Uses a local reference (i.e. starts at 0,0).

Definition at line 41 of file ImageShapeFinder.cpp.

References layer, and width.

Referenced by getValueAtOverall().

double ImageShapeFinder::getValueAtOverall ( int  x,
int  y,
int  z 
)

double getValueAtOverall(int x, int y, int z) int x - x index int y - y index int z - z index returns the value at the location specified, Location is specified in terms of the original image.

Definition at line 47 of file ImageShapeFinder.cpp.

References getValueAtLocal(), lowx, and lowy.

Here is the call graph for this function:

void ImageShapeFinder::doSelecting (  )  [protected]

void doSelecting() Starts the process of creating selections based on pixel values

Definition at line 56 of file ImageShapeFinder.cpp.

References adjacentBorderPixs(), checkLegalAdjacents(), handlePoly(), height, isSelectable(), layer, paths, pathsFilled, and width.

Referenced by setSelectedValues().

Here is the call graph for this function:

int ImageShapeFinder::nextBorderPoint ( int  i,
std::vector< bool > &  flags 
) [protected]

int nextBorderPoint(int i, std::vector<bool> &flags) int i - the index of the point in question std::vector<bool> &flags - reference to the vector of boder points returns the index of the next selectable border point.

If there is more than one eligable next point, it picks one It favors neighbors in straigt over diagonals...here's the order 5 1 6 4 X 2 8 3 7 Pixel reference layout 8 1 2 7 X 3 6 5 4

Todo:
dls - get rid of algorithm chooser

Todo:
dls - get rid of algorithm chooser

Definition at line 207 of file ImageShapeFinder.cpp.

References adjacentBorderPixs(), algorithm, checkLegalAdjacents(), curDir, findLongestPath(), and width.

Referenced by handleLine(), and handlePoly().

Here is the call graph for this function:

bool ImageShapeFinder::isSelectable ( double  val  )  [protected]

bool isSelectable(double val) double val - the value in question Checks to see if val is in the inSelection vector.

Returns true if found, false if not found.

Definition at line 372 of file ImageShapeFinder.cpp.

References inSelection.

Referenced by doSelecting().

int ImageShapeFinder::adjacentBorderPixs ( int  i,
std::vector< bool > &  flags 
) [protected]

int adjacentBorderPixs(int i) int i - the index in question Checks to see how many border pixels are in the 8 pixels surrounding i.

Returns an int 0-8 of how may border pixels are found.

Definition at line 381 of file ImageShapeFinder.cpp.

References checkLegalAdjacents(), and width.

Referenced by doSelecting(), findLongestPathLength(), handleLine(), handlePoly(), and nextBorderPoint().

Here is the call graph for this function:

int ImageShapeFinder::findLongestPath ( int  i,
std::vector< bool > &  flags 
) [protected]

Searches for the the longest path from this location.

Parameters:
[in] i Index of current pixel in flags
[in] flags Vector of pixel locations to include/exclude in the drawing
Returns:
int Reference into flags of of pixel with longest path leading away from it
Author:
Deborah Lee Soltesz 2006-08-05 - added to support algorithm enhancements to handlePoly.

Definition at line 423 of file ImageShapeFinder.cpp.

References checkLegalAdjacents(), findLongestPathLength(), and width.

Referenced by nextBorderPoint().

Here is the call graph for this function:

int ImageShapeFinder::findLongestPathLength ( int  i,
std::vector< bool > &  flags,
int  source 
) [protected]

Recursive algorithm that counts the longest path from the input pixel location (i) by examining the surrounding pixels (which, in turn, call this function in examining the pixels surrounding them, etc.

)

Parameters:
[in] source Location of pixel this function was originally called from
[in] i Index of current pixel in flags
[in] flags Vector of pixel locations to include/exclude in the drawing
Returns:
int Length of longest path from this pixel
Author:
Deborah Lee Soltesz 2006-08-05 - added to support algorithm enhancements to handlePoly. Used by findLongestPath.

Definition at line 522 of file ImageShapeFinder.cpp.

References adjacentBorderPixs(), checkLegalAdjacents(), pathsFilled, and width.

Referenced by findLongestPath().

Here is the call graph for this function:

std::vector< bool > ImageShapeFinder::checkLegalAdjacents ( int  i  )  [protected]

checks the surroundeding 8 pixels to ensure they are all legal values (i.e.

they aren't off the edge). Returns a vector of 8 booleans: true if the value is legal, false if the value is not legal. The correlation is as follows:

      0 1 2
      7 X 3
      6 5 4
 

Parameters:
[in] i Location of pixel to check for legal adjacents
Returns:
vector of booleans representing the legality of the surrounding pixels

Definition at line 705 of file ImageShapeFinder.cpp.

References layer, and width.

Referenced by adjacentBorderPixs(), doSelecting(), findLongestPath(), findLongestPathLength(), and nextBorderPoint().

void ImageShapeFinder::handlePoint ( int  i,
std::vector< bool > &  flags 
) [protected]

void handlePoint(int i, std::vector<bool> &flags) int i - the index of the point to handle std::vector<bool> &flags - reference to the vector of border points handles a point that is selectable and floating by itself

Definition at line 745 of file ImageShapeFinder.cpp.

References selections, ImageSelectionCube::setSelection(), width, ImageCube::Pixel::x, and ImageCube::Pixel::y.

Here is the call graph for this function:

void ImageShapeFinder::handleLine ( int  i,
std::vector< bool > &  flags 
) [protected]

void handleLine(int i, std::vector<bool> &flags) int i - index of the first pixel in the line std::vector<bool> &flags - reference to the vector of border points Handles a single-pixel-width line.

Will return if the line splits

Definition at line 771 of file ImageShapeFinder.cpp.

References adjacentBorderPixs(), nextBorderPoint(), selections, ImageSelectionCube::setSelection(), width, ImageCube::Pixel::x, and ImageCube::Pixel::y.

Here is the call graph for this function:

void ImageShapeFinder::handlePoly ( int  i,
std::vector< bool > &  flags 
) [protected]

void handlePoly(int i, std::vector<bool> &flags) int i - index of the first pixel in the polygon std::vector<bool> &flags - reference to the vector of border points handles a closed polygon by repeating the initial point.

.. will also handle a line if the polygons just ends

Definition at line 839 of file ImageShapeFinder.cpp.

References adjacentBorderPixs(), nextBorderPoint(), selections, ImageSelectionCube::setSelection(), width, ImageCube::Pixel::x, and ImageCube::Pixel::y.

Referenced by doSelecting().

Here is the call graph for this function:


Member Data Documentation

Todo:
get rid of the poly drawing algorithm chooser

Definition at line 83 of file ImageShapeFinder.h.

Referenced by nextBorderPoint(), and setAlgorithm().

the selected shapes

Definition at line 137 of file ImageShapeFinder.h.

Referenced by getSelections(), handleLine(), handlePoint(), handlePoly(), and ~ImageShapeFinder().

std::vector<double>* ImageShapeFinder::layer [protected]

the entire layer to select from

Definition at line 138 of file ImageShapeFinder.h.

Referenced by checkLegalAdjacents(), doSelecting(), getValueAtLocal(), and ImageShapeFinder().

std::vector<double> ImageShapeFinder::inSelection [protected]

the values that are counted as selected

Definition at line 139 of file ImageShapeFinder.h.

Referenced by isSelectable(), and setSelectedValues().

int ImageShapeFinder::lowx [protected]

the lowest x value

Definition at line 140 of file ImageShapeFinder.h.

Referenced by getValueAtOverall(), and ImageShapeFinder().

int ImageShapeFinder::lowy [protected]

the lowest y value

Definition at line 141 of file ImageShapeFinder.h.

Referenced by getValueAtOverall(), and ImageShapeFinder().

int ImageShapeFinder::width [protected]

int ImageShapeFinder::height [protected]

the height

Definition at line 143 of file ImageShapeFinder.h.

Referenced by doSelecting(), and ImageShapeFinder().

int ImageShapeFinder::curDir [protected]

the direction nextBorderPoint looked for the next pixel the last time it was called (referencing the "layout" discussed in the nextBorderPoint documentation)

Definition at line 144 of file ImageShapeFinder.h.

Referenced by ImageShapeFinder(), and nextBorderPoint().

std::vector<int>* ImageShapeFinder::paths [protected]

Definition at line 148 of file ImageShapeFinder.h.

Referenced by doSelecting().

Definition at line 149 of file ImageShapeFinder.h.

Referenced by doSelecting(), findLongestPathLength(), and ImageShapeFinder().


The documentation for this class was generated from the following files:

Home | Search | Disclaimers & Privacy | Contact Us
GLIMSView Maintainer: dsoltesz@usgs.gov