#include <ImageShapeFinder.h>
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.
This change is temporary. When a final algorithm is developed, choices amongst the different implementations will be removed.
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 |
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 | ( | ) |
void ImageShapeFinder::setAlgorithm | ( | int | choice | ) | [inline] |
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().
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.
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.
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().
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
Definition at line 207 of file ImageShapeFinder.cpp.
References adjacentBorderPixs(), algorithm, checkLegalAdjacents(), curDir, findLongestPath(), and width.
Referenced by handleLine(), and handlePoly().
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().
int ImageShapeFinder::findLongestPath | ( | int | i, | |
std::vector< bool > & | flags | |||
) | [protected] |
Searches for the the longest path from this location.
[in] | i | Index of current pixel in flags |
[in] | flags | Vector of pixel locations to include/exclude in the drawing |
Definition at line 423 of file ImageShapeFinder.cpp.
References checkLegalAdjacents(), findLongestPathLength(), and width.
Referenced by nextBorderPoint().
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.
)
[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 |
Definition at line 522 of file ImageShapeFinder.cpp.
References adjacentBorderPixs(), checkLegalAdjacents(), pathsFilled, and width.
Referenced by findLongestPath().
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
[in] | i | Location of pixel to check for legal adjacents |
Definition at line 705 of file ImageShapeFinder.cpp.
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.
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.
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().
Definition at line 83 of file ImageShapeFinder.h.
Referenced by nextBorderPoint(), and setAlgorithm().
std::vector<ImageSelectionCube*> ImageShapeFinder::selections [protected] |
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] |
the width
Definition at line 142 of file ImageShapeFinder.h.
Referenced by adjacentBorderPixs(), checkLegalAdjacents(), doSelecting(), findLongestPath(), findLongestPathLength(), getValueAtLocal(), handleLine(), handlePoint(), handlePoly(), ImageShapeFinder(), and nextBorderPoint().
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] |
bool ImageShapeFinder::pathsFilled [protected] |
Definition at line 149 of file ImageShapeFinder.h.
Referenced by doSelecting(), findLongestPathLength(), and ImageShapeFinder().
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |