Commit ed2c3dc6 authored by mzed's avatar mzed
Browse files

cleaning up things that could be pairs

parent cb2b27bd
......@@ -10,44 +10,38 @@
template<typename T>
searchWindow<T>::searchWindow(const int seriesXSize, const int seriesYSize, const warpPath &shrunkenWarpPath, const int searchRadius) :
minValues(seriesXSize, -1), maxValues(seriesXSize, 0), maxY(seriesYSize - 1) {
minValues(seriesXSize, -1), maxValues(seriesXSize, 0), minMaxValues(seriesXSize, std::make_pair(-1, 0)), maxY(seriesYSize - 1) {
//Current location of higher resolution path
int currentX = shrunkenWarpPath.xIndices[0];
int currentY = shrunkenWarpPath.yIndices[0];
std::pair<int, int> currentIndex = shrunkenWarpPath.indices[0];
//Last evaluated part of low resolution path
int lastWarpedX = std::numeric_limits<int>::max();
int lastWarpedY = std::numeric_limits<int>::max();
std::pair<int, int> lastWarped = std::make_pair(std::numeric_limits<int>::max(), std::numeric_limits<int>::max());
int blockSize = 2; //TODO: something other than 2? Different for x and y?
//project each part of the low-res path to high res cells
for (int i = 0; i < shrunkenWarpPath.xIndices.size(); ++i) {
for ( auto &xyIndex : shrunkenWarpPath.indices) {
int warpedX = shrunkenWarpPath.xIndices[i];
int warpedY = shrunkenWarpPath.yIndices[i];
if (warpedX > lastWarpedX) {
currentX += blockSize;
if (xyIndex.first > lastWarped.first) {
currentIndex.first += blockSize;
}
if (warpedY > lastWarpedY) {
currentY += blockSize;
if (xyIndex.second > lastWarped.second) {
currentIndex.second += blockSize;
}
if ((warpedX > lastWarpedX) && (warpedY > lastWarpedY))
if ((xyIndex.first > lastWarped.first) && (xyIndex.second > lastWarped.second))
{
markVisited(currentX-1, currentY);
markVisited(currentX, currentY-1);
markVisited(currentIndex.first - 1, currentIndex.second);
markVisited(currentIndex.first, currentIndex.second - 1);
}
for (int j = 0; j < blockSize; ++j) {
markVisited(currentX + j, currentY);
markVisited(currentX + j, currentY + blockSize - 1); //TODO: These are redundant?
markVisited(currentIndex.first + j, currentIndex.second);
markVisited(currentIndex.first + j, currentIndex.second + blockSize - 1); //TODO: These are redundant?
}
lastWarpedX = warpedX;
lastWarpedY = warpedY;
lastWarped = xyIndex;
}
if (searchRadius > 0) {
......@@ -69,6 +63,7 @@ void searchWindow<T>::markVisited(int col, int row) {
} else if (maxValues[col] < row) {
//size += row - maxValues[col];
maxValues[col] = row;
minMaxValues[col].second = row;
}
}
}
......@@ -81,15 +76,13 @@ void searchWindow<T>::expandWindow(int radius) {
std::vector<std::pair<int, int>> windowCells;
for (int currentX = 0; currentX < minValues.size(); ++currentX) {
for (int currentY = minValues[currentX]; currentY <= maxValues[currentX]; ++currentY) {
std::pair<int, int> currentCell = std::make_pair(currentX, currentY);
windowCells.push_back(currentCell);
windowCells.push_back(std::make_pair(currentX, currentY));
}
}
int maxX = int(minValues.size() - 1);
for (int cell = 0; cell < windowCells.size(); ++cell) {
std::pair<int, int> currentCell = windowCells[cell]; //TODO: is pair necessary? easier to make currentX and currentY?
for (auto &currentCell : windowCells) {
if (currentCell.first != 0 && currentCell.second != maxY) { //move to upper left if possible
//expand until edges are met
......@@ -187,4 +180,4 @@ void searchWindow<T>::expandWindow(int radius) {
//explicit instantiation
template class searchWindow<double>;
template class searchWindow<float>;
\ No newline at end of file
template class searchWindow<float>;
......@@ -25,10 +25,10 @@ public:
std::vector<int> minValues;
std::vector<int> maxValues;
std::vector< std::pair<int, int> > minMaxValues;
private:
int maxY;
//int size;
void markVisited(int col, int row);
void expandWindow(int searchRadius);
};
......
......@@ -13,6 +13,5 @@ warpPath::warpPath() {};
warpPath::~warpPath() {};
void warpPath::add(int x, int y) {
xIndices.insert(xIndices.begin(), x);
yIndices.insert(yIndices.begin(), y);
indices.insert(indices.begin(), std::make_pair(x, y));
};
......@@ -22,8 +22,7 @@ public:
*/
void add(int x, int y);
std::vector<int> xIndices;
std::vector<int> yIndices;
std::vector< std::pair<int, int> > indices;
};
/** return struct holding a warp path and the cost of that path */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment