# Java – Affine transformation with interpolation

Affine transformation with interpolation… here is a solution to the problem.

## Affine transformation with interpolation

I want

to do affine transformation on a bitmap with a very low resolution, and I want to do it while retaining the maximum amount of information.

My input data is a 1-bit 64 x 64 pixel image of handwritten characters, and my output will be grayscale and higher resolution. After analyzing the image, I construct a series of affine transformations (rotate, scale, clip, translation) that I can multiply by a single affine transformation matrix.

My question is, given the input image and the affine transformation matrix I calculated, how can I compute the output image in the highest possible quality? I’ve read articles about different interpolation techniques, but they’re all about scaling interpolation, not general affine transformations.

It’s a demo and it’s doing what I’m looking for. Given affine transformation matrices and interpolation techniques, it can compute images.

If I have a lower resolution 1-bit input and a given T affine transformation matrix, can you explain what steps are required to calculate a higher resolution (e.g. 4x) grayscale image?

Can you give me some links to source code or tutorials or articles or maybe even books on how to use affine transformations to achieve linear, cubic or better interpolation?

I

need to implement this problem in Java, I know Java has an Affiliate class, but I don’t know if it implements interpolation. Do you know any C++ or Java libraries that are easy to read code for figuring out how to write algorithms that use interpolation for affine transformations?

Are there any free Java or C++ libraries with built-in functions that use interpolation to compute affine transformations?

### Solution

The same person you link to has a C implementation with multiple interpolation options here. There is also JavaCV, which wraps OpenCV. OpenCV includes warpAffine with interpolation. Also, look at Java Advanced Imaging API here .