Question

Imagine you have an large picture, let's say about 10000px x 3000px and you like to translate it left on the x axis and in a very efficient way. So no AffineTransform or smth like that is wanted. If possible, the part moved out on the left side should be appended on the right side, so a kind of turn around would be very cool.

What you have on hand are: Java 7, OpenCV.

Do you have any suggestions?

Was it helpful?

Solution

Here you can see how it can be done with OpenCV in C++. You just need to translate it to Java:

// C++:
Mat outImg(inputImg.size(),inputImg.type());
inputImg(Rect(0, 0, shiftX, height)).copyTo(outImg(Rect(width-shiftX, 0, shiftX, height)));

Becomes something like:

Mat outImg = new Mat(inputImg.size(),inputImg.type());
inputImg.submat(new Rect(0, 0, shiftX, height)).copyTo(outImg.submat(new Rect(width-shiftX, 0, shiftX, height)));

Although this one liner is not very readable ;)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top