Skip to content
Advertisement

Shift image in OpenCV

I want to shift an image upward of 10 pixels without changing the size of the image. I know there was a very similar question about this but there is no information on the web on how to do it using Java. OpenCV Documentation also doesn’t say anything about this.

Original image:

enter image description here

Shifted image should look like this:

enter image description here

I tried doing it with matrix using warpAffine() function but I don’t know how to get it working and I only messed around with random values but it’s only transposing the image and maybe I can’t find the right function for this.

JavaScript

Advertisement

Answer

You’ll need to construct the warp mat manually to achieve this instead of using getAffineTransform. Try using warpAffine with the following Mat (untested):

JavaScript

Sources:

Shift image content with OpenCV

declare Mat in OpenCV java

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement