inverseTransform method
Transforms a point
from coordinates system of the result image back to the one of the input
image.
Implementation
Point inverseTransform(
Point point, int inputImageHeight, int inputImageWidth) {
List<int> widths = [];
List<int> heights = [];
int currentWidth = inputImageWidth;
int currentHeight = inputImageHeight;
for (Operator<TensorImage> op in operatorList) {
widths.add(currentWidth);
heights.add(currentHeight);
ImageOperator imageOperator = op as ImageOperator;
int newHeight =
imageOperator.getOutputImageHeight(currentHeight, currentWidth);
int newWidth =
imageOperator.getOutputImageWidth(currentHeight, currentWidth);
currentHeight = newHeight;
currentWidth = newWidth;
}
Iterator<Operator<TensorImage>> opIterator = operatorList.reversed.iterator;
Iterator<int> widthIterator = widths.reversed.iterator;
Iterator<int> heightIterator = heights.reversed.iterator;
while (opIterator.moveNext()) {
heightIterator.moveNext();
widthIterator.moveNext();
ImageOperator imageOperator = opIterator.current as ImageOperator;
int height = heightIterator.current;
int width = widthIterator.current;
point = imageOperator.inverseTransform(point, height, width);
}
return point;
}